1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63bba73cSAndrew Rist  * distributed with this work for additional information
6*63bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*63bba73cSAndrew Rist  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist  *
13*63bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist  * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63bba73cSAndrew Rist  * specific language governing permissions and limitations
18*63bba73cSAndrew Rist  * under the License.
19*63bba73cSAndrew Rist  *
20*63bba73cSAndrew Rist  *************************************************************/
21*63bba73cSAndrew Rist 
22*63bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include <tools/debug.hxx>
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/text/XTextFrame.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
32cdf0e10cSrcweir #include <com/sun/star/text/SizeType.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
34cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
35cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
36cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
37cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
38cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
39cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
40cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
41cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
42cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
43cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
44cdf0e10cSrcweir #include "XMLAnchorTypePropHdl.hxx"
45cdf0e10cSrcweir #include "XMLEmbeddedObjectImportContext.hxx"
46cdf0e10cSrcweir #include <xmloff/XMLBase64ImportContext.hxx>
47cdf0e10cSrcweir #include "XMLReplacementImageContext.hxx"
48cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
49cdf0e10cSrcweir #include "xmloff/i18nmap.hxx"
50cdf0e10cSrcweir #include "xexptran.hxx"
51cdf0e10cSrcweir #include <xmloff/shapeimport.hxx>
52cdf0e10cSrcweir #include <xmloff/XMLEventsImportContext.hxx>
53cdf0e10cSrcweir #include "XMLImageMapContext.hxx"
54cdf0e10cSrcweir #include "XMLTextFrameContext.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include "XMLTextListBlockContext.hxx"
57cdf0e10cSrcweir #include "XMLTextListItemContext.hxx"
58cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
59cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include <map>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir using ::rtl::OUString;
65cdf0e10cSrcweir using ::rtl::OUStringBuffer;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace ::com::sun::star;
68cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69cdf0e10cSrcweir using namespace ::com::sun::star::text;
70cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
71cdf0e10cSrcweir using namespace ::com::sun::star::beans;
72cdf0e10cSrcweir using namespace ::com::sun::star::lang;
73cdf0e10cSrcweir using namespace ::com::sun::star::container;
74cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
75cdf0e10cSrcweir using namespace ::com::sun::star::document;
76cdf0e10cSrcweir using namespace ::xmloff::token;
77cdf0e10cSrcweir using ::com::sun::star::document::XEventsSupplier;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #define XML_TEXT_FRAME_TEXTBOX 1
80cdf0e10cSrcweir #define XML_TEXT_FRAME_GRAPHIC 2
81cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT 3
82cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT_OLE 4
83cdf0e10cSrcweir #define XML_TEXT_FRAME_APPLET 5
84cdf0e10cSrcweir #define XML_TEXT_FRAME_PLUGIN 6
85cdf0e10cSrcweir #define XML_TEXT_FRAME_FLOATING_FRAME 7
86cdf0e10cSrcweir 
87cdf0e10cSrcweir typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> ParamMap;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir class XMLTextFrameContextHyperlink_Impl
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	OUString sHRef;
92cdf0e10cSrcweir 	OUString sName;
93cdf0e10cSrcweir 	OUString sTargetFrameName;
94cdf0e10cSrcweir 	sal_Bool bMap;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir public:
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef,
99cdf0e10cSrcweir 					   const OUString& rName,
100cdf0e10cSrcweir 					   const OUString& rTargetFrameName,
101cdf0e10cSrcweir 					   sal_Bool bMap );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	const OUString& GetHRef() const { return sHRef; }
104cdf0e10cSrcweir 	const OUString& GetName() const { return sName; }
105cdf0e10cSrcweir 	const OUString& GetTargetFrameName() const { return sTargetFrameName; }
106cdf0e10cSrcweir 	sal_Bool GetMap() const { return bMap; }
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl(
110cdf0e10cSrcweir 	const OUString& rHRef, const OUString& rName,
111cdf0e10cSrcweir 	const OUString& rTargetFrameName, sal_Bool bM ) :
112cdf0e10cSrcweir 	sHRef( rHRef ),
113cdf0e10cSrcweir 	sName( rName ),
114cdf0e10cSrcweir 	sTargetFrameName( rTargetFrameName ),
115cdf0e10cSrcweir 	bMap( bM )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
120cdf0e10cSrcweir class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     OUString&   mrTitleOrDesc;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir public:
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	TYPEINFO();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
129cdf0e10cSrcweir                                          sal_uInt16 nPrfx,
130cdf0e10cSrcweir                                          const ::rtl::OUString& rLName,
131cdf0e10cSrcweir                                          OUString& rTitleOrDesc );
132cdf0e10cSrcweir     virtual ~XMLTextFrameTitleOrDescContext_Impl();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	virtual void Characters( const OUString& rText );
135cdf0e10cSrcweir };
136cdf0e10cSrcweir 
137cdf0e10cSrcweir TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
140cdf0e10cSrcweir 		SvXMLImport& rImport,
141cdf0e10cSrcweir         sal_uInt16 nPrfx,
142cdf0e10cSrcweir         const OUString& rLName,
143cdf0e10cSrcweir         OUString& rTitleOrDesc )
144cdf0e10cSrcweir     : SvXMLImportContext( rImport, nPrfx, rLName )
145cdf0e10cSrcweir     , mrTitleOrDesc( rTitleOrDesc )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     mrTitleOrDesc += rText;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir // <--
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // ------------------------------------------------------------------------
160cdf0e10cSrcweir 
161cdf0e10cSrcweir class XMLTextFrameParam_Impl : public SvXMLImportContext
162cdf0e10cSrcweir {
163cdf0e10cSrcweir public:
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	TYPEINFO();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	XMLTextFrameParam_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
168cdf0e10cSrcweir 								  const ::rtl::OUString& rLName,
169cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
170cdf0e10cSrcweir 				::com::sun::star::xml::sax::XAttributeList > & xAttrList,
171cdf0e10cSrcweir 			sal_uInt16 nType,
172cdf0e10cSrcweir             ParamMap &rParamMap);
173cdf0e10cSrcweir 	virtual ~XMLTextFrameParam_Impl();
174cdf0e10cSrcweir };
175cdf0e10cSrcweir 
176cdf0e10cSrcweir TYPEINIT1( XMLTextFrameParam_Impl, SvXMLImportContext );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir XMLTextFrameParam_Impl::~XMLTextFrameParam_Impl()
179cdf0e10cSrcweir {
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir XMLTextFrameParam_Impl::XMLTextFrameParam_Impl(
183cdf0e10cSrcweir 		SvXMLImport& rImport, sal_uInt16 nPrfx,
184cdf0e10cSrcweir 	  	const ::rtl::OUString& rLName,
185cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference<
186cdf0e10cSrcweir 				::com::sun::star::xml::sax::XAttributeList > & xAttrList,
187cdf0e10cSrcweir 		sal_uInt16 /*nType*/,
188cdf0e10cSrcweir         ParamMap &rParamMap):
189cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	OUString sName, sValue;
192cdf0e10cSrcweir     sal_Bool bFoundValue = sal_False; // to allow empty values
193cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
194cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
197cdf0e10cSrcweir 		const OUString& rValue = xAttrList->getValueByIndex( i );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		OUString aLocalName;
200cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
201cdf0e10cSrcweir 		if ( XML_NAMESPACE_DRAW == nPrefix )
202cdf0e10cSrcweir 		{
203cdf0e10cSrcweir 		   	if( IsXMLToken(aLocalName, XML_VALUE) )
204cdf0e10cSrcweir 			{
205cdf0e10cSrcweir 				sValue = rValue;
206cdf0e10cSrcweir 				bFoundValue=sal_True;
207cdf0e10cSrcweir 			}
208cdf0e10cSrcweir 			else if( IsXMLToken(aLocalName, XML_NAME) )
209cdf0e10cSrcweir 			{
210cdf0e10cSrcweir 				sName = rValue;
211cdf0e10cSrcweir 			}
212cdf0e10cSrcweir 		}
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 	if (sName.getLength() && bFoundValue )
215cdf0e10cSrcweir         rParamMap[sName] = sValue;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir class XMLTextFrameContourContext_Impl : public SvXMLImportContext
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	Reference < XPropertySet > xPropSet;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir public:
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	TYPEINFO();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
226cdf0e10cSrcweir 								  const ::rtl::OUString& rLName,
227cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
228cdf0e10cSrcweir 				::com::sun::star::xml::sax::XAttributeList > & xAttrList,
229cdf0e10cSrcweir 			const Reference < XPropertySet >& rPropSet,
230cdf0e10cSrcweir 			sal_Bool bPath );
231cdf0e10cSrcweir 	virtual ~XMLTextFrameContourContext_Impl();
232cdf0e10cSrcweir };
233cdf0e10cSrcweir 
234cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext );
235cdf0e10cSrcweir 
236cdf0e10cSrcweir XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
237cdf0e10cSrcweir 		SvXMLImport& rImport,
238cdf0e10cSrcweir 		sal_uInt16 nPrfx, const OUString& rLName,
239cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList,
240cdf0e10cSrcweir 		const Reference < XPropertySet >& rPropSet,
241cdf0e10cSrcweir 	    sal_Bool bPath ) :
242cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName ),
243cdf0e10cSrcweir 	xPropSet( rPropSet )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	OUString sD, sPoints, sViewBox;
246cdf0e10cSrcweir 	sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False;
247cdf0e10cSrcweir 	sal_Bool bAuto = sal_False;
248cdf0e10cSrcweir 	sal_Int32 nWidth = 0;
249cdf0e10cSrcweir 	sal_Int32 nHeight = 0;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
252cdf0e10cSrcweir 		GetImport().GetTextImport()->GetTextContourAttrTokenMap();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
255cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
258cdf0e10cSrcweir 		const OUString& rValue = xAttrList->getValueByIndex( i );
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 		OUString aLocalName;
261cdf0e10cSrcweir 		sal_uInt16 nPrefix =
262cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
263cdf0e10cSrcweir 															&aLocalName );
264cdf0e10cSrcweir 		switch( rTokenMap.Get( nPrefix, aLocalName ) )
265cdf0e10cSrcweir 		{
266cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_VIEWBOX:
267cdf0e10cSrcweir 			sViewBox = rValue;
268cdf0e10cSrcweir 			break;
269cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_D:
270cdf0e10cSrcweir 			if( bPath )
271cdf0e10cSrcweir 				sD = rValue;
272cdf0e10cSrcweir 			break;
273cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_POINTS:
274cdf0e10cSrcweir 			if( !bPath )
275cdf0e10cSrcweir 				sPoints = rValue;
276cdf0e10cSrcweir 			break;
277cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_WIDTH:
278cdf0e10cSrcweir 			if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth,
279cdf0e10cSrcweir 																	  rValue) )
280cdf0e10cSrcweir 				bPixelWidth = sal_True;
281cdf0e10cSrcweir 			else
282cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
283cdf0e10cSrcweir 																rValue);
284cdf0e10cSrcweir 			break;
285cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_HEIGHT:
286cdf0e10cSrcweir 			if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight,
287cdf0e10cSrcweir 																rValue) )
288cdf0e10cSrcweir 				bPixelHeight = sal_True;
289cdf0e10cSrcweir 			else
290cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
291cdf0e10cSrcweir 																	rValue);
292cdf0e10cSrcweir 			break;
293cdf0e10cSrcweir 		case XML_TOK_TEXT_CONTOUR_AUTO:
294cdf0e10cSrcweir 			bAuto = IsXMLToken(rValue, XML_TRUE);
295cdf0e10cSrcweir 			break;
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	OUString sContourPolyPolygon(
300cdf0e10cSrcweir 			RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon") );
301cdf0e10cSrcweir 	Reference < XPropertySetInfo > xPropSetInfo =
302cdf0e10cSrcweir 		rPropSet->getPropertySetInfo();
303cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName(
304cdf0e10cSrcweir 													sContourPolyPolygon ) &&
305cdf0e10cSrcweir 		nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight &&
306cdf0e10cSrcweir 		(bPath ? sD : sPoints).getLength() )
307cdf0e10cSrcweir 	{
308cdf0e10cSrcweir 		awt::Point aPoint( 0,  0 );
309cdf0e10cSrcweir 		awt::Size aSize( nWidth, nHeight );
310cdf0e10cSrcweir 		SdXMLImExViewBox aViewBox( sViewBox,
311cdf0e10cSrcweir 								   GetImport().GetMM100UnitConverter());
312cdf0e10cSrcweir 		Any aAny;
313cdf0e10cSrcweir 		if( bPath )
314cdf0e10cSrcweir 		{
315cdf0e10cSrcweir 			SdXMLImExSvgDElement aPoints( sD, aViewBox, aPoint, aSize,
316cdf0e10cSrcweir 										  GetImport().GetMM100UnitConverter() );
317cdf0e10cSrcweir 			aAny <<= aPoints.GetPointSequenceSequence();
318cdf0e10cSrcweir 		}
319cdf0e10cSrcweir 		else
320cdf0e10cSrcweir 		{
321cdf0e10cSrcweir 			SdXMLImExPointsElement aPoints( sPoints, aViewBox, aPoint, aSize,
322cdf0e10cSrcweir 										GetImport().GetMM100UnitConverter() );
323cdf0e10cSrcweir 			aAny <<= aPoints.GetPointSequenceSequence();
324cdf0e10cSrcweir 		}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 		OUString sIsPixelContour(
327cdf0e10cSrcweir 				RTL_CONSTASCII_USTRINGPARAM("IsPixelContour") );
328cdf0e10cSrcweir 		xPropSet->setPropertyValue( sContourPolyPolygon, aAny );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			aAny.setValue( &bPixelWidth, ::getBooleanCppuType() );
333cdf0e10cSrcweir 			xPropSet->setPropertyValue( sIsPixelContour, aAny );
334cdf0e10cSrcweir 		}
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 		OUString sIsAutomaticContour(
337cdf0e10cSrcweir 				RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") );
338cdf0e10cSrcweir 		if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
339cdf0e10cSrcweir 		{
340cdf0e10cSrcweir 			aAny.setValue( &bAuto, ::getBooleanCppuType() );
341cdf0e10cSrcweir 			xPropSet->setPropertyValue( sIsAutomaticContour, aAny );
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl()
347cdf0e10cSrcweir {
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir // ------------------------------------------------------------------------
351cdf0e10cSrcweir 
352cdf0e10cSrcweir class XMLTextFrameContext_Impl : public SvXMLImportContext
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	::com::sun::star::uno::Reference <
355cdf0e10cSrcweir 		::com::sun::star::text::XTextCursor > xOldTextCursor;
356cdf0e10cSrcweir 	::com::sun::star::uno::Reference <
357cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet > xPropSet;
358cdf0e10cSrcweir 	::com::sun::star::uno::Reference <
359cdf0e10cSrcweir 		::com::sun::star::io::XOutputStream > xBase64Stream;
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     /// old list item and block (#89891#)
362cdf0e10cSrcweir     bool mbListContextPushed;
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	const ::rtl::OUString sWidth;
365cdf0e10cSrcweir 	const ::rtl::OUString sWidthType;
366cdf0e10cSrcweir 	const ::rtl::OUString sRelativeWidth;
367cdf0e10cSrcweir 	const ::rtl::OUString sHeight;
368cdf0e10cSrcweir 	const ::rtl::OUString sRelativeHeight;
369cdf0e10cSrcweir 	const ::rtl::OUString sSizeType;
370cdf0e10cSrcweir 	const ::rtl::OUString sIsSyncWidthToHeight;
371cdf0e10cSrcweir 	const ::rtl::OUString sIsSyncHeightToWidth;
372cdf0e10cSrcweir 	const ::rtl::OUString sHoriOrient;
373cdf0e10cSrcweir 	const ::rtl::OUString sHoriOrientPosition;
374cdf0e10cSrcweir 	const ::rtl::OUString sVertOrient;
375cdf0e10cSrcweir 	const ::rtl::OUString sVertOrientPosition;
376cdf0e10cSrcweir 	const ::rtl::OUString sChainNextName;
377cdf0e10cSrcweir 	const ::rtl::OUString sAnchorType;
378cdf0e10cSrcweir 	const ::rtl::OUString sAnchorPageNo;
379cdf0e10cSrcweir 	const ::rtl::OUString sGraphicURL;
380cdf0e10cSrcweir 	const ::rtl::OUString sGraphicFilter;
381cdf0e10cSrcweir     // --> OD 2009-07-22 #i73249#
382cdf0e10cSrcweir //    const ::rtl::OUString sAlternativeText;
383cdf0e10cSrcweir     const ::rtl::OUString sTitle;
384cdf0e10cSrcweir     const ::rtl::OUString sDescription;
385cdf0e10cSrcweir     // <--
386cdf0e10cSrcweir 	const ::rtl::OUString sFrameStyleName;
387cdf0e10cSrcweir 	const ::rtl::OUString sGraphicRotation;
388cdf0e10cSrcweir 	const ::rtl::OUString sTextBoxServiceName;
389cdf0e10cSrcweir 	const ::rtl::OUString sGraphicServiceName;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	::rtl::OUString	sName;
392cdf0e10cSrcweir 	::rtl::OUString	sStyleName;
393cdf0e10cSrcweir 	::rtl::OUString	sNextName;
394cdf0e10cSrcweir 	::rtl::OUString	sHRef;
395cdf0e10cSrcweir 	::rtl::OUString	sFilterName;
396cdf0e10cSrcweir 	::rtl::OUString	sCode;
397cdf0e10cSrcweir 	::rtl::OUString	sObject;
398cdf0e10cSrcweir 	::rtl::OUString	sArchive;
399cdf0e10cSrcweir 	::rtl::OUString	sMimeType;
400cdf0e10cSrcweir 	::rtl::OUString sFrameName;
401cdf0e10cSrcweir 	::rtl::OUString sAppletName;
402cdf0e10cSrcweir 	::rtl::OUString	sFilterService;
403cdf0e10cSrcweir 	::rtl::OUString sBase64CharsLeft;
404cdf0e10cSrcweir 	::rtl::OUString	sTblName;
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     ParamMap aParamMap;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	sal_Int32	nX;
409cdf0e10cSrcweir 	sal_Int32	nY;
410cdf0e10cSrcweir 	sal_Int32	nWidth;
411cdf0e10cSrcweir 	sal_Int32	nHeight;
412cdf0e10cSrcweir 	sal_Int32	nZIndex;
413cdf0e10cSrcweir 	sal_Int16	nPage;
414cdf0e10cSrcweir 	sal_Int16	nRotation;
415cdf0e10cSrcweir 	sal_Int16	nRelWidth;
416cdf0e10cSrcweir 	sal_Int16	nRelHeight;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 	sal_uInt16 nType;
419cdf0e10cSrcweir 	::com::sun::star::text::TextContentAnchorType 	eAnchorType;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	sal_Bool	bMayScript : 1;
422cdf0e10cSrcweir 	sal_Bool	bMinWidth : 1;
423cdf0e10cSrcweir 	sal_Bool	bMinHeight : 1;
424cdf0e10cSrcweir 	sal_Bool	bSyncWidth : 1;
425cdf0e10cSrcweir 	sal_Bool	bSyncHeight : 1;
426cdf0e10cSrcweir 	sal_Bool	bCreateFailed : 1;
427cdf0e10cSrcweir 	sal_Bool	bOwnBase64Stream : 1;
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	void Create( sal_Bool bHRefOrBase64 );
430cdf0e10cSrcweir 
431cdf0e10cSrcweir public:
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 	TYPEINFO();
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	sal_Bool CreateIfNotThere();
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 	XMLTextFrameContext_Impl( SvXMLImport& rImport,
438cdf0e10cSrcweir 			sal_uInt16 nPrfx,
439cdf0e10cSrcweir 			const ::rtl::OUString& rLName,
440cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
441cdf0e10cSrcweir 				::com::sun::star::xml::sax::XAttributeList > & rAttrList,
442cdf0e10cSrcweir 			::com::sun::star::text::TextContentAnchorType eAnchorType,
443cdf0e10cSrcweir 			sal_uInt16 nType,
444cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
445cdf0e10cSrcweir 				::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList );
446cdf0e10cSrcweir 	virtual ~XMLTextFrameContext_Impl();
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	virtual void EndElement();
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 	virtual void Characters( const ::rtl::OUString& rChars );
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
453cdf0e10cSrcweir 				const ::rtl::OUString& rLocalName,
454cdf0e10cSrcweir 			 	const ::com::sun::star::uno::Reference<
455cdf0e10cSrcweir 					::com::sun::star::xml::sax::XAttributeList > & xAttrList );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	void SetHyperlink( const ::rtl::OUString& rHRef,
458cdf0e10cSrcweir 					   const ::rtl::OUString& rName,
459cdf0e10cSrcweir 					   const ::rtl::OUString& rTargetFrameName,
460cdf0e10cSrcweir 					   sal_Bool bMap );
461cdf0e10cSrcweir     // --> OD 2009-07-22 #i73249#
462cdf0e10cSrcweir     void SetTitle( const ::rtl::OUString& rTitle );
463cdf0e10cSrcweir     // <--
464cdf0e10cSrcweir     void SetDesc( const ::rtl::OUString& rDesc );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference <
469cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >& GetPropSet() { return xPropSet; }
470cdf0e10cSrcweir };
471cdf0e10cSrcweir 
472cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
473cdf0e10cSrcweir 
474cdf0e10cSrcweir void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir 	UniReference < XMLTextImportHelper > xTextImportHelper =
477cdf0e10cSrcweir 		GetImport().GetTextImport();
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     switch ( nType)
480cdf0e10cSrcweir     {
481cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT:
482cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT_OLE:
483cdf0e10cSrcweir 			if( xBase64Stream.is() )
484cdf0e10cSrcweir 			{
485cdf0e10cSrcweir 				OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
486cdf0e10cSrcweir 				if( sURL.getLength() )
487cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
488cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
489cdf0e10cSrcweir 														sStyleName,
490cdf0e10cSrcweir 														sTblName,
491cdf0e10cSrcweir 														nWidth, nHeight );
492cdf0e10cSrcweir 			}
493cdf0e10cSrcweir 			else if( sHRef.getLength() )
494cdf0e10cSrcweir 			{
495cdf0e10cSrcweir 				OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
496cdf0e10cSrcweir 																OUString() ) );
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 				if( GetImport().IsPackageURL( sHRef ) )
499cdf0e10cSrcweir 				{
500cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
501cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
502cdf0e10cSrcweir 														sStyleName,
503cdf0e10cSrcweir 														sTblName,
504cdf0e10cSrcweir 														nWidth, nHeight );
505cdf0e10cSrcweir 				}
506cdf0e10cSrcweir 				else
507cdf0e10cSrcweir 				{
508cdf0e10cSrcweir 					// it should be an own OOo link that has no storage persistance
509cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
510cdf0e10cSrcweir 							->createAndInsertOOoLink( GetImport(),
511cdf0e10cSrcweir 														sURL,
512cdf0e10cSrcweir 														sStyleName,
513cdf0e10cSrcweir 														sTblName,
514cdf0e10cSrcweir 														nWidth, nHeight );
515cdf0e10cSrcweir 				}
516cdf0e10cSrcweir 			}
517cdf0e10cSrcweir 			else
518cdf0e10cSrcweir 			{
519cdf0e10cSrcweir 				OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") );
520cdf0e10cSrcweir 				sURL += sFilterService;
521cdf0e10cSrcweir 				xPropSet = GetImport().GetTextImport()
522cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
523cdf0e10cSrcweir 														sStyleName,
524cdf0e10cSrcweir 														sTblName,
525cdf0e10cSrcweir 														nWidth, nHeight );
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 			}
528cdf0e10cSrcweir 			break;
529cdf0e10cSrcweir         case XML_TEXT_FRAME_APPLET:
530cdf0e10cSrcweir         {
531cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
532cdf0e10cSrcweir 							->createAndInsertApplet( sAppletName, sCode,
533cdf0e10cSrcweir 													 bMayScript, sHRef,
534cdf0e10cSrcweir 													 nWidth, nHeight);
535cdf0e10cSrcweir             break;
536cdf0e10cSrcweir         }
537cdf0e10cSrcweir         case XML_TEXT_FRAME_PLUGIN:
538cdf0e10cSrcweir         {
539cdf0e10cSrcweir             if(sHRef.getLength())
540cdf0e10cSrcweir                 GetImport().GetAbsoluteReference(sHRef);
541cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
542cdf0e10cSrcweir 							->createAndInsertPlugin( sMimeType, sHRef,
543cdf0e10cSrcweir 								   				 	 nWidth, nHeight);
544cdf0e10cSrcweir 
545cdf0e10cSrcweir             break;
546cdf0e10cSrcweir         }
547cdf0e10cSrcweir         case XML_TEXT_FRAME_FLOATING_FRAME:
548cdf0e10cSrcweir         {
549cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
550cdf0e10cSrcweir 							->createAndInsertFloatingFrame( sFrameName, sHRef,
551cdf0e10cSrcweir 															sStyleName,
552cdf0e10cSrcweir 															nWidth, nHeight);
553cdf0e10cSrcweir             break;
554cdf0e10cSrcweir         }
555cdf0e10cSrcweir 	    default:
556cdf0e10cSrcweir         {
557cdf0e10cSrcweir             Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
558cdf0e10cSrcweir                                                       UNO_QUERY );
559cdf0e10cSrcweir             if( xFactory.is() )
560cdf0e10cSrcweir             {
561cdf0e10cSrcweir                 OUString sServiceName;
562cdf0e10cSrcweir                 switch( nType )
563cdf0e10cSrcweir                 {
564cdf0e10cSrcweir                     case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break;
565cdf0e10cSrcweir                     case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break;
566cdf0e10cSrcweir                 }
567cdf0e10cSrcweir                 Reference<XInterface> xIfc = xFactory->createInstance( sServiceName );
568cdf0e10cSrcweir                 DBG_ASSERT( xIfc.is(), "couldn't create frame" );
569cdf0e10cSrcweir                 if( xIfc.is() )
570cdf0e10cSrcweir                     xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY );
571cdf0e10cSrcweir             }
572cdf0e10cSrcweir         }
573cdf0e10cSrcweir     }
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	if( !xPropSet.is() )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		bCreateFailed = sal_True;
578cdf0e10cSrcweir 		return;
579cdf0e10cSrcweir 	}
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	// set name
584cdf0e10cSrcweir 	Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
585cdf0e10cSrcweir 	if( xNamed.is() )
586cdf0e10cSrcweir 	{
587cdf0e10cSrcweir 		OUString sOrigName( xNamed->getName() );
588cdf0e10cSrcweir 		if( !sOrigName.getLength() ||
589cdf0e10cSrcweir 			(sName.getLength() && sOrigName != sName) )
590cdf0e10cSrcweir 		{
591cdf0e10cSrcweir 			OUString sOldName( sName );
592cdf0e10cSrcweir 			sal_Int32 i = 0;
593cdf0e10cSrcweir 			while( xTextImportHelper->HasFrameByName( sName ) )
594cdf0e10cSrcweir 			{
595cdf0e10cSrcweir 				sName = sOldName;
596cdf0e10cSrcweir 				sName += OUString::valueOf( ++i );
597cdf0e10cSrcweir 			}
598cdf0e10cSrcweir 			xNamed->setName( sName );
599cdf0e10cSrcweir 			if( sName != sOldName )
600cdf0e10cSrcweir 				xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
601cdf0e10cSrcweir 											 sOldName, sName );
602cdf0e10cSrcweir 		}
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	// frame style
606cdf0e10cSrcweir 	XMLPropStyleContext *pStyle = 0;
607cdf0e10cSrcweir 	if( sStyleName.getLength() )
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
610cdf0e10cSrcweir 		if( pStyle )
611cdf0e10cSrcweir             sStyleName = pStyle->GetParentName();
612cdf0e10cSrcweir 	}
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 	Any aAny;
615cdf0e10cSrcweir 	if( sStyleName.getLength() )
616cdf0e10cSrcweir 	{
617cdf0e10cSrcweir 		OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
618cdf0e10cSrcweir 							XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) );
619cdf0e10cSrcweir 		const Reference < XNameContainer > & rStyles =
620cdf0e10cSrcweir 			xTextImportHelper->GetFrameStyles();
621cdf0e10cSrcweir 		if( rStyles.is() &&
622cdf0e10cSrcweir 			rStyles->hasByName( sDisplayStyleName ) )
623cdf0e10cSrcweir 		{
624cdf0e10cSrcweir 			aAny <<= sDisplayStyleName;
625cdf0e10cSrcweir 			xPropSet->setPropertyValue( sFrameStyleName, aAny );
626cdf0e10cSrcweir 		}
627cdf0e10cSrcweir 	}
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 	// anchor type (must be set before any other properties, because
630cdf0e10cSrcweir 	// otherwise some orientations cannot be set or will be changed
631cdf0e10cSrcweir 	// afterwards)
632cdf0e10cSrcweir 	aAny <<= eAnchorType;
633cdf0e10cSrcweir 	xPropSet->setPropertyValue( sAnchorType, aAny );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 	// hard properties
636cdf0e10cSrcweir 	if( pStyle )
637cdf0e10cSrcweir 		pStyle->FillPropertySet( xPropSet );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	// x and y
641cdf0e10cSrcweir 	sal_Int16 nHoriOrient =  HoriOrientation::NONE;
642cdf0e10cSrcweir 	aAny = xPropSet->getPropertyValue( sHoriOrient );
643cdf0e10cSrcweir 	aAny >>= nHoriOrient;
644cdf0e10cSrcweir 	if( HoriOrientation::NONE == nHoriOrient )
645cdf0e10cSrcweir 	{
646cdf0e10cSrcweir 		aAny <<= nX;
647cdf0e10cSrcweir 		xPropSet->setPropertyValue( sHoriOrientPosition, aAny );
648cdf0e10cSrcweir 	}
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 	sal_Int16 nVertOrient =  VertOrientation::NONE;
651cdf0e10cSrcweir 	aAny = xPropSet->getPropertyValue( sVertOrient );
652cdf0e10cSrcweir 	aAny >>= nVertOrient;
653cdf0e10cSrcweir 	if( VertOrientation::NONE == nVertOrient )
654cdf0e10cSrcweir 	{
655cdf0e10cSrcweir 		aAny <<= nY;
656cdf0e10cSrcweir 		xPropSet->setPropertyValue( sVertOrientPosition, aAny );
657cdf0e10cSrcweir 	}
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 	// width
660cdf0e10cSrcweir 	if( nWidth > 0 )
661cdf0e10cSrcweir 	{
662cdf0e10cSrcweir 		aAny <<= nWidth;
663cdf0e10cSrcweir 		xPropSet->setPropertyValue( sWidth, aAny );
664cdf0e10cSrcweir 	}
665cdf0e10cSrcweir 	if( nRelWidth > 0 || nWidth > 0 )
666cdf0e10cSrcweir 	{
667cdf0e10cSrcweir 		aAny <<= nRelWidth;
668cdf0e10cSrcweir 		xPropSet->setPropertyValue( sRelativeWidth, aAny );
669cdf0e10cSrcweir 	}
670cdf0e10cSrcweir 	if( bSyncWidth || nWidth > 0 )
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		sal_Bool bTmp = bSyncWidth;
673cdf0e10cSrcweir 		aAny.setValue( &bTmp, ::getBooleanCppuType() );
674cdf0e10cSrcweir 		xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny );
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sWidthType ) &&
677cdf0e10cSrcweir 		(bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 		sal_Int16 nSizeType =
680cdf0e10cSrcweir 			(bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
681cdf0e10cSrcweir                                                            : SizeType::FIX;
682cdf0e10cSrcweir 		aAny <<= nSizeType;
683cdf0e10cSrcweir 		xPropSet->setPropertyValue( sWidthType, aAny );
684cdf0e10cSrcweir 	}
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 	if( nHeight > 0 )
687cdf0e10cSrcweir 	{
688cdf0e10cSrcweir 		aAny <<= nHeight;
689cdf0e10cSrcweir 		xPropSet->setPropertyValue( sHeight, aAny );
690cdf0e10cSrcweir 	}
691cdf0e10cSrcweir 	if( nRelHeight > 0 || nHeight > 0 )
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		aAny <<= nRelHeight;
694cdf0e10cSrcweir 		xPropSet->setPropertyValue( sRelativeHeight, aAny );
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir 	if( bSyncHeight || nHeight > 0 )
697cdf0e10cSrcweir 	{
698cdf0e10cSrcweir 		sal_Bool bTmp = bSyncHeight;
699cdf0e10cSrcweir 		aAny.setValue( &bTmp, ::getBooleanCppuType() );
700cdf0e10cSrcweir 		xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny );
701cdf0e10cSrcweir 	}
702cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sSizeType ) &&
703cdf0e10cSrcweir 		(bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
704cdf0e10cSrcweir 	{
705cdf0e10cSrcweir 		sal_Int16 nSizeType =
706cdf0e10cSrcweir 			(bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
707cdf0e10cSrcweir 															: SizeType::FIX;
708cdf0e10cSrcweir 		aAny <<= nSizeType;
709cdf0e10cSrcweir 		xPropSet->setPropertyValue( sSizeType, aAny );
710cdf0e10cSrcweir 	}
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 	if( XML_TEXT_FRAME_GRAPHIC == nType )
713cdf0e10cSrcweir 	{
714cdf0e10cSrcweir 		// URL
715cdf0e10cSrcweir 		OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(),
716cdf0e10cSrcweir 					"neither URL nor base64 image data given" );
717cdf0e10cSrcweir 		UniReference < XMLTextImportHelper > xTxtImport =
718cdf0e10cSrcweir 			GetImport().GetTextImport();
719cdf0e10cSrcweir 		if( sHRef.getLength() )
720cdf0e10cSrcweir 		{
721cdf0e10cSrcweir 			sal_Bool bForceLoad = xTxtImport->IsInsertMode() ||
722cdf0e10cSrcweir 								  xTxtImport->IsBlockMode() ||
723cdf0e10cSrcweir 								  xTxtImport->IsStylesOnlyMode() ||
724cdf0e10cSrcweir 								  xTxtImport->IsOrganizerMode();
725cdf0e10cSrcweir 			sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad );
726cdf0e10cSrcweir 		}
727cdf0e10cSrcweir 		else if( xBase64Stream.is() )
728cdf0e10cSrcweir 		{
729cdf0e10cSrcweir 			sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
730cdf0e10cSrcweir 			xBase64Stream = 0;
731cdf0e10cSrcweir 		}
732cdf0e10cSrcweir 		aAny <<= sHRef;
733cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicURL, aAny );
734cdf0e10cSrcweir 
735cdf0e10cSrcweir 		// filter name
736cdf0e10cSrcweir 		aAny <<=sFilterName;
737cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicFilter, aAny );
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 		// rotation
740cdf0e10cSrcweir 		aAny <<= nRotation;
741cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicRotation, aAny );
742cdf0e10cSrcweir 	}
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	// page number (must be set after the frame is inserted, because it
745cdf0e10cSrcweir 	// will be overwritten then inserting the frame.
746cdf0e10cSrcweir 	if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
747cdf0e10cSrcweir 	{
748cdf0e10cSrcweir 		aAny <<= nPage;
749cdf0e10cSrcweir 		xPropSet->setPropertyValue( sAnchorPageNo, aAny );
750cdf0e10cSrcweir 	}
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 	if( XML_TEXT_FRAME_OBJECT != nType  &&
753cdf0e10cSrcweir 		XML_TEXT_FRAME_OBJECT_OLE != nType  &&
754cdf0e10cSrcweir 		XML_TEXT_FRAME_APPLET != nType &&
755cdf0e10cSrcweir 		XML_TEXT_FRAME_PLUGIN!= nType &&
756cdf0e10cSrcweir 		XML_TEXT_FRAME_FLOATING_FRAME != nType)
757cdf0e10cSrcweir 	{
758cdf0e10cSrcweir 		Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
759cdf0e10cSrcweir 		xTextImportHelper->InsertTextContent( xTxtCntnt );
760cdf0e10cSrcweir 	}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 	Reference < XShape > xShape( xPropSet, UNO_QUERY );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 	// #107848#
765cdf0e10cSrcweir 	// Make adding the shepe to Z-Ordering dependent from if we are
766cdf0e10cSrcweir 	// inside a inside_deleted_section (redlining). That is necessary
767cdf0e10cSrcweir 	// since the shape will be removed again later. It would lead to
768cdf0e10cSrcweir 	// errors if it would stay inside the Z-Ordering. Thus, the
769cdf0e10cSrcweir 	// easiest way to solve that conflict is to not add it here.
770cdf0e10cSrcweir 	if(!GetImport().HasTextImport()
771cdf0e10cSrcweir 		|| !GetImport().GetTextImport()->IsInsideDeleteContext())
772cdf0e10cSrcweir 	{
773cdf0e10cSrcweir 		GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
774cdf0e10cSrcweir 	}
775cdf0e10cSrcweir 
776cdf0e10cSrcweir 	if( XML_TEXT_FRAME_TEXTBOX == nType )
777cdf0e10cSrcweir 	{
778cdf0e10cSrcweir 		xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
779cdf0e10cSrcweir 		Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
780cdf0e10cSrcweir 		Reference < XText > xTxt = xTxtFrame->getText();
781cdf0e10cSrcweir 		xOldTextCursor = xTextImportHelper->GetCursor();
782cdf0e10cSrcweir 		xTextImportHelper->SetCursor( xTxt->createTextCursor() );
783cdf0e10cSrcweir 
784cdf0e10cSrcweir         // remember old list item and block (#89892#) and reset them
785cdf0e10cSrcweir         // for the text frame
786cdf0e10cSrcweir         xTextImportHelper->PushListContext();
787cdf0e10cSrcweir         mbListContextPushed = true;
788cdf0e10cSrcweir 	}
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere()
792cdf0e10cSrcweir {
793cdf0e10cSrcweir 	if( !xPropSet.is() &&
794cdf0e10cSrcweir 		( XML_TEXT_FRAME_OBJECT_OLE == nType ||
795cdf0e10cSrcweir 		  XML_TEXT_FRAME_GRAPHIC == nType ) &&
796cdf0e10cSrcweir 		xBase64Stream.is() && !bCreateFailed )
797cdf0e10cSrcweir 	{
798cdf0e10cSrcweir 		if( bOwnBase64Stream )
799cdf0e10cSrcweir 			xBase64Stream->closeOutput();
800cdf0e10cSrcweir 		Create( sal_True );
801cdf0e10cSrcweir 	}
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 	return xPropSet.is();
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
806cdf0e10cSrcweir XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
807cdf0e10cSrcweir 		SvXMLImport& rImport,
808cdf0e10cSrcweir 		sal_uInt16 nPrfx, const OUString& rLName,
809cdf0e10cSrcweir 		const Reference< XAttributeList > & rAttrList,
810cdf0e10cSrcweir 		TextContentAnchorType eATyp,
811cdf0e10cSrcweir 		sal_uInt16 nNewType,
812cdf0e10cSrcweir 		const Reference< XAttributeList > & rFrameAttrList )
813cdf0e10cSrcweir :	SvXMLImportContext( rImport, nPrfx, rLName )
814cdf0e10cSrcweir ,   mbListContextPushed( false )
815cdf0e10cSrcweir ,	sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
816cdf0e10cSrcweir ,	sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
817cdf0e10cSrcweir ,	sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
818cdf0e10cSrcweir ,	sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
819cdf0e10cSrcweir ,	sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
820cdf0e10cSrcweir ,	sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
821cdf0e10cSrcweir ,	sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
822cdf0e10cSrcweir ,	sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
823cdf0e10cSrcweir ,	sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
824cdf0e10cSrcweir ,	sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
825cdf0e10cSrcweir ,	sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
826cdf0e10cSrcweir ,	sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
827cdf0e10cSrcweir ,	sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
828cdf0e10cSrcweir ,	sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
829cdf0e10cSrcweir ,	sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
830cdf0e10cSrcweir ,	sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
831cdf0e10cSrcweir ,	sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
832cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
833cdf0e10cSrcweir //,   sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
834cdf0e10cSrcweir ,   sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
835cdf0e10cSrcweir ,   sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
836cdf0e10cSrcweir // <--
837cdf0e10cSrcweir ,	sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
838cdf0e10cSrcweir ,	sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
839cdf0e10cSrcweir ,	sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
840cdf0e10cSrcweir ,	sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
841cdf0e10cSrcweir ,	nType( nNewType )
842cdf0e10cSrcweir ,	eAnchorType( eATyp )
843cdf0e10cSrcweir {
844cdf0e10cSrcweir 	nX = 0;
845cdf0e10cSrcweir 	nY = 0;
846cdf0e10cSrcweir 	nWidth = 0;
847cdf0e10cSrcweir 	nHeight = 0;
848cdf0e10cSrcweir 	nZIndex = -1;
849cdf0e10cSrcweir 	nPage = 0;
850cdf0e10cSrcweir 	nRotation = 0;
851cdf0e10cSrcweir 	nRelWidth = 0;
852cdf0e10cSrcweir 	nRelHeight = 0;
853cdf0e10cSrcweir 	bMayScript = sal_False;
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 	bMinHeight = sal_False;
856cdf0e10cSrcweir 	bMinWidth = sal_False;
857cdf0e10cSrcweir 	bSyncWidth = sal_False;
858cdf0e10cSrcweir 	bSyncHeight = sal_False;
859cdf0e10cSrcweir 	bCreateFailed = sal_False;
860cdf0e10cSrcweir 	bOwnBase64Stream = sal_False;
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 	UniReference < XMLTextImportHelper > xTxtImport =
863cdf0e10cSrcweir 		GetImport().GetTextImport();
864cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
865cdf0e10cSrcweir 		xTxtImport->GetTextFrameAttrTokenMap();
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 	sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
868cdf0e10cSrcweir 	sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0);
869cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nTotalAttrCount; i++ )
870cdf0e10cSrcweir 	{
871cdf0e10cSrcweir 		const OUString& rAttrName =
872cdf0e10cSrcweir 			i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount );
873cdf0e10cSrcweir 		const OUString& rValue =
874cdf0e10cSrcweir 			i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 		OUString aLocalName;
877cdf0e10cSrcweir 		sal_uInt16 nPrefix =
878cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
879cdf0e10cSrcweir 															&aLocalName );
880cdf0e10cSrcweir 		switch( rTokenMap.Get( nPrefix, aLocalName ) )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_STYLE_NAME:
883cdf0e10cSrcweir 			sStyleName = rValue;
884cdf0e10cSrcweir 			break;
885cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NAME:
886cdf0e10cSrcweir 			sName = rValue;
887cdf0e10cSrcweir 			break;
888cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_FRAME_NAME:
889cdf0e10cSrcweir 			sFrameName = rValue;
890cdf0e10cSrcweir 			break;
891cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_APPLET_NAME:
892cdf0e10cSrcweir 			sAppletName = rValue;
893cdf0e10cSrcweir 			break;
894cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ANCHOR_TYPE:
895cdf0e10cSrcweir 			if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
896cdf0e10cSrcweir 				TextContentAnchorType_AT_CHARACTER == eAnchorType ||
897cdf0e10cSrcweir 				TextContentAnchorType_AS_CHARACTER == eAnchorType )
898cdf0e10cSrcweir 			{
899cdf0e10cSrcweir 
900cdf0e10cSrcweir 				TextContentAnchorType eNew;
901cdf0e10cSrcweir 				if( XMLAnchorTypePropHdl::convert( rValue, eNew ) &&
902cdf0e10cSrcweir 					( TextContentAnchorType_AT_PARAGRAPH == eNew ||
903cdf0e10cSrcweir 					  TextContentAnchorType_AT_CHARACTER == eNew ||
904cdf0e10cSrcweir 					  TextContentAnchorType_AS_CHARACTER == eNew ||
905cdf0e10cSrcweir 					  TextContentAnchorType_AT_PAGE == eNew) )
906cdf0e10cSrcweir 					eAnchorType = eNew;
907cdf0e10cSrcweir 			}
908cdf0e10cSrcweir 			break;
909cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER:
910cdf0e10cSrcweir 			{
911cdf0e10cSrcweir 				sal_Int32 nTmp;
912cdf0e10cSrcweir 			   	if( GetImport().GetMM100UnitConverter().
913cdf0e10cSrcweir 								convertNumber( nTmp, rValue, 1, SHRT_MAX ) )
914cdf0e10cSrcweir 					nPage = (sal_Int16)nTmp;
915cdf0e10cSrcweir 			}
916cdf0e10cSrcweir 			break;
917cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_X:
918cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue );
919cdf0e10cSrcweir 			break;
920cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_Y:
921cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue );
922cdf0e10cSrcweir 			break;
923cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_WIDTH:
924cdf0e10cSrcweir 			// relative widths are obsolete since SRC617. Remove them some day!
925cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
926cdf0e10cSrcweir 			{
927cdf0e10cSrcweir 				sal_Int32 nTmp;
928cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
929cdf0e10cSrcweir 																	rValue );
930cdf0e10cSrcweir 				nRelWidth = (sal_Int16)nTmp;
931cdf0e10cSrcweir 			}
932cdf0e10cSrcweir 			else
933cdf0e10cSrcweir 			{
934cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
935cdf0e10cSrcweir 																	rValue, 0 );
936cdf0e10cSrcweir 			}
937cdf0e10cSrcweir 			break;
938cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_REL_WIDTH:
939cdf0e10cSrcweir 			if( IsXMLToken(rValue, XML_SCALE) )
940cdf0e10cSrcweir 			{
941cdf0e10cSrcweir 				bSyncWidth = sal_True;
942cdf0e10cSrcweir 			}
943cdf0e10cSrcweir 			else
944cdf0e10cSrcweir 			{
945cdf0e10cSrcweir 				sal_Int32 nTmp;
946cdf0e10cSrcweir 				if( GetImport().GetMM100UnitConverter().
947cdf0e10cSrcweir 						convertPercent( nTmp, rValue ) )
948cdf0e10cSrcweir 					nRelWidth = (sal_Int16)nTmp;
949cdf0e10cSrcweir 			}
950cdf0e10cSrcweir 			break;
951cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIN_WIDTH:
952cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
953cdf0e10cSrcweir 			{
954cdf0e10cSrcweir 				sal_Int32 nTmp;
955cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
956cdf0e10cSrcweir 																	rValue );
957cdf0e10cSrcweir 				nRelWidth = (sal_Int16)nTmp;
958cdf0e10cSrcweir 			}
959cdf0e10cSrcweir 			else
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
962cdf0e10cSrcweir 																	rValue, 0 );
963cdf0e10cSrcweir 			}
964cdf0e10cSrcweir 			bMinWidth = sal_True;
965cdf0e10cSrcweir 			break;
966cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_HEIGHT:
967cdf0e10cSrcweir 			// relative heights are obsolete since SRC617. Remove them some day!
968cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
969cdf0e10cSrcweir 			{
970cdf0e10cSrcweir 				sal_Int32 nTmp;
971cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
972cdf0e10cSrcweir 																	rValue );
973cdf0e10cSrcweir 				nRelHeight = (sal_Int16)nTmp;
974cdf0e10cSrcweir 			}
975cdf0e10cSrcweir 			else
976cdf0e10cSrcweir 			{
977cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
978cdf0e10cSrcweir 																	rValue, 0 );
979cdf0e10cSrcweir 			}
980cdf0e10cSrcweir 			break;
981cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_REL_HEIGHT:
982cdf0e10cSrcweir 			if( IsXMLToken( rValue, XML_SCALE ) )
983cdf0e10cSrcweir 			{
984cdf0e10cSrcweir 				bSyncHeight = sal_True;
985cdf0e10cSrcweir 			}
986cdf0e10cSrcweir 			else if( IsXMLToken( rValue, XML_SCALE_MIN ) )
987cdf0e10cSrcweir 			{
988cdf0e10cSrcweir 				bSyncHeight = sal_True;
989cdf0e10cSrcweir 				bMinHeight = sal_True;
990cdf0e10cSrcweir 			}
991cdf0e10cSrcweir 			else
992cdf0e10cSrcweir 			{
993cdf0e10cSrcweir 				sal_Int32 nTmp;
994cdf0e10cSrcweir 				if( GetImport().GetMM100UnitConverter().
995cdf0e10cSrcweir 						convertPercent( nTmp, rValue ) )
996cdf0e10cSrcweir 					nRelHeight = (sal_Int16)nTmp;
997cdf0e10cSrcweir 			}
998cdf0e10cSrcweir 			break;
999cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIN_HEIGHT:
1000cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
1001cdf0e10cSrcweir 			{
1002cdf0e10cSrcweir 				sal_Int32 nTmp;
1003cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1004cdf0e10cSrcweir 																	rValue );
1005cdf0e10cSrcweir 				nRelHeight = (sal_Int16)nTmp;
1006cdf0e10cSrcweir 			}
1007cdf0e10cSrcweir 			else
1008cdf0e10cSrcweir 			{
1009cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1010cdf0e10cSrcweir 																	rValue, 0 );
1011cdf0e10cSrcweir 			}
1012cdf0e10cSrcweir 			bMinHeight = sal_True;
1013cdf0e10cSrcweir 			break;
1014cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_Z_INDEX:
1015cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 );
1016cdf0e10cSrcweir 			break;
1017cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME:
1018cdf0e10cSrcweir 			sNextName = rValue;
1019cdf0e10cSrcweir 			break;
1020cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_HREF:
1021cdf0e10cSrcweir 			sHRef = rValue;
1022cdf0e10cSrcweir 			break;
1023cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_FILTER_NAME:
1024cdf0e10cSrcweir 			sFilterName = rValue;
1025cdf0e10cSrcweir 			break;
1026cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_TRANSFORM:
1027cdf0e10cSrcweir 			{
1028cdf0e10cSrcweir 				OUString sValue( rValue );
1029cdf0e10cSrcweir 				sValue.trim();
1030cdf0e10cSrcweir                 const OUString aRotate(GetXMLToken(XML_ROTATE));
1031cdf0e10cSrcweir 				const sal_Int32 nRotateLen(aRotate.getLength());
1032cdf0e10cSrcweir 				sal_Int32 nLen = sValue.getLength();
1033cdf0e10cSrcweir 				if( nLen >= nRotateLen+3 &&
1034cdf0e10cSrcweir 					0 == sValue.compareTo( aRotate, nRotateLen ) &&
1035cdf0e10cSrcweir 					'(' == sValue[nRotateLen] &&
1036cdf0e10cSrcweir 					')' == sValue[nLen-1] )
1037cdf0e10cSrcweir 				{
1038cdf0e10cSrcweir 					sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) );
1039cdf0e10cSrcweir 					sValue.trim();
1040cdf0e10cSrcweir 					sal_Int32 nVal;
1041cdf0e10cSrcweir 					if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) )
1042cdf0e10cSrcweir 						nRotation = (sal_Int16)(nVal % 360 );
1043cdf0e10cSrcweir 				}
1044cdf0e10cSrcweir 			}
1045cdf0e10cSrcweir 			break;
1046cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_CODE:
1047cdf0e10cSrcweir 			sCode = rValue;
1048cdf0e10cSrcweir 			break;
1049cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_OBJECT:
1050cdf0e10cSrcweir 			sObject = rValue;
1051cdf0e10cSrcweir 			break;
1052cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ARCHIVE:
1053cdf0e10cSrcweir 			sArchive = rValue;
1054cdf0e10cSrcweir 			break;
1055cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MAY_SCRIPT:
1056cdf0e10cSrcweir 			bMayScript = IsXMLToken( rValue, XML_TRUE );
1057cdf0e10cSrcweir 			break;
1058cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIME_TYPE:
1059cdf0e10cSrcweir 			sMimeType = rValue;
1060cdf0e10cSrcweir 			break;
1061cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE:
1062cdf0e10cSrcweir 			sTblName = rValue;
1063cdf0e10cSrcweir 			break;
1064cdf0e10cSrcweir 		}
1065cdf0e10cSrcweir 	}
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 	if( ( (XML_TEXT_FRAME_GRAPHIC == nType ||
1068cdf0e10cSrcweir 		   XML_TEXT_FRAME_OBJECT == nType ||
1069cdf0e10cSrcweir 		   XML_TEXT_FRAME_OBJECT_OLE == nType) &&
1070cdf0e10cSrcweir 		  !sHRef.getLength() ) ||
1071cdf0e10cSrcweir 		( XML_TEXT_FRAME_APPLET  == nType && !sCode.getLength() ) ||
1072cdf0e10cSrcweir         ( XML_TEXT_FRAME_PLUGIN == nType &&
1073cdf0e10cSrcweir           sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) )
1074cdf0e10cSrcweir 		return;	// no URL: no image or OLE object
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 	Create( sal_True );
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl()
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir void XMLTextFrameContext_Impl::EndElement()
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir 	CreateIfNotThere();
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir 	if( xOldTextCursor.is() )
1088cdf0e10cSrcweir 	{
1089cdf0e10cSrcweir 		GetImport().GetTextImport()->DeleteParagraph();
1090cdf0e10cSrcweir 		GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1091cdf0e10cSrcweir 	}
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir     // reinstall old list item (if necessary) #89892#
1094cdf0e10cSrcweir     if (mbListContextPushed) {
1095cdf0e10cSrcweir         GetImport().GetTextImport()->PopListContext();
1096cdf0e10cSrcweir     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is())
1099cdf0e10cSrcweir 		GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext(
1103cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1104cdf0e10cSrcweir 		const OUString& rLocalName,
1105cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList )
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
1110cdf0e10cSrcweir 	{
1111cdf0e10cSrcweir 		if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) &&
1112cdf0e10cSrcweir 			  IsXMLToken( rLocalName, XML_PARAM ) )
1113cdf0e10cSrcweir 		{
1114cdf0e10cSrcweir 			pContext = new XMLTextFrameParam_Impl( GetImport(),
1115cdf0e10cSrcweir 											  nPrefix, rLocalName,
1116cdf0e10cSrcweir 							 				  xAttrList, nType, aParamMap );
1117cdf0e10cSrcweir 		}
1118cdf0e10cSrcweir 	}
1119cdf0e10cSrcweir 	else if( (XML_NAMESPACE_OFFICE == nPrefix) )
1120cdf0e10cSrcweir 	{
1121cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_BINARY_DATA ) )
1122cdf0e10cSrcweir 		{
1123cdf0e10cSrcweir 			if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1124cdf0e10cSrcweir 			{
1125cdf0e10cSrcweir 				switch( nType )
1126cdf0e10cSrcweir 				{
1127cdf0e10cSrcweir 				case XML_TEXT_FRAME_GRAPHIC:
1128cdf0e10cSrcweir 					xBase64Stream =
1129cdf0e10cSrcweir 						GetImport().GetStreamForGraphicObjectURLFromBase64();
1130cdf0e10cSrcweir 					break;
1131cdf0e10cSrcweir 				case XML_TEXT_FRAME_OBJECT_OLE:
1132cdf0e10cSrcweir 					xBase64Stream =
1133cdf0e10cSrcweir 						GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1134cdf0e10cSrcweir 					break;
1135cdf0e10cSrcweir 				}
1136cdf0e10cSrcweir 				if( xBase64Stream.is() )
1137cdf0e10cSrcweir 					pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
1138cdf0e10cSrcweir 													rLocalName, xAttrList,
1139cdf0e10cSrcweir 													xBase64Stream );
1140cdf0e10cSrcweir 			}
1141cdf0e10cSrcweir 		}
1142cdf0e10cSrcweir 	}
1143cdf0e10cSrcweir     // --> OD 2009-08-17 #i100480#
1144cdf0e10cSrcweir     // correction of condition which also avoids warnings.
1145cdf0e10cSrcweir     if( !pContext &&
1146cdf0e10cSrcweir         ( XML_TEXT_FRAME_OBJECT == nType &&
1147cdf0e10cSrcweir           ( ( XML_NAMESPACE_OFFICE == nPrefix &&
1148cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_DOCUMENT ) ) ||
1149cdf0e10cSrcweir             ( XML_NAMESPACE_MATH == nPrefix &&
1150cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_MATH ) ) ) ) )
1151cdf0e10cSrcweir     // <--
1152cdf0e10cSrcweir 	{
1153cdf0e10cSrcweir 		if( !xPropSet.is() && !bCreateFailed )
1154cdf0e10cSrcweir 		{
1155cdf0e10cSrcweir 			XMLEmbeddedObjectImportContext *pEContext =
1156cdf0e10cSrcweir 				new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
1157cdf0e10cSrcweir 													rLocalName, xAttrList );
1158cdf0e10cSrcweir 			sFilterService = pEContext->GetFilterServiceName();
1159cdf0e10cSrcweir 			if( sFilterService.getLength() != 0 )
1160cdf0e10cSrcweir 			{
1161cdf0e10cSrcweir 				Create( sal_False );
1162cdf0e10cSrcweir 				if( xPropSet.is() )
1163cdf0e10cSrcweir 				{
1164cdf0e10cSrcweir 					Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1165cdf0e10cSrcweir 																UNO_QUERY );
1166cdf0e10cSrcweir 					OSL_ENSURE( xEOS.is(),
1167cdf0e10cSrcweir 							"no embedded object supplier for own object" );
1168cdf0e10cSrcweir                     Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1169cdf0e10cSrcweir 					pEContext->SetComponent( aXComponent );
1170cdf0e10cSrcweir 				}
1171cdf0e10cSrcweir 			}
1172cdf0e10cSrcweir 			pContext = pEContext;
1173cdf0e10cSrcweir 		}
1174cdf0e10cSrcweir 	}
1175cdf0e10cSrcweir 	if( !pContext && xOldTextCursor.is() )	// text-box
1176cdf0e10cSrcweir 		pContext = GetImport().GetTextImport()->CreateTextChildContext(
1177cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xAttrList,
1178cdf0e10cSrcweir 							XML_TEXT_TYPE_TEXTBOX );
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 	if( !pContext )
1181cdf0e10cSrcweir 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 	return pContext;
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir void XMLTextFrameContext_Impl::Characters( const OUString& rChars )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir 	if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
1189cdf0e10cSrcweir 		  XML_TEXT_FRAME_GRAPHIC == nType) &&
1190cdf0e10cSrcweir 		!xPropSet.is() && !bCreateFailed )
1191cdf0e10cSrcweir 	{
1192cdf0e10cSrcweir 		OUString sTrimmedChars( rChars. trim() );
1193cdf0e10cSrcweir 		if( sTrimmedChars.getLength() )
1194cdf0e10cSrcweir 		{
1195cdf0e10cSrcweir 			if( !xBase64Stream.is() )
1196cdf0e10cSrcweir 			{
1197cdf0e10cSrcweir 				if( XML_TEXT_FRAME_GRAPHIC == nType )
1198cdf0e10cSrcweir 				{
1199cdf0e10cSrcweir 					xBase64Stream =
1200cdf0e10cSrcweir 						GetImport().GetStreamForGraphicObjectURLFromBase64();
1201cdf0e10cSrcweir 				}
1202cdf0e10cSrcweir 				else
1203cdf0e10cSrcweir 				{
1204cdf0e10cSrcweir 					xBase64Stream =
1205cdf0e10cSrcweir 						GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1206cdf0e10cSrcweir 				}
1207cdf0e10cSrcweir 				if( xBase64Stream.is() )
1208cdf0e10cSrcweir 					bOwnBase64Stream = sal_True;
1209cdf0e10cSrcweir 			}
1210cdf0e10cSrcweir 			if( bOwnBase64Stream && xBase64Stream.is() )
1211cdf0e10cSrcweir 			{
1212cdf0e10cSrcweir 				OUString sChars;
1213cdf0e10cSrcweir 				if( sBase64CharsLeft )
1214cdf0e10cSrcweir 				{
1215cdf0e10cSrcweir 					sChars = sBase64CharsLeft;
1216cdf0e10cSrcweir 					sChars += sTrimmedChars;
1217cdf0e10cSrcweir 					sBase64CharsLeft = OUString();
1218cdf0e10cSrcweir 				}
1219cdf0e10cSrcweir 				else
1220cdf0e10cSrcweir 				{
1221cdf0e10cSrcweir 					sChars = sTrimmedChars;
1222cdf0e10cSrcweir 				}
1223cdf0e10cSrcweir 				Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
1224cdf0e10cSrcweir 				sal_Int32 nCharsDecoded =
1225cdf0e10cSrcweir 					GetImport().GetMM100UnitConverter().
1226cdf0e10cSrcweir 						decodeBase64SomeChars( aBuffer, sChars );
1227cdf0e10cSrcweir 				xBase64Stream->writeBytes( aBuffer );
1228cdf0e10cSrcweir 				if( nCharsDecoded != sChars.getLength() )
1229cdf0e10cSrcweir 					sBase64CharsLeft = sChars.copy( nCharsDecoded );
1230cdf0e10cSrcweir 			}
1231cdf0e10cSrcweir 		}
1232cdf0e10cSrcweir 	}
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
1236cdf0e10cSrcweir 					   const OUString& rName,
1237cdf0e10cSrcweir 					   const OUString& rTargetFrameName,
1238cdf0e10cSrcweir 					   sal_Bool bMap )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkURL(
1241cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
1242cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkName(
1243cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"));
1244cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkTarget(
1245cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"));
1246cdf0e10cSrcweir     static ::rtl::OUString s_ServerMap(
1247cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("ServerMap"));
1248cdf0e10cSrcweir 	if( !xPropSet.is() )
1249cdf0e10cSrcweir 		return;
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 	UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport();
1252cdf0e10cSrcweir 	Reference < XPropertySetInfo > xPropSetInfo =
1253cdf0e10cSrcweir 		xPropSet->getPropertySetInfo();
1254cdf0e10cSrcweir 	if( !xPropSetInfo.is() ||
1255cdf0e10cSrcweir         !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1256cdf0e10cSrcweir 		return;
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir 	Any aAny;
1259cdf0e10cSrcweir 	aAny <<= rHRef;
1260cdf0e10cSrcweir     xPropSet->setPropertyValue( s_HyperLinkURL, aAny );
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1263cdf0e10cSrcweir 	{
1264cdf0e10cSrcweir 		aAny <<= rName;
1265cdf0e10cSrcweir         xPropSet->setPropertyValue(s_HyperLinkName, aAny);
1266cdf0e10cSrcweir 	}
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1269cdf0e10cSrcweir 	{
1270cdf0e10cSrcweir 		aAny <<= rTargetFrameName;
1271cdf0e10cSrcweir         xPropSet->setPropertyValue( s_HyperLinkTarget, aAny );
1272cdf0e10cSrcweir 	}
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1275cdf0e10cSrcweir 	{
1276cdf0e10cSrcweir 		aAny.setValue( &bMap, ::getBooleanCppuType() );
1277cdf0e10cSrcweir         xPropSet->setPropertyValue(s_ServerMap, aAny);
1278cdf0e10cSrcweir 	}
1279cdf0e10cSrcweir }
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
1282cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle )
1283cdf0e10cSrcweir {
1284cdf0e10cSrcweir     if ( xPropSet.is() )
1285cdf0e10cSrcweir     {
1286cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1287cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sTitle ) )
1288cdf0e10cSrcweir         {
1289cdf0e10cSrcweir             xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) );
1290cdf0e10cSrcweir         }
1291cdf0e10cSrcweir     }
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc )
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir 	if ( xPropSet.is() )
1297cdf0e10cSrcweir 	{
1298cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1299cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sDescription ) )
1300cdf0e10cSrcweir 		{
1301cdf0e10cSrcweir             xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) );
1302cdf0e10cSrcweir 		}
1303cdf0e10cSrcweir 	}
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir // <--
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext, SvXMLImportContext );
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere()
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1314cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1315cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1316cdf0e10cSrcweir 	if( pImpl )
1317cdf0e10cSrcweir 		bRet = pImpl->CreateIfNotThere();
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir 	return bRet;
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference <
1323cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >& rPropSet )
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1326cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1327cdf0e10cSrcweir 	if( pImpl )
1328cdf0e10cSrcweir 	{
1329cdf0e10cSrcweir 		if( pImpl->CreateIfNotThere() )
1330cdf0e10cSrcweir 			rPropSet = pImpl->GetPropSet();
1331cdf0e10cSrcweir 	}
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir 	return rPropSet.is();
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir XMLTextFrameContext::XMLTextFrameContext(
1337cdf0e10cSrcweir 		SvXMLImport& rImport,
1338cdf0e10cSrcweir 		sal_uInt16 nPrfx, const OUString& rLName,
1339cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList,
1340cdf0e10cSrcweir 		TextContentAnchorType eATyp )
1341cdf0e10cSrcweir :	SvXMLImportContext( rImport, nPrfx, rLName )
1342cdf0e10cSrcweir ,	m_xAttrList( new SvXMLAttributeList( xAttrList ) )
1343cdf0e10cSrcweir ,	m_pHyperlink( 0 )
1344cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
1345cdf0e10cSrcweir ,   m_sTitle()
1346cdf0e10cSrcweir ,   m_sDesc()
1347cdf0e10cSrcweir // <--
1348cdf0e10cSrcweir ,	m_eDefaultAnchorType( eATyp )
1349cdf0e10cSrcweir     // --> OD 2006-03-10 #i51726#
1350cdf0e10cSrcweir ,   m_HasAutomaticStyleWithoutParentStyle( sal_False )
1351cdf0e10cSrcweir     // <--
1352cdf0e10cSrcweir ,	m_bSupportsReplacement( sal_False )
1353cdf0e10cSrcweir {
1354cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1355cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
1356cdf0e10cSrcweir 	{
1357cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 		OUString aLocalName;
1360cdf0e10cSrcweir 		sal_uInt16 nPrefix =
1361cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
1362cdf0e10cSrcweir         // --> OD 2006-03-10 #i51726#
1363cdf0e10cSrcweir         // New distinguish attribute between Writer objects and Draw objects is:
1364cdf0e10cSrcweir         // Draw objects have an automatic style without a parent style
1365cdf0e10cSrcweir         if ( XML_NAMESPACE_DRAW == nPrefix &&
1366cdf0e10cSrcweir              IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1367cdf0e10cSrcweir 		{
1368cdf0e10cSrcweir             OUString aStyleName = xAttrList->getValueByIndex( i );
1369cdf0e10cSrcweir             if( aStyleName.getLength() )
1370cdf0e10cSrcweir             {
1371cdf0e10cSrcweir                 UniReference < XMLTextImportHelper > xTxtImport =
1372cdf0e10cSrcweir                                                     GetImport().GetTextImport();
1373cdf0e10cSrcweir                 XMLPropStyleContext* pStyle( 0L );
1374cdf0e10cSrcweir                 pStyle = xTxtImport->FindAutoFrameStyle( aStyleName );
1375cdf0e10cSrcweir                 if ( pStyle && !pStyle->GetParentName().getLength() )
1376cdf0e10cSrcweir                 {
1377cdf0e10cSrcweir                     m_HasAutomaticStyleWithoutParentStyle = sal_True;
1378cdf0e10cSrcweir                 }
1379cdf0e10cSrcweir             }
1380cdf0e10cSrcweir         }
1381cdf0e10cSrcweir         // <--
1382cdf0e10cSrcweir         else if ( XML_NAMESPACE_TEXT == nPrefix &&
1383cdf0e10cSrcweir                   IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) )
1384cdf0e10cSrcweir 		{
1385cdf0e10cSrcweir 			TextContentAnchorType eNew;
1386cdf0e10cSrcweir 			if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i),
1387cdf0e10cSrcweir 						eNew ) &&
1388cdf0e10cSrcweir 				( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1389cdf0e10cSrcweir 				  TextContentAnchorType_AT_CHARACTER == eNew ||
1390cdf0e10cSrcweir 				  TextContentAnchorType_AS_CHARACTER == eNew ||
1391cdf0e10cSrcweir 				  TextContentAnchorType_AT_PAGE == eNew) )
1392cdf0e10cSrcweir 				m_eDefaultAnchorType = eNew;
1393cdf0e10cSrcweir 		}
1394cdf0e10cSrcweir 	}
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir XMLTextFrameContext::~XMLTextFrameContext()
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir 	delete m_pHyperlink;
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir void XMLTextFrameContext::EndElement()
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1405cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1406cdf0e10cSrcweir 	if( pImpl )
1407cdf0e10cSrcweir 	{
1408cdf0e10cSrcweir 		pImpl->CreateIfNotThere();
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir         // --> OD 2009-07-22 #i73249#
1411cdf0e10cSrcweir //        // alternative text
1412cdf0e10cSrcweir //        if( m_sDesc.getLength() )
1413cdf0e10cSrcweir //            pImpl->SetDesc( m_sDesc );
1414cdf0e10cSrcweir         // svg:title
1415cdf0e10cSrcweir         if( m_sTitle.getLength() )
1416cdf0e10cSrcweir         {
1417cdf0e10cSrcweir             pImpl->SetTitle( m_sTitle );
1418cdf0e10cSrcweir         }
1419cdf0e10cSrcweir         if( m_sDesc.getLength() )
1420cdf0e10cSrcweir         {
1421cdf0e10cSrcweir             pImpl->SetDesc( m_sDesc );
1422cdf0e10cSrcweir         }
1423cdf0e10cSrcweir         // <--
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 		if( m_pHyperlink )
1426cdf0e10cSrcweir 		{
1427cdf0e10cSrcweir 			pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
1428cdf0e10cSrcweir 						  m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
1429cdf0e10cSrcweir 			delete m_pHyperlink;
1430cdf0e10cSrcweir 			m_pHyperlink = 0;
1431cdf0e10cSrcweir 		}
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 	}
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
1437cdf0e10cSrcweir 		sal_uInt16 p_nPrefix,
1438cdf0e10cSrcweir 		const OUString& rLocalName,
1439cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList )
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir 	if( !m_xImplContext.Is() )
1444cdf0e10cSrcweir 	{
1445cdf0e10cSrcweir 		// no child exists
1446cdf0e10cSrcweir 		if( XML_NAMESPACE_DRAW == p_nPrefix )
1447cdf0e10cSrcweir 		{
1448cdf0e10cSrcweir 			sal_uInt16 nFrameType = USHRT_MAX;
1449cdf0e10cSrcweir 			if( IsXMLToken( rLocalName, XML_TEXT_BOX ) )
1450cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_TEXTBOX;
1451cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_IMAGE ) )
1452cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_GRAPHIC;
1453cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_OBJECT ) )
1454cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_OBJECT;
1455cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) )
1456cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_OBJECT_OLE;
1457cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_APPLET) )
1458cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_APPLET;
1459cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_PLUGIN ) )
1460cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_PLUGIN;
1461cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) )
1462cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 			if( USHRT_MAX != nFrameType )
1465cdf0e10cSrcweir 			{
1466cdf0e10cSrcweir                 // --> OD 2006-03-10 #i51726#
1467cdf0e10cSrcweir                 if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType ||
1468cdf0e10cSrcweir                        XML_TEXT_FRAME_GRAPHIC == nFrameType ) &&
1469cdf0e10cSrcweir                      m_HasAutomaticStyleWithoutParentStyle )
1470cdf0e10cSrcweir                 // <--
1471cdf0e10cSrcweir 				{
1472cdf0e10cSrcweir 					Reference < XShapes > xShapes;
1473cdf0e10cSrcweir 					pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1474cdf0e10cSrcweir 									GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1475cdf0e10cSrcweir 				}
1476cdf0e10cSrcweir 				else if( XML_TEXT_FRAME_PLUGIN == nFrameType )
1477cdf0e10cSrcweir 				{
1478cdf0e10cSrcweir 				    bool bMedia = false;
1479cdf0e10cSrcweir 
1480cdf0e10cSrcweir 				    // check, if we have a media object
1481cdf0e10cSrcweir 	                for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
1482cdf0e10cSrcweir 	                {
1483cdf0e10cSrcweir 		                OUString 	aLocalName;
1484cdf0e10cSrcweir 		                sal_uInt16 	nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir 		                if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
1487cdf0e10cSrcweir 		                {
1488cdf0e10cSrcweir 			                if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
1489cdf0e10cSrcweir 				                bMedia = true;
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir 			                // leave this loop
1492cdf0e10cSrcweir 			                n = nAttrCount - 1;
1493cdf0e10cSrcweir 		                }
1494cdf0e10cSrcweir 	                }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 	                if( bMedia )
1497cdf0e10cSrcweir 	                {
1498cdf0e10cSrcweir 	                    Reference < XShapes > xShapes;
1499cdf0e10cSrcweir 					    pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1500cdf0e10cSrcweir 									    GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1501cdf0e10cSrcweir 					}
1502cdf0e10cSrcweir 				}
1503cdf0e10cSrcweir 				else if( XML_TEXT_FRAME_OBJECT == nFrameType ||
1504cdf0e10cSrcweir 						 XML_TEXT_FRAME_OBJECT_OLE == nFrameType )
1505cdf0e10cSrcweir 				{
1506cdf0e10cSrcweir 					m_bSupportsReplacement = sal_True;
1507cdf0e10cSrcweir 				}
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 				if( !pContext )
1510cdf0e10cSrcweir 				{
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir 					pContext = new XMLTextFrameContext_Impl( GetImport(), p_nPrefix,
1513cdf0e10cSrcweir 														rLocalName, xAttrList,
1514cdf0e10cSrcweir 														m_eDefaultAnchorType,
1515cdf0e10cSrcweir 														nFrameType,
1516cdf0e10cSrcweir 														m_xAttrList	);
1517cdf0e10cSrcweir 				}
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir 				m_xImplContext = pContext;
1520cdf0e10cSrcweir 			}
1521cdf0e10cSrcweir 		}
1522cdf0e10cSrcweir 	}
1523cdf0e10cSrcweir 	else if( m_bSupportsReplacement && !m_xReplImplContext &&
1524cdf0e10cSrcweir 			 XML_NAMESPACE_DRAW == p_nPrefix &&
1525cdf0e10cSrcweir 			 IsXMLToken( rLocalName, XML_IMAGE ) )
1526cdf0e10cSrcweir 	{
1527cdf0e10cSrcweir 		// read replacement image
1528cdf0e10cSrcweir 		Reference < XPropertySet > xPropSet;
1529cdf0e10cSrcweir 		if( CreateIfNotThere( xPropSet ) )
1530cdf0e10cSrcweir 		{
1531cdf0e10cSrcweir 			pContext = new XMLReplacementImageContext( GetImport(),
1532cdf0e10cSrcweir 								p_nPrefix, rLocalName, xAttrList, xPropSet );
1533cdf0e10cSrcweir 			m_xReplImplContext = pContext;
1534cdf0e10cSrcweir 		}
1535cdf0e10cSrcweir 	}
1536cdf0e10cSrcweir 	else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) )
1537cdf0e10cSrcweir 	{
1538cdf0e10cSrcweir 		// the child is a writer frame
1539cdf0e10cSrcweir 		if( XML_NAMESPACE_SVG == p_nPrefix )
1540cdf0e10cSrcweir 		{
1541cdf0e10cSrcweir             // --> OD 2009-07-22 #i73249#
1542cdf0e10cSrcweir //            bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1543cdf0e10cSrcweir //            if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
1544cdf0e10cSrcweir //                pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
1545cdf0e10cSrcweir //                                                         xAttrList, m_sDesc );
1546cdf0e10cSrcweir             const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1547cdf0e10cSrcweir             if ( bOld )
1548cdf0e10cSrcweir             {
1549cdf0e10cSrcweir                 if ( IsXMLToken( rLocalName, XML_DESC ) )
1550cdf0e10cSrcweir                 {
1551cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1552cdf0e10cSrcweir                                                                         p_nPrefix,
1553cdf0e10cSrcweir                                                                         rLocalName,
1554cdf0e10cSrcweir                                                                         m_sTitle );
1555cdf0e10cSrcweir                 }
1556cdf0e10cSrcweir             }
1557cdf0e10cSrcweir             else
1558cdf0e10cSrcweir             {
1559cdf0e10cSrcweir                 if( IsXMLToken( rLocalName, XML_TITLE ) )
1560cdf0e10cSrcweir                 {
1561cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1562cdf0e10cSrcweir                                                                         p_nPrefix,
1563cdf0e10cSrcweir                                                                         rLocalName,
1564cdf0e10cSrcweir                                                                         m_sTitle );
1565cdf0e10cSrcweir                 }
1566cdf0e10cSrcweir                 else if ( IsXMLToken( rLocalName, XML_DESC ) )
1567cdf0e10cSrcweir                 {
1568cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1569cdf0e10cSrcweir                                                                         p_nPrefix,
1570cdf0e10cSrcweir                                                                         rLocalName,
1571cdf0e10cSrcweir                                                                         m_sDesc );
1572cdf0e10cSrcweir                 }
1573cdf0e10cSrcweir             }
1574cdf0e10cSrcweir             // <--
1575cdf0e10cSrcweir 		}
1576cdf0e10cSrcweir 		else if( XML_NAMESPACE_DRAW == p_nPrefix )
1577cdf0e10cSrcweir 		{
1578cdf0e10cSrcweir 			Reference < XPropertySet > xPropSet;
1579cdf0e10cSrcweir 			if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) )
1580cdf0e10cSrcweir 			{
1581cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1582cdf0e10cSrcweir 					pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1583cdf0e10cSrcweir 												  xAttrList, xPropSet, sal_False );
1584cdf0e10cSrcweir 			}
1585cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) )
1586cdf0e10cSrcweir 			{
1587cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1588cdf0e10cSrcweir 					pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1589cdf0e10cSrcweir 												  xAttrList, xPropSet, sal_True );
1590cdf0e10cSrcweir 			}
1591cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
1592cdf0e10cSrcweir 			{
1593cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1594cdf0e10cSrcweir 					pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet );
1595cdf0e10cSrcweir 			}
1596cdf0e10cSrcweir 		}
1597cdf0e10cSrcweir 		else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
1598cdf0e10cSrcweir 		{
1599cdf0e10cSrcweir 			// do we still have the frame object?
1600cdf0e10cSrcweir 			Reference < XPropertySet > xPropSet;
1601cdf0e10cSrcweir 			if( CreateIfNotThere( xPropSet ) )
1602cdf0e10cSrcweir 			{
1603cdf0e10cSrcweir 				// is it an event supplier?
1604cdf0e10cSrcweir 				Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1605cdf0e10cSrcweir 				if (xEventsSupplier.is())
1606cdf0e10cSrcweir 				{
1607cdf0e10cSrcweir 					// OK, we have the events, so create the context
1608cdf0e10cSrcweir 					pContext = new XMLEventsImportContext(GetImport(), p_nPrefix,
1609cdf0e10cSrcweir 													  rLocalName, xEventsSupplier);
1610cdf0e10cSrcweir 				}
1611cdf0e10cSrcweir 			}
1612cdf0e10cSrcweir 		}
1613cdf0e10cSrcweir 	}
1614cdf0e10cSrcweir 	else if( p_nPrefix == XML_NAMESPACE_SVG &&	// #i68101#
1615cdf0e10cSrcweir 				(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
1616cdf0e10cSrcweir 	{
1617cdf0e10cSrcweir 		pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList );
1618cdf0e10cSrcweir 	}
1619cdf0e10cSrcweir 	else
1620cdf0e10cSrcweir 	{
1621cdf0e10cSrcweir 		// the child is a drawing shape
1622cdf0e10cSrcweir 		pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1623cdf0e10cSrcweir 									&m_xImplContext, p_nPrefix, rLocalName, xAttrList );
1624cdf0e10cSrcweir 	}
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir 	if( !pContext )
1627cdf0e10cSrcweir 		pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir 	return pContext;
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
1633cdf0e10cSrcweir 					   const OUString& rName,
1634cdf0e10cSrcweir 					   const OUString& rTargetFrameName,
1635cdf0e10cSrcweir 					   sal_Bool bMap )
1636cdf0e10cSrcweir {
1637cdf0e10cSrcweir 	OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" );
1638cdf0e10cSrcweir 	delete m_pHyperlink;
1639cdf0e10cSrcweir 	m_pHyperlink = new XMLTextFrameContextHyperlink_Impl(
1640cdf0e10cSrcweir 				rHRef, rName, rTargetFrameName, bMap );
1641cdf0e10cSrcweir }
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir TextContentAnchorType XMLTextFrameContext::GetAnchorType() const
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1646cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1647cdf0e10cSrcweir 	if( pImpl )
1648cdf0e10cSrcweir 		return pImpl->GetAnchorType();
1649cdf0e10cSrcweir 	else
1650cdf0e10cSrcweir 		return m_eDefaultAnchorType;
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir Reference < XTextContent > XMLTextFrameContext::GetTextContent() const
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir 	Reference < XTextContent > xTxtCntnt;
1656cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1657cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1658cdf0e10cSrcweir 	if( pImpl )
1659cdf0e10cSrcweir 		xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 	return xTxtCntnt;
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir // --> OD 2004-08-24 #33242#
1665cdf0e10cSrcweir Reference < XShape > XMLTextFrameContext::GetShape() const
1666cdf0e10cSrcweir {
1667cdf0e10cSrcweir     Reference < XShape > xShape;
1668cdf0e10cSrcweir     SvXMLImportContext* pContext = &m_xImplContext;
1669cdf0e10cSrcweir     SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext );
1670cdf0e10cSrcweir     if ( pImpl )
1671cdf0e10cSrcweir     {
1672cdf0e10cSrcweir         xShape = pImpl->getShape();
1673cdf0e10cSrcweir     }
1674cdf0e10cSrcweir 
1675cdf0e10cSrcweir     return xShape;
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir // <--
1678