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