xref: /aoo41x/main/xmloff/source/draw/ximpshap.cxx (revision f3b8b509)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24 
25 #include <tools/debug.hxx>
26 #include <com/sun/star/document/XEventsSupplier.hpp>
27 #include <com/sun/star/container/XNameReplace.hpp>
28 #include <com/sun/star/presentation/ClickAction.hpp>
29 #include <com/sun/star/drawing/FillStyle.hpp>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include "unointerfacetouniqueidentifiermapper.hxx"
32 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
33 #include <com/sun/star/container/XIdentifierAccess.hpp>
34 #include <com/sun/star/drawing/GluePoint2.hpp>
35 #include <com/sun/star/drawing/Alignment.hpp>
36 #include <com/sun/star/drawing/EscapeDirection.hpp>
37 #include <com/sun/star/media/ZoomLevel.hpp>
38 #include <com/sun/star/awt/Rectangle.hpp>
39 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <comphelper/extract.hxx>
42 #include "ximpshap.hxx"
43 #include <xmloff/XMLBase64ImportContext.hxx>
44 #include <xmloff/XMLShapeStyleContext.hxx>
45 #include <xmloff/xmluconv.hxx>
46 #include <com/sun/star/container/XNamed.hpp>
47 #include <com/sun/star/drawing/CircleKind.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/awt/XControlModel.hpp>
50 #include <com/sun/star/drawing/XControlShape.hpp>
51 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
52 #include <com/sun/star/drawing/PointSequence.hpp>
53 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
54 #include <com/sun/star/lang/XServiceInfo.hpp>
55 #include <com/sun/star/util/XCloneable.hpp>
56 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
57 #include "xexptran.hxx"
58 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
59 #include <com/sun/star/beans/XPropertySetInfo.hpp>
60 #include <com/sun/star/drawing/ConnectorType.hpp>
61 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
62 #include "PropertySetMerger.hxx"
63 #include <xmloff/families.hxx>
64 #include "ximpstyl.hxx"
65 #include"xmloff/xmlnmspe.hxx"
66 #include <xmloff/xmltoken.hxx>
67 #include "EnhancedCustomShapeToken.hxx"
68 #include "XMLReplacementImageContext.hxx"
69 #include "XMLImageMapContext.hxx"
70 #include "sdpropls.hxx"
71 #include "eventimp.hxx"
72 #include "descriptionimp.hxx"
73 #include "ximpcustomshape.hxx"
74 #include "XMLEmbeddedObjectImportContext.hxx"
75 #include "xmloff/xmlerror.hxx"
76 #include <basegfx/matrix/b2dhommatrix.hxx>
77 #include <tools/string.hxx>
78 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
79 #include <com/sun/star/container/XChild.hpp>
80 #include <com/sun/star/text/XTextDocument.hpp>
81 #include <basegfx/vector/b2dvector.hxx>
82 #include <basegfx/point/b2dpoint.hxx>
83 #include <basegfx/polygon/b2dpolygon.hxx>
84 #include <basegfx/polygon/b2dpolygontools.hxx>
85 #include <basegfx/polygon/b2dpolypolygontools.hxx>
86 #include <basegfx/matrix/b2dhommatrixtools.hxx>
87 
88 using ::rtl::OUString;
89 using ::rtl::OUStringBuffer;
90 
91 using namespace ::com::sun::star;
92 using namespace ::com::sun::star::uno;
93 using namespace ::com::sun::star::drawing;
94 using namespace ::com::sun::star::style;
95 using namespace ::com::sun::star::container;
96 using namespace ::com::sun::star::document;
97 using namespace ::xmloff::token;
98 using namespace ::xmloff::EnhancedCustomShapeToken;
99 
100 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[] =
101 {
102 	{ XML_TOP_LEFT, 	drawing::Alignment_TOP_LEFT },
103 	{ XML_TOP,			drawing::Alignment_TOP },
104 	{ XML_TOP_RIGHT,	drawing::Alignment_TOP_RIGHT },
105 	{ XML_LEFT,		    drawing::Alignment_LEFT },
106 	{ XML_CENTER,		drawing::Alignment_CENTER },
107 	{ XML_RIGHT,		drawing::Alignment_RIGHT },
108 	{ XML_BOTTOM_LEFT,	drawing::Alignment_BOTTOM_LEFT },
109 	{ XML_BOTTOM,		drawing::Alignment_BOTTOM },
110 	{ XML_BOTTOM_RIGHT, drawing::Alignment_BOTTOM_RIGHT },
111 	{ XML_TOKEN_INVALID, 0 }
112 };
113 
114 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[] =
115 {
116 	{ XML_AUTO, 		drawing::EscapeDirection_SMART },
117 	{ XML_LEFT,	    	drawing::EscapeDirection_LEFT },
118     { XML_RIGHT,		drawing::EscapeDirection_RIGHT },
119     { XML_UP,			drawing::EscapeDirection_UP },
120     { XML_DOWN,		    drawing::EscapeDirection_DOWN },
121     { XML_HORIZONTAL,	drawing::EscapeDirection_HORIZONTAL },
122     { XML_VERTICAL,	    drawing::EscapeDirection_VERTICAL },
123 	{ XML_TOKEN_INVALID, 0 }
124 };
125 
126 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
127 
ImpIsEmptyURL(const::rtl::OUString & rURL)128 static bool ImpIsEmptyURL( const ::rtl::OUString& rURL )
129 {
130     if( rURL.getLength() == 0 )
131         return true;
132 
133     // #i13140# Also compare against 'toplevel' URLs. which also
134     // result in empty filename strings.
135     if( 0 == rURL.compareToAscii( "#./" ) )
136         return true;
137 
138     return false;
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
142 
143 TYPEINIT1( SvXMLShapeContext, SvXMLImportContext );
144 TYPEINIT1( SdXMLShapeContext, SvXMLShapeContext );
145 
SdXMLShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)146 SdXMLShapeContext::SdXMLShapeContext(
147 	SvXMLImport& rImport,
148 	sal_uInt16 nPrfx,
149 	const OUString& rLocalName,
150 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
151 	uno::Reference< drawing::XShapes >& rShapes,
152     sal_Bool bTemporaryShape)
153 :	SvXMLShapeContext( rImport, nPrfx, rLocalName, bTemporaryShape )
154 ,	mxShapes( rShapes )
155 ,	mxAttrList(xAttrList)
156 ,	mbListContextPushed( false )
157 ,	mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID)
158 ,	mbIsPlaceholder(sal_False)
159 ,	mbClearDefaultAttributes( true )
160 ,	mbIsUserTransformed(sal_False)
161 ,	mnZOrder(-1)
162 ,	maSize(1, 1)
163 ,	maPosition(0, 0)
164 ,   maUsedTransformation()
165 ,	mbVisible(true)
166 ,	mbPrintable(true)
167 {
168 }
169 
170 //////////////////////////////////////////////////////////////////////////////
171 
~SdXMLShapeContext()172 SdXMLShapeContext::~SdXMLShapeContext()
173 {
174 }
175 
176 //////////////////////////////////////////////////////////////////////////////
177 
CreateChildContext(sal_uInt16 p_nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)178 SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
179 	const OUString& rLocalName,
180 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
181 {
182 	SvXMLImportContext * pContext = NULL;
183 
184 	// #i68101#
185 	if( p_nPrefix == XML_NAMESPACE_SVG &&
186 		(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
187 	{
188 		pContext = new SdXMLDescriptionContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
189 	}
190 	else if( p_nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
191 	{
192 		pContext = new SdXMLEventsContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
193 	}
194 	else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
195 	{
196 		addGluePoint( xAttrList );
197 	}
198 	else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_THUMBNAIL ) )
199 	{
200 		// search attributes for xlink:href
201 		sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
202 		for(sal_Int16 i=0; i < nAttrCount; i++)
203 		{
204 			OUString sAttrName = xAttrList->getNameByIndex( i );
205 			OUString aLocalName;
206 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
207 
208 			if( nPrefix == XML_NAMESPACE_XLINK )
209 			{
210 				if( IsXMLToken( aLocalName, XML_HREF ) )
211 				{
212 					maThumbnailURL = xAttrList->getValueByIndex( i );
213 					break;
214 				}
215 			}
216 		}
217 	}
218 	else
219 	{
220 		// create text cursor on demand
221 		if( !mxCursor.is() )
222 		{
223 			uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
224 			if( xText.is() )
225 			{
226 				UniReference < XMLTextImportHelper > xTxtImport =
227 					GetImport().GetTextImport();
228 				mxOldCursor = xTxtImport->GetCursor();
229 				mxCursor = xText->createTextCursor();
230 				if( mxCursor.is() )
231 				{
232 					xTxtImport->SetCursor( mxCursor );
233 				}
234 
235 				// remember old list item and block (#91964#) and reset them
236 				// for the text frame
237                 xTxtImport->PushListContext();
238                 mbListContextPushed = true;
239 			}
240 		}
241 
242 		// if we have a text cursor, lets  try to import some text
243 		if( mxCursor.is() )
244 		{
245 			pContext = GetImport().GetTextImport()->CreateTextChildContext(
246 				GetImport(), p_nPrefix, rLocalName, xAttrList );
247 		}
248 	}
249 
250 	// call parent for content
251 	if(!pContext)
252 		pContext = SvXMLImportContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
253 
254 	return pContext;
255 }
256 
addGluePoint(const uno::Reference<xml::sax::XAttributeList> & xAttrList)257 void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList )
258 {
259 	// get the glue points container for this shape if its not already there
260 	if( !mxGluePoints.is() )
261 	{
262 		uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
263 		if( !xSupplier.is() )
264 			return;
265 
266 		mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
267 
268 		if( !mxGluePoints.is() )
269 			return;
270 	}
271 
272 	drawing::GluePoint2 aGluePoint;
273 	aGluePoint.IsUserDefined = sal_True;
274 	aGluePoint.Position.X = 0;
275 	aGluePoint.Position.Y = 0;
276 	aGluePoint.Escape = drawing::EscapeDirection_SMART;
277 	aGluePoint.PositionAlignment = drawing::Alignment_CENTER;
278 	aGluePoint.IsRelative = sal_True;
279 
280 	sal_Int32 nId = -1;
281 
282 	// read attributes for the 3DScene
283 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
284 	for(sal_Int16 i=0; i < nAttrCount; i++)
285 	{
286 		OUString sAttrName = xAttrList->getNameByIndex( i );
287 		OUString aLocalName;
288 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
289 		const OUString sValue( xAttrList->getValueByIndex( i ) );
290 
291 		if( nPrefix == XML_NAMESPACE_SVG )
292 		{
293 			if( IsXMLToken( aLocalName, XML_X ) )
294 			{
295 				GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.X, sValue);
296 			}
297 			else if( IsXMLToken( aLocalName, XML_Y ) )
298 			{
299 				GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.Y, sValue);
300 			}
301 		}
302 		else if( nPrefix == XML_NAMESPACE_DRAW )
303 		{
304 			if( IsXMLToken( aLocalName, XML_ID ) )
305 			{
306 				nId = sValue.toInt32();
307 			}
308 			else if( IsXMLToken( aLocalName, XML_ALIGN ) )
309 			{
310 				sal_uInt16 eKind;
311 				if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) )
312 				{
313 					aGluePoint.PositionAlignment = (drawing::Alignment)eKind;
314 					aGluePoint.IsRelative = sal_False;
315 				}
316 			}
317 			else if( IsXMLToken( aLocalName, XML_ESCAPE_DIRECTION ) )
318 			{
319 				sal_uInt16 eKind;
320 				if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueEscapeDirection_EnumMap ) )
321 				{
322 					aGluePoint.Escape = (drawing::EscapeDirection)eKind;
323 				}
324 			}
325 		}
326 	}
327 
328 	if( nId != -1 )
329 	{
330 		try
331 		{
332 			sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aGluePoint ) );
333 			GetImport().GetShapeImport()->addGluePointMapping( mxShape, nId, nInternalId );
334 		}
335 		catch( uno::Exception& )
336 		{
337 			DBG_ERROR( "exception during setting of glue points!");
338 		}
339 	}
340 }
341 //////////////////////////////////////////////////////////////////////////////
342 
StartElement(const uno::Reference<xml::sax::XAttributeList> &)343 void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
344 {
345     GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
346 }
347 
EndElement()348 void SdXMLShapeContext::EndElement()
349 {
350 	if(mxCursor.is())
351 	{
352 		// delete addition newline
353 		const OUString aEmpty;
354 		mxCursor->gotoEnd( sal_False );
355 		mxCursor->goLeft( 1, sal_True );
356 		mxCursor->setString( aEmpty );
357 
358 		// reset cursor
359 		GetImport().GetTextImport()->ResetCursor();
360 	}
361 
362 	if(mxOldCursor.is())
363 		GetImport().GetTextImport()->SetCursor( mxOldCursor );
364 
365     // reinstall old list item (if necessary) #91964#
366     if (mbListContextPushed) {
367         GetImport().GetTextImport()->PopListContext();
368     }
369 
370 	if( msHyperlink.getLength() != 0 ) try
371 	{
372 		const OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
373 
374         Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY );
375 		if( xEventsSupplier.is() )
376 		{
377 			const OUString sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) );
378 			const OUString sClickAction( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) );
379 
380 			Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
381 
382 			uno::Sequence< beans::PropertyValue > aProperties( 3 );
383 			aProperties[0].Name = sEventType;
384 			aProperties[0].Handle = -1;
385 			aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") );
386 			aProperties[0].State = beans::PropertyState_DIRECT_VALUE;
387 
388 			aProperties[1].Name = sClickAction;
389 			aProperties[1].Handle = -1;
390 			aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT;
391 			aProperties[1].State = beans::PropertyState_DIRECT_VALUE;
392 
393 			aProperties[2].Name = sBookmark;
394 			aProperties[2].Handle = -1;
395 			aProperties[2].Value <<= msHyperlink;
396 			aProperties[2].State = beans::PropertyState_DIRECT_VALUE;
397 
398 			const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
399 			xEvents->replaceByName( sAPIEventName, Any( aProperties ) );
400 		}
401 		else
402 		{
403 			// in draw use the Bookmark property
404 			Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
405 			xSet->setPropertyValue( sBookmark, Any( msHyperlink ) );
406 			xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) );
407 		}
408 	}
409 	catch( Exception& )
410 	{
411 		DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
412 	}
413 
414 	if( mxLockable.is() )
415 		mxLockable->removeActionLock();
416 }
417 
418 //////////////////////////////////////////////////////////////////////////////
419 
AddShape(uno::Reference<drawing::XShape> & xShape)420 void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
421 {
422 	if(xShape.is())
423 	{
424 		// set shape local
425 		mxShape = xShape;
426 
427 		if(maShapeName.getLength())
428 		{
429 			uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY );
430 			if( xNamed.is() )
431 				xNamed->setName( maShapeName );
432 		}
433 
434 		UniReference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() );
435 		xImp->addShape( xShape, mxAttrList, mxShapes );
436 
437 		if( mbClearDefaultAttributes )
438 		{
439 	        uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY );
440 		    if (xMultiPropertyStates.is())
441 			    xMultiPropertyStates->setAllPropertiesToDefault();
442 		}
443 
444 		if( !mbVisible || !mbPrintable ) try
445 		{
446 			uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY_THROW );
447 			if( !mbVisible )
448 				xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), uno::Any( sal_False ) );
449 
450 			if( !mbPrintable )
451 				xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Printable" ) ), uno::Any( sal_False ) );
452 		}
453 		catch( Exception& )
454 		{
455 			DBG_ERROR( "SdXMLShapeContext::AddShape(), exception caught!" );
456 		}
457 
458 		// #107848#
459 		if(!mbTemporaryShape && (!GetImport().HasTextImport()
460 			|| !GetImport().GetTextImport()->IsInsideDeleteContext()))
461 		{
462 			xImp->shapeWithZIndexAdded( xShape, mnZOrder );
463 		}
464 
465 		if( maShapeId.getLength() )
466 		{
467             const SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(this);
468 
469             /* avoid registering when LateRegister is needed. E.g. MultiImage support where in-between multiple
470                xShapes with the same ID would be registered. Registration is done after deciding which image
471                to keep, see calls to solveMultipleImages */
472             if(!pGSC || !pGSC->getLateAddToIdentifierMapper())
473             {
474                 uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
475                 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
476             }
477 		}
478 
479 		// #91065# count only if counting for shape import is enabled
480 		if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
481 		{
482 			// #80365# increment progress bar at load once for each draw object
483 			GetImport().GetProgressBarHelper()->Increment();
484 		}
485 	}
486 
487 	mxLockable = uno::Reference< document::XActionLockable >::query( xShape );
488 
489 	if( mxLockable.is() )
490 		mxLockable->addActionLock();
491 
492 }
493 
494 //////////////////////////////////////////////////////////////////////////////
495 
AddShape(const char * pServiceName)496 void SdXMLShapeContext::AddShape(const char* pServiceName )
497 {
498 	uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
499 	if(xServiceFact.is())
500 	{
501         try
502         {
503             // --> OD 2006-02-22 #b6382898#
504             // Since fix for issue i33294 the Writer model doesn't support
505             // com.sun.star.drawing.OLE2Shape anymore.
506             // To handle Draw OLE objects it's decided to import these
507             // objects as com.sun.star.drawing.OLE2Shape and convert these
508             // objects after the import into com.sun.star.drawing.GraphicObjectShape.
509             uno::Reference< drawing::XShape > xShape;
510             if ( OUString::createFromAscii(pServiceName).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 &&
511                  uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
512             {
513                 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY);
514             }
515             else
516             {
517                 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii(pServiceName)), uno::UNO_QUERY);
518             }
519             // <--
520             if( xShape.is() )
521                 AddShape( xShape );
522         }
523         catch( const uno::Exception& e )
524         {
525             uno::Sequence<rtl::OUString> aSeq( 1 );
526             aSeq[0] = OUString::createFromAscii(pServiceName);
527             GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API,
528                                   aSeq, e.Message, NULL );
529         }
530 	}
531 }
532 
533 //////////////////////////////////////////////////////////////////////////////
534 
SetTransformation()535 void SdXMLShapeContext::SetTransformation()
536 {
537 	if(mxShape.is())
538 	{
539 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
540 		if(xPropSet.is())
541 		{
542 			maUsedTransformation.identity();
543 
544 			if(maSize.Width != 1 || maSize.Height != 1)
545 			{
546 				// take care there are no zeros used by error
547 				if(0 == maSize.Width)
548 					maSize.Width = 1;
549 				if(0 == maSize.Height)
550 					maSize.Height = 1;
551 
552 				// set global size. This should always be used.
553 				maUsedTransformation.scale(maSize.Width, maSize.Height);
554 			}
555 
556 			if(maPosition.X != 0 || maPosition.Y != 0)
557 			{
558 				// if global position is used, add it to transformation
559 				maUsedTransformation.translate(maPosition.X, maPosition.Y);
560 			}
561 
562 			if(mnTransform.NeedsAction())
563 			{
564 				// transformation is used, apply to object.
565 				// NOTICE: The transformation is applied AFTER evtl. used
566 				// global positioning and scaling is used, so any shear or
567 				// rotate used herein is applied around the (0,0) position
568 				// of the PAGE object !!!
569 				::basegfx::B2DHomMatrix aMat;
570 				mnTransform.GetFullTransform(aMat);
571 
572 				// now add to transformation
573 				maUsedTransformation *= aMat;
574 			}
575 
576 			// now set transformation for this object
577 			uno::Any aAny;
578 			drawing::HomogenMatrix3 aMatrix;
579 
580 			aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0);
581 			aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1);
582 			aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2);
583 
584 			aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0);
585 			aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1);
586 			aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2);
587 
588 			aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0);
589 			aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1);
590 			aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2);
591 
592 			aAny <<= aMatrix;
593 
594 			xPropSet->setPropertyValue(
595 				OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")), aAny);
596         }
597 	}
598 }
599 
600 //////////////////////////////////////////////////////////////////////////////
601 
SetStyle(bool bSupportsStyle)602 void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
603 {
604 	try
605 	{
606 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
607 		if( !xPropSet.is() )
608 			return;
609 
610 		do
611 		{
612 			XMLPropStyleContext* pDocStyle = NULL;
613 
614 			// set style on shape
615 			if(maDrawStyleName.getLength() == 0)
616 				break;
617 
618 			const SvXMLStyleContext* pStyle = 0L;
619 			sal_Bool bAutoStyle(sal_False);
620 
621 			if(GetImport().GetShapeImport()->GetAutoStylesContext())
622 				pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
623 
624 			if(pStyle)
625 				bAutoStyle = sal_True;
626 
627 			if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
628 				pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
629 
630 			OUString aStyleName = maDrawStyleName;
631 			uno::Reference< style::XStyle > xStyle;
632 
633 			if( pStyle && pStyle->ISA(XMLShapeStyleContext) )
634 			{
635 				pDocStyle = PTR_CAST( XMLShapeStyleContext, pStyle );
636 
637 				if( pDocStyle->GetStyle().is() )
638 				{
639 					xStyle = pDocStyle->GetStyle();
640 				}
641 				else
642 				{
643                     aStyleName = pDocStyle->GetParentName();
644 				}
645 			}
646 
647 			if( !xStyle.is() && aStyleName.getLength() )
648 			{
649 				try
650 				{
651 
652 					uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY );
653 
654 					if( xFamiliesSupplier.is() )
655 					{
656 						uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() );
657 						if( xFamilies.is() )
658 						{
659 
660 							uno::Reference< container::XNameAccess > xFamily;
661 
662 							if( XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily )
663 							{
664 								aStyleName = GetImport().GetStyleDisplayName(
665 									XML_STYLE_FAMILY_SD_PRESENTATION_ID,
666 									aStyleName );
667 								sal_Int32 nPos = aStyleName.lastIndexOf( sal_Unicode('-') );
668 								if( -1 != nPos )
669 								{
670 									OUString aFamily( aStyleName.copy( 0, nPos ) );
671 
672 									xFamilies->getByName( aFamily ) >>= xFamily;
673 									aStyleName = aStyleName.copy( nPos + 1 );
674 								}
675 							}
676 							else
677 							{
678 								// get graphics familie
679 								xFamilies->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ) ) >>= xFamily;
680 								aStyleName = GetImport().GetStyleDisplayName(
681 									XML_STYLE_FAMILY_SD_GRAPHICS_ID,
682 									aStyleName );
683 							}
684 
685 							if( xFamily.is() )
686 								xFamily->getByName( aStyleName ) >>= xStyle;
687 						}
688 					}
689 				}
690 				catch( uno::Exception& )
691 				{
692 					DBG_ERROR( "could not find style for shape!" );
693 				}
694 			}
695 
696 			if( bSupportsStyle && xStyle.is() )
697 			{
698 				try
699 				{
700 					// set style on object
701 					uno::Any aAny;
702 					aAny <<= xStyle;
703 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny);
704 				}
705 				catch( uno::Exception& )
706 				{
707 					DBG_ERROR( "could not find style for shape!" );
708 				}
709 			}
710 
711 			// if this is an auto style, set its properties
712 			if(bAutoStyle && pDocStyle)
713 			{
714 				// set PropertySet on object
715 				pDocStyle->FillPropertySet(xPropSet);
716 			}
717 
718 		} while(0);
719 
720 		// try to set text auto style
721 		do
722 		{
723 			// set style on shape
724 			if( 0 == maTextStyleName.getLength() )
725 				break;
726 
727 			if( NULL == GetImport().GetShapeImport()->GetAutoStylesContext())
728 				break;
729 
730             const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH, maTextStyleName);
731 			XMLPropStyleContext* pStyle = PTR_CAST( XMLPropStyleContext, pTempStyle ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
732 			if( pStyle == NULL )
733 				break;
734 
735 			// set PropertySet on object
736 			pStyle->FillPropertySet(xPropSet);
737 
738 		} while(0);
739 	}
740 	catch( uno::Exception& )
741 	{
742 	}
743 }
744 
SetLayer()745 void SdXMLShapeContext::SetLayer()
746 {
747 	if( maLayerName.getLength() )
748 	{
749 		try
750 		{
751 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
752 			if(xPropSet.is() )
753 			{
754 				uno::Any aAny;
755 				aAny <<= maLayerName;
756 
757 				xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LayerName")), aAny);
758 				return;
759 			}
760 		}
761 		catch( uno::Exception e )
762 		{
763 		}
764 	}
765 }
766 
SetThumbnail()767 void SdXMLShapeContext::SetThumbnail()
768 {
769 	if( 0 == maThumbnailURL.getLength() )
770 		return;
771 
772 	try
773 	{
774 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
775 		if( !xPropSet.is() )
776 			return;
777 
778 		const OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("ThumbnailGraphicURL"));
779 
780 		uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
781 		if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( sProperty ) )
782 		{
783 			// load the thumbnail graphic and export it to a wmf stream so we can set
784 			// it at the api
785 
786 			const OUString aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL, sal_False ) );
787 			xPropSet->setPropertyValue( sProperty, uno::makeAny( aInternalURL ) );
788 		}
789 	}
790 	catch( uno::Exception e )
791 	{
792 	}
793 }
794 
795 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)796 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
797 {
798     bool bHaveXmlId( false );
799 	if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) )
800 	{
801 		if( IsXMLToken( rLocalName, XML_ZINDEX ) )
802 		{
803 			mnZOrder = rValue.toInt32();
804 		}
805 		else if( IsXMLToken( rLocalName, XML_ID ) )
806         {
807             if (!bHaveXmlId) { maShapeId = rValue; };
808         }
809 		else if( IsXMLToken( rLocalName, XML_NAME ) )
810 		{
811 			maShapeName = rValue;
812 		}
813 		else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
814 		{
815 			maDrawStyleName = rValue;
816 		}
817 		else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) )
818 		{
819 			maTextStyleName = rValue;
820 		}
821 		else if( IsXMLToken( rLocalName, XML_LAYER ) )
822 		{
823 			maLayerName = rValue;
824 		}
825 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
826 		{
827 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
828 		}
829 		else if( IsXMLToken( rLocalName, XML_DISPLAY ) )
830 		{
831 			mbVisible = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_SCREEN );
832 			mbPrintable = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_PRINTER );
833 		}
834 	}
835 	else if( XML_NAMESPACE_PRESENTATION == nPrefix )
836 	{
837 		if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) )
838 		{
839 			mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE );
840 		}
841 		else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
842 		{
843 			mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE );
844 			if( mbIsPlaceholder )
845 				mbClearDefaultAttributes = false;
846 		}
847 		else if( IsXMLToken( rLocalName, XML_CLASS ) )
848 		{
849 			maPresentationClass = rValue;
850 		}
851 		else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
852 		{
853 			maDrawStyleName = rValue;
854 			mnStyleFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
855 		}
856 	}
857 	else if( XML_NAMESPACE_SVG == nPrefix )
858 	{
859 		if( IsXMLToken( rLocalName, XML_X ) )
860 		{
861 			GetImport().GetMM100UnitConverter().convertMeasure(maPosition.X, rValue);
862 		}
863 		else if( IsXMLToken( rLocalName, XML_Y ) )
864 		{
865 			GetImport().GetMM100UnitConverter().convertMeasure(maPosition.Y, rValue);
866 		}
867 		else if( IsXMLToken( rLocalName, XML_WIDTH ) )
868 		{
869 			GetImport().GetMM100UnitConverter().convertMeasure(maSize.Width, rValue);
870 			if( maSize.Width > 0 )
871 				maSize.Width += 1;
872 			else if( maSize.Width < 0 )
873 				maSize.Width -= 1;
874 		}
875 		else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
876 		{
877 			GetImport().GetMM100UnitConverter().convertMeasure(maSize.Height, rValue);
878 			if( maSize.Height > 0 )
879 				maSize.Height += 1;
880 			else if( maSize.Height < 0 )
881 				maSize.Height -= 1;
882 		}
883 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
884 		{
885 			// because of #85127# take svg:transform into account and hanle like
886 			// draw:transform for compatibility
887 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
888 		}
889 
890 		// #i68101#
891 		else if( IsXMLToken( rLocalName, XML_TITLE ) )
892 		{
893 			maShapeTitle = rValue;
894 		}
895 		else if( IsXMLToken( rLocalName, XML_DESC ) )
896 		{
897 			maShapeDescription = rValue;
898 		}
899 	}
900 	else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) )
901 	{
902 		if( IsXMLToken( rLocalName, XML_ID ) )
903 		{
904 			maShapeId = rValue;
905             bHaveXmlId = true;
906         }
907     }
908 }
909 
isPresentationShape() const910 sal_Bool SdXMLShapeContext::isPresentationShape() const
911 {
912 	if( maPresentationClass.getLength() && (const_cast<SdXMLShapeContext*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
913 	{
914 		if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily)
915 		{
916 			return sal_True;
917 		}
918 
919 		if( IsXMLToken( maPresentationClass, XML_HEADER ) || IsXMLToken( maPresentationClass, XML_FOOTER ) ||
920 			IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) || IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
921 		{
922 			return sal_True;
923 		}
924 	}
925 
926 	return sal_False;
927 }
928 
onDemandRescueUsefulDataFromTemporary(const SvXMLImportContext & rCandidate)929 void SdXMLShapeContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate )
930 {
931     const SdXMLShapeContext* pCandidate = dynamic_cast< const SdXMLShapeContext* >(&rCandidate);
932 
933     if(!mxGluePoints.is() && pCandidate)
934     {
935         // try to rescue GluePoints from rCandidate to local if we not yet have GluePoints by copying them
936         uno::Reference< drawing::XGluePointsSupplier > xSourceSupplier( pCandidate->getShape(), uno::UNO_QUERY );
937         if( !xSourceSupplier.is() )
938             return;
939 
940         uno::Reference< container::XIdentifierAccess > xSourceGluePoints( xSourceSupplier->getGluePoints(), uno::UNO_QUERY );
941         if( !xSourceGluePoints.is() )
942             return;
943 
944         uno::Sequence< sal_Int32 > aSourceIdSequence( xSourceGluePoints->getIdentifiers() );
945         const sal_Int32 nSourceCount(aSourceIdSequence.getLength());
946         UniReference< XMLShapeImportHelper > xSourceShapeImportHelper(const_cast< SdXMLShapeContext* >(pCandidate)->GetImport().GetShapeImport());
947 
948         if(nSourceCount)
949         {
950             // rCandidate has GluePoints; prepare the GluePoint container for the local shape
951             uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
952             if( !xSupplier.is() )
953                 return;
954 
955             mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
956 
957             if( !mxGluePoints.is() )
958                 return;
959 
960             drawing::GluePoint2 aSourceGluePoint;
961 
962             for( sal_Int32 nSourceIndex(0); nSourceIndex < nSourceCount; nSourceIndex++ )
963             {
964                 const sal_Int32 nSourceIdentifier = aSourceIdSequence[nSourceIndex];
965 
966                 // loop over GluePoints which are UserDefined (avoid the auto mapped ones)
967                 if((xSourceGluePoints->getByIdentifier( nSourceIdentifier ) >>= aSourceGluePoint)
968                     && aSourceGluePoint.IsUserDefined)
969                 {
970                     // get original mappingID back, this is the draw:id imported with a draw:glue-point
971                     const sal_Int32 nDestinnationId = xSourceShapeImportHelper->findGluePointMapping(
972                         pCandidate->getShape(),
973                         nSourceIdentifier );
974 
975                     if(-1 != nSourceIdentifier)
976                     {
977                         // if we got that we are able to add a copy of that GluePoint to the local
978                         // context and xShape since we have all information that the source shape
979                         // and context had at import time
980                         try
981                         {
982                             const sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aSourceGluePoint ) );
983                             GetImport().GetShapeImport()->addGluePointMapping( mxShape, nDestinnationId, nInternalId );
984                         }
985                         catch( uno::Exception& )
986                         {
987                             DBG_ERROR( "exception during setting of glue points!");
988                         }
989                     }
990                 }
991             }
992         }
993     }
994 }
995 
996 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
997 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
998 
999 TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext );
1000 
SdXMLRectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1001 SdXMLRectShapeContext::SdXMLRectShapeContext(
1002 	SvXMLImport& rImport,
1003 	sal_uInt16 nPrfx,
1004 	const OUString& rLocalName,
1005 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1006 	uno::Reference< drawing::XShapes >& rShapes,
1007     sal_Bool bTemporaryShape)
1008 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1009 	mnRadius( 0L )
1010 {
1011 }
1012 
1013 //////////////////////////////////////////////////////////////////////////////
1014 
~SdXMLRectShapeContext()1015 SdXMLRectShapeContext::~SdXMLRectShapeContext()
1016 {
1017 }
1018 
1019 //////////////////////////////////////////////////////////////////////////////
1020 
1021 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1022 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1023 {
1024 	if( XML_NAMESPACE_DRAW == nPrefix )
1025 	{
1026 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
1027 		{
1028 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
1029 			return;
1030 		}
1031 	}
1032 
1033 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1034 }
1035 
1036 //////////////////////////////////////////////////////////////////////////////
1037 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1038 void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1039 {
1040 	// create rectangle shape
1041 	AddShape("com.sun.star.drawing.RectangleShape");
1042 	if(mxShape.is())
1043 	{
1044 		// Add, set Style and properties from base shape
1045 		SetStyle();
1046 		SetLayer();
1047 
1048 		// set pos, size, shear and rotate
1049 		SetTransformation();
1050 
1051 		if(mnRadius)
1052 		{
1053 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1054 			if(xPropSet.is())
1055 			{
1056 				try
1057 				{
1058 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
1059 				}
1060 				catch( uno::Exception& )
1061 				{
1062 					DBG_ERROR( "exception during setting of corner radius!");
1063 				}
1064 			}
1065 		}
1066 		SdXMLShapeContext::StartElement(xAttrList);
1067 	}
1068 }
1069 
1070 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1071 ////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1072 
1073 TYPEINIT1( SdXMLLineShapeContext, SdXMLShapeContext );
1074 
SdXMLLineShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1075 SdXMLLineShapeContext::SdXMLLineShapeContext(
1076 	SvXMLImport& rImport,
1077 	sal_uInt16 nPrfx,
1078 	const OUString& rLocalName,
1079 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1080 	uno::Reference< drawing::XShapes >& rShapes,
1081     sal_Bool bTemporaryShape)
1082 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1083 	mnX1( 0L ),
1084 	mnY1( 0L ),
1085 	mnX2( 1L ),
1086 	mnY2( 1L )
1087 {
1088 }
1089 
1090 //////////////////////////////////////////////////////////////////////////////
1091 
~SdXMLLineShapeContext()1092 SdXMLLineShapeContext::~SdXMLLineShapeContext()
1093 {
1094 }
1095 
1096 //////////////////////////////////////////////////////////////////////////////
1097 
1098 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1099 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1100 {
1101 	if( XML_NAMESPACE_SVG == nPrefix )
1102 	{
1103 		if( IsXMLToken( rLocalName, XML_X1 ) )
1104 		{
1105 			GetImport().GetMM100UnitConverter().convertMeasure(mnX1, rValue);
1106 			return;
1107 		}
1108 		if( IsXMLToken( rLocalName, XML_Y1 ) )
1109 		{
1110 			GetImport().GetMM100UnitConverter().convertMeasure(mnY1, rValue);
1111 			return;
1112 		}
1113 		if( IsXMLToken( rLocalName, XML_X2 ) )
1114 		{
1115 			GetImport().GetMM100UnitConverter().convertMeasure(mnX2, rValue);
1116 			return;
1117 		}
1118 		if( IsXMLToken( rLocalName, XML_Y2 ) )
1119 		{
1120 			GetImport().GetMM100UnitConverter().convertMeasure(mnY2, rValue);
1121 			return;
1122 		}
1123 	}
1124 
1125 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1126 }
1127 
1128 //////////////////////////////////////////////////////////////////////////////
1129 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1130 void SdXMLLineShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1131 {
1132 	// #85920# use SetTransformation() to handle import of simple lines.
1133 	// This is necessary to kake into account all anchor positions and
1134 	// other things. All shape imports use the same import schemata now.
1135 	// create necessary shape (Line Shape)
1136 	AddShape("com.sun.star.drawing.PolyLineShape");
1137 
1138 	if(mxShape.is())
1139 	{
1140 		// Add, set Style and properties from base shape
1141 		SetStyle();
1142 		SetLayer();
1143 
1144 		// get sizes and offsets
1145 		awt::Point aTopLeft(mnX1, mnY1);
1146 		awt::Point aBottomRight(mnX2, mnY2);
1147 
1148 		if(mnX1 > mnX2)
1149 		{
1150 			aTopLeft.X = mnX2;
1151 			aBottomRight.X = mnX1;
1152 		}
1153 
1154 		if(mnY1 > mnY2)
1155 		{
1156 			aTopLeft.Y = mnY2;
1157 			aBottomRight.Y = mnY1;
1158 		}
1159 
1160 		// set local parameters on shape
1161 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1162 		if(xPropSet.is())
1163 		{
1164 			drawing::PointSequenceSequence aPolyPoly(1L);
1165 			drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
1166 			pOuterSequence->realloc(2L);
1167 			awt::Point* pInnerSequence = pOuterSequence->getArray();
1168 			uno::Any aAny;
1169 
1170 			*pInnerSequence = awt::Point( mnX1 - aTopLeft.X, mnY1 - aTopLeft.Y);
1171 			pInnerSequence++;
1172 			*pInnerSequence = awt::Point( mnX2 - aTopLeft.X, mnY2 - aTopLeft.Y);
1173 
1174 			aAny <<= aPolyPoly;
1175 			xPropSet->setPropertyValue(
1176 				OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1177 		}
1178 
1179 		// set sizes for transformation
1180 		maSize.Width = aBottomRight.X - aTopLeft.X;
1181 		maSize.Height = aBottomRight.Y - aTopLeft.Y;
1182 		maPosition.X = aTopLeft.X;
1183 		maPosition.Y = aTopLeft.Y;
1184 
1185 		// set pos, size, shear and rotate and get copy of matrix
1186 		SetTransformation();
1187 
1188 		SdXMLShapeContext::StartElement(xAttrList);
1189 	}
1190 }
1191 
1192 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1193 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1194 
1195 TYPEINIT1( SdXMLEllipseShapeContext, SdXMLShapeContext );
1196 
SdXMLEllipseShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1197 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1198 	SvXMLImport& rImport,
1199 	sal_uInt16 nPrfx,
1200 	const OUString& rLocalName,
1201 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1202 	uno::Reference< drawing::XShapes >& rShapes,
1203     sal_Bool bTemporaryShape)
1204 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1205 	mnCX( 0L ),
1206 	mnCY( 0L ),
1207 	mnRX( 1L ),
1208 	mnRY( 1L ),
1209 	meKind( drawing::CircleKind_FULL ),
1210 	mnStartAngle( 0 ),
1211 	mnEndAngle( 0 )
1212 {
1213 }
1214 
1215 //////////////////////////////////////////////////////////////////////////////
1216 
~SdXMLEllipseShapeContext()1217 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1218 {
1219 }
1220 
1221 //////////////////////////////////////////////////////////////////////////////
1222 
1223 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1224 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1225 {
1226 	if( XML_NAMESPACE_SVG == nPrefix )
1227 	{
1228 		if( IsXMLToken( rLocalName, XML_RX ) )
1229 		{
1230 			GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue);
1231 			return;
1232 		}
1233 		if( IsXMLToken( rLocalName, XML_RY ) )
1234 		{
1235 			GetImport().GetMM100UnitConverter().convertMeasure(mnRY, rValue);
1236 			return;
1237 		}
1238 		if( IsXMLToken( rLocalName, XML_CX ) )
1239 		{
1240 			GetImport().GetMM100UnitConverter().convertMeasure(mnCX, rValue);
1241 			return;
1242 		}
1243 		if( IsXMLToken( rLocalName, XML_CY ) )
1244 		{
1245 			GetImport().GetMM100UnitConverter().convertMeasure(mnCY, rValue);
1246 			return;
1247 		}
1248 		if( IsXMLToken( rLocalName, XML_R ) )
1249 		{
1250 			// single radius, it's a circle and both radii are the same
1251 			GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue);
1252 			mnRY = mnRX;
1253 			return;
1254 		}
1255 	}
1256 	else if( XML_NAMESPACE_DRAW == nPrefix )
1257 	{
1258 		if( IsXMLToken( rLocalName, XML_KIND ) )
1259 		{
1260 			sal_uInt16 eKind;
1261 			if( SvXMLUnitConverter::convertEnum( eKind, rValue, aXML_CircleKind_EnumMap ) )
1262 			{
1263 				meKind = eKind;
1264 			}
1265 			return;
1266 		}
1267 		if( IsXMLToken( rLocalName, XML_START_ANGLE ) )
1268 		{
1269 			double dStartAngle;
1270 			if( SvXMLUnitConverter::convertDouble( dStartAngle, rValue ) )
1271 				mnStartAngle = (sal_Int32)(dStartAngle * 100.0);
1272 			return;
1273 		}
1274 		if( IsXMLToken( rLocalName, XML_END_ANGLE ) )
1275 		{
1276 			double dEndAngle;
1277 			if( SvXMLUnitConverter::convertDouble( dEndAngle, rValue ) )
1278 				mnEndAngle = (sal_Int32)(dEndAngle * 100.0);
1279 			return;
1280 		}
1281 	}
1282 
1283 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1284 }
1285 
1286 //////////////////////////////////////////////////////////////////////////////
1287 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1288 void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1289 {
1290 	// create rectangle shape
1291 	AddShape("com.sun.star.drawing.EllipseShape");
1292 	if(mxShape.is())
1293 	{
1294 		// Add, set Style and properties from base shape
1295 		SetStyle();
1296 		SetLayer();
1297 
1298         if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1299         {
1300             // #121972# center/radius is used, put to pos and size
1301             maSize.Width = 2 * mnRX;
1302             maSize.Height = 2 * mnRY;
1303             maPosition.X = mnCX - mnRX;
1304             maPosition.Y = mnCY - mnRY;
1305         }
1306 
1307 		// set pos, size, shear and rotate
1308 		SetTransformation();
1309 
1310 		if( meKind != drawing::CircleKind_FULL )
1311 		{
1312 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1313 			if( xPropSet.is() )
1314 			{
1315 				uno::Any aAny;
1316 				aAny <<= (drawing::CircleKind)meKind;
1317 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")), aAny );
1318 
1319 				aAny <<= mnStartAngle;
1320 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")), aAny );
1321 
1322 				aAny <<= mnEndAngle;
1323 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")), aAny );
1324 			}
1325 		}
1326 
1327 		SdXMLShapeContext::StartElement(xAttrList);
1328 	}
1329 }
1330 
1331 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1332 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1333 
1334 TYPEINIT1( SdXMLPolygonShapeContext, SdXMLShapeContext );
1335 
SdXMLPolygonShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bClosed,sal_Bool bTemporaryShape)1336 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1337 	SvXMLImport& rImport,
1338 	sal_uInt16 nPrfx,
1339 	const OUString& rLocalName,
1340 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1341 	uno::Reference< drawing::XShapes >& rShapes, sal_Bool bClosed, sal_Bool bTemporaryShape)
1342 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1343 	mbClosed( bClosed )
1344 {
1345 }
1346 
1347 //////////////////////////////////////////////////////////////////////////////
1348 
1349 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1350 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1351 {
1352 	if( XML_NAMESPACE_SVG == nPrefix )
1353 	{
1354 		if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1355 		{
1356 			maViewBox = rValue;
1357 			return;
1358 		}
1359 	}
1360 	else if( XML_NAMESPACE_DRAW == nPrefix )
1361 	{
1362 		if( IsXMLToken( rLocalName, XML_POINTS ) )
1363 		{
1364 			maPoints = rValue;
1365 			return;
1366 		}
1367 	}
1368 
1369 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1370 }
1371 
1372 //////////////////////////////////////////////////////////////////////////////
1373 
~SdXMLPolygonShapeContext()1374 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1375 {
1376 }
1377 
1378 //////////////////////////////////////////////////////////////////////////////
1379 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1380 void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1381 {
1382     // Add, set Style and properties from base shape
1383     if(mbClosed)
1384         AddShape("com.sun.star.drawing.PolyPolygonShape");
1385     else
1386         AddShape("com.sun.star.drawing.PolyLineShape");
1387 
1388     if( mxShape.is() )
1389     {
1390         SetStyle();
1391         SetLayer();
1392 
1393         // set local parameters on shape
1394         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1395         if(xPropSet.is())
1396         {
1397             // set polygon
1398             if(maPoints.getLength() && maViewBox.getLength())
1399             {
1400                 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1401                 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1402 
1403                 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1404                 // sense to have the geometry content size different from object size
1405                 if(maSize.Width != 0 && maSize.Height != 0)
1406                 {
1407                     aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1408                 }
1409 
1410                 basegfx::B2DPolygon aPolygon;
1411 
1412                 if(basegfx::tools::importFromSvgPoints(aPolygon, maPoints))
1413                 {
1414                     if(aPolygon.count())
1415                     {
1416                         const basegfx::B2DRange aSourceRange(
1417                             aViewBox.GetX(), aViewBox.GetY(),
1418                             aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1419                         const basegfx::B2DRange aTargetRange(
1420                             aViewBox.GetX(), aViewBox.GetY(),
1421                             aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1422 
1423                         if(!aSourceRange.equal(aTargetRange))
1424                         {
1425                             aPolygon.transform(
1426                                 basegfx::tools::createSourceRangeTargetRangeTransform(
1427                                     aSourceRange,
1428                                     aTargetRange));
1429                         }
1430 
1431                         com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence;
1432                         uno::Any aAny;
1433 
1434                         basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence);
1435                         aAny <<= aPointSequenceSequence;
1436                         xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1437                     }
1438                 }
1439             }
1440         }
1441 
1442         // set pos, size, shear and rotate and get copy of matrix
1443         SetTransformation();
1444 
1445         SdXMLShapeContext::StartElement(xAttrList);
1446     }
1447 }
1448 
1449 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1450 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1451 
1452 TYPEINIT1( SdXMLPathShapeContext, SdXMLShapeContext );
1453 
SdXMLPathShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1454 SdXMLPathShapeContext::SdXMLPathShapeContext(
1455 	SvXMLImport& rImport,
1456 	sal_uInt16 nPrfx,
1457 	const OUString& rLocalName,
1458 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1459 	uno::Reference< drawing::XShapes >& rShapes,
1460     sal_Bool bTemporaryShape)
1461 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1462 	mbClosed( sal_True )
1463 {
1464 }
1465 
1466 //////////////////////////////////////////////////////////////////////////////
1467 
~SdXMLPathShapeContext()1468 SdXMLPathShapeContext::~SdXMLPathShapeContext()
1469 {
1470 }
1471 
1472 //////////////////////////////////////////////////////////////////////////////
1473 
1474 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1475 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1476 {
1477 	if( XML_NAMESPACE_SVG == nPrefix )
1478 	{
1479 		if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1480 		{
1481 			maViewBox = rValue;
1482 			return;
1483 		}
1484 		else if( IsXMLToken( rLocalName, XML_D ) )
1485 		{
1486 			maD = rValue;
1487 			return;
1488 		}
1489 	}
1490 
1491 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1492 }
1493 
1494 //////////////////////////////////////////////////////////////////////////////
1495 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1496 void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1497 {
1498     // create polygon shape
1499     if(maD.getLength())
1500     {
1501         const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1502         basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1503 
1504         // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1505         // sense to have the geometry content size different from object size
1506         if(maSize.Width != 0 && maSize.Height != 0)
1507         {
1508             aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1509         }
1510 
1511         basegfx::B2DPolyPolygon aPolyPolygon;
1512 
1513         if(basegfx::tools::importFromSvgD(aPolyPolygon, maD, true, 0))
1514         {
1515             if(aPolyPolygon.count())
1516             {
1517                 const basegfx::B2DRange aSourceRange(
1518                     aViewBox.GetX(), aViewBox.GetY(),
1519                     aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1520                 const basegfx::B2DRange aTargetRange(
1521                     aViewBox.GetX(), aViewBox.GetY(),
1522                     aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1523 
1524                 if(!aSourceRange.equal(aTargetRange))
1525                 {
1526                     aPolyPolygon.transform(
1527                         basegfx::tools::createSourceRangeTargetRangeTransform(
1528                             aSourceRange,
1529                             aTargetRange));
1530                 }
1531 
1532                 // create shape
1533                 const char* pService;
1534 
1535                 if(aPolyPolygon.areControlPointsUsed())
1536                 {
1537                     if(aPolyPolygon.isClosed())
1538                     {
1539                         pService = "com.sun.star.drawing.ClosedBezierShape";
1540                     }
1541                     else
1542                     {
1543                         pService = "com.sun.star.drawing.OpenBezierShape";
1544                     }
1545                 }
1546                 else
1547                 {
1548                     if(aPolyPolygon.isClosed())
1549                     {
1550                         pService = "com.sun.star.drawing.PolyPolygonShape";
1551                     }
1552                     else
1553                     {
1554                         pService = "com.sun.star.drawing.PolyLineShape";
1555                     }
1556                 }
1557 
1558                 // Add, set Style and properties from base shape
1559                 AddShape(pService);
1560 
1561                 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1562                 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1563                 // is used by the writer.
1564                 if( mxShape.is() )
1565                 {
1566                     SetStyle();
1567                     SetLayer();
1568 
1569                     // set local parameters on shape
1570                     uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1571 
1572                     if(xPropSet.is())
1573                     {
1574                         uno::Any aAny;
1575 
1576                         // set polygon data
1577                         if(aPolyPolygon.areControlPointsUsed())
1578                         {
1579                             drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1580 
1581                             basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
1582                                 aPolyPolygon,
1583                                 aSourcePolyPolygon);
1584                             aAny <<= aSourcePolyPolygon;
1585                         }
1586                         else
1587                         {
1588                             drawing::PointSequenceSequence aSourcePolyPolygon;
1589 
1590                             basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(
1591                                 aPolyPolygon,
1592                                 aSourcePolyPolygon);
1593                             aAny <<= aSourcePolyPolygon;
1594                         }
1595 
1596                         xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1597                     }
1598 
1599                     // set pos, size, shear and rotate
1600                     SetTransformation();
1601 
1602                     SdXMLShapeContext::StartElement(xAttrList);
1603                 }
1604             }
1605         }
1606     }
1607 }
1608 
1609 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1610 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1611 
1612 TYPEINIT1( SdXMLTextBoxShapeContext, SdXMLShapeContext );
1613 
SdXMLTextBoxShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1614 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1615 	SvXMLImport& rImport,
1616 	sal_uInt16 nPrfx,
1617 	const OUString& rLocalName,
1618 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1619 	uno::Reference< drawing::XShapes >& rShapes,
1620     sal_Bool bTemporaryShape)
1621 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1622 	mnRadius(0)
1623 {
1624 }
1625 
1626 //////////////////////////////////////////////////////////////////////////////
1627 
~SdXMLTextBoxShapeContext()1628 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1629 {
1630 }
1631 
1632 //////////////////////////////////////////////////////////////////////////////
1633 
1634 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1635 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1636 {
1637 	if( XML_NAMESPACE_DRAW == nPrefix )
1638 	{
1639 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
1640 		{
1641 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
1642 			return;
1643 		}
1644 	}
1645 
1646 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1647 }
1648 
1649 //////////////////////////////////////////////////////////////////////////////
1650 
StartElement(const uno::Reference<xml::sax::XAttributeList> &)1651 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
1652 {
1653 	// create textbox shape
1654 	sal_Bool bIsPresShape = sal_False;
1655 	bool bClearText = false;
1656 
1657 	const char *pService = NULL;
1658 
1659 	if( isPresentationShape() )
1660 	{
1661 		// check if the current document supports presentation shapes
1662 		if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1663 		{
1664 			if( IsXMLToken( maPresentationClass, XML_PRESENTATION_SUBTITLE ))
1665 			{
1666 				// XmlShapeTypePresSubtitleShape
1667 				pService = "com.sun.star.presentation.SubtitleShape";
1668 			}
1669 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OUTLINE ) )
1670 			{
1671 				// XmlShapeTypePresOutlinerShape
1672 				pService = "com.sun.star.presentation.OutlinerShape";
1673 			}
1674 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_NOTES ) )
1675 			{
1676 				// XmlShapeTypePresNotesShape
1677 				pService = "com.sun.star.presentation.NotesShape";
1678 			}
1679 			else if( IsXMLToken( maPresentationClass, XML_HEADER ) )
1680 			{
1681 				// XmlShapeTypePresHeaderShape
1682 				pService = "com.sun.star.presentation.HeaderShape";
1683 				bClearText = true;
1684 			}
1685 			else if( IsXMLToken( maPresentationClass, XML_FOOTER ) )
1686 			{
1687 				// XmlShapeTypePresFooterShape
1688 				pService = "com.sun.star.presentation.FooterShape";
1689 				bClearText = true;
1690 			}
1691 			else if( IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) )
1692 			{
1693 				// XmlShapeTypePresSlideNumberShape
1694 				pService = "com.sun.star.presentation.SlideNumberShape";
1695 				bClearText = true;
1696 			}
1697 			else if( IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
1698 			{
1699 				// XmlShapeTypePresDateTimeShape
1700 				pService = "com.sun.star.presentation.DateTimeShape";
1701 				bClearText = true;
1702 			}
1703 			else //  IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1704 			{
1705 				// XmlShapeTypePresTitleTextShape
1706 				pService = "com.sun.star.presentation.TitleTextShape";
1707 			}
1708 			bIsPresShape = sal_True;
1709 		}
1710 	}
1711 
1712 	if( NULL == pService )
1713 	{
1714 		// normal text shape
1715 		pService = "com.sun.star.drawing.TextShape";
1716 	}
1717 
1718 	// Add, set Style and properties from base shape
1719 	AddShape(pService);
1720 
1721 	if( mxShape.is() )
1722 	{
1723 		SetStyle();
1724 		SetLayer();
1725 
1726 		if(bIsPresShape)
1727 		{
1728 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1729 			if(xProps.is())
1730 			{
1731 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1732 				if( xPropsInfo.is() )
1733 				{
1734 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
1735 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
1736 
1737 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
1738 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
1739 				}
1740 			}
1741 		}
1742 
1743 		if( bClearText )
1744 		{
1745 			uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1746 			OUString aEmpty;
1747 			xText->setString( aEmpty );
1748 		}
1749 
1750 		// set parameters on shape
1751 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1752 //A to reach the same goal again.
1753 //A		if(!bIsPresShape || mbIsUserTransformed)
1754 //A		{
1755 //A			// set pos and size on shape, this should remove binding
1756 //A			// to pres object on masterpage
1757 //A			SetSizeAndPosition();
1758 //A		}
1759 
1760 		// set pos, size, shear and rotate
1761 		SetTransformation();
1762 
1763 		if(mnRadius)
1764 		{
1765 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1766 			if(xPropSet.is())
1767 			{
1768 				try
1769 				{
1770 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
1771 				}
1772 				catch( uno::Exception& )
1773 				{
1774 					DBG_ERROR( "exception during setting of corner radius!");
1775 				}
1776 			}
1777 		}
1778 
1779 		SdXMLShapeContext::StartElement(mxAttrList);
1780 	}
1781 }
1782 
1783 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1784 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1785 
1786 TYPEINIT1( SdXMLControlShapeContext, SdXMLShapeContext );
1787 
SdXMLControlShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1788 SdXMLControlShapeContext::SdXMLControlShapeContext(
1789 	SvXMLImport& rImport,
1790 	sal_uInt16 nPrfx,
1791 	const OUString& rLocalName,
1792 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1793 	uno::Reference< drawing::XShapes >& rShapes,
1794     sal_Bool bTemporaryShape)
1795 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
1796 {
1797 }
1798 
1799 //////////////////////////////////////////////////////////////////////////////
1800 
~SdXMLControlShapeContext()1801 SdXMLControlShapeContext::~SdXMLControlShapeContext()
1802 {
1803 }
1804 
1805 //////////////////////////////////////////////////////////////////////////////
1806 
1807 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1808 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1809 {
1810 	if( XML_NAMESPACE_DRAW == nPrefix )
1811 	{
1812 		if( IsXMLToken( rLocalName, XML_CONTROL ) )
1813 		{
1814 			maFormId = rValue;
1815 			return;
1816 		}
1817 	}
1818 
1819 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1820 }
1821 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1822 void SdXMLControlShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1823 {
1824 	// create Control shape
1825 	// add, set style and properties from base shape
1826 	AddShape("com.sun.star.drawing.ControlShape");
1827 	if( mxShape.is() )
1828 	{
1829 		DBG_ASSERT( maFormId.getLength(), "draw:control without a form:id attribute!" );
1830 		if( maFormId.getLength() )
1831 		{
1832 #ifndef SVX_LIGHT
1833 			if( GetImport().IsFormsSupported() )
1834 			{
1835 				uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1836 				if( xControlModel.is() )
1837 				{
1838 					uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1839 					if( xControl.is() )
1840 						xControl->setControl(  xControlModel );
1841 
1842 				}
1843 			}
1844 #endif // #ifndef SVX_LIGHT
1845 		}
1846 
1847 		SetStyle();
1848 		SetLayer();
1849 
1850 		// set pos, size, shear and rotate
1851 		SetTransformation();
1852 
1853 		SdXMLShapeContext::StartElement(xAttrList);
1854 	}
1855 }
1856 
1857 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1858 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1859 
1860 TYPEINIT1( SdXMLConnectorShapeContext, SdXMLShapeContext );
1861 
SdXMLConnectorShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)1862 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1863 	SvXMLImport& rImport,
1864 	sal_uInt16 nPrfx,
1865 	const OUString& rLocalName,
1866 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1867 	uno::Reference< drawing::XShapes >& rShapes,
1868     sal_Bool bTemporaryShape)
1869 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1870 	maStart(0,0),
1871 	maEnd(1,1),
1872 	mnType( (sal_uInt16)drawing::ConnectorType_STANDARD ),
1873 	mnStartGlueId(-1),
1874 	mnEndGlueId(-1),
1875 	mnDelta1(0),
1876 	mnDelta2(0),
1877 	mnDelta3(0)
1878 {
1879 }
1880 
1881 //////////////////////////////////////////////////////////////////////////////
1882 
~SdXMLConnectorShapeContext()1883 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1884 {
1885 }
1886 
1887 //////////////////////////////////////////////////////////////////////////////
1888 
1889 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)1890 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1891 {
1892 	switch( nPrefix )
1893 	{
1894 	case XML_NAMESPACE_DRAW:
1895 	{
1896 		if( IsXMLToken( rLocalName, XML_START_SHAPE ) )
1897 		{
1898 			maStartShapeId = rValue;
1899 			return;
1900 		}
1901 		if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) )
1902 		{
1903 			mnStartGlueId = rValue.toInt32();
1904 			return;
1905 		}
1906 		if( IsXMLToken( rLocalName, XML_END_SHAPE ) )
1907 		{
1908 			maEndShapeId = rValue;
1909 			return;
1910 		}
1911 		if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) )
1912 		{
1913 			mnEndGlueId = rValue.toInt32();
1914 			return;
1915 		}
1916 		if( IsXMLToken( rLocalName, XML_LINE_SKEW ) )
1917 		{
1918 			SvXMLTokenEnumerator aTokenEnum( rValue );
1919 			OUString aToken;
1920 			if( aTokenEnum.getNextToken( aToken ) )
1921 			{
1922 				GetImport().GetMM100UnitConverter().convertMeasure(mnDelta1, aToken);
1923 				if( aTokenEnum.getNextToken( aToken ) )
1924 				{
1925 					GetImport().GetMM100UnitConverter().convertMeasure(mnDelta2, aToken);
1926 					if( aTokenEnum.getNextToken( aToken ) )
1927 					{
1928 						GetImport().GetMM100UnitConverter().convertMeasure(mnDelta3, aToken);
1929 					}
1930 				}
1931 			}
1932 			return;
1933 		}
1934 		if( IsXMLToken( rLocalName, XML_TYPE ) )
1935 		{
1936 			SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap );
1937 			return;
1938 		}
1939         // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these
1940 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
1941 		{
1942 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
1943 		}
1944 	}
1945 	case XML_NAMESPACE_SVG:
1946 	{
1947 		if( IsXMLToken( rLocalName, XML_X1 ) )
1948 		{
1949 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
1950 			return;
1951 		}
1952 		if( IsXMLToken( rLocalName, XML_Y1 ) )
1953 		{
1954 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
1955 			return;
1956 		}
1957 		if( IsXMLToken( rLocalName, XML_X2 ) )
1958 		{
1959 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
1960 			return;
1961 		}
1962 		if( IsXMLToken( rLocalName, XML_Y2 ) )
1963 		{
1964 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
1965 			return;
1966 		}
1967         if( IsXMLToken( rLocalName, XML_D ) )
1968         {
1969             basegfx::B2DPolyPolygon aPolyPolygon;
1970 
1971             if(basegfx::tools::importFromSvgD(aPolyPolygon, rValue, true, 0))
1972             {
1973                 if(aPolyPolygon.count())
1974                 {
1975                     // set polygon data
1976                     if(aPolyPolygon.areControlPointsUsed())
1977                     {
1978                         drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1979 
1980                         basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
1981                             aPolyPolygon,
1982                             aSourcePolyPolygon);
1983                         maPath <<= aSourcePolyPolygon;
1984                     }
1985                     else
1986                     {
1987                         drawing::PointSequenceSequence aSourcePolyPolygon;
1988 
1989                         basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(
1990                             aPolyPolygon,
1991                             aSourcePolyPolygon);
1992                         maPath <<= aSourcePolyPolygon;
1993                     }
1994                 }
1995             }
1996         }
1997 	}
1998 	}
1999 
2000 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2001 }
2002 
2003 //////////////////////////////////////////////////////////////////////////////
2004 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)2005 void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2006 {
2007 	// #107928#
2008 	// For security reasons, do not add empty connectors. There may have been an error in EA2
2009 	// that created empty, far set off connectors (e.g. 63 meters below top of document). This
2010 	// is not guaranteed, but it's definitely safe to not add empty connectors.
2011 	sal_Bool bDoAdd(sal_True);
2012 
2013 	if(    0 == maStartShapeId.getLength()
2014 		&& 0 == maEndShapeId.getLength()
2015 		&& maStart.X == maEnd.X
2016 		&& maStart.Y == maEnd.Y
2017 		&& 0 == mnDelta1
2018 		&& 0 == mnDelta2
2019 		&& 0 == mnDelta3
2020 		)
2021 	{
2022 		bDoAdd = sal_False;
2023 	}
2024 
2025 	if(bDoAdd)
2026 	{
2027 		// create Connector shape
2028 		// add, set style and properties from base shape
2029 		AddShape("com.sun.star.drawing.ConnectorShape");
2030 		if(mxShape.is())
2031 		{
2032             // #121965# if draw:transform is used, apply directly to the start
2033             // and end positions before using these
2034             if(mnTransform.NeedsAction())
2035             {
2036                 // transformation is used, apply to object.
2037                 ::basegfx::B2DHomMatrix aMat;
2038                 mnTransform.GetFullTransform(aMat);
2039 
2040                 if(!aMat.isIdentity())
2041                 {
2042                     basegfx::B2DPoint aStart(maStart.X, maStart.Y);
2043                     basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
2044 
2045                     aStart = aMat * aStart;
2046                     aEnd = aMat * aEnd;
2047 
2048                     maStart.X = basegfx::fround(aStart.getX());
2049                     maStart.Y = basegfx::fround(aStart.getY());
2050                     maEnd.X = basegfx::fround(aEnd.getX());
2051                     maEnd.Y = basegfx::fround(aEnd.getY());
2052                 }
2053             }
2054 
2055             // add connection ids
2056 			if( maStartShapeId.getLength() )
2057 				GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_True, maStartShapeId, mnStartGlueId );
2058 			if( maEndShapeId.getLength() )
2059 				GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_False, maEndShapeId, mnEndGlueId );
2060 
2061 			uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2062 			if( xProps.is() )
2063 			{
2064 				uno::Any aAny;
2065 				aAny <<= maStart;
2066 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
2067 
2068 				aAny <<= maEnd;
2069 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
2070 
2071 				aAny <<= (drawing::ConnectorType)mnType;
2072 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")), aAny );
2073 
2074 				aAny <<= mnDelta1;
2075 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")), aAny );
2076 
2077 				aAny <<= mnDelta2;
2078 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")), aAny );
2079 
2080 				aAny <<= mnDelta3;
2081 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")), aAny );
2082 			}
2083 			SetStyle();
2084 			SetLayer();
2085 
2086 			if ( maPath.hasValue() )
2087             {
2088                 // --> OD #i115492#
2089                 // Ignore svg:d attribute for text documents created by OpenOffice.org
2090                 // versions before OOo 3.3, because these OOo versions are storing
2091                 // svg:d values not using the correct unit.
2092                 bool bApplySVGD( true );
2093                 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
2094                 {
2095                     sal_Int32 nUPD( 0 );
2096                     sal_Int32 nBuild( 0 );
2097                     const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
2098                     if ( GetImport().IsTextDocInOOoFileFormat() ||
2099                          ( bBuildIdFound &&
2100                            ( ( nUPD == 641 ) || ( nUPD == 645 ) ||  // prior OOo 2.0
2101                              ( nUPD == 680 ) ||                     // OOo 2.x
2102                              ( nUPD == 300 ) ||                     // OOo 3.0 - OOo 3.0.1
2103                              ( nUPD == 310 ) ||                     // OOo 3.1 - OOo 3.1.1
2104                              ( nUPD == 320 ) ) ) )                  // OOo 3.2 - OOo 3.2.1
2105                     {
2106                         bApplySVGD = false;
2107                     }
2108                 }
2109 
2110                 if ( bApplySVGD )
2111                 {
2112                     xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath );
2113                 }
2114                 // <--
2115             }
2116 
2117 			SdXMLShapeContext::StartElement(xAttrList);
2118 		}
2119 	}
2120 }
2121 
2122 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2123 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2124 
2125 TYPEINIT1( SdXMLMeasureShapeContext, SdXMLShapeContext );
2126 
SdXMLMeasureShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2127 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
2128 	SvXMLImport& rImport,
2129 	sal_uInt16 nPrfx,
2130 	const OUString& rLocalName,
2131 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2132 	uno::Reference< drawing::XShapes >& rShapes,
2133     sal_Bool bTemporaryShape)
2134 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2135 	maStart(0,0),
2136 	maEnd(1,1)
2137 {
2138 }
2139 
2140 //////////////////////////////////////////////////////////////////////////////
2141 
~SdXMLMeasureShapeContext()2142 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
2143 {
2144 }
2145 
2146 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2147 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2148 {
2149 	switch( nPrefix )
2150 	{
2151 	case XML_NAMESPACE_SVG:
2152 	{
2153 		if( IsXMLToken( rLocalName, XML_X1 ) )
2154 		{
2155 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
2156 			return;
2157 		}
2158 		if( IsXMLToken( rLocalName, XML_Y1 ) )
2159 		{
2160 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
2161 			return;
2162 		}
2163 		if( IsXMLToken( rLocalName, XML_X2 ) )
2164 		{
2165 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
2166 			return;
2167 		}
2168 		if( IsXMLToken( rLocalName, XML_Y2 ) )
2169 		{
2170 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
2171 			return;
2172 		}
2173 	}
2174 	}
2175 
2176 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2177 }
2178 
2179 //////////////////////////////////////////////////////////////////////////////
2180 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)2181 void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2182 {
2183 	// create Measure shape
2184 	// add, set style and properties from base shape
2185 	AddShape("com.sun.star.drawing.MeasureShape");
2186 	if(mxShape.is())
2187 	{
2188 		SetStyle();
2189 		SetLayer();
2190 
2191 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2192 		if( xProps.is() )
2193 		{
2194 			uno::Any aAny;
2195 			aAny <<= maStart;
2196 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
2197 
2198 			aAny <<= maEnd;
2199 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
2200 		}
2201 
2202 		// delete pre created fields
2203 		uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2204 		if( xText.is() )
2205 		{
2206 			const OUString aEmpty( RTL_CONSTASCII_USTRINGPARAM( " " ) );
2207 			xText->setString( aEmpty );
2208 		}
2209 
2210 		SdXMLShapeContext::StartElement(xAttrList);
2211 	}
2212 }
2213 
EndElement()2214 void SdXMLMeasureShapeContext::EndElement()
2215 {
2216 	do
2217 	{
2218 		// delete pre created fields
2219 		uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2220 		if( !xText.is() )
2221 			break;
2222 
2223 		uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
2224 		if( !xCursor.is() )
2225 			break;
2226 
2227 		const OUString aEmpty;
2228 		xCursor->collapseToStart();
2229 		xCursor->goRight( 1, sal_True );
2230 		xCursor->setString( aEmpty );
2231 	}
2232 	while(0);
2233 
2234 	SdXMLShapeContext::EndElement();
2235 }
2236 
2237 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2238 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2239 
2240 TYPEINIT1( SdXMLPageShapeContext, SdXMLShapeContext );
2241 
SdXMLPageShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2242 SdXMLPageShapeContext::SdXMLPageShapeContext(
2243 	SvXMLImport& rImport,
2244 	sal_uInt16 nPrfx,
2245 	const OUString& rLocalName,
2246 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2247 	uno::Reference< drawing::XShapes >& rShapes,
2248     sal_Bool bTemporaryShape)
2249 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
2250 {
2251 	mbClearDefaultAttributes = false;
2252 }
2253 
2254 //////////////////////////////////////////////////////////////////////////////
2255 
~SdXMLPageShapeContext()2256 SdXMLPageShapeContext::~SdXMLPageShapeContext()
2257 {
2258 }
2259 
2260 //////////////////////////////////////////////////////////////////////////////
2261 
2262 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2263 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2264 {
2265 	if( XML_NAMESPACE_DRAW == nPrefix )
2266 	{
2267 		if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) )
2268 		{
2269 			mnPageNumber = rValue.toInt32();
2270 			return;
2271 		}
2272 	}
2273 
2274 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2275 }
2276 
2277 //////////////////////////////////////////////////////////////////////////////
2278 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)2279 void SdXMLPageShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2280 {
2281 	// create Page shape
2282 	// add, set style and properties from base shape
2283 
2284 	// #86163# take into account which type of PageShape needs to
2285 	// be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2286 	sal_Bool bIsPresentation = maPresentationClass.getLength() &&
2287 		   GetImport().GetShapeImport()->IsPresentationShapesSupported();
2288 
2289 	uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
2290 	const sal_Bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutMasterPage")) );
2291 
2292 	if( bIsOnHandoutPage )
2293 	{
2294 		AddShape("com.sun.star.presentation.HandoutShape");
2295 	}
2296 	else
2297 	{
2298 		if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
2299 		{
2300 			bIsPresentation = sal_False;
2301 		}
2302 
2303 		if(bIsPresentation)
2304 		{
2305 			AddShape("com.sun.star.presentation.PageShape");
2306 		}
2307 		else
2308 		{
2309 			AddShape("com.sun.star.drawing.PageShape");
2310 		}
2311 	}
2312 
2313 	if(mxShape.is())
2314 	{
2315 		SetStyle();
2316 		SetLayer();
2317 
2318 		// set pos, size, shear and rotate
2319 		SetTransformation();
2320 
2321 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2322 		if(xPropSet.is())
2323 		{
2324 			uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2325 			const OUString aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
2326 			if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2327 				xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber ));
2328 		}
2329 
2330 		SdXMLShapeContext::StartElement(xAttrList);
2331 	}
2332 }
2333 
2334 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2335 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2336 
2337 TYPEINIT1( SdXMLCaptionShapeContext, SdXMLShapeContext );
2338 
SdXMLCaptionShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2339 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2340 	SvXMLImport& rImport,
2341 	sal_uInt16 nPrfx,
2342 	const OUString& rLocalName,
2343 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2344 	uno::Reference< drawing::XShapes >& rShapes,
2345     sal_Bool bTemporaryShape)
2346 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2347 	// #86616# for correct edge rounding import mnRadius needs to be initialized
2348 	mnRadius( 0L )
2349 {
2350 }
2351 
2352 //////////////////////////////////////////////////////////////////////////////
2353 
~SdXMLCaptionShapeContext()2354 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2355 {
2356 }
2357 
2358 //////////////////////////////////////////////////////////////////////////////
2359 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)2360 void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2361 {
2362 	// create Caption shape
2363 	// add, set style and properties from base shape
2364 	AddShape("com.sun.star.drawing.CaptionShape");
2365 	if( mxShape.is() )
2366 	{
2367 		SetStyle();
2368 		SetLayer();
2369 
2370 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2371 
2372 		// SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2373 		// because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2374 		// is the default setting, so the top left reference point that is used by the caption point is
2375 		// no longer correct) There are two ways to solve this problem, temporarily disabling the
2376 		// autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2377 		sal_Bool bIsAutoGrowWidth = sal_False;
2378 		if ( xProps.is() )
2379 		{
2380 			uno::Any aAny( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth") ) ) );
2381 			aAny >>= bIsAutoGrowWidth;
2382 
2383 			if ( bIsAutoGrowWidth )
2384 				xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_False ) );
2385 		}
2386 
2387 		// set pos, size, shear and rotate
2388 		SetTransformation();
2389 		if( xProps.is() )
2390 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint")), uno::makeAny( maCaptionPoint ) );
2391 
2392 		if ( bIsAutoGrowWidth )
2393 			xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_True ) );
2394 
2395 		if(mnRadius)
2396 		{
2397 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2398 			if(xPropSet.is())
2399 			{
2400 				try
2401 				{
2402 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
2403 				}
2404 				catch( uno::Exception& )
2405 				{
2406 					DBG_ERROR( "exception during setting of corner radius!");
2407 				}
2408 			}
2409 		}
2410 
2411 		SdXMLShapeContext::StartElement(xAttrList);
2412 	}
2413 }
2414 
2415 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2416 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2417 {
2418 	if( XML_NAMESPACE_DRAW == nPrefix )
2419 	{
2420 		if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) )
2421 		{
2422 			GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.X, rValue);
2423 			return;
2424 		}
2425 		if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) )
2426 		{
2427 			GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.Y, rValue);
2428 			return;
2429 		}
2430 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
2431 		{
2432 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
2433 			return;
2434 		}
2435 	}
2436 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2437 }
2438 
2439 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2440 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2441 
2442 TYPEINIT1( SdXMLGraphicObjectShapeContext, SdXMLShapeContext );
2443 
SdXMLGraphicObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2444 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2445 	SvXMLImport& rImport,
2446 	sal_uInt16 nPrfx,
2447 	const OUString& rLocalName,
2448 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2449 	uno::Reference< drawing::XShapes >& rShapes,
2450     sal_Bool bTemporaryShape)
2451 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2452 	maURL(),
2453     mbLateAddToIdentifierMapper(false)
2454 {
2455 }
2456 
2457 //////////////////////////////////////////////////////////////////////////////
2458 
2459 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2460 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2461 {
2462 	if( XML_NAMESPACE_XLINK == nPrefix )
2463 	{
2464 		if( IsXMLToken( rLocalName, XML_HREF ) )
2465 		{
2466 			maURL = rValue;
2467 			return;
2468 		}
2469 	}
2470 
2471 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2472 }
2473 
2474 //////////////////////////////////////////////////////////////////////////////
2475 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> &)2476 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2477 {
2478 	// create graphic object shape
2479 	const char *pService;
2480 
2481 	if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2482 	{
2483 		pService = "com.sun.star.presentation.GraphicObjectShape";
2484 	}
2485 	else
2486 	{
2487 		pService = "com.sun.star.drawing.GraphicObjectShape";
2488 	}
2489 
2490 	AddShape( pService );
2491 
2492 	if(mxShape.is())
2493 	{
2494 		SetStyle();
2495 		SetLayer();
2496 
2497 		uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2498 		if(xPropset.is())
2499 		{
2500 			// since OOo 1.x had no line or fill style for graphics, but may create
2501 			// documents with them, we have to override them here
2502 			sal_Int32 nUPD, nBuildId;
2503 			if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2504 			{
2505 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), Any( FillStyle_NONE ) );
2506 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("LineStyle")), Any( LineStyle_NONE ) );
2507 			}
2508 			catch( Exception& )
2509 			{
2510 			}
2511 
2512 			uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2513 			if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2514 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( mbIsPlaceholder ) );
2515 
2516 			if( !mbIsPlaceholder )
2517 			{
2518 				if( maURL.getLength() )
2519 				{
2520 					uno::Any aAny;
2521 					aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() );
2522 					try
2523 					{
2524 						xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny );
2525 						xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny );
2526 					}
2527 					catch (lang::IllegalArgumentException const &)
2528 					{
2529 					}
2530 				}
2531 			}
2532 		}
2533 
2534 		if(mbIsUserTransformed)
2535 		{
2536 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2537 			if(xProps.is())
2538 			{
2539 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2540 				if( xPropsInfo.is() )
2541 				{
2542 					if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2543 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2544 				}
2545 			}
2546 		}
2547 
2548 		// set pos, size, shear and rotate
2549 		SetTransformation();
2550 
2551 		SdXMLShapeContext::StartElement(mxAttrList);
2552 	}
2553 }
2554 
EndElement()2555 void SdXMLGraphicObjectShapeContext::EndElement()
2556 {
2557 	if( mxBase64Stream.is() )
2558 	{
2559 		OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ) );
2560 		if( sURL.getLength() )
2561 		{
2562 			try
2563 			{
2564 				uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2565 				if(xProps.is())
2566 				{
2567 					const uno::Any aAny( uno::makeAny( sURL ) );
2568 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny );
2569 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny );
2570 				}
2571 			}
2572 			catch (lang::IllegalArgumentException const &)
2573 			{
2574 			}
2575 		}
2576 	}
2577 
2578 	SdXMLShapeContext::EndElement();
2579 }
2580 
2581 
2582 //////////////////////////////////////////////////////////////////////////////
2583 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)2584 SvXMLImportContext* SdXMLGraphicObjectShapeContext::CreateChildContext(
2585 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2586 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2587 {
2588 	SvXMLImportContext* pContext = NULL;
2589 
2590 	if( (XML_NAMESPACE_OFFICE == nPrefix) &&
2591 			 xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) )
2592 	{
2593 		if( !maURL.getLength() && !mxBase64Stream.is() )
2594 		{
2595 			mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
2596 			if( mxBase64Stream.is() )
2597 				pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2598 													rLocalName, xAttrList,
2599 													mxBase64Stream );
2600 		}
2601 	}
2602 
2603 	// delegate to parent class if no context could be created
2604 	if ( NULL == pContext )
2605 		pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName,
2606 														 xAttrList);
2607 
2608 	return pContext;
2609 }
2610 
2611 //////////////////////////////////////////////////////////////////////////////
2612 
~SdXMLGraphicObjectShapeContext()2613 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2614 {
2615 
2616 }
2617 
2618 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2619 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2620 
2621 TYPEINIT1( SdXMLChartShapeContext, SdXMLShapeContext );
2622 
SdXMLChartShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2623 SdXMLChartShapeContext::SdXMLChartShapeContext(
2624 	SvXMLImport& rImport,
2625 	sal_uInt16 nPrfx,
2626 	const OUString& rLocalName,
2627 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2628 	uno::Reference< drawing::XShapes >& rShapes,
2629     sal_Bool bTemporaryShape)
2630 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2631 	mpChartContext( NULL )
2632 {
2633 }
2634 
2635 //////////////////////////////////////////////////////////////////////////////
2636 
~SdXMLChartShapeContext()2637 SdXMLChartShapeContext::~SdXMLChartShapeContext()
2638 {
2639 	if( mpChartContext )
2640 		delete mpChartContext;
2641 }
2642 
2643 //////////////////////////////////////////////////////////////////////////////
2644 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)2645 void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2646 {
2647 	const sal_Bool bIsPresentation = isPresentationShape();
2648 
2649 	AddShape( bIsPresentation ? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" );
2650 
2651 	if(mxShape.is())
2652 	{
2653 		SetStyle();
2654 		SetLayer();
2655 
2656 		if( !mbIsPlaceholder )
2657 		{
2658 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2659 			if(xProps.is())
2660 			{
2661 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2662 				if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2663 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
2664 
2665 				uno::Any aAny;
2666 
2667 				const OUString aCLSID( RTL_CONSTASCII_USTRINGPARAM("12DCAE26-281F-416F-a234-c3086127382e"));
2668 
2669 				aAny <<= aCLSID;
2670 				xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), aAny );
2671 
2672 #ifndef SVX_LIGHT
2673 				aAny = xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) );
2674 				uno::Reference< frame::XModel > xChartModel;
2675 				if( aAny >>= xChartModel )
2676 				{
2677 					mpChartContext = GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList );
2678 				}
2679 #endif
2680 			}
2681 		}
2682 
2683 		if(mbIsUserTransformed)
2684 		{
2685 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2686 			if(xProps.is())
2687 			{
2688 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2689 				if( xPropsInfo.is() )
2690 				{
2691 					if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2692 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2693 				}
2694 			}
2695 		}
2696 
2697 
2698 		// set pos, size, shear and rotate
2699 		SetTransformation();
2700 
2701 		SdXMLShapeContext::StartElement(xAttrList);
2702 
2703 		if( mpChartContext )
2704 			mpChartContext->StartElement( xAttrList );
2705 	}
2706 }
2707 
EndElement()2708 void SdXMLChartShapeContext::EndElement()
2709 {
2710 	if( mpChartContext )
2711 		mpChartContext->EndElement();
2712 
2713 	SdXMLShapeContext::EndElement();
2714 }
2715 
Characters(const::rtl::OUString & rChars)2716 void SdXMLChartShapeContext::Characters( const ::rtl::OUString& rChars )
2717 {
2718 	if( mpChartContext )
2719 		mpChartContext->Characters( rChars );
2720 }
2721 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)2722 SvXMLImportContext * SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2723 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
2724 {
2725 	if( mpChartContext )
2726 		return mpChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
2727 
2728 	return NULL;
2729 }
2730 
2731 //////////////////////////////////////////////////////////////////////////////
2732 
2733 TYPEINIT1( SdXMLObjectShapeContext, SdXMLShapeContext );
2734 
SdXMLObjectShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2735 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2736 		const rtl::OUString& rLocalName,
2737 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2738 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2739         sal_Bool bTemporaryShape)
2740 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
2741 {
2742 }
2743 
~SdXMLObjectShapeContext()2744 SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2745 {
2746 }
2747 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> &)2748 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2749 {
2750 	// #96717# in theorie, if we don't have a url we shouldn't even
2751 	// export this ole shape. But practical its to risky right now
2752 	// to change this so we better dispose this on load
2753 	//if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2754 	//	return;
2755 
2756 	// #100592# this BugFix prevents that a shape is created. CL
2757 	// is thinking about an alternative.
2758     // #i13140# Check for more than empty string in maHref, there are
2759     // other possibilities that maHref results in empty container
2760     // storage names
2761 	if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2762 		return;
2763 
2764 	const char* pService = "com.sun.star.drawing.OLE2Shape";
2765 
2766 	sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2767 
2768 	if( bIsPresShape )
2769 	{
2770 		if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) )
2771 		{
2772 			pService = "com.sun.star.presentation.ChartShape";
2773 		}
2774 		else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
2775 		{
2776 			pService = "com.sun.star.presentation.CalcShape";
2777 		}
2778 		else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
2779 		{
2780 			pService = "com.sun.star.presentation.OLE2Shape";
2781 		}
2782 	}
2783 
2784 	AddShape( pService );
2785 
2786 	if( mxShape.is() )
2787 	{
2788 		SetLayer();
2789 
2790 		if(bIsPresShape)
2791 		{
2792 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2793 			if(xProps.is())
2794 			{
2795 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2796 				if( xPropsInfo.is() )
2797 				{
2798 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2799 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
2800 
2801 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2802 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2803 				}
2804 			}
2805 		}
2806 
2807 		if( !mbIsPlaceholder && maHref.getLength() )
2808 		{
2809         	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2810 
2811             if( xProps.is() )
2812         	{
2813 				OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2814 
2815 				if ( GetImport().IsPackageURL( maHref ) )
2816 				{
2817 					const OUString  sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2818 
2819 					if ( aPersistName.compareTo( sURL, sURL.getLength() ) == 0 )
2820 						aPersistName = aPersistName.copy( sURL.getLength() );
2821 
2822         			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ),
2823 											  uno::makeAny( aPersistName ) );
2824 				}
2825 				else
2826 				{
2827 					// this is OOo link object
2828 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LinkURL" ) ),
2829 											  uno::makeAny( aPersistName ) );
2830 				}
2831 			}
2832 		}
2833 
2834 		// set pos, size, shear and rotate
2835 		SetTransformation();
2836 
2837 		SetStyle();
2838 
2839 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2840 	}
2841 }
2842 
EndElement()2843 void SdXMLObjectShapeContext::EndElement()
2844 {
2845     // #i67705#
2846     const sal_uInt16 nGeneratorVersion(GetImport().getGeneratorVersion());
2847 
2848     if(nGeneratorVersion < SvXMLImport::OOo_34x)
2849     {
2850         // #i118485#
2851         // If it's an old file from us written before OOo3.4, we need to correct
2852         // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2853         // implementations just ignored added fill/linestyles completely, thus
2854         // those objects need to be corrected to not show blue and hairline which
2855         // always was the default, but would be shown now
2856 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2857 
2858         if( xProps.is() )
2859         {
2860             xProps->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), uno::makeAny(drawing::FillStyle_NONE));
2861             xProps->setPropertyValue(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")), uno::makeAny(drawing::LineStyle_NONE));
2862         }
2863     }
2864 
2865     // #100592#
2866 	if( mxBase64Stream.is() )
2867 	{
2868 		OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2869 		const OUString  sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2870 
2871         aPersistName = aPersistName.copy( sURL.getLength() );
2872 
2873 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2874 		if( xProps.is() )
2875 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), uno::makeAny( aPersistName ) );
2876 	}
2877 
2878 	SdXMLShapeContext::EndElement();
2879 }
2880 
2881 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2882 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2883 {
2884 	switch( nPrefix )
2885 	{
2886 	case XML_NAMESPACE_DRAW:
2887 		if( IsXMLToken( rLocalName, XML_CLASS_ID ) )
2888 		{
2889 			maCLSID = rValue;
2890 			return;
2891 		}
2892 		break;
2893 	case XML_NAMESPACE_XLINK:
2894 		if( IsXMLToken( rLocalName, XML_HREF ) )
2895 		{
2896 			maHref = rValue;
2897 			return;
2898 		}
2899 		break;
2900 	}
2901 
2902 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2903 }
2904 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)2905 SvXMLImportContext* SdXMLObjectShapeContext::CreateChildContext(
2906 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2907 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2908 {
2909 	// #100592#
2910 	SvXMLImportContext* pContext = NULL;
2911 
2912 	if((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_BINARY_DATA))
2913 	{
2914 		mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2915 		if( mxBase64Stream.is() )
2916 			pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2917 												rLocalName, xAttrList,
2918 												mxBase64Stream );
2919 	}
2920 	else if( ((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_DOCUMENT)) ||
2921 				((XML_NAMESPACE_MATH == nPrefix) && IsXMLToken(rLocalName, XML_MATH)) )
2922 	{
2923 		XMLEmbeddedObjectImportContext *pEContext =
2924 			new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
2925 												rLocalName, xAttrList );
2926 		maCLSID = pEContext->GetFilterCLSID();
2927 		if( maCLSID.getLength() != 0 )
2928 		{
2929 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2930 			if( xPropSet.is() )
2931 			{
2932 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), uno::makeAny( maCLSID ) );
2933 
2934 				uno::Reference< lang::XComponent > xComp;
2935 				xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
2936 				DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
2937 				pEContext->SetComponent( xComp );
2938 			}
2939 		}
2940 		pContext = pEContext;
2941 	}
2942 
2943 	// delegate to parent class if no context could be created
2944 	if(!pContext)
2945 		pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
2946 
2947 	return pContext;
2948 }
2949 
2950 //////////////////////////////////////////////////////////////////////////////
2951 
2952 TYPEINIT1( SdXMLAppletShapeContext, SdXMLShapeContext );
2953 
SdXMLAppletShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)2954 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2955 		const rtl::OUString& rLocalName,
2956 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2957 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2958         sal_Bool bTemporaryShape)
2959 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2960   mbIsScript( sal_False )
2961 {
2962 }
2963 
~SdXMLAppletShapeContext()2964 SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2965 {
2966 }
2967 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> &)2968 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2969 {
2970 	const char* pService = "com.sun.star.drawing.AppletShape";
2971 	AddShape( pService );
2972 
2973 	if( mxShape.is() )
2974 	{
2975 		SetLayer();
2976 
2977 		// set pos, size, shear and rotate
2978 		SetTransformation();
2979 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2980 	}
2981 }
2982 
2983 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)2984 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2985 {
2986 	switch( nPrefix )
2987 	{
2988 	case XML_NAMESPACE_DRAW:
2989 		if( IsXMLToken( rLocalName, XML_APPLET_NAME ) )
2990 		{
2991 			maAppletName = rValue;
2992 			return;
2993 		}
2994 		if( IsXMLToken( rLocalName, XML_CODE ) )
2995 		{
2996 			maAppletCode = rValue;
2997 			return;
2998 		}
2999 		if( IsXMLToken( rLocalName, XML_MAY_SCRIPT ) )
3000 		{
3001 			mbIsScript = IsXMLToken( rValue, XML_TRUE );
3002 			return;
3003 		}
3004 		break;
3005 	case XML_NAMESPACE_XLINK:
3006 		if( IsXMLToken( rLocalName, XML_HREF ) )
3007 		{
3008 			maHref = GetImport().GetAbsoluteReference(rValue);
3009 			return;
3010 		}
3011 		break;
3012 	}
3013 
3014 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3015 }
3016 
EndElement()3017 void SdXMLAppletShapeContext::EndElement()
3018 {
3019 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3020 	if( xProps.is() )
3021 	{
3022 		uno::Any aAny;
3023 
3024 		if ( maSize.Width && maSize.Height )
3025 		{
3026 			// the visual area for applet must be set on loading
3027 			awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3028 			aAny <<= aRect;
3029 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny );
3030 		}
3031 
3032 		if( maParams.getLength() )
3033 		{
3034 			aAny <<= maParams;
3035 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ), aAny );
3036 		}
3037 
3038 		if( maHref.getLength() )
3039 		{
3040 			aAny <<= maHref;
3041 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ), aAny );
3042 		}
3043 
3044 		if( maAppletName.getLength() )
3045 		{
3046 			aAny <<= maAppletName;
3047 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ), aAny );
3048 		}
3049 
3050 		if( mbIsScript )
3051 		{
3052 			aAny <<= mbIsScript;
3053 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ), aAny );
3054 
3055 		}
3056 
3057 		if( maAppletCode.getLength() )
3058 		{
3059 			aAny <<= maAppletCode;
3060 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ), aAny );
3061 		}
3062 
3063         aAny <<= ::rtl::OUString( GetImport().GetDocumentBase() );
3064         xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletDocBase" ) ), aAny );
3065 
3066 		SetThumbnail();
3067 	}
3068 
3069 	SdXMLShapeContext::EndElement();
3070 }
3071 
CreateChildContext(sal_uInt16 p_nPrefix,const::rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)3072 SvXMLImportContext * SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
3073 {
3074 	if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
3075 	{
3076 		OUString aParamName, aParamValue;
3077 		const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3078 		// now parse the attribute list and look for draw:name and draw:value
3079 		for(sal_Int16 a(0); a < nAttrCount; a++)
3080 		{
3081 			const OUString& rAttrName = xAttrList->getNameByIndex(a);
3082 			OUString aLocalName;
3083 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3084 			const OUString aValue( xAttrList->getValueByIndex(a) );
3085 
3086 			if( nPrefix == XML_NAMESPACE_DRAW )
3087 			{
3088 				if( IsXMLToken( aLocalName, XML_NAME ) )
3089 				{
3090 					aParamName = aValue;
3091 				}
3092 				else if( IsXMLToken( aLocalName, XML_VALUE ) )
3093 				{
3094 					aParamValue = aValue;
3095 				}
3096 			}
3097 		}
3098 
3099 		if( aParamName.getLength() )
3100 		{
3101 			sal_Int32 nIndex = maParams.getLength();
3102 			maParams.realloc( nIndex + 1 );
3103 			maParams[nIndex].Name = aParamName;
3104 			maParams[nIndex].Handle = -1;
3105 			maParams[nIndex].Value <<= aParamValue;
3106 			maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3107 		}
3108 
3109 		return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
3110 	}
3111 
3112 	return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
3113 }
3114 
3115 //////////////////////////////////////////////////////////////////////////////
3116 
3117 TYPEINIT1( SdXMLPluginShapeContext, SdXMLShapeContext );
3118 
SdXMLPluginShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)3119 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3120 		const rtl::OUString& rLocalName,
3121 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3122 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3123         sal_Bool bTemporaryShape) :
3124 SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3125 mbMedia( false )
3126 {
3127 }
3128 
~SdXMLPluginShapeContext()3129 SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
3130 {
3131 }
3132 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList)3133 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList)
3134 {
3135 	// watch for MimeType attribute to see if we have a media object
3136 	for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
3137 	{
3138 		OUString 	aLocalName;
3139 		sal_uInt16 	nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
3140 
3141 		if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
3142 		{
3143 			if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
3144 				mbMedia = true;
3145 
3146 			// leave this loop
3147 			n = nAttrCount - 1;
3148 		}
3149 	}
3150 
3151 	const char* pService;
3152 
3153 	sal_Bool bIsPresShape = sal_False;
3154 
3155 	if( mbMedia )
3156 	{
3157 		pService = "com.sun.star.drawing.MediaShape";
3158 
3159 		bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3160 		if( bIsPresShape )
3161 		{
3162 			if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3163 			{
3164 				pService = "com.sun.star.presentation.MediaShape";
3165 			}
3166 		}
3167 	}
3168 	else
3169 		pService = "com.sun.star.drawing.PluginShape";
3170 
3171 	AddShape( pService );
3172 
3173 	if( mxShape.is() )
3174 	{
3175 		SetLayer();
3176 
3177 		if(bIsPresShape)
3178 		{
3179 			uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3180 			if(xProps.is())
3181 			{
3182 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3183 				if( xPropsInfo.is() )
3184 				{
3185 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
3186 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
3187 
3188 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
3189 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
3190 				}
3191 			}
3192 		}
3193 
3194 		// set pos, size, shear and rotate
3195 		SetTransformation();
3196 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3197 	}
3198 }
3199 
3200 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)3201 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3202 {
3203 	switch( nPrefix )
3204 	{
3205 	case XML_NAMESPACE_DRAW:
3206 		if( IsXMLToken( rLocalName, XML_MIME_TYPE ) )
3207 		{
3208 			maMimeType = rValue;
3209 			return;
3210 		}
3211 		break;
3212 	case XML_NAMESPACE_XLINK:
3213 		if( IsXMLToken( rLocalName, XML_HREF ) )
3214 		{
3215 			maHref = GetImport().GetAbsoluteReference(rValue);
3216 			return;
3217 		}
3218 		break;
3219 	}
3220 
3221 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3222 }
3223 
EndElement()3224 void SdXMLPluginShapeContext::EndElement()
3225 {
3226 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3227 
3228 	if( xProps.is() )
3229 	{
3230 		uno::Any aAny;
3231 
3232 		if ( maSize.Width && maSize.Height )
3233 		{
3234 			const rtl::OUString sVisibleArea( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) );
3235 			uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
3236             if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) )
3237 			{
3238 				// the visual area for a plugin must be set on loading
3239 				awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3240 				aAny <<= aRect;
3241 				xProps->setPropertyValue( sVisibleArea, aAny );
3242 			}
3243 		}
3244 
3245 		if( !mbMedia )
3246 		{
3247 			// in case we have a plugin object
3248 			if( maParams.getLength() )
3249 			{
3250 				aAny <<= maParams;
3251 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ), aAny );
3252 			}
3253 
3254 			if( maMimeType.getLength() )
3255 			{
3256 				aAny <<= maMimeType;
3257 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ), aAny );
3258 			}
3259 
3260 			if( maHref.getLength() )
3261 			{
3262 				aAny <<= maHref;
3263 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ), aAny );
3264 			}
3265 		}
3266 		else
3267 		{
3268 			// in case we have a media object
3269 
3270 			OUString sTempRef;
3271 
3272 			// check for package URL
3273 			if( GetImport().IsPackageURL( maHref ) )
3274 			{
3275 			    sTempRef = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
3276 			}
3277 
3278 			sTempRef += maHref;
3279 
3280 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), uno::makeAny( sTempRef ) );
3281 
3282 			for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
3283 			{
3284 				const OUString& rName = maParams[ nParam ].Name;
3285 
3286 				if( 0 == rName.compareToAscii( "Loop" ) )
3287 				{
3288 					OUString aValueStr;
3289 					maParams[ nParam ].Value >>= aValueStr;
3290 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) ),
3291 						uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) );
3292 				}
3293 				else if( 0 == rName.compareToAscii( "Mute" ) )
3294 				{
3295 					OUString aValueStr;
3296 					maParams[ nParam ].Value >>= aValueStr;
3297 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) ),
3298 						uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) );
3299 				}
3300 				else if( 0 == rName.compareToAscii( "VolumeDB" ) )
3301 				{
3302 					OUString aValueStr;
3303 					maParams[ nParam ].Value >>= aValueStr;
3304 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ),
3305 					                            uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
3306 				}
3307 				else if( 0 == rName.compareToAscii( "Zoom" ) )
3308 				{
3309 					OUString 			aZoomStr;
3310 					media::ZoomLevel	eZoomLevel;
3311 
3312 					maParams[ nParam ].Value >>= aZoomStr;
3313 
3314 					if( 0 == aZoomStr.compareToAscii( "25%" ) )
3315 						eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
3316 					else if( 0 == aZoomStr.compareToAscii( "50%" ) )
3317 						eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
3318 					else if( 0 == aZoomStr.compareToAscii( "100%" ) )
3319 						eZoomLevel = media::ZoomLevel_ORIGINAL;
3320 					else if( 0 == aZoomStr.compareToAscii( "200%" ) )
3321 						eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
3322 					else if( 0 == aZoomStr.compareToAscii( "400%" ) )
3323 						eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
3324 					else if( 0 == aZoomStr.compareToAscii( "fit" ) )
3325 						eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
3326 					else if( 0 == aZoomStr.compareToAscii( "fixedfit" ) )
3327 						eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
3328 					else if( 0 == aZoomStr.compareToAscii( "fullscreen" ) )
3329 						eZoomLevel = media::ZoomLevel_FULLSCREEN;
3330 					else
3331 						eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
3332 
3333 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), uno::makeAny( eZoomLevel ) );
3334 				}
3335 			}
3336 		}
3337 
3338 		SetThumbnail();
3339 	}
3340 
3341 	SdXMLShapeContext::EndElement();
3342 }
3343 
CreateChildContext(sal_uInt16 p_nPrefix,const::rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList)3344 SvXMLImportContext * SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
3345 {
3346 	if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
3347 	{
3348 		OUString aParamName, aParamValue;
3349 		const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3350 		// now parse the attribute list and look for draw:name and draw:value
3351 		for(sal_Int16 a(0); a < nAttrCount; a++)
3352 		{
3353 			const OUString& rAttrName = xAttrList->getNameByIndex(a);
3354 			OUString aLocalName;
3355 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3356 			const OUString aValue( xAttrList->getValueByIndex(a) );
3357 
3358 			if( nPrefix == XML_NAMESPACE_DRAW )
3359 			{
3360 				if( IsXMLToken( aLocalName, XML_NAME ) )
3361 				{
3362 					aParamName = aValue;
3363 				}
3364 				else if( IsXMLToken( aLocalName, XML_VALUE ) )
3365 				{
3366 					aParamValue = aValue;
3367 				}
3368 			}
3369 
3370 			if( aParamName.getLength() )
3371 			{
3372 				sal_Int32 nIndex = maParams.getLength();
3373 				maParams.realloc( nIndex + 1 );
3374 				maParams[nIndex].Name = aParamName;
3375 				maParams[nIndex].Handle = -1;
3376 				maParams[nIndex].Value <<= aParamValue;
3377 				maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3378 			}
3379 		}
3380 
3381 		return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
3382 	}
3383 
3384 	return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
3385 }
3386 
3387 //////////////////////////////////////////////////////////////////////////////
3388 
3389 TYPEINIT1( SdXMLFloatingFrameShapeContext, SdXMLShapeContext );
3390 
SdXMLFloatingFrameShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)3391 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3392 		const rtl::OUString& rLocalName,
3393 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3394 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3395         sal_Bool bTemporaryShape)
3396 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3397 {
3398 }
3399 
~SdXMLFloatingFrameShapeContext()3400 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3401 {
3402 }
3403 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> &)3404 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
3405 {
3406 	const char* pService = "com.sun.star.drawing.FrameShape";
3407 	AddShape( pService );
3408 
3409 	if( mxShape.is() )
3410 	{
3411 		SetLayer();
3412 
3413 		// set pos, size, shear and rotate
3414 		SetTransformation();
3415 
3416 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3417 		if( xProps.is() )
3418 		{
3419 			uno::Any aAny;
3420 
3421 			if( maFrameName.getLength() )
3422 			{
3423 				aAny <<= maFrameName;
3424 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ), aAny );
3425 			}
3426 
3427 			if( maHref.getLength() )
3428 			{
3429 				aAny <<= maHref;
3430 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ), aAny );
3431 			}
3432 		}
3433 
3434 		SetStyle();
3435 
3436 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3437 	}
3438 }
3439 
3440 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)3441 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3442 {
3443 	switch( nPrefix )
3444 	{
3445 	case XML_NAMESPACE_DRAW:
3446 		if( IsXMLToken( rLocalName, XML_FRAME_NAME ) )
3447 		{
3448 			maFrameName = rValue;
3449 			return;
3450 		}
3451 		break;
3452 	case XML_NAMESPACE_XLINK:
3453 		if( IsXMLToken( rLocalName, XML_HREF ) )
3454 		{
3455 			maHref = GetImport().GetAbsoluteReference(rValue);
3456 			return;
3457 		}
3458 		break;
3459 	}
3460 
3461 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3462 }
3463 
EndElement()3464 void SdXMLFloatingFrameShapeContext::EndElement()
3465 {
3466 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3467 
3468 	if( xProps.is() )
3469 	{
3470 		if ( maSize.Width && maSize.Height )
3471 		{
3472 			// the visual area for a floating frame must be set on loading
3473 			awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3474 			uno::Any aAny;
3475 			aAny <<= aRect;
3476 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny );
3477 		}
3478 	}
3479 
3480 	SetThumbnail();
3481 	SdXMLShapeContext::EndElement();
3482 }
3483 
3484 //////////////////////////////////////////////////////////////////////////////
3485 
3486 TYPEINIT1( SdXMLFrameShapeContext, SdXMLShapeContext );
3487 
SdXMLFrameShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)3488 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3489 		const rtl::OUString& rLocalName,
3490 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3491 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3492         sal_Bool bTemporaryShape)
3493 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3494     multiImageImportHelper(),
3495 	mbSupportsReplacement( sal_False ),
3496     mxImplContext(),
3497     mxReplImplContext()
3498 {
3499 	uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
3500 	if( xClone.is() )
3501 		mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
3502 	else
3503 		mxAttrList = new SvXMLAttributeList( xAttrList );
3504 
3505 }
3506 
~SdXMLFrameShapeContext()3507 SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3508 {
3509 }
3510 
removeGraphicFromImportContext(const SvXMLImportContext & rContext) const3511 void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
3512 {
3513     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3514 
3515     if(pSdXMLGraphicObjectShapeContext)
3516     {
3517         try
3518         {
3519             uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3520 
3521             if(xChild.is())
3522             {
3523                 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3524 
3525                 if(xParent.is())
3526                 {
3527                     // remove from parent
3528                     xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3529 
3530                     // dispose
3531                     uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3532 
3533                     if(xComp.is())
3534                     {
3535                         xComp->dispose();
3536                     }
3537                 }
3538             }
3539         }
3540         catch( uno::Exception& )
3541         {
3542             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
3543         }
3544     }
3545 }
3546 
getGraphicURLFromImportContext(const SvXMLImportContext & rContext) const3547 rtl::OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
3548 {
3549     rtl::OUString aRetval;
3550     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3551 
3552     if(pSdXMLGraphicObjectShapeContext)
3553     {
3554         try
3555         {
3556             const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3557 
3558             if(xPropSet.is())
3559             {
3560                 xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aRetval;
3561 
3562                 if(!aRetval.getLength())
3563                 {
3564                     // it maybe a link, try GraphicURL
3565                     xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= aRetval;
3566                 }
3567             }
3568         }
3569         catch( uno::Exception& )
3570         {
3571             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
3572         }
3573     }
3574 
3575     return aRetval;
3576 }
3577 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)3578 SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix,
3579 	const OUString& rLocalName,
3580 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
3581 {
3582 	SvXMLImportContext * pContext = 0;
3583 
3584 	if( !mxImplContext.Is() )
3585 	{
3586         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3587             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3588 
3589         mxImplContext = pContext;
3590         mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE);
3591         setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
3592 
3593         if(getSupportsMultipleContents())
3594         {
3595             SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext);
3596 
3597             if(pGSC)
3598             {
3599                 // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID
3600                 pGSC->setLateAddToIdentifierMapper(true);
3601                 addContent(*mxImplContext);
3602             }
3603         }
3604     }
3605     else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
3606     {
3607         // read another image
3608         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3609             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3610         mxImplContext = pContext;
3611 
3612         SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext);
3613 
3614         if(pGSC)
3615         {
3616             // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID
3617             pGSC->setLateAddToIdentifierMapper(true);
3618             addContent(*mxImplContext);
3619         }
3620     }
3621 	else if( mbSupportsReplacement && !mxReplImplContext &&
3622 			 XML_NAMESPACE_DRAW == nPrefix &&
3623 			 IsXMLToken( rLocalName, XML_IMAGE ) )
3624 	{
3625 		// read replacement image
3626 		SvXMLImportContext *pImplContext = &mxImplContext;
3627 		SdXMLShapeContext *pSContext =
3628 			PTR_CAST( SdXMLShapeContext, pImplContext );
3629 		if( pSContext )
3630 		{
3631 			uno::Reference < beans::XPropertySet > xPropSet(
3632 					pSContext->getShape(), uno::UNO_QUERY );
3633 			if( xPropSet.is() )
3634 			{
3635 				pContext = new XMLReplacementImageContext( GetImport(),
3636 									nPrefix, rLocalName, xAttrList, xPropSet );
3637 				mxReplImplContext = pContext;
3638 			}
3639 		}
3640 	}
3641 	else if(
3642 			( nPrefix == XML_NAMESPACE_SVG &&	// #i68101#
3643 				(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) ||
3644 			 (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) ||
3645 			 (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) ||
3646 												IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) )
3647 	{
3648 		SvXMLImportContext *pImplContext = &mxImplContext;
3649 		pContext = PTR_CAST( SdXMLShapeContext, pImplContext )->CreateChildContext( nPrefix,
3650 																		rLocalName, xAttrList );
3651 	}
3652 	else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
3653 	{
3654 		SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( &mxImplContext );
3655 		if( pSContext )
3656 		{
3657 			uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3658 			if (xPropSet.is())
3659 			{
3660 				pContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet);
3661 			}
3662 		}
3663 	}
3664 
3665 	// call parent for content
3666 	if(!pContext)
3667 		pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
3668 
3669 	return pContext;
3670 }
3671 
StartElement(const uno::Reference<xml::sax::XAttributeList> &)3672 void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
3673 {
3674 	// ignore
3675 }
3676 
EndElement()3677 void SdXMLFrameShapeContext::EndElement()
3678 {
3679     /// solve if multiple image child contexts were imported
3680     const SvXMLImportContext* pWinner = solveMultipleImages();
3681     const SdXMLGraphicObjectShapeContext* pGSCWinner = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(pWinner);
3682 
3683     /// if we have a winner and it's on LateAdd, add it now
3684     if(pGSCWinner && pGSCWinner->getLateAddToIdentifierMapper() && pGSCWinner->getShapeId().getLength())
3685     {
3686         uno::Reference< uno::XInterface > xRef( pGSCWinner->getShape(), uno::UNO_QUERY );
3687         GetImport().getInterfaceToIdentifierMapper().registerReference( pGSCWinner->getShapeId(), xRef );
3688     }
3689 
3690 	if( !mxImplContext.Is() )
3691 	{
3692 		// now check if this is an empty presentation object
3693 		sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0;
3694 		for(sal_Int16 a(0); a < nAttrCount; a++)
3695 		{
3696 			OUString aLocalName;
3697 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName);
3698 
3699 			if( nPrefix == XML_NAMESPACE_PRESENTATION )
3700 			{
3701 				if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) )
3702 				{
3703 					mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE );
3704 				}
3705 				else if( IsXMLToken( aLocalName, XML_CLASS ) )
3706 				{
3707 					maPresentationClass = mxAttrList->getValueByIndex(a);
3708 				}
3709 			}
3710 		}
3711 
3712 		if( (maPresentationClass.getLength() != 0) && mbIsPlaceholder )
3713 		{
3714 			uno::Reference< xml::sax::XAttributeList> xEmpty;
3715 
3716 			enum XMLTokenEnum eToken = XML_TEXT_BOX;
3717 
3718 			if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) )
3719 			{
3720 				eToken = XML_IMAGE;
3721 
3722 			}
3723 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
3724 			{
3725 				eToken = XML_PAGE_THUMBNAIL;
3726 			}
3727 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) ||
3728 					 IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) ||
3729 					 IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3730 			{
3731 				eToken = XML_OBJECT;
3732 			}
3733 
3734 			mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3735 					GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty );
3736 
3737 			if( mxImplContext.Is() )
3738 			{
3739 				mxImplContext->StartElement( mxAttrList );
3740 				mxImplContext->EndElement();
3741 			}
3742 		}
3743 	}
3744 
3745 	mxImplContext = 0;
3746 	SdXMLShapeContext::EndElement();
3747 }
3748 
processAttribute(sal_uInt16,const::rtl::OUString &,const::rtl::OUString &)3749 void SdXMLFrameShapeContext::processAttribute( sal_uInt16,
3750 		const ::rtl::OUString&, const ::rtl::OUString& )
3751 {
3752 	// ignore
3753 }
3754 
3755 TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext );
3756 
SdXMLCustomShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)3757 SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3758 	SvXMLImport& rImport,
3759 	sal_uInt16 nPrfx,
3760 	const OUString& rLocalName,
3761 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3762 	uno::Reference< drawing::XShapes >& rShapes,
3763     sal_Bool bTemporaryShape)
3764 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3765 {
3766 }
3767 
3768 //////////////////////////////////////////////////////////////////////////////
3769 
~SdXMLCustomShapeContext()3770 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3771 {
3772 }
3773 
3774 //////////////////////////////////////////////////////////////////////////////
3775 
3776 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)3777 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3778 {
3779 	if( XML_NAMESPACE_DRAW == nPrefix )
3780 	{
3781 		if( IsXMLToken( rLocalName, XML_ENGINE ) )
3782 		{
3783 			maCustomShapeEngine = rValue;
3784 			return;
3785 		}
3786 		if ( IsXMLToken( rLocalName, XML_DATA ) )
3787 		{
3788 			maCustomShapeData = rValue;
3789 			return;
3790 		}
3791 	}
3792 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3793 }
3794 
3795 //////////////////////////////////////////////////////////////////////////////
3796 
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)3797 void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
3798 {
3799 	// create rectangle shape
3800 	AddShape("com.sun.star.drawing.CustomShape");
3801 	if ( mxShape.is() )
3802 	{
3803 		// Add, set Style and properties from base shape
3804 		SetStyle();
3805 		SetLayer();
3806 
3807 		// set pos, size, shear and rotate
3808 		SetTransformation();
3809 
3810 		try
3811 		{
3812 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3813 			if( xPropSet.is() )
3814 			{
3815 				if ( maCustomShapeEngine.getLength() )
3816 				{
3817 					uno::Any aAny;
3818 					aAny <<= maCustomShapeEngine;
3819 					xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), aAny );
3820 				}
3821 				if ( maCustomShapeData.getLength() )
3822 				{
3823 					uno::Any aAny;
3824 					aAny <<= maCustomShapeData;
3825 					xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), aAny );
3826 				}
3827 			}
3828 		}
3829 		catch( uno::Exception& )
3830 		{
3831 			DBG_ERROR( "could not set enhanced customshape geometry" );
3832 		}
3833 		SdXMLShapeContext::StartElement(xAttrList);
3834 	}
3835 }
3836 
EndElement()3837 void SdXMLCustomShapeContext::EndElement()
3838 {
3839     // for backward compatibility, the above SetTransformation() may alraedy have
3840     // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the
3841     // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this
3842     // would be lost again.
3843     // TTTT: Remove again after aw080
3844     if(!maUsedTransformation.isIdentity())
3845     {
3846         basegfx::B2DVector aScale, aTranslate;
3847         double fRotate, fShearX;
3848 
3849         maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
3850 
3851         bool bFlippedX(aScale.getX() < 0.0);
3852         bool bFlippedY(aScale.getY() < 0.0);
3853 
3854         if(bFlippedX && bFlippedY)
3855         {
3856             // when both are used it is the same as 180 degree rotation; reset
3857             bFlippedX = bFlippedY = false;
3858         }
3859 
3860         if(bFlippedX || bFlippedY)
3861         {
3862             beans::PropertyValue aNewPoroperty;
3863 
3864             if(bFlippedX)
3865             {
3866                 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredX"));
3867             }
3868             else
3869             {
3870                 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredY"));
3871             }
3872 
3873             aNewPoroperty.Handle = -1;
3874             aNewPoroperty.Value <<= sal_True;
3875             aNewPoroperty.State = beans::PropertyState_DIRECT_VALUE;
3876 
3877             maCustomShapeGeometry.push_back(aNewPoroperty);
3878         }
3879     }
3880 
3881 	if ( !maCustomShapeGeometry.empty() )
3882 	{
3883 		const rtl::OUString	sCustomShapeGeometry	( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
3884 
3885 		// converting the vector to a sequence
3886 		uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() );
3887 		beans::PropertyValue* pValues = aSeq.getArray();
3888 		std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() );
3889 		std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() );
3890 		while ( aIter != aEnd )
3891 			*pValues++ = *aIter++;
3892 
3893 		try
3894 		{
3895 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3896 			if( xPropSet.is() )
3897 			{
3898 				uno::Any aAny;
3899 				aAny <<= aSeq;
3900 				xPropSet->setPropertyValue( sCustomShapeGeometry, aAny );
3901 			}
3902 		}
3903 		catch( uno::Exception& )
3904 		{
3905 			DBG_ERROR( "could not set enhanced customshape geometry" );
3906 		}
3907 
3908         sal_Int32 nUPD( 0 );
3909         sal_Int32 nBuild( 0 );
3910         GetImport().getBuildIds( nUPD, nBuild );
3911         if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3912 		{
3913 			Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3914 			if( xDefaulter.is() )
3915 			{
3916 				rtl::OUString aEmptyType;
3917 				xDefaulter->createCustomShapeDefaults( aEmptyType );
3918 			}
3919 		}
3920 	}
3921 
3922 	SdXMLShapeContext::EndElement();
3923 }
3924 
3925 //////////////////////////////////////////////////////////////////////////////
3926 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)3927 SvXMLImportContext* SdXMLCustomShapeContext::CreateChildContext(
3928 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
3929 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
3930 {
3931 	SvXMLImportContext* pContext = NULL;
3932 	if ( XML_NAMESPACE_DRAW == nPrefix )
3933 	{
3934 		if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) )
3935 		{
3936 			uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3937 			if ( xPropSet.is() )
3938 				pContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry );
3939 		}
3940 	}
3941 	// delegate to parent class if no context could be created
3942 	if ( NULL == pContext )
3943 		pContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName,
3944 														 xAttrList);
3945 	return pContext;
3946 }
3947 
3948 ///////////////////////////////////////////////////////////////////////
3949 
3950 //////////////////////////////////////////////////////////////////////////////
3951 
3952 TYPEINIT1( SdXMLTableShapeContext, SdXMLShapeContext );
3953 
SdXMLTableShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const rtl::OUString & rLocalName,const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> & xAttrList,com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> & rShapes)3954 SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
3955 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, sal_False )
3956 {
3957 	memset( &maTemplateStylesUsed, 0, sizeof( maTemplateStylesUsed ) );
3958 }
3959 
~SdXMLTableShapeContext()3960 SdXMLTableShapeContext::~SdXMLTableShapeContext()
3961 {
3962 }
3963 
StartElement(const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList)3964 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
3965 {
3966 	const char* pService = "com.sun.star.drawing.TableShape";
3967 
3968 	sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3969 	if( bIsPresShape )
3970 	{
3971 		if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
3972 		{
3973 			pService = "com.sun.star.presentation.TableShape";
3974 		}
3975 	}
3976 
3977 	AddShape( pService );
3978 
3979 	if( mxShape.is() )
3980 	{
3981 		SetLayer();
3982 
3983 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3984 
3985 		if(bIsPresShape)
3986 		{
3987 			if(xProps.is())
3988 			{
3989 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3990 				if( xPropsInfo.is() )
3991 				{
3992 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
3993 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
3994 
3995 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
3996 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
3997 				}
3998 			}
3999 		}
4000 
4001 		SetStyle();
4002 
4003 		if( xProps.is() )
4004 		{
4005 			if( msTemplateStyleName.getLength() ) try
4006 			{
4007 				Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
4008 				Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
4009 				const OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM("table" ) );
4010 				Reference< XNameAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
4011 				Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
4012 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableTemplate" ) ), Any( xTableStyle ) );
4013 			}
4014 			catch( Exception& )
4015 			{
4016 				DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
4017 			}
4018 
4019 			const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
4020 			for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
4021 			{
4022 			    try
4023 			    {
4024 				    const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
4025 				    xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) );
4026 			    }
4027 			    catch( Exception& )
4028 			    {
4029 				    DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
4030 			    }
4031             }
4032 		}
4033 
4034 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
4035 
4036 		const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
4037 		if( xTableImport.is() && xProps.is() )
4038 		{
4039 			uno::Reference< table::XColumnRowRange > xColumnRowRange(
4040 				xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY );
4041 
4042 			if( xColumnRowRange.is() )
4043 				mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange );
4044 
4045 			if( mxTableImportContext.Is() )
4046 				mxTableImportContext->StartElement( xAttrList );
4047 		}
4048 	}
4049 }
4050 
EndElement()4051 void SdXMLTableShapeContext::EndElement()
4052 {
4053 	if( mxTableImportContext.Is() )
4054 		mxTableImportContext->EndElement();
4055 
4056 	SdXMLShapeContext::EndElement();
4057 
4058 	if( mxShape.is() )
4059 	{
4060 		// set pos, size, shear and rotate
4061 		SetTransformation();
4062 	}
4063 }
4064 
4065 // this is called from the parent group for each unparsed attribute in the attribute list
processAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)4066 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
4067 {
4068 	if( nPrefix == XML_NAMESPACE_TABLE )
4069 	{
4070 		if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) )
4071 		{
4072 			msTemplateStyleName = rValue;
4073 		}
4074 		else
4075 		{
4076 			int i = 0;
4077 			const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
4078 			while( pEntry->msApiName && (i < 6) )
4079 			{
4080 				if( IsXMLToken( rLocalName, pEntry->meXMLName ) )
4081 				{
4082 					if( IsXMLToken( rValue, XML_TRUE ) )
4083 						maTemplateStylesUsed[i] = sal_True;
4084 					break;
4085 				}
4086 				pEntry++;
4087 				i++;
4088 			}
4089 		}
4090 	}
4091 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
4092 }
4093 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)4094 SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList )
4095 {
4096 	if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) )
4097 		return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList);
4098 	else
4099 		return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
4100 }
4101 
4102