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