xref: /AOO41X/main/xmloff/source/text/XMLTextFrameContext.cxx (revision 011bafbf7306e753bb26371bcb5220d51e4d4ead)
163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
2263bba73cSAndrew 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;
428*011bafbfSArmin Le Grand     bool        mbSetNameForFrame : 1; // #123261# remember if to set the NameForFrame
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 	void Create( sal_Bool bHRefOrBase64 );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir public:
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	TYPEINFO();
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	sal_Bool CreateIfNotThere();
437ddde725dSArmin Le Grand 	const OUString& GetHRef() const { return sHRef; }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir     XMLTextFrameContext_Impl( SvXMLImport& rImport,
440cdf0e10cSrcweir         sal_uInt16 nPrfx,
441cdf0e10cSrcweir         const ::rtl::OUString& rLName,
442cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
443cdf0e10cSrcweir         ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
444cdf0e10cSrcweir         ::com::sun::star::text::TextContentAnchorType eAnchorType,
445cdf0e10cSrcweir         sal_uInt16 nType,
446*011bafbfSArmin Le Grand         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList,
447*011bafbfSArmin Le Grand         bool bSetNameForFrame); // #123261# control if to set the NameForFrame
448cdf0e10cSrcweir     virtual ~XMLTextFrameContext_Impl();
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 	virtual void EndElement();
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	virtual void Characters( const ::rtl::OUString& rChars );
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
455cdf0e10cSrcweir 				const ::rtl::OUString& rLocalName,
456cdf0e10cSrcweir 			 	const ::com::sun::star::uno::Reference<
457cdf0e10cSrcweir 					::com::sun::star::xml::sax::XAttributeList > & xAttrList );
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	void SetHyperlink( const ::rtl::OUString& rHRef,
460cdf0e10cSrcweir 					   const ::rtl::OUString& rName,
461cdf0e10cSrcweir 					   const ::rtl::OUString& rTargetFrameName,
462cdf0e10cSrcweir 					   sal_Bool bMap );
463cdf0e10cSrcweir     // --> OD 2009-07-22 #i73249#
464cdf0e10cSrcweir     void SetTitle( const ::rtl::OUString& rTitle );
465cdf0e10cSrcweir     // <--
466cdf0e10cSrcweir     void SetDesc( const ::rtl::OUString& rDesc );
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference <
471ddde725dSArmin Le Grand 		::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
472*011bafbfSArmin Le Grand 
473*011bafbfSArmin Le Grand     // #123261# helper to set the NameForFrame
474*011bafbfSArmin Le Grand     void SetNameForFrameFromPropSet();
475cdf0e10cSrcweir };
476cdf0e10cSrcweir 
477cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
478cdf0e10cSrcweir 
479*011bafbfSArmin Le Grand void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet()
480*011bafbfSArmin Le Grand {
481*011bafbfSArmin Le Grand     // set name
482*011bafbfSArmin Le Grand     UniReference < XMLTextImportHelper > xTextImportHelper = GetImport().GetTextImport();
483*011bafbfSArmin Le Grand     Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
484*011bafbfSArmin Le Grand 
485*011bafbfSArmin Le Grand     if( xNamed.is() && xTextImportHelper.is() )
486*011bafbfSArmin Le Grand     {
487*011bafbfSArmin Le Grand         OUString sOrigName( xNamed->getName() );
488*011bafbfSArmin Le Grand         if( !sOrigName.getLength() ||
489*011bafbfSArmin Le Grand             (sName.getLength() && sOrigName != sName) )
490*011bafbfSArmin Le Grand         {
491*011bafbfSArmin Le Grand             OUString sOldName( sName );
492*011bafbfSArmin Le Grand             sal_Int32 i = 0;
493*011bafbfSArmin Le Grand             while( xTextImportHelper->HasFrameByName( sName ) )
494*011bafbfSArmin Le Grand             {
495*011bafbfSArmin Le Grand                 sName = sOldName;
496*011bafbfSArmin Le Grand                 sName += OUString::valueOf( ++i );
497*011bafbfSArmin Le Grand             }
498*011bafbfSArmin Le Grand             xNamed->setName( sName );
499*011bafbfSArmin Le Grand             if( sName != sOldName )
500*011bafbfSArmin Le Grand                 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
501*011bafbfSArmin Le Grand                                              sOldName, sName );
502*011bafbfSArmin Le Grand         }
503*011bafbfSArmin Le Grand     }
504*011bafbfSArmin Le Grand }
505*011bafbfSArmin Le Grand 
506cdf0e10cSrcweir void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	UniReference < XMLTextImportHelper > xTextImportHelper =
509cdf0e10cSrcweir 		GetImport().GetTextImport();
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     switch ( nType)
512cdf0e10cSrcweir     {
513cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT:
514cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT_OLE:
515cdf0e10cSrcweir 			if( xBase64Stream.is() )
516cdf0e10cSrcweir 			{
517cdf0e10cSrcweir 				OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
518cdf0e10cSrcweir 				if( sURL.getLength() )
519cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
520cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
521cdf0e10cSrcweir 														sStyleName,
522cdf0e10cSrcweir 														sTblName,
523cdf0e10cSrcweir 														nWidth, nHeight );
524cdf0e10cSrcweir 			}
525cdf0e10cSrcweir 			else if( sHRef.getLength() )
526cdf0e10cSrcweir 			{
527cdf0e10cSrcweir 				OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
528cdf0e10cSrcweir 																OUString() ) );
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 				if( GetImport().IsPackageURL( sHRef ) )
531cdf0e10cSrcweir 				{
532cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
533cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
534cdf0e10cSrcweir 														sStyleName,
535cdf0e10cSrcweir 														sTblName,
536cdf0e10cSrcweir 														nWidth, nHeight );
537cdf0e10cSrcweir 				}
538cdf0e10cSrcweir 				else
539cdf0e10cSrcweir 				{
540cdf0e10cSrcweir 					// it should be an own OOo link that has no storage persistance
541cdf0e10cSrcweir 					xPropSet = GetImport().GetTextImport()
542cdf0e10cSrcweir 							->createAndInsertOOoLink( GetImport(),
543cdf0e10cSrcweir 														sURL,
544cdf0e10cSrcweir 														sStyleName,
545cdf0e10cSrcweir 														sTblName,
546cdf0e10cSrcweir 														nWidth, nHeight );
547cdf0e10cSrcweir 				}
548cdf0e10cSrcweir 			}
549cdf0e10cSrcweir 			else
550cdf0e10cSrcweir 			{
551cdf0e10cSrcweir 				OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") );
552cdf0e10cSrcweir 				sURL += sFilterService;
553cdf0e10cSrcweir 				xPropSet = GetImport().GetTextImport()
554cdf0e10cSrcweir 							->createAndInsertOLEObject( GetImport(), sURL,
555cdf0e10cSrcweir 														sStyleName,
556cdf0e10cSrcweir 														sTblName,
557cdf0e10cSrcweir 														nWidth, nHeight );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 			}
560cdf0e10cSrcweir 			break;
561cdf0e10cSrcweir         case XML_TEXT_FRAME_APPLET:
562cdf0e10cSrcweir         {
563cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
564cdf0e10cSrcweir 							->createAndInsertApplet( sAppletName, sCode,
565cdf0e10cSrcweir 													 bMayScript, sHRef,
566cdf0e10cSrcweir 													 nWidth, nHeight);
567cdf0e10cSrcweir             break;
568cdf0e10cSrcweir         }
569cdf0e10cSrcweir         case XML_TEXT_FRAME_PLUGIN:
570cdf0e10cSrcweir         {
571cdf0e10cSrcweir             if(sHRef.getLength())
572cdf0e10cSrcweir                 GetImport().GetAbsoluteReference(sHRef);
573cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
574cdf0e10cSrcweir 							->createAndInsertPlugin( sMimeType, sHRef,
575cdf0e10cSrcweir 								   				 	 nWidth, nHeight);
576cdf0e10cSrcweir 
577cdf0e10cSrcweir             break;
578cdf0e10cSrcweir         }
579cdf0e10cSrcweir         case XML_TEXT_FRAME_FLOATING_FRAME:
580cdf0e10cSrcweir         {
581cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
582cdf0e10cSrcweir 							->createAndInsertFloatingFrame( sFrameName, sHRef,
583cdf0e10cSrcweir 															sStyleName,
584cdf0e10cSrcweir 															nWidth, nHeight);
585cdf0e10cSrcweir             break;
586cdf0e10cSrcweir         }
587cdf0e10cSrcweir 	    default:
588cdf0e10cSrcweir         {
589cdf0e10cSrcweir             Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
590cdf0e10cSrcweir                                                       UNO_QUERY );
591cdf0e10cSrcweir             if( xFactory.is() )
592cdf0e10cSrcweir             {
593cdf0e10cSrcweir                 OUString sServiceName;
594cdf0e10cSrcweir                 switch( nType )
595cdf0e10cSrcweir                 {
596cdf0e10cSrcweir                     case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break;
597cdf0e10cSrcweir                     case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break;
598cdf0e10cSrcweir                 }
599cdf0e10cSrcweir                 Reference<XInterface> xIfc = xFactory->createInstance( sServiceName );
600cdf0e10cSrcweir                 DBG_ASSERT( xIfc.is(), "couldn't create frame" );
601cdf0e10cSrcweir                 if( xIfc.is() )
602cdf0e10cSrcweir                     xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY );
603cdf0e10cSrcweir             }
604cdf0e10cSrcweir         }
605cdf0e10cSrcweir     }
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 	if( !xPropSet.is() )
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		bCreateFailed = sal_True;
610cdf0e10cSrcweir 		return;
611cdf0e10cSrcweir 	}
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
614cdf0e10cSrcweir 
615*011bafbfSArmin Le Grand     // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it will be set after
616*011bafbfSArmin Le Grand     // it is decided which image will be used. This is done e.g. to avoid double stuff and effects
617*011bafbfSArmin Le Grand     // for the target to avoid double names
618*011bafbfSArmin Le Grand     if(mbSetNameForFrame)
619cdf0e10cSrcweir     {
620*011bafbfSArmin Le Grand         SetNameForFrameFromPropSet();
621cdf0e10cSrcweir     }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 	// frame style
624cdf0e10cSrcweir 	XMLPropStyleContext *pStyle = 0;
625cdf0e10cSrcweir 	if( sStyleName.getLength() )
626cdf0e10cSrcweir 	{
627cdf0e10cSrcweir 		pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
628cdf0e10cSrcweir 		if( pStyle )
629cdf0e10cSrcweir             sStyleName = pStyle->GetParentName();
630cdf0e10cSrcweir 	}
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	Any aAny;
633cdf0e10cSrcweir 	if( sStyleName.getLength() )
634cdf0e10cSrcweir 	{
635cdf0e10cSrcweir 		OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
636cdf0e10cSrcweir 							XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) );
637cdf0e10cSrcweir 		const Reference < XNameContainer > & rStyles =
638cdf0e10cSrcweir 			xTextImportHelper->GetFrameStyles();
639cdf0e10cSrcweir 		if( rStyles.is() &&
640cdf0e10cSrcweir 			rStyles->hasByName( sDisplayStyleName ) )
641cdf0e10cSrcweir 		{
642cdf0e10cSrcweir 			aAny <<= sDisplayStyleName;
643cdf0e10cSrcweir 			xPropSet->setPropertyValue( sFrameStyleName, aAny );
644cdf0e10cSrcweir 		}
645cdf0e10cSrcweir 	}
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 	// anchor type (must be set before any other properties, because
648cdf0e10cSrcweir 	// otherwise some orientations cannot be set or will be changed
649cdf0e10cSrcweir 	// afterwards)
650cdf0e10cSrcweir 	aAny <<= eAnchorType;
651cdf0e10cSrcweir 	xPropSet->setPropertyValue( sAnchorType, aAny );
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 	// hard properties
654cdf0e10cSrcweir 	if( pStyle )
655cdf0e10cSrcweir 		pStyle->FillPropertySet( xPropSet );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 	// x and y
659cdf0e10cSrcweir 	sal_Int16 nHoriOrient =  HoriOrientation::NONE;
660cdf0e10cSrcweir 	aAny = xPropSet->getPropertyValue( sHoriOrient );
661cdf0e10cSrcweir 	aAny >>= nHoriOrient;
662cdf0e10cSrcweir 	if( HoriOrientation::NONE == nHoriOrient )
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		aAny <<= nX;
665cdf0e10cSrcweir 		xPropSet->setPropertyValue( sHoriOrientPosition, aAny );
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	sal_Int16 nVertOrient =  VertOrientation::NONE;
669cdf0e10cSrcweir 	aAny = xPropSet->getPropertyValue( sVertOrient );
670cdf0e10cSrcweir 	aAny >>= nVertOrient;
671cdf0e10cSrcweir 	if( VertOrientation::NONE == nVertOrient )
672cdf0e10cSrcweir 	{
673cdf0e10cSrcweir 		aAny <<= nY;
674cdf0e10cSrcweir 		xPropSet->setPropertyValue( sVertOrientPosition, aAny );
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	// width
678cdf0e10cSrcweir 	if( nWidth > 0 )
679cdf0e10cSrcweir 	{
680cdf0e10cSrcweir 		aAny <<= nWidth;
681cdf0e10cSrcweir 		xPropSet->setPropertyValue( sWidth, aAny );
682cdf0e10cSrcweir 	}
683cdf0e10cSrcweir 	if( nRelWidth > 0 || nWidth > 0 )
684cdf0e10cSrcweir 	{
685cdf0e10cSrcweir 		aAny <<= nRelWidth;
686cdf0e10cSrcweir 		xPropSet->setPropertyValue( sRelativeWidth, aAny );
687cdf0e10cSrcweir 	}
688cdf0e10cSrcweir 	if( bSyncWidth || nWidth > 0 )
689cdf0e10cSrcweir 	{
690cdf0e10cSrcweir 		sal_Bool bTmp = bSyncWidth;
691cdf0e10cSrcweir 		aAny.setValue( &bTmp, ::getBooleanCppuType() );
692cdf0e10cSrcweir 		xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny );
693cdf0e10cSrcweir 	}
694cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sWidthType ) &&
695cdf0e10cSrcweir 		(bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
696cdf0e10cSrcweir 	{
697cdf0e10cSrcweir 		sal_Int16 nSizeType =
698cdf0e10cSrcweir 			(bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
699cdf0e10cSrcweir                                                            : SizeType::FIX;
700cdf0e10cSrcweir 		aAny <<= nSizeType;
701cdf0e10cSrcweir 		xPropSet->setPropertyValue( sWidthType, aAny );
702cdf0e10cSrcweir 	}
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 	if( nHeight > 0 )
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir 		aAny <<= nHeight;
707cdf0e10cSrcweir 		xPropSet->setPropertyValue( sHeight, aAny );
708cdf0e10cSrcweir 	}
709cdf0e10cSrcweir 	if( nRelHeight > 0 || nHeight > 0 )
710cdf0e10cSrcweir 	{
711cdf0e10cSrcweir 		aAny <<= nRelHeight;
712cdf0e10cSrcweir 		xPropSet->setPropertyValue( sRelativeHeight, aAny );
713cdf0e10cSrcweir 	}
714cdf0e10cSrcweir 	if( bSyncHeight || nHeight > 0 )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		sal_Bool bTmp = bSyncHeight;
717cdf0e10cSrcweir 		aAny.setValue( &bTmp, ::getBooleanCppuType() );
718cdf0e10cSrcweir 		xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny );
719cdf0e10cSrcweir 	}
720cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sSizeType ) &&
721cdf0e10cSrcweir 		(bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
722cdf0e10cSrcweir 	{
723cdf0e10cSrcweir 		sal_Int16 nSizeType =
724cdf0e10cSrcweir 			(bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
725cdf0e10cSrcweir 															: SizeType::FIX;
726cdf0e10cSrcweir 		aAny <<= nSizeType;
727cdf0e10cSrcweir 		xPropSet->setPropertyValue( sSizeType, aAny );
728cdf0e10cSrcweir 	}
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 	if( XML_TEXT_FRAME_GRAPHIC == nType )
731cdf0e10cSrcweir 	{
732cdf0e10cSrcweir 		// URL
733cdf0e10cSrcweir 		OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(),
734cdf0e10cSrcweir 					"neither URL nor base64 image data given" );
735cdf0e10cSrcweir 		UniReference < XMLTextImportHelper > xTxtImport =
736cdf0e10cSrcweir 			GetImport().GetTextImport();
737cdf0e10cSrcweir 		if( sHRef.getLength() )
738cdf0e10cSrcweir 		{
739cdf0e10cSrcweir 			sal_Bool bForceLoad = xTxtImport->IsInsertMode() ||
740cdf0e10cSrcweir 								  xTxtImport->IsBlockMode() ||
741cdf0e10cSrcweir 								  xTxtImport->IsStylesOnlyMode() ||
742cdf0e10cSrcweir 								  xTxtImport->IsOrganizerMode();
743cdf0e10cSrcweir 			sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad );
744cdf0e10cSrcweir 		}
745cdf0e10cSrcweir 		else if( xBase64Stream.is() )
746cdf0e10cSrcweir 		{
747cdf0e10cSrcweir 			sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
748cdf0e10cSrcweir 			xBase64Stream = 0;
749cdf0e10cSrcweir 		}
750cdf0e10cSrcweir 		aAny <<= sHRef;
751cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicURL, aAny );
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 		// filter name
754cdf0e10cSrcweir 		aAny <<=sFilterName;
755cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicFilter, aAny );
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 		// rotation
758cdf0e10cSrcweir 		aAny <<= nRotation;
759cdf0e10cSrcweir 		xPropSet->setPropertyValue( sGraphicRotation, aAny );
760cdf0e10cSrcweir 	}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 	// page number (must be set after the frame is inserted, because it
763cdf0e10cSrcweir 	// will be overwritten then inserting the frame.
764cdf0e10cSrcweir 	if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
765cdf0e10cSrcweir 	{
766cdf0e10cSrcweir 		aAny <<= nPage;
767cdf0e10cSrcweir 		xPropSet->setPropertyValue( sAnchorPageNo, aAny );
768cdf0e10cSrcweir 	}
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	if( XML_TEXT_FRAME_OBJECT != nType  &&
771cdf0e10cSrcweir 		XML_TEXT_FRAME_OBJECT_OLE != nType  &&
772cdf0e10cSrcweir 		XML_TEXT_FRAME_APPLET != nType &&
773cdf0e10cSrcweir 		XML_TEXT_FRAME_PLUGIN!= nType &&
774cdf0e10cSrcweir 		XML_TEXT_FRAME_FLOATING_FRAME != nType)
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
777cdf0e10cSrcweir 		xTextImportHelper->InsertTextContent( xTxtCntnt );
778cdf0e10cSrcweir 	}
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 	// #107848#
781cdf0e10cSrcweir 	// Make adding the shepe to Z-Ordering dependent from if we are
782cdf0e10cSrcweir 	// inside a inside_deleted_section (redlining). That is necessary
783cdf0e10cSrcweir 	// since the shape will be removed again later. It would lead to
784cdf0e10cSrcweir 	// errors if it would stay inside the Z-Ordering. Thus, the
785cdf0e10cSrcweir 	// easiest way to solve that conflict is to not add it here.
786cdf0e10cSrcweir 	if(!GetImport().HasTextImport()
787cdf0e10cSrcweir 		|| !GetImport().GetTextImport()->IsInsideDeleteContext())
788cdf0e10cSrcweir 	{
789ddde725dSArmin Le Grand     	Reference < XShape > xShape( xPropSet, UNO_QUERY );
790ddde725dSArmin Le Grand 
791cdf0e10cSrcweir         GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
792cdf0e10cSrcweir 	}
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 	if( XML_TEXT_FRAME_TEXTBOX == nType )
795cdf0e10cSrcweir 	{
796cdf0e10cSrcweir 		xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
797cdf0e10cSrcweir 		Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
798cdf0e10cSrcweir 		Reference < XText > xTxt = xTxtFrame->getText();
799cdf0e10cSrcweir 		xOldTextCursor = xTextImportHelper->GetCursor();
800cdf0e10cSrcweir 		xTextImportHelper->SetCursor( xTxt->createTextCursor() );
801cdf0e10cSrcweir 
802cdf0e10cSrcweir         // remember old list item and block (#89892#) and reset them
803cdf0e10cSrcweir         // for the text frame
804cdf0e10cSrcweir         xTextImportHelper->PushListContext();
805cdf0e10cSrcweir         mbListContextPushed = true;
806cdf0e10cSrcweir 	}
807cdf0e10cSrcweir }
808cdf0e10cSrcweir 
809cdf0e10cSrcweir sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere()
810cdf0e10cSrcweir {
811cdf0e10cSrcweir 	if( !xPropSet.is() &&
812cdf0e10cSrcweir 		( XML_TEXT_FRAME_OBJECT_OLE == nType ||
813cdf0e10cSrcweir 		  XML_TEXT_FRAME_GRAPHIC == nType ) &&
814cdf0e10cSrcweir 		xBase64Stream.is() && !bCreateFailed )
815cdf0e10cSrcweir 	{
816cdf0e10cSrcweir 		if( bOwnBase64Stream )
817cdf0e10cSrcweir 			xBase64Stream->closeOutput();
818cdf0e10cSrcweir 		Create( sal_True );
819cdf0e10cSrcweir 	}
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 	return xPropSet.is();
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
825cdf0e10cSrcweir     SvXMLImport& rImport,
826cdf0e10cSrcweir     sal_uInt16 nPrfx, const OUString& rLName,
827cdf0e10cSrcweir     const Reference< XAttributeList > & rAttrList,
828cdf0e10cSrcweir     TextContentAnchorType eATyp,
829cdf0e10cSrcweir     sal_uInt16 nNewType,
830*011bafbfSArmin Le Grand     const Reference< XAttributeList > & rFrameAttrList,
831*011bafbfSArmin Le Grand     bool bSetNameForFrame)
832cdf0e10cSrcweir :   SvXMLImportContext( rImport, nPrfx, rLName )
833cdf0e10cSrcweir ,   mbListContextPushed( false )
834cdf0e10cSrcweir ,   sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
835cdf0e10cSrcweir ,   sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
836cdf0e10cSrcweir ,   sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
837cdf0e10cSrcweir ,   sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
838cdf0e10cSrcweir ,   sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
839cdf0e10cSrcweir ,   sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
840cdf0e10cSrcweir ,   sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
841cdf0e10cSrcweir ,   sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
842cdf0e10cSrcweir ,   sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
843cdf0e10cSrcweir ,   sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
844cdf0e10cSrcweir ,   sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
845cdf0e10cSrcweir ,   sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
846cdf0e10cSrcweir ,   sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
847cdf0e10cSrcweir ,   sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
848cdf0e10cSrcweir ,   sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
849cdf0e10cSrcweir ,   sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
850cdf0e10cSrcweir ,   sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
851cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
852cdf0e10cSrcweir //,   sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
853cdf0e10cSrcweir ,   sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
854cdf0e10cSrcweir ,   sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
855cdf0e10cSrcweir // <--
856cdf0e10cSrcweir ,   sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
857cdf0e10cSrcweir ,   sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
858cdf0e10cSrcweir ,   sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
859cdf0e10cSrcweir ,   sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
860cdf0e10cSrcweir ,   nType( nNewType )
861cdf0e10cSrcweir ,   eAnchorType( eATyp )
862*011bafbfSArmin Le Grand ,   mbSetNameForFrame(bSetNameForFrame)
863cdf0e10cSrcweir {
864cdf0e10cSrcweir 	nX = 0;
865cdf0e10cSrcweir 	nY = 0;
866cdf0e10cSrcweir 	nWidth = 0;
867cdf0e10cSrcweir 	nHeight = 0;
868cdf0e10cSrcweir 	nZIndex = -1;
869cdf0e10cSrcweir 	nPage = 0;
870cdf0e10cSrcweir 	nRotation = 0;
871cdf0e10cSrcweir 	nRelWidth = 0;
872cdf0e10cSrcweir 	nRelHeight = 0;
873cdf0e10cSrcweir 	bMayScript = sal_False;
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 	bMinHeight = sal_False;
876cdf0e10cSrcweir 	bMinWidth = sal_False;
877cdf0e10cSrcweir 	bSyncWidth = sal_False;
878cdf0e10cSrcweir 	bSyncHeight = sal_False;
879cdf0e10cSrcweir 	bCreateFailed = sal_False;
880cdf0e10cSrcweir 	bOwnBase64Stream = sal_False;
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 	UniReference < XMLTextImportHelper > xTxtImport =
883cdf0e10cSrcweir 		GetImport().GetTextImport();
884cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
885cdf0e10cSrcweir 		xTxtImport->GetTextFrameAttrTokenMap();
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
888cdf0e10cSrcweir 	sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0);
889cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nTotalAttrCount; i++ )
890cdf0e10cSrcweir 	{
891cdf0e10cSrcweir 		const OUString& rAttrName =
892cdf0e10cSrcweir 			i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount );
893cdf0e10cSrcweir 		const OUString& rValue =
894cdf0e10cSrcweir 			i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount );
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 		OUString aLocalName;
897cdf0e10cSrcweir 		sal_uInt16 nPrefix =
898cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
899cdf0e10cSrcweir 															&aLocalName );
900cdf0e10cSrcweir 		switch( rTokenMap.Get( nPrefix, aLocalName ) )
901cdf0e10cSrcweir 		{
902cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_STYLE_NAME:
903cdf0e10cSrcweir 			sStyleName = rValue;
904cdf0e10cSrcweir 			break;
905cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NAME:
906cdf0e10cSrcweir 			sName = rValue;
907cdf0e10cSrcweir 			break;
908cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_FRAME_NAME:
909cdf0e10cSrcweir 			sFrameName = rValue;
910cdf0e10cSrcweir 			break;
911cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_APPLET_NAME:
912cdf0e10cSrcweir 			sAppletName = rValue;
913cdf0e10cSrcweir 			break;
914cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ANCHOR_TYPE:
915cdf0e10cSrcweir 			if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
916cdf0e10cSrcweir 				TextContentAnchorType_AT_CHARACTER == eAnchorType ||
917cdf0e10cSrcweir 				TextContentAnchorType_AS_CHARACTER == eAnchorType )
918cdf0e10cSrcweir 			{
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 				TextContentAnchorType eNew;
921cdf0e10cSrcweir 				if( XMLAnchorTypePropHdl::convert( rValue, eNew ) &&
922cdf0e10cSrcweir 					( TextContentAnchorType_AT_PARAGRAPH == eNew ||
923cdf0e10cSrcweir 					  TextContentAnchorType_AT_CHARACTER == eNew ||
924cdf0e10cSrcweir 					  TextContentAnchorType_AS_CHARACTER == eNew ||
925cdf0e10cSrcweir 					  TextContentAnchorType_AT_PAGE == eNew) )
926cdf0e10cSrcweir 					eAnchorType = eNew;
927cdf0e10cSrcweir 			}
928cdf0e10cSrcweir 			break;
929cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER:
930cdf0e10cSrcweir 			{
931cdf0e10cSrcweir 				sal_Int32 nTmp;
932cdf0e10cSrcweir 			   	if( GetImport().GetMM100UnitConverter().
933cdf0e10cSrcweir 								convertNumber( nTmp, rValue, 1, SHRT_MAX ) )
934cdf0e10cSrcweir 					nPage = (sal_Int16)nTmp;
935cdf0e10cSrcweir 			}
936cdf0e10cSrcweir 			break;
937cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_X:
938cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue );
939cdf0e10cSrcweir 			break;
940cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_Y:
941cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue );
942cdf0e10cSrcweir 			break;
943cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_WIDTH:
944cdf0e10cSrcweir 			// relative widths are obsolete since SRC617. Remove them some day!
945cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
946cdf0e10cSrcweir 			{
947cdf0e10cSrcweir 				sal_Int32 nTmp;
948cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
949cdf0e10cSrcweir 																	rValue );
950cdf0e10cSrcweir 				nRelWidth = (sal_Int16)nTmp;
951cdf0e10cSrcweir 			}
952cdf0e10cSrcweir 			else
953cdf0e10cSrcweir 			{
954cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
955cdf0e10cSrcweir 																	rValue, 0 );
956cdf0e10cSrcweir 			}
957cdf0e10cSrcweir 			break;
958cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_REL_WIDTH:
959cdf0e10cSrcweir 			if( IsXMLToken(rValue, XML_SCALE) )
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir 				bSyncWidth = sal_True;
962cdf0e10cSrcweir 			}
963cdf0e10cSrcweir 			else
964cdf0e10cSrcweir 			{
965cdf0e10cSrcweir 				sal_Int32 nTmp;
966cdf0e10cSrcweir 				if( GetImport().GetMM100UnitConverter().
967cdf0e10cSrcweir 						convertPercent( nTmp, rValue ) )
968cdf0e10cSrcweir 					nRelWidth = (sal_Int16)nTmp;
969cdf0e10cSrcweir 			}
970cdf0e10cSrcweir 			break;
971cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIN_WIDTH:
972cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
973cdf0e10cSrcweir 			{
974cdf0e10cSrcweir 				sal_Int32 nTmp;
975cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
976cdf0e10cSrcweir 																	rValue );
977cdf0e10cSrcweir 				nRelWidth = (sal_Int16)nTmp;
978cdf0e10cSrcweir 			}
979cdf0e10cSrcweir 			else
980cdf0e10cSrcweir 			{
981cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
982cdf0e10cSrcweir 																	rValue, 0 );
983cdf0e10cSrcweir 			}
984cdf0e10cSrcweir 			bMinWidth = sal_True;
985cdf0e10cSrcweir 			break;
986cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_HEIGHT:
987cdf0e10cSrcweir 			// relative heights are obsolete since SRC617. Remove them some day!
988cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
989cdf0e10cSrcweir 			{
990cdf0e10cSrcweir 				sal_Int32 nTmp;
991cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
992cdf0e10cSrcweir 																	rValue );
993cdf0e10cSrcweir 				nRelHeight = (sal_Int16)nTmp;
994cdf0e10cSrcweir 			}
995cdf0e10cSrcweir 			else
996cdf0e10cSrcweir 			{
997cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
998cdf0e10cSrcweir 																	rValue, 0 );
999cdf0e10cSrcweir 			}
1000cdf0e10cSrcweir 			break;
1001cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_REL_HEIGHT:
1002cdf0e10cSrcweir 			if( IsXMLToken( rValue, XML_SCALE ) )
1003cdf0e10cSrcweir 			{
1004cdf0e10cSrcweir 				bSyncHeight = sal_True;
1005cdf0e10cSrcweir 			}
1006cdf0e10cSrcweir 			else if( IsXMLToken( rValue, XML_SCALE_MIN ) )
1007cdf0e10cSrcweir 			{
1008cdf0e10cSrcweir 				bSyncHeight = sal_True;
1009cdf0e10cSrcweir 				bMinHeight = sal_True;
1010cdf0e10cSrcweir 			}
1011cdf0e10cSrcweir 			else
1012cdf0e10cSrcweir 			{
1013cdf0e10cSrcweir 				sal_Int32 nTmp;
1014cdf0e10cSrcweir 				if( GetImport().GetMM100UnitConverter().
1015cdf0e10cSrcweir 						convertPercent( nTmp, rValue ) )
1016cdf0e10cSrcweir 					nRelHeight = (sal_Int16)nTmp;
1017cdf0e10cSrcweir 			}
1018cdf0e10cSrcweir 			break;
1019cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIN_HEIGHT:
1020cdf0e10cSrcweir 			if( rValue.indexOf( '%' ) != -1 )
1021cdf0e10cSrcweir 			{
1022cdf0e10cSrcweir 				sal_Int32 nTmp;
1023cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1024cdf0e10cSrcweir 																	rValue );
1025cdf0e10cSrcweir 				nRelHeight = (sal_Int16)nTmp;
1026cdf0e10cSrcweir 			}
1027cdf0e10cSrcweir 			else
1028cdf0e10cSrcweir 			{
1029cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1030cdf0e10cSrcweir 																	rValue, 0 );
1031cdf0e10cSrcweir 			}
1032cdf0e10cSrcweir 			bMinHeight = sal_True;
1033cdf0e10cSrcweir 			break;
1034cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_Z_INDEX:
1035cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 );
1036cdf0e10cSrcweir 			break;
1037cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME:
1038cdf0e10cSrcweir 			sNextName = rValue;
1039cdf0e10cSrcweir 			break;
1040cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_HREF:
1041cdf0e10cSrcweir 			sHRef = rValue;
1042cdf0e10cSrcweir 			break;
1043cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_FILTER_NAME:
1044cdf0e10cSrcweir 			sFilterName = rValue;
1045cdf0e10cSrcweir 			break;
1046cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_TRANSFORM:
1047cdf0e10cSrcweir 			{
1048cdf0e10cSrcweir 				OUString sValue( rValue );
1049cdf0e10cSrcweir 				sValue.trim();
1050cdf0e10cSrcweir                 const OUString aRotate(GetXMLToken(XML_ROTATE));
1051cdf0e10cSrcweir 				const sal_Int32 nRotateLen(aRotate.getLength());
1052cdf0e10cSrcweir 				sal_Int32 nLen = sValue.getLength();
1053cdf0e10cSrcweir 				if( nLen >= nRotateLen+3 &&
1054cdf0e10cSrcweir 					0 == sValue.compareTo( aRotate, nRotateLen ) &&
1055cdf0e10cSrcweir 					'(' == sValue[nRotateLen] &&
1056cdf0e10cSrcweir 					')' == sValue[nLen-1] )
1057cdf0e10cSrcweir 				{
1058cdf0e10cSrcweir 					sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) );
1059cdf0e10cSrcweir 					sValue.trim();
1060cdf0e10cSrcweir 					sal_Int32 nVal;
1061cdf0e10cSrcweir 					if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) )
1062cdf0e10cSrcweir 						nRotation = (sal_Int16)(nVal % 360 );
1063cdf0e10cSrcweir 				}
1064cdf0e10cSrcweir 			}
1065cdf0e10cSrcweir 			break;
1066cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_CODE:
1067cdf0e10cSrcweir 			sCode = rValue;
1068cdf0e10cSrcweir 			break;
1069cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_OBJECT:
1070cdf0e10cSrcweir 			sObject = rValue;
1071cdf0e10cSrcweir 			break;
1072cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_ARCHIVE:
1073cdf0e10cSrcweir 			sArchive = rValue;
1074cdf0e10cSrcweir 			break;
1075cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MAY_SCRIPT:
1076cdf0e10cSrcweir 			bMayScript = IsXMLToken( rValue, XML_TRUE );
1077cdf0e10cSrcweir 			break;
1078cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_MIME_TYPE:
1079cdf0e10cSrcweir 			sMimeType = rValue;
1080cdf0e10cSrcweir 			break;
1081cdf0e10cSrcweir 		case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE:
1082cdf0e10cSrcweir 			sTblName = rValue;
1083cdf0e10cSrcweir 			break;
1084cdf0e10cSrcweir 		}
1085cdf0e10cSrcweir 	}
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir 	if( ( (XML_TEXT_FRAME_GRAPHIC == nType ||
1088cdf0e10cSrcweir 		   XML_TEXT_FRAME_OBJECT == nType ||
1089cdf0e10cSrcweir 		   XML_TEXT_FRAME_OBJECT_OLE == nType) &&
1090cdf0e10cSrcweir 		  !sHRef.getLength() ) ||
1091cdf0e10cSrcweir 		( XML_TEXT_FRAME_APPLET  == nType && !sCode.getLength() ) ||
1092cdf0e10cSrcweir         ( XML_TEXT_FRAME_PLUGIN == nType &&
1093cdf0e10cSrcweir           sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) )
1094cdf0e10cSrcweir 		return;	// no URL: no image or OLE object
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 	Create( sal_True );
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl()
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir void XMLTextFrameContext_Impl::EndElement()
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir 	CreateIfNotThere();
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir 	if( xOldTextCursor.is() )
1108cdf0e10cSrcweir 	{
1109cdf0e10cSrcweir 		GetImport().GetTextImport()->DeleteParagraph();
1110cdf0e10cSrcweir 		GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1111cdf0e10cSrcweir 	}
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     // reinstall old list item (if necessary) #89892#
1114cdf0e10cSrcweir     if (mbListContextPushed) {
1115cdf0e10cSrcweir         GetImport().GetTextImport()->PopListContext();
1116cdf0e10cSrcweir     }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 	if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is())
1119cdf0e10cSrcweir 		GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext(
1123cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1124cdf0e10cSrcweir 		const OUString& rLocalName,
1125cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
1130cdf0e10cSrcweir 	{
1131cdf0e10cSrcweir 		if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) &&
1132cdf0e10cSrcweir 			  IsXMLToken( rLocalName, XML_PARAM ) )
1133cdf0e10cSrcweir 		{
1134cdf0e10cSrcweir 			pContext = new XMLTextFrameParam_Impl( GetImport(),
1135cdf0e10cSrcweir 											  nPrefix, rLocalName,
1136cdf0e10cSrcweir 							 				  xAttrList, nType, aParamMap );
1137cdf0e10cSrcweir 		}
1138cdf0e10cSrcweir 	}
1139cdf0e10cSrcweir 	else if( (XML_NAMESPACE_OFFICE == nPrefix) )
1140cdf0e10cSrcweir 	{
1141cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_BINARY_DATA ) )
1142cdf0e10cSrcweir 		{
1143cdf0e10cSrcweir 			if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1144cdf0e10cSrcweir 			{
1145cdf0e10cSrcweir 				switch( nType )
1146cdf0e10cSrcweir 				{
1147cdf0e10cSrcweir 				case XML_TEXT_FRAME_GRAPHIC:
1148cdf0e10cSrcweir 					xBase64Stream =
1149cdf0e10cSrcweir 						GetImport().GetStreamForGraphicObjectURLFromBase64();
1150cdf0e10cSrcweir 					break;
1151cdf0e10cSrcweir 				case XML_TEXT_FRAME_OBJECT_OLE:
1152cdf0e10cSrcweir 					xBase64Stream =
1153cdf0e10cSrcweir 						GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1154cdf0e10cSrcweir 					break;
1155cdf0e10cSrcweir 				}
1156cdf0e10cSrcweir 				if( xBase64Stream.is() )
1157cdf0e10cSrcweir 					pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
1158cdf0e10cSrcweir 													rLocalName, xAttrList,
1159cdf0e10cSrcweir 													xBase64Stream );
1160cdf0e10cSrcweir 			}
1161cdf0e10cSrcweir 		}
1162cdf0e10cSrcweir 	}
1163cdf0e10cSrcweir     // --> OD 2009-08-17 #i100480#
1164cdf0e10cSrcweir     // correction of condition which also avoids warnings.
1165cdf0e10cSrcweir     if( !pContext &&
1166cdf0e10cSrcweir         ( XML_TEXT_FRAME_OBJECT == nType &&
1167cdf0e10cSrcweir           ( ( XML_NAMESPACE_OFFICE == nPrefix &&
1168cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_DOCUMENT ) ) ||
1169cdf0e10cSrcweir             ( XML_NAMESPACE_MATH == nPrefix &&
1170cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_MATH ) ) ) ) )
1171cdf0e10cSrcweir     // <--
1172cdf0e10cSrcweir 	{
1173cdf0e10cSrcweir 		if( !xPropSet.is() && !bCreateFailed )
1174cdf0e10cSrcweir 		{
1175cdf0e10cSrcweir 			XMLEmbeddedObjectImportContext *pEContext =
1176cdf0e10cSrcweir 				new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
1177cdf0e10cSrcweir 													rLocalName, xAttrList );
1178cdf0e10cSrcweir 			sFilterService = pEContext->GetFilterServiceName();
1179cdf0e10cSrcweir 			if( sFilterService.getLength() != 0 )
1180cdf0e10cSrcweir 			{
1181cdf0e10cSrcweir 				Create( sal_False );
1182cdf0e10cSrcweir 				if( xPropSet.is() )
1183cdf0e10cSrcweir 				{
1184cdf0e10cSrcweir 					Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1185cdf0e10cSrcweir 																UNO_QUERY );
1186cdf0e10cSrcweir 					OSL_ENSURE( xEOS.is(),
1187cdf0e10cSrcweir 							"no embedded object supplier for own object" );
1188cdf0e10cSrcweir                     Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1189cdf0e10cSrcweir 					pEContext->SetComponent( aXComponent );
1190cdf0e10cSrcweir 				}
1191cdf0e10cSrcweir 			}
1192cdf0e10cSrcweir 			pContext = pEContext;
1193cdf0e10cSrcweir 		}
1194cdf0e10cSrcweir 	}
1195cdf0e10cSrcweir 	if( !pContext && xOldTextCursor.is() )	// text-box
1196cdf0e10cSrcweir 		pContext = GetImport().GetTextImport()->CreateTextChildContext(
1197cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xAttrList,
1198cdf0e10cSrcweir 							XML_TEXT_TYPE_TEXTBOX );
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 	if( !pContext )
1201cdf0e10cSrcweir 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir 	return pContext;
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir void XMLTextFrameContext_Impl::Characters( const OUString& rChars )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir 	if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
1209cdf0e10cSrcweir 		  XML_TEXT_FRAME_GRAPHIC == nType) &&
1210cdf0e10cSrcweir 		!xPropSet.is() && !bCreateFailed )
1211cdf0e10cSrcweir 	{
1212cdf0e10cSrcweir 		OUString sTrimmedChars( rChars. trim() );
1213cdf0e10cSrcweir 		if( sTrimmedChars.getLength() )
1214cdf0e10cSrcweir 		{
1215cdf0e10cSrcweir 			if( !xBase64Stream.is() )
1216cdf0e10cSrcweir 			{
1217cdf0e10cSrcweir 				if( XML_TEXT_FRAME_GRAPHIC == nType )
1218cdf0e10cSrcweir 				{
1219cdf0e10cSrcweir 					xBase64Stream =
1220cdf0e10cSrcweir 						GetImport().GetStreamForGraphicObjectURLFromBase64();
1221cdf0e10cSrcweir 				}
1222cdf0e10cSrcweir 				else
1223cdf0e10cSrcweir 				{
1224cdf0e10cSrcweir 					xBase64Stream =
1225cdf0e10cSrcweir 						GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1226cdf0e10cSrcweir 				}
1227cdf0e10cSrcweir 				if( xBase64Stream.is() )
1228cdf0e10cSrcweir 					bOwnBase64Stream = sal_True;
1229cdf0e10cSrcweir 			}
1230cdf0e10cSrcweir 			if( bOwnBase64Stream && xBase64Stream.is() )
1231cdf0e10cSrcweir 			{
1232cdf0e10cSrcweir 				OUString sChars;
1233cdf0e10cSrcweir 				if( sBase64CharsLeft )
1234cdf0e10cSrcweir 				{
1235cdf0e10cSrcweir 					sChars = sBase64CharsLeft;
1236cdf0e10cSrcweir 					sChars += sTrimmedChars;
1237cdf0e10cSrcweir 					sBase64CharsLeft = OUString();
1238cdf0e10cSrcweir 				}
1239cdf0e10cSrcweir 				else
1240cdf0e10cSrcweir 				{
1241cdf0e10cSrcweir 					sChars = sTrimmedChars;
1242cdf0e10cSrcweir 				}
1243cdf0e10cSrcweir 				Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
1244cdf0e10cSrcweir 				sal_Int32 nCharsDecoded =
1245cdf0e10cSrcweir 					GetImport().GetMM100UnitConverter().
1246cdf0e10cSrcweir 						decodeBase64SomeChars( aBuffer, sChars );
1247cdf0e10cSrcweir 				xBase64Stream->writeBytes( aBuffer );
1248cdf0e10cSrcweir 				if( nCharsDecoded != sChars.getLength() )
1249cdf0e10cSrcweir 					sBase64CharsLeft = sChars.copy( nCharsDecoded );
1250cdf0e10cSrcweir 			}
1251cdf0e10cSrcweir 		}
1252cdf0e10cSrcweir 	}
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
1256cdf0e10cSrcweir 					   const OUString& rName,
1257cdf0e10cSrcweir 					   const OUString& rTargetFrameName,
1258cdf0e10cSrcweir 					   sal_Bool bMap )
1259cdf0e10cSrcweir {
1260cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkURL(
1261cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
1262cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkName(
1263cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"));
1264cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkTarget(
1265cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"));
1266cdf0e10cSrcweir     static ::rtl::OUString s_ServerMap(
1267cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("ServerMap"));
1268cdf0e10cSrcweir 	if( !xPropSet.is() )
1269cdf0e10cSrcweir 		return;
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport();
1272cdf0e10cSrcweir 	Reference < XPropertySetInfo > xPropSetInfo =
1273cdf0e10cSrcweir 		xPropSet->getPropertySetInfo();
1274cdf0e10cSrcweir 	if( !xPropSetInfo.is() ||
1275cdf0e10cSrcweir         !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1276cdf0e10cSrcweir 		return;
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir 	Any aAny;
1279cdf0e10cSrcweir 	aAny <<= rHRef;
1280cdf0e10cSrcweir     xPropSet->setPropertyValue( s_HyperLinkURL, aAny );
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1283cdf0e10cSrcweir 	{
1284cdf0e10cSrcweir 		aAny <<= rName;
1285cdf0e10cSrcweir         xPropSet->setPropertyValue(s_HyperLinkName, aAny);
1286cdf0e10cSrcweir 	}
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1289cdf0e10cSrcweir 	{
1290cdf0e10cSrcweir 		aAny <<= rTargetFrameName;
1291cdf0e10cSrcweir         xPropSet->setPropertyValue( s_HyperLinkTarget, aAny );
1292cdf0e10cSrcweir 	}
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1295cdf0e10cSrcweir 	{
1296cdf0e10cSrcweir 		aAny.setValue( &bMap, ::getBooleanCppuType() );
1297cdf0e10cSrcweir         xPropSet->setPropertyValue(s_ServerMap, aAny);
1298cdf0e10cSrcweir 	}
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
1302cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle )
1303cdf0e10cSrcweir {
1304cdf0e10cSrcweir     if ( xPropSet.is() )
1305cdf0e10cSrcweir     {
1306cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1307cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sTitle ) )
1308cdf0e10cSrcweir         {
1309cdf0e10cSrcweir             xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) );
1310cdf0e10cSrcweir         }
1311cdf0e10cSrcweir     }
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir 	if ( xPropSet.is() )
1317cdf0e10cSrcweir 	{
1318cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1319cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sDescription ) )
1320cdf0e10cSrcweir 		{
1321cdf0e10cSrcweir             xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) );
1322cdf0e10cSrcweir 		}
1323cdf0e10cSrcweir 	}
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir // <--
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext, SvXMLImportContext );
1330cdf0e10cSrcweir 
1331ddde725dSArmin Le Grand void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
1332ddde725dSArmin Le Grand {
1333ddde725dSArmin Le Grand     const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1334ddde725dSArmin Le Grand 
1335ddde725dSArmin Le Grand     if(pXMLTextFrameContext_Impl)
1336ddde725dSArmin Le Grand     {
1337ddde725dSArmin Le Grand         try
1338ddde725dSArmin Le Grand         {
1339ddde725dSArmin Le Grand             // just dispose to delete
1340ddde725dSArmin Le Grand             uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
1341ddde725dSArmin Le Grand 
1342ddde725dSArmin Le Grand             if(xComp.is())
1343ddde725dSArmin Le Grand             {
1344ddde725dSArmin Le Grand                 xComp->dispose();
1345ddde725dSArmin Le Grand             }
1346ddde725dSArmin Le Grand         }
1347ddde725dSArmin Le Grand         catch( uno::Exception& )
1348ddde725dSArmin Le Grand         {
1349ddde725dSArmin Le Grand             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
1350ddde725dSArmin Le Grand         }
1351ddde725dSArmin Le Grand     }
1352ddde725dSArmin Le Grand }
1353ddde725dSArmin Le Grand 
1354ddde725dSArmin Le Grand rtl::OUString XMLTextFrameContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
1355ddde725dSArmin Le Grand {
1356ddde725dSArmin Le Grand     rtl::OUString aRetval;
1357ddde725dSArmin Le Grand     const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1358ddde725dSArmin Le Grand 
1359ddde725dSArmin Le Grand     if(pXMLTextFrameContext_Impl)
1360ddde725dSArmin Le Grand     {
1361ddde725dSArmin Le Grand         return pXMLTextFrameContext_Impl->GetHRef();
1362ddde725dSArmin Le Grand     }
1363ddde725dSArmin Le Grand 
1364ddde725dSArmin Le Grand     return aRetval;
1365ddde725dSArmin Le Grand }
1366ddde725dSArmin Le Grand 
1367cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere()
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1370cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1371cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1372cdf0e10cSrcweir 	if( pImpl )
1373cdf0e10cSrcweir 		bRet = pImpl->CreateIfNotThere();
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 	return bRet;
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference <
1379cdf0e10cSrcweir 		::com::sun::star::beans::XPropertySet >& rPropSet )
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1382cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1383cdf0e10cSrcweir 	if( pImpl )
1384cdf0e10cSrcweir 	{
1385cdf0e10cSrcweir 		if( pImpl->CreateIfNotThere() )
1386cdf0e10cSrcweir 			rPropSet = pImpl->GetPropSet();
1387cdf0e10cSrcweir 	}
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir 	return rPropSet.is();
1390cdf0e10cSrcweir }
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir XMLTextFrameContext::XMLTextFrameContext(
1393cdf0e10cSrcweir 		SvXMLImport& rImport,
1394cdf0e10cSrcweir 		sal_uInt16 nPrfx, const OUString& rLName,
1395cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList,
1396cdf0e10cSrcweir 		TextContentAnchorType eATyp )
1397cdf0e10cSrcweir :	SvXMLImportContext( rImport, nPrfx, rLName )
1398ddde725dSArmin Le Grand ,   multiImageImportHelper()
1399cdf0e10cSrcweir ,	m_xAttrList( new SvXMLAttributeList( xAttrList ) )
1400cdf0e10cSrcweir ,	m_pHyperlink( 0 )
1401cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
1402cdf0e10cSrcweir ,   m_sTitle()
1403cdf0e10cSrcweir ,   m_sDesc()
1404cdf0e10cSrcweir // <--
1405cdf0e10cSrcweir ,	m_eDefaultAnchorType( eATyp )
1406cdf0e10cSrcweir     // --> OD 2006-03-10 #i51726#
1407cdf0e10cSrcweir ,   m_HasAutomaticStyleWithoutParentStyle( sal_False )
1408cdf0e10cSrcweir     // <--
1409cdf0e10cSrcweir ,	m_bSupportsReplacement( sal_False )
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1412cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
1413cdf0e10cSrcweir 	{
1414cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 		OUString aLocalName;
1417cdf0e10cSrcweir 		sal_uInt16 nPrefix =
1418cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
1419cdf0e10cSrcweir         // --> OD 2006-03-10 #i51726#
1420cdf0e10cSrcweir         // New distinguish attribute between Writer objects and Draw objects is:
1421cdf0e10cSrcweir         // Draw objects have an automatic style without a parent style
1422cdf0e10cSrcweir         if ( XML_NAMESPACE_DRAW == nPrefix &&
1423cdf0e10cSrcweir              IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1424cdf0e10cSrcweir 		{
1425cdf0e10cSrcweir             OUString aStyleName = xAttrList->getValueByIndex( i );
1426cdf0e10cSrcweir             if( aStyleName.getLength() )
1427cdf0e10cSrcweir             {
1428cdf0e10cSrcweir                 UniReference < XMLTextImportHelper > xTxtImport =
1429cdf0e10cSrcweir                                                     GetImport().GetTextImport();
1430cdf0e10cSrcweir                 XMLPropStyleContext* pStyle( 0L );
1431cdf0e10cSrcweir                 pStyle = xTxtImport->FindAutoFrameStyle( aStyleName );
1432cdf0e10cSrcweir                 if ( pStyle && !pStyle->GetParentName().getLength() )
1433cdf0e10cSrcweir                 {
1434cdf0e10cSrcweir                     m_HasAutomaticStyleWithoutParentStyle = sal_True;
1435cdf0e10cSrcweir                 }
1436cdf0e10cSrcweir             }
1437cdf0e10cSrcweir         }
1438cdf0e10cSrcweir         // <--
1439cdf0e10cSrcweir         else if ( XML_NAMESPACE_TEXT == nPrefix &&
1440cdf0e10cSrcweir                   IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) )
1441cdf0e10cSrcweir 		{
1442cdf0e10cSrcweir 			TextContentAnchorType eNew;
1443cdf0e10cSrcweir 			if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i),
1444cdf0e10cSrcweir 						eNew ) &&
1445cdf0e10cSrcweir 				( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1446cdf0e10cSrcweir 				  TextContentAnchorType_AT_CHARACTER == eNew ||
1447cdf0e10cSrcweir 				  TextContentAnchorType_AS_CHARACTER == eNew ||
1448cdf0e10cSrcweir 				  TextContentAnchorType_AT_PAGE == eNew) )
1449cdf0e10cSrcweir 				m_eDefaultAnchorType = eNew;
1450cdf0e10cSrcweir 		}
1451cdf0e10cSrcweir 	}
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir XMLTextFrameContext::~XMLTextFrameContext()
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir     delete m_pHyperlink;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir void XMLTextFrameContext::EndElement()
1460cdf0e10cSrcweir {
1461ddde725dSArmin Le Grand     /// solve if multiple image child contexts were imported
1462598d8f9fSArmin Le Grand     /// the winner is returned, if something has yet to be done with it
1463*011bafbfSArmin Le Grand     const SvXMLImportContext* pWinner = solveMultipleImages();
1464*011bafbfSArmin Le Grand 
1465*011bafbfSArmin Le Grand     // #123261# see if the winner is a XMLTextFrameContext_Impl
1466*011bafbfSArmin Le Grand     const XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< const XMLTextFrameContext_Impl* >(pWinner);
1467*011bafbfSArmin Le Grand 
1468*011bafbfSArmin Le Grand     if(pImplWinner)
1469*011bafbfSArmin Le Grand     {
1470*011bafbfSArmin Le Grand         // #123261# if yes, set name now, after the winner is identified (setting at each
1471*011bafbfSArmin Le Grand         // candidate may run into problems due to colliding with efforts in the target to
1472*011bafbfSArmin Le Grand         // avoid double names, so only set one name at one image and not at each)
1473*011bafbfSArmin Le Grand         const_cast< XMLTextFrameContext_Impl* >(pImplWinner)->SetNameForFrameFromPropSet();
1474*011bafbfSArmin Le Grand     }
1475ddde725dSArmin Le Grand 
1476cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1477*011bafbfSArmin Le Grand     XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl* >(pContext);
1478*011bafbfSArmin Le Grand 
1479cdf0e10cSrcweir     if( pImpl )
1480cdf0e10cSrcweir     {
1481cdf0e10cSrcweir         pImpl->CreateIfNotThere();
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir         // --> OD 2009-07-22 #i73249#
1484cdf0e10cSrcweir //        // alternative text
1485cdf0e10cSrcweir //        if( m_sDesc.getLength() )
1486cdf0e10cSrcweir //            pImpl->SetDesc( m_sDesc );
1487cdf0e10cSrcweir         // svg:title
1488cdf0e10cSrcweir         if( m_sTitle.getLength() )
1489cdf0e10cSrcweir         {
1490cdf0e10cSrcweir             pImpl->SetTitle( m_sTitle );
1491cdf0e10cSrcweir         }
1492cdf0e10cSrcweir         if( m_sDesc.getLength() )
1493cdf0e10cSrcweir         {
1494cdf0e10cSrcweir             pImpl->SetDesc( m_sDesc );
1495cdf0e10cSrcweir         }
1496cdf0e10cSrcweir         // <--
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir 		if( m_pHyperlink )
1499cdf0e10cSrcweir 		{
1500cdf0e10cSrcweir 			pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
1501cdf0e10cSrcweir 						  m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
1502cdf0e10cSrcweir 			delete m_pHyperlink;
1503cdf0e10cSrcweir 			m_pHyperlink = 0;
1504cdf0e10cSrcweir 		}
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 	}
1507cdf0e10cSrcweir }
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
1510cdf0e10cSrcweir 		sal_uInt16 p_nPrefix,
1511cdf0e10cSrcweir 		const OUString& rLocalName,
1512cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList )
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 	if( !m_xImplContext.Is() )
1517cdf0e10cSrcweir 	{
1518cdf0e10cSrcweir 		// no child exists
1519cdf0e10cSrcweir 		if( XML_NAMESPACE_DRAW == p_nPrefix )
1520cdf0e10cSrcweir 		{
1521cdf0e10cSrcweir 			sal_uInt16 nFrameType = USHRT_MAX;
1522cdf0e10cSrcweir 			if( IsXMLToken( rLocalName, XML_TEXT_BOX ) )
1523cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_TEXTBOX;
1524cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_IMAGE ) )
1525cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_GRAPHIC;
1526cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_OBJECT ) )
1527cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_OBJECT;
1528cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) )
1529cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_OBJECT_OLE;
1530cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_APPLET) )
1531cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_APPLET;
1532cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_PLUGIN ) )
1533cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_PLUGIN;
1534cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) )
1535cdf0e10cSrcweir 				nFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 			if( USHRT_MAX != nFrameType )
1538cdf0e10cSrcweir 			{
1539cdf0e10cSrcweir                 // --> OD 2006-03-10 #i51726#
1540cdf0e10cSrcweir                 if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType ||
1541cdf0e10cSrcweir                        XML_TEXT_FRAME_GRAPHIC == nFrameType ) &&
1542cdf0e10cSrcweir                      m_HasAutomaticStyleWithoutParentStyle )
1543cdf0e10cSrcweir                 // <--
1544cdf0e10cSrcweir 				{
1545cdf0e10cSrcweir 					Reference < XShapes > xShapes;
1546cdf0e10cSrcweir 					pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1547cdf0e10cSrcweir 									GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1548cdf0e10cSrcweir 				}
1549cdf0e10cSrcweir 				else if( XML_TEXT_FRAME_PLUGIN == nFrameType )
1550cdf0e10cSrcweir 				{
1551cdf0e10cSrcweir 				    bool bMedia = false;
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 				    // check, if we have a media object
1554cdf0e10cSrcweir 	                for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
1555cdf0e10cSrcweir 	                {
1556cdf0e10cSrcweir 		                OUString 	aLocalName;
1557cdf0e10cSrcweir 		                sal_uInt16 	nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 		                if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
1560cdf0e10cSrcweir 		                {
1561cdf0e10cSrcweir 			                if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
1562cdf0e10cSrcweir 				                bMedia = true;
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir 			                // leave this loop
1565cdf0e10cSrcweir 			                n = nAttrCount - 1;
1566cdf0e10cSrcweir 		                }
1567cdf0e10cSrcweir 	                }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir 	                if( bMedia )
1570cdf0e10cSrcweir 	                {
1571cdf0e10cSrcweir 	                    Reference < XShapes > xShapes;
1572cdf0e10cSrcweir 					    pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1573cdf0e10cSrcweir 									    GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1574cdf0e10cSrcweir 					}
1575cdf0e10cSrcweir 				}
1576cdf0e10cSrcweir 				else if( XML_TEXT_FRAME_OBJECT == nFrameType ||
1577cdf0e10cSrcweir 						 XML_TEXT_FRAME_OBJECT_OLE == nFrameType )
1578cdf0e10cSrcweir 				{
1579cdf0e10cSrcweir 					m_bSupportsReplacement = sal_True;
1580cdf0e10cSrcweir 				}
1581ddde725dSArmin Le Grand                 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
1582ddde725dSArmin Le Grand                 {
1583ddde725dSArmin Le Grand                     setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
1584ddde725dSArmin Le Grand                 }
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir                 if( !pContext )
1587cdf0e10cSrcweir                 {
1588*011bafbfSArmin Le Grand                     pContext = new XMLTextFrameContext_Impl(
1589*011bafbfSArmin Le Grand                         GetImport(),
1590*011bafbfSArmin Le Grand                         p_nPrefix,
1591*011bafbfSArmin Le Grand                         rLocalName,
1592*011bafbfSArmin Le Grand                         xAttrList,
1593cdf0e10cSrcweir                         m_eDefaultAnchorType,
1594cdf0e10cSrcweir                         nFrameType,
1595*011bafbfSArmin Le Grand                         m_xAttrList,
1596*011bafbfSArmin Le Grand                         !getSupportsMultipleContents());
1597cdf0e10cSrcweir                 }
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir                 m_xImplContext = pContext;
1600ddde725dSArmin Le Grand 
1601ddde725dSArmin Le Grand                 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
1602ddde725dSArmin Le Grand                 {
1603ddde725dSArmin Le Grand                     addContent(*m_xImplContext);
1604cdf0e10cSrcweir                 }
1605cdf0e10cSrcweir             }
1606cdf0e10cSrcweir         }
1607ddde725dSArmin Le Grand     }
1608ddde725dSArmin Le Grand     else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
1609ddde725dSArmin Le Grand     {
1610ddde725dSArmin Le Grand         // read another image
1611ddde725dSArmin Le Grand         pContext = new XMLTextFrameContext_Impl(
1612*011bafbfSArmin Le Grand             GetImport(),
1613*011bafbfSArmin Le Grand             p_nPrefix,
1614*011bafbfSArmin Le Grand             rLocalName,
1615*011bafbfSArmin Le Grand             xAttrList,
1616*011bafbfSArmin Le Grand             m_eDefaultAnchorType,
1617*011bafbfSArmin Le Grand             XML_TEXT_FRAME_GRAPHIC,
1618*011bafbfSArmin Le Grand             m_xAttrList,
1619*011bafbfSArmin Le Grand             false);
1620ddde725dSArmin Le Grand 
1621ddde725dSArmin Le Grand         m_xImplContext = pContext;
1622ddde725dSArmin Le Grand         addContent(*m_xImplContext);
1623ddde725dSArmin Le Grand     }
1624cdf0e10cSrcweir 	else if( m_bSupportsReplacement && !m_xReplImplContext &&
1625cdf0e10cSrcweir 			 XML_NAMESPACE_DRAW == p_nPrefix &&
1626cdf0e10cSrcweir 			 IsXMLToken( rLocalName, XML_IMAGE ) )
1627cdf0e10cSrcweir 	{
1628cdf0e10cSrcweir 		// read replacement image
1629cdf0e10cSrcweir 		Reference < XPropertySet > xPropSet;
1630cdf0e10cSrcweir 		if( CreateIfNotThere( xPropSet ) )
1631cdf0e10cSrcweir 		{
1632cdf0e10cSrcweir 			pContext = new XMLReplacementImageContext( GetImport(),
1633cdf0e10cSrcweir 								p_nPrefix, rLocalName, xAttrList, xPropSet );
1634cdf0e10cSrcweir 			m_xReplImplContext = pContext;
1635cdf0e10cSrcweir 		}
1636cdf0e10cSrcweir 	}
1637cdf0e10cSrcweir 	else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) )
1638cdf0e10cSrcweir 	{
1639cdf0e10cSrcweir 		// the child is a writer frame
1640cdf0e10cSrcweir 		if( XML_NAMESPACE_SVG == p_nPrefix )
1641cdf0e10cSrcweir 		{
1642cdf0e10cSrcweir             // --> OD 2009-07-22 #i73249#
1643cdf0e10cSrcweir //            bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1644cdf0e10cSrcweir //            if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
1645cdf0e10cSrcweir //                pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
1646cdf0e10cSrcweir //                                                         xAttrList, m_sDesc );
1647cdf0e10cSrcweir             const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1648cdf0e10cSrcweir             if ( bOld )
1649cdf0e10cSrcweir             {
1650cdf0e10cSrcweir                 if ( IsXMLToken( rLocalName, XML_DESC ) )
1651cdf0e10cSrcweir                 {
1652cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1653cdf0e10cSrcweir                                                                         p_nPrefix,
1654cdf0e10cSrcweir                                                                         rLocalName,
1655cdf0e10cSrcweir                                                                         m_sTitle );
1656cdf0e10cSrcweir                 }
1657cdf0e10cSrcweir             }
1658cdf0e10cSrcweir             else
1659cdf0e10cSrcweir             {
1660cdf0e10cSrcweir                 if( IsXMLToken( rLocalName, XML_TITLE ) )
1661cdf0e10cSrcweir                 {
1662cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1663cdf0e10cSrcweir                                                                         p_nPrefix,
1664cdf0e10cSrcweir                                                                         rLocalName,
1665cdf0e10cSrcweir                                                                         m_sTitle );
1666cdf0e10cSrcweir                 }
1667cdf0e10cSrcweir                 else if ( IsXMLToken( rLocalName, XML_DESC ) )
1668cdf0e10cSrcweir                 {
1669cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1670cdf0e10cSrcweir                                                                         p_nPrefix,
1671cdf0e10cSrcweir                                                                         rLocalName,
1672cdf0e10cSrcweir                                                                         m_sDesc );
1673cdf0e10cSrcweir                 }
1674cdf0e10cSrcweir             }
1675cdf0e10cSrcweir             // <--
1676cdf0e10cSrcweir 		}
1677cdf0e10cSrcweir 		else if( XML_NAMESPACE_DRAW == p_nPrefix )
1678cdf0e10cSrcweir 		{
1679cdf0e10cSrcweir 			Reference < XPropertySet > xPropSet;
1680cdf0e10cSrcweir 			if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) )
1681cdf0e10cSrcweir 			{
1682cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1683cdf0e10cSrcweir 					pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1684cdf0e10cSrcweir 												  xAttrList, xPropSet, sal_False );
1685cdf0e10cSrcweir 			}
1686cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) )
1687cdf0e10cSrcweir 			{
1688cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1689cdf0e10cSrcweir 					pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1690cdf0e10cSrcweir 												  xAttrList, xPropSet, sal_True );
1691cdf0e10cSrcweir 			}
1692cdf0e10cSrcweir 			else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
1693cdf0e10cSrcweir 			{
1694cdf0e10cSrcweir 				if( CreateIfNotThere( xPropSet ) )
1695cdf0e10cSrcweir 					pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet );
1696cdf0e10cSrcweir 			}
1697cdf0e10cSrcweir 		}
1698cdf0e10cSrcweir 		else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
1699cdf0e10cSrcweir 		{
1700cdf0e10cSrcweir 			// do we still have the frame object?
1701cdf0e10cSrcweir 			Reference < XPropertySet > xPropSet;
1702cdf0e10cSrcweir 			if( CreateIfNotThere( xPropSet ) )
1703cdf0e10cSrcweir 			{
1704cdf0e10cSrcweir 				// is it an event supplier?
1705cdf0e10cSrcweir 				Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1706cdf0e10cSrcweir 				if (xEventsSupplier.is())
1707cdf0e10cSrcweir 				{
1708cdf0e10cSrcweir 					// OK, we have the events, so create the context
1709cdf0e10cSrcweir 					pContext = new XMLEventsImportContext(GetImport(), p_nPrefix,
1710cdf0e10cSrcweir 													  rLocalName, xEventsSupplier);
1711cdf0e10cSrcweir 				}
1712cdf0e10cSrcweir 			}
1713cdf0e10cSrcweir 		}
1714cdf0e10cSrcweir 	}
1715cdf0e10cSrcweir 	else if( p_nPrefix == XML_NAMESPACE_SVG &&	// #i68101#
1716cdf0e10cSrcweir 				(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
1717cdf0e10cSrcweir 	{
1718cdf0e10cSrcweir 		pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList );
1719cdf0e10cSrcweir 	}
1720cdf0e10cSrcweir 	else
1721cdf0e10cSrcweir 	{
1722cdf0e10cSrcweir 		// the child is a drawing shape
1723cdf0e10cSrcweir 		pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1724cdf0e10cSrcweir 									&m_xImplContext, p_nPrefix, rLocalName, xAttrList );
1725cdf0e10cSrcweir 	}
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir 	if( !pContext )
1728cdf0e10cSrcweir 		pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir 	return pContext;
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
1734cdf0e10cSrcweir 					   const OUString& rName,
1735cdf0e10cSrcweir 					   const OUString& rTargetFrameName,
1736cdf0e10cSrcweir 					   sal_Bool bMap )
1737cdf0e10cSrcweir {
1738cdf0e10cSrcweir 	OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" );
1739cdf0e10cSrcweir 	delete m_pHyperlink;
1740cdf0e10cSrcweir 	m_pHyperlink = new XMLTextFrameContextHyperlink_Impl(
1741cdf0e10cSrcweir 				rHRef, rName, rTargetFrameName, bMap );
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir TextContentAnchorType XMLTextFrameContext::GetAnchorType() const
1745cdf0e10cSrcweir {
1746cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1747cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1748cdf0e10cSrcweir 	if( pImpl )
1749cdf0e10cSrcweir 		return pImpl->GetAnchorType();
1750cdf0e10cSrcweir 	else
1751cdf0e10cSrcweir 		return m_eDefaultAnchorType;
1752cdf0e10cSrcweir }
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir Reference < XTextContent > XMLTextFrameContext::GetTextContent() const
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir 	Reference < XTextContent > xTxtCntnt;
1757cdf0e10cSrcweir 	SvXMLImportContext *pContext = &m_xImplContext;
1758cdf0e10cSrcweir 	XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1759cdf0e10cSrcweir 	if( pImpl )
1760cdf0e10cSrcweir 		xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir 	return xTxtCntnt;
1763cdf0e10cSrcweir }
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir // --> OD 2004-08-24 #33242#
1766cdf0e10cSrcweir Reference < XShape > XMLTextFrameContext::GetShape() const
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir     Reference < XShape > xShape;
1769cdf0e10cSrcweir     SvXMLImportContext* pContext = &m_xImplContext;
1770cdf0e10cSrcweir     SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext );
1771cdf0e10cSrcweir     if ( pImpl )
1772cdf0e10cSrcweir     {
1773cdf0e10cSrcweir         xShape = pImpl->getShape();
1774cdf0e10cSrcweir     }
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir     return xShape;
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir // <--
1779