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