1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24 #include "unointerfacetouniqueidentifiermapper.hxx"
25 #include <com/sun/star/text/XText.hpp>
26 #include <com/sun/star/container/XNamed.hpp>
27 #include <com/sun/star/container/XEnumerationAccess.hpp>
28 #include <com/sun/star/drawing/CircleKind.hpp>
29 #include <com/sun/star/drawing/ConnectorType.hpp>
30 #include <com/sun/star/drawing/XControlShape.hpp>
31 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
32 #include <com/sun/star/document/XEventsSupplier.hpp>
33 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
34 #include <com/sun/star/media/ZoomLevel.hpp>
35 #include "anim.hxx"
36 #include <xmloff/shapeexport.hxx>
37 #include "sdpropls.hxx"
38 #include <tools/debug.hxx>
39 #include <tools/urlobj.hxx>
40 #include <rtl/ustrbuf.hxx>
41 #include <xmloff/xmlexp.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include "XMLImageMapExport.hxx"
44 #include "xexptran.hxx"
45 #include <tools/gen.hxx>		// FRound
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/nmspmap.hxx>
48 #include "xmloff/xmlnmspe.hxx"
49 #include <basegfx/matrix/b2dhommatrix.hxx>
50 #include <basegfx/tuple/b2dtuple.hxx>
51 #include <basegfx/matrix/b2dhommatrixtools.hxx>
52 #include <basegfx/point/b2dpoint.hxx>
53 #include <basegfx/polygon/b2dpolypolygon.hxx>
54 #include <basegfx/polygon/b2dpolypolygontools.hxx>
55 #include <basegfx/polygon/b2dpolygontools.hxx>
56 
57 using ::rtl::OUString;
58 using ::rtl::OUStringBuffer;
59 
60 using namespace ::com::sun::star;
61 using namespace ::xmloff::token;
62 
63 
64 //////////////////////////////////////////////////////////////////////////////
65 
ImpExportNewTrans(const uno::Reference<beans::XPropertySet> & xPropSet,sal_Int32 nFeatures,awt::Point * pRefPoint)66 void XMLShapeExport::ImpExportNewTrans(const uno::Reference< beans::XPropertySet >& xPropSet,
67 	sal_Int32 nFeatures, awt::Point* pRefPoint)
68 {
69 	// get matrix
70 	::basegfx::B2DHomMatrix aMatrix;
71 	ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
72 
73 	// decompose and correct abour pRefPoint
74 	::basegfx::B2DTuple aTRScale;
75 	double fTRShear(0.0);
76 	double fTRRotate(0.0);
77 	::basegfx::B2DTuple aTRTranslate;
78 	ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
79 
80 	// use features and write
81 	ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
82 }
83 
ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix & rMatrix,const uno::Reference<beans::XPropertySet> & xPropSet)84 void XMLShapeExport::ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix,
85 	const uno::Reference< beans::XPropertySet >& xPropSet)
86 {
87     // --> OD 2004-08-09 #i28749# - Get <TransformationInHoriL2R>, if it exist
88     // and if the document is exported into the OpenOffice.org file format.
89     // This property only exists at service com::sun::star::text::Shape - the
90     // Writer UNO service for shapes.
91     // This code is needed, because the positioning attributes in the
92     // OpenOffice.org file format are given in horizontal left-to-right layout
93     // regardless the layout direction the shape is in. In the OASIS Open Office
94     // file format the positioning attributes are correctly given in the layout
95     // direction the shape is in. Thus, this code provides the conversion from
96     // the OASIS Open Office file format to the OpenOffice.org file format.
97     uno::Any aAny;
98     if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
99          xPropSet->getPropertySetInfo()->hasPropertyByName(
100             OUString(RTL_CONSTASCII_USTRINGPARAM("TransformationInHoriL2R"))) )
101     {
102         aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TransformationInHoriL2R")));
103     }
104     else
105     {
106         aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")));
107     }
108     // <--
109 	drawing::HomogenMatrix3 aMatrix;
110 	aAny >>= aMatrix;
111 
112 	rMatrix.set(0, 0, aMatrix.Line1.Column1);
113 	rMatrix.set(0, 1, aMatrix.Line1.Column2);
114 	rMatrix.set(0, 2, aMatrix.Line1.Column3);
115 	rMatrix.set(1, 0, aMatrix.Line2.Column1);
116 	rMatrix.set(1, 1, aMatrix.Line2.Column2);
117 	rMatrix.set(1, 2, aMatrix.Line2.Column3);
118 	rMatrix.set(2, 0, aMatrix.Line3.Column1);
119 	rMatrix.set(2, 1, aMatrix.Line3.Column2);
120 	rMatrix.set(2, 2, aMatrix.Line3.Column3);
121 }
122 
ImpExportNewTrans_DecomposeAndRefPoint(const::basegfx::B2DHomMatrix & rMatrix,::basegfx::B2DTuple & rTRScale,double & fTRShear,double & fTRRotate,::basegfx::B2DTuple & rTRTranslate,com::sun::star::awt::Point * pRefPoint)123 void XMLShapeExport::ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMatrix, ::basegfx::B2DTuple& rTRScale,
124 	double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, com::sun::star::awt::Point* pRefPoint)
125 {
126 	// decompose matrix
127 	rMatrix.decompose(rTRScale, rTRTranslate, fTRRotate, fTRShear);
128 
129 	// correct translation about pRefPoint
130 	if(pRefPoint)
131 	{
132 		rTRTranslate -= ::basegfx::B2DTuple(pRefPoint->X, pRefPoint->Y);
133 	}
134 }
135 
ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple & rTRScale,double fTRShear,double fTRRotate,::basegfx::B2DTuple & rTRTranslate,const sal_Int32 nFeatures)136 void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTRScale, double fTRShear,
137 	double fTRRotate, ::basegfx::B2DTuple& rTRTranslate, const sal_Int32 nFeatures)
138 {
139 	// allways write Size (rTRScale) since this statement carries the union
140 	// of the object
141 	OUString aStr;
142 	OUStringBuffer sStringBuffer;
143 	::basegfx::B2DTuple aTRScale(rTRScale);
144 
145 	// svg: width
146 	if(!(nFeatures & SEF_EXPORT_WIDTH))
147 	{
148 		aTRScale.setX(1.0);
149 	}
150 	else
151 	{
152 		if( aTRScale.getX() > 0.0 )
153 			aTRScale.setX(aTRScale.getX() - 1.0);
154 		else if( aTRScale.getX() < 0.0 )
155 			aTRScale.setX(aTRScale.getX() + 1.0);
156 	}
157 
158 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getX()));
159 	aStr = sStringBuffer.makeStringAndClear();
160 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
161 
162 	// svg: height
163 	if(!(nFeatures & SEF_EXPORT_HEIGHT))
164 	{
165 		aTRScale.setY(1.0);
166 	}
167 	else
168 	{
169 		if( aTRScale.getY() > 0.0 )
170 			aTRScale.setY(aTRScale.getY() - 1.0);
171 		else if( aTRScale.getY() < 0.0 )
172 			aTRScale.setY(aTRScale.getY() + 1.0);
173 	}
174 
175 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getY()));
176 	aStr = sStringBuffer.makeStringAndClear();
177 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
178 
179 	// decide if transformation is neccessary
180 	sal_Bool bTransformationIsNeccessary(fTRShear != 0.0 || fTRRotate != 0.0);
181 
182 	if(bTransformationIsNeccessary)
183 	{
184 		// write transformation, but WITHOUT scale which is exported as size above
185 		SdXMLImExTransform2D aTransform;
186 
187 		aTransform.AddSkewX(atan(fTRShear));
188 
189         // #i78696#
190         // fTRRotate is mathematically correct, but due to the error
191         // we export/import it mirrored. Since the API implementation is fixed and
192         // uses the correctly oriented angle, it is necessary for compatibility to
193         // mirror the angle here to stay at the old behaviour. There is a follow-up
194         // task (#i78698#) to fix this in the next ODF FileFormat version
195 		aTransform.AddRotate(-fTRRotate);
196 
197         aTransform.AddTranslate(rTRTranslate);
198 
199 		// does transformation need to be exported?
200 		if(aTransform.NeedsAction())
201 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
202 	}
203 	else
204 	{
205 		// no shear, no rotate; just add object position to export and we are done
206 		if(nFeatures & SEF_EXPORT_X)
207 		{
208 			// svg: x
209 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getX()));
210 			aStr = sStringBuffer.makeStringAndClear();
211 			mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
212 		}
213 
214 		if(nFeatures & SEF_EXPORT_Y)
215 		{
216 			// svg: y
217 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getY()));
218 			aStr = sStringBuffer.makeStringAndClear();
219 			mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
220 		}
221 	}
222 }
223 
224 //////////////////////////////////////////////////////////////////////////////
225 
ImpExportPresentationAttributes(const uno::Reference<beans::XPropertySet> & xPropSet,const rtl::OUString & rClass)226 sal_Bool XMLShapeExport::ImpExportPresentationAttributes( const uno::Reference< beans::XPropertySet >& xPropSet, const rtl::OUString& rClass )
227 {
228 	sal_Bool bIsEmpty = sal_False;
229 
230 	OUStringBuffer sStringBuffer;
231 
232 	// write presentation class entry
233 	mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS, rClass);
234 
235 	if( xPropSet.is() )
236 	{
237 		uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
238 
239 		sal_Bool bTemp = false;
240 
241 		// is empty pes shape?
242 		if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
243 		{
244 			xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))) >>= bIsEmpty;
245 			if( bIsEmpty )
246 				mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, XML_TRUE);
247 		}
248 
249 		// is user-transformed?
250 		if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))))
251 		{
252 			xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))) >>= bTemp;
253 			if(!bTemp)
254 				mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_USER_TRANSFORMED, XML_TRUE);
255 		}
256 	}
257 
258 	return bIsEmpty;
259 }
260 
261 //////////////////////////////////////////////////////////////////////////////
262 
ImpExportText(const uno::Reference<drawing::XShape> & xShape)263 void XMLShapeExport::ImpExportText( const uno::Reference< drawing::XShape >& xShape )
264 {
265 	uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
266 	if( xText.is() )
267 	{
268 		uno::Reference< container::XEnumerationAccess > xEnumAccess( xShape, uno::UNO_QUERY );
269 		if( xEnumAccess.is() && xEnumAccess->hasElements() )
270 			mrExport.GetTextParagraphExport()->exportText( xText );
271 	}
272 }
273 
274 //////////////////////////////////////////////////////////////////////////////
275 #include <com/sun/star/presentation/ClickAction.hpp>
276 #include <com/sun/star/presentation/AnimationSpeed.hpp>
277 
278 namespace {
279 
280 const sal_Int32 FOUND_CLICKACTION       = 0x00000001;
281 const sal_Int32 FOUND_BOOKMARK          = 0x00000002;
282 const sal_Int32 FOUND_EFFECT            = 0x00000004;
283 const sal_Int32 FOUND_PLAYFULL          = 0x00000008;
284 const sal_Int32 FOUND_VERB              = 0x00000010;
285 const sal_Int32 FOUND_SOUNDURL          = 0x00000020;
286 const sal_Int32 FOUND_SPEED             = 0x00000040;
287 const sal_Int32 FOUND_CLICKEVENTTYPE    = 0x00000080;
288 const sal_Int32 FOUND_MACRO             = 0x00000100;
289 const sal_Int32 FOUND_LIBRARY           = 0x00000200;
290 const sal_Int32 FOUND_ACTIONEVENTTYPE   = 0x00000400;
291 #ifdef ISSUE66550_HLINK_FOR_SHAPES
292 const sal_Int32 FOUND_URL               = 0x00000800;
293 #endif
294 
295 } // namespace
296 
ImpExportEvents(const uno::Reference<drawing::XShape> & xShape)297 void XMLShapeExport::ImpExportEvents( const uno::Reference< drawing::XShape >& xShape )
298 {
299     uno::Reference< document::XEventsSupplier > xEventsSupplier( xShape, uno::UNO_QUERY );
300     if( !xEventsSupplier.is() )
301         return;
302 
303     uno::Reference< container::XNameAccess > xEvents( xEventsSupplier->getEvents(), uno::UNO_QUERY );
304     DBG_ASSERT( xEvents.is(), "XEventsSupplier::getEvents() returned NULL" );
305     if( !xEvents.is() )
306         return;
307 
308     sal_Int32 nFound = 0;
309 
310     // extract properties from "OnClick" event --------------------------------
311 
312     OUString aClickEventType;
313     presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
314     presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
315     presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_SLOW;
316     OUString aStrSoundURL;
317     sal_Bool bPlayFull = false;
318     sal_Int32 nVerb = 0;
319     OUString aStrMacro;
320     OUString aStrLibrary;
321     OUString aStrBookmark;
322 
323     uno::Sequence< beans::PropertyValue > aClickProperties;
324     if( xEvents->hasByName( msOnClick ) && (xEvents->getByName( msOnClick ) >>= aClickProperties) )
325     {
326         const beans::PropertyValue* pProperty = aClickProperties.getConstArray();
327         const beans::PropertyValue* pPropertyEnd = pProperty + aClickProperties.getLength();
328         for( ; pProperty != pPropertyEnd; ++pProperty )
329         {
330             if( ( ( nFound & FOUND_CLICKEVENTTYPE ) == 0 ) && pProperty->Name == msEventType )
331             {
332                 if( pProperty->Value >>= aClickEventType )
333                     nFound |= FOUND_CLICKEVENTTYPE;
334             }
335             else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperty->Name == msClickAction )
336             {
337                 if( pProperty->Value >>= eClickAction )
338                     nFound |= FOUND_CLICKACTION;
339             }
340             else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperty->Name == msMacroName || pProperty->Name == msScript ) )
341             {
342                 if( pProperty->Value >>= aStrMacro )
343                     nFound |= FOUND_MACRO;
344             }
345             else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperty->Name == msLibrary )
346             {
347                 if( pProperty->Value >>= aStrLibrary )
348                     nFound |= FOUND_LIBRARY;
349             }
350             else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperty->Name == msEffect )
351             {
352                 if( pProperty->Value >>= eEffect )
353                     nFound |= FOUND_EFFECT;
354             }
355             else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperty->Name == msBookmark )
356             {
357                 if( pProperty->Value >>= aStrBookmark )
358                     nFound |= FOUND_BOOKMARK;
359             }
360             else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperty->Name == msSpeed )
361             {
362                 if( pProperty->Value >>= eSpeed )
363                     nFound |= FOUND_SPEED;
364             }
365             else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperty->Name == msSoundURL )
366             {
367                 if( pProperty->Value >>= aStrSoundURL )
368                     nFound |= FOUND_SOUNDURL;
369             }
370             else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperty->Name == msPlayFull )
371             {
372                 if( pProperty->Value >>= bPlayFull )
373                     nFound |= FOUND_PLAYFULL;
374             }
375             else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperty->Name == msVerb )
376             {
377                 if( pProperty->Value >>= nVerb )
378                     nFound |= FOUND_VERB;
379             }
380         }
381     }
382 
383 #ifdef ISSUE66550_HLINK_FOR_SHAPES
384     // extract properties from "OnAction" event -------------------------------
385 
386     OUString aActionEventType;
387     OUString aHyperURL;
388 
389     uno::Sequence< beans::PropertyValue > aActionProperties;
390     if( xEvents->hasByName( msOnAction ) && (xEvents->getByName( msOnAction ) >>= aActionProperties) )
391     {
392         const beans::PropertyValue* pProperty = aActionProperties.getConstArray();
393         const beans::PropertyValue* pPropertyEnd = pProperty + aActionProperties.getLength();
394         for( ; pProperty != pPropertyEnd; ++pProperty )
395         {
396             if( ( ( nFound & FOUND_ACTIONEVENTTYPE ) == 0 ) && pProperty->Name == msEventType )
397             {
398                 if( pProperty->Value >>= aActionEventType )
399                     nFound |= FOUND_ACTIONEVENTTYPE;
400             }
401             else if( ( ( nFound & FOUND_URL ) == 0 ) && ( pProperty->Name == msURL  ) )
402             {
403                 if( pProperty->Value >>= aHyperURL )
404                     nFound |= FOUND_URL;
405             }
406         }
407     }
408 #endif
409 
410     // create the XML elements
411 
412     if( aClickEventType == msPresentation )
413     {
414         if( ((nFound & FOUND_CLICKACTION) == 0) || (eClickAction == presentation::ClickAction_NONE) )
415             return;
416 
417         SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
418 
419         enum XMLTokenEnum eStrAction;
420 
421         switch( eClickAction )
422         {
423             case presentation::ClickAction_PREVPAGE:        eStrAction = XML_PREVIOUS_PAGE; break;
424             case presentation::ClickAction_NEXTPAGE:        eStrAction = XML_NEXT_PAGE; break;
425             case presentation::ClickAction_FIRSTPAGE:       eStrAction = XML_FIRST_PAGE; break;
426             case presentation::ClickAction_LASTPAGE:        eStrAction = XML_LAST_PAGE; break;
427             case presentation::ClickAction_INVISIBLE:       eStrAction = XML_HIDE; break;
428             case presentation::ClickAction_STOPPRESENTATION:eStrAction = XML_STOP; break;
429             case presentation::ClickAction_PROGRAM:         eStrAction = XML_EXECUTE; break;
430             case presentation::ClickAction_BOOKMARK:        eStrAction = XML_SHOW; break;
431             case presentation::ClickAction_DOCUMENT:        eStrAction = XML_SHOW; break;
432             case presentation::ClickAction_MACRO:           eStrAction = XML_EXECUTE_MACRO; break;
433             case presentation::ClickAction_VERB:            eStrAction = XML_VERB; break;
434             case presentation::ClickAction_VANISH:          eStrAction = XML_FADE_OUT; break;
435             case presentation::ClickAction_SOUND:           eStrAction = XML_SOUND; break;
436             default:
437                 DBG_ERROR( "unknown presentation::ClickAction found!" );
438                 eStrAction = XML_UNKNOWN;
439         }
440 
441         OUString aEventQName(
442             mrExport.GetNamespaceMap().GetQNameByKey(
443                     XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
444         mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
445         mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_ACTION, eStrAction );
446 
447         if( eClickAction == presentation::ClickAction_VANISH )
448         {
449             if( nFound & FOUND_EFFECT )
450             {
451                 XMLEffect eKind;
452                 XMLEffectDirection eDirection;
453                 sal_Int16 nStartScale;
454                 sal_Bool bIn;
455 
456                 SdXMLImplSetEffect( eEffect, eKind, eDirection, nStartScale, bIn );
457 
458                 if( eKind != EK_none )
459                 {
460                     SvXMLUnitConverter::convertEnum( msBuffer, eKind, aXML_AnimationEffect_EnumMap );
461                     mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, msBuffer.makeStringAndClear() );
462                 }
463 
464                 if( eDirection != ED_none )
465                 {
466                     SvXMLUnitConverter::convertEnum( msBuffer, eDirection, aXML_AnimationDirection_EnumMap );
467                     mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, msBuffer.makeStringAndClear() );
468                 }
469 
470                 if( nStartScale != -1 )
471                 {
472                     SvXMLUnitConverter::convertPercent( msBuffer, nStartScale );
473                     mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, msBuffer.makeStringAndClear() );
474                 }
475             }
476 
477             if( nFound & FOUND_SPEED && eEffect != presentation::AnimationEffect_NONE )
478             {
479                  if( eSpeed != presentation::AnimationSpeed_MEDIUM )
480                     {
481                     SvXMLUnitConverter::convertEnum( msBuffer, eSpeed, aXML_AnimationSpeed_EnumMap );
482                     mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, msBuffer.makeStringAndClear() );
483                 }
484             }
485         }
486 
487         if( eClickAction == presentation::ClickAction_PROGRAM ||
488             eClickAction == presentation::ClickAction_BOOKMARK ||
489             eClickAction == presentation::ClickAction_DOCUMENT )
490         {
491             if( eClickAction == presentation::ClickAction_BOOKMARK )
492                 msBuffer.append( sal_Unicode('#') );
493 
494             msBuffer.append( aStrBookmark );
495             mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(msBuffer.makeStringAndClear()) );
496             mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
497             mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
498             mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
499         }
500 
501         if( ( nFound & FOUND_VERB ) && eClickAction == presentation::ClickAction_VERB )
502         {
503             msBuffer.append( nVerb );
504             mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_VERB, msBuffer.makeStringAndClear());
505         }
506 
507         SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_PRESENTATION, XML_EVENT_LISTENER, sal_True, sal_True);
508 
509         if( eClickAction == presentation::ClickAction_VANISH || eClickAction == presentation::ClickAction_SOUND )
510         {
511             if( ( nFound & FOUND_SOUNDURL ) && aStrSoundURL.getLength() != 0 )
512             {
513                 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStrSoundURL) );
514                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
515                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
516                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
517                 if( nFound & FOUND_PLAYFULL && bPlayFull )
518                     mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
519 
520                 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True );
521             }
522        }
523     }
524     else if( aClickEventType == msStarBasic )
525     {
526         if( nFound & FOUND_MACRO )
527         {
528             SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
529 
530             mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE,
531                         mrExport.GetNamespaceMap().GetQNameByKey(
532                             XML_NAMESPACE_OOO,
533                             OUString( RTL_CONSTASCII_USTRINGPARAM(
534                                             "starbasic" ) ) ) );
535             OUString aEventQName(
536                 mrExport.GetNamespaceMap().GetQNameByKey(
537                         XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
538             mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
539 
540             if( nFound & FOUND_LIBRARY )
541             {
542                 OUString sLocation( GetXMLToken(
543                     (aStrLibrary.equalsIgnoreAsciiCaseAscii("StarOffice") ||
544                      aStrLibrary.equalsIgnoreAsciiCaseAscii("application") ) ? XML_APPLICATION
545                                                                        : XML_DOCUMENT ) );
546                 OUStringBuffer sTmp( sLocation.getLength() + aStrMacro.getLength() + 1 );
547                 sTmp = sLocation;
548                 sTmp.append( sal_Unicode( ':' ) );
549                 sTmp.append( aStrMacro );
550                 mrExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME,
551                                      sTmp.makeStringAndClear());
552             }
553             else
554             {
555                 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, aStrMacro );
556             }
557 
558             SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, sal_True, sal_True);
559         }
560     }
561 #ifdef ISSUE66550_HLINK_FOR_SHAPES
562     else if( aClickEventType == msScript || aActionEventType == msAction )
563     {
564         if( nFound & ( FOUND_MACRO | FOUND_URL ) )
565 #else
566     else if( aClickEventType == msScript )
567     {
568         if( nFound & FOUND_MACRO )
569 #endif
570         {
571             SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
572             if ( nFound & FOUND_MACRO )
573             {
574                 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, mrExport.GetNamespaceMap().GetQNameByKey(
575                          XML_NAMESPACE_OOO, GetXMLToken(XML_SCRIPT) ) );
576                 OUString aEventQName(
577                     mrExport.GetNamespaceMap().GetQNameByKey(
578                             XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
579                 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
580                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStrMacro );
581 
582                 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, sal_True, sal_True);
583             }
584 #ifdef ISSUE66550_HLINK_FOR_SHAPES
585             if ( nFound & FOUND_URL )
586             {
587                 OUString aEventQName(
588                     mrExport.GetNamespaceMap().GetQNameByKey(
589                             XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "action" ) ) ) );
590                 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
591                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aHyperURL );
592 
593                 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_PRESENTATION, XML_EVENT_LISTENER, sal_True, sal_True);
594             }
595 #endif
596         }
597     }
598 }
599 
600 //////////////////////////////////////////////////////////////////////////////
601 
602 /** #i68101# export shape Title and Description */
603 void XMLShapeExport::ImpExportDescription( const uno::Reference< drawing::XShape >& xShape )
604 {
605 	try
606 	{
607 		OUString aTitle;
608 		OUString aDescription;
609 
610 		uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW );
611 		xProps->getPropertyValue( OUString::createFromAscii( "Title" ) ) >>= aTitle;
612 		xProps->getPropertyValue( OUString::createFromAscii( "Description" ) ) >>= aDescription;
613 
614 		if(aTitle.getLength())
615 		{
616 			SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_TITLE, sal_True, sal_False);
617 			mrExport.Characters( aTitle );
618 		}
619 
620 		if(aDescription.getLength())
621 		{
622 			SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_DESC, sal_True, sal_False );
623 			mrExport.Characters( aDescription );
624 		}
625 	}
626 	catch( uno::Exception& )
627 	{
628 		DBG_ERROR( "could not export Title and/or Description for shape!" );
629 	}
630 }
631 
632 //////////////////////////////////////////////////////////////////////////////
633 
634 void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
635 {
636 	uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
637 	if(xShapes.is() && xShapes->getCount())
638 	{
639 		// write group shape
640 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
641 		SvXMLElementExport aPGR(mrExport, XML_NAMESPACE_DRAW, XML_G, bCreateNewline, sal_True);
642 
643 		ImpExportDescription( xShape ); // #i68101#
644 		ImpExportEvents( xShape );
645 		ImpExportGluePoints( xShape );
646 
647 		// #89764# if export of position is supressed for group shape,
648 		// positions of contained objects should be written relative to
649 		// the upper left edge of the group.
650 		awt::Point aUpperLeft;
651 
652 		if(!(nFeatures & SEF_EXPORT_POSITION))
653 		{
654 			nFeatures |= SEF_EXPORT_POSITION;
655 			aUpperLeft = xShape->getPosition();
656 			pRefPoint = &aUpperLeft;
657 		}
658 
659 		// write members
660 		exportShapes( xShapes, nFeatures, pRefPoint );
661 	}
662 }
663 
664 //////////////////////////////////////////////////////////////////////////////
665 
666 void XMLShapeExport::ImpExportTextBoxShape(
667 	const uno::Reference< drawing::XShape >& xShape,
668 	XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
669 {
670 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
671 	if(xPropSet.is())
672 	{
673 		uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
674 
675 		// presentation attribute (if presentation)
676 		sal_Bool bIsPresShape(sal_False);
677 		sal_Bool bIsEmptyPresObj(sal_False);
678 		OUString aStr;
679 
680 		switch(eShapeType)
681 		{
682 			case XmlShapeTypePresSubtitleShape:
683 			{
684 				aStr = GetXMLToken(XML_PRESENTATION_SUBTITLE);
685 				bIsPresShape = sal_True;
686 				break;
687 			}
688 			case XmlShapeTypePresTitleTextShape:
689 			{
690 				aStr = GetXMLToken(XML_PRESENTATION_TITLE);
691 				bIsPresShape = sal_True;
692 				break;
693 			}
694 			case XmlShapeTypePresOutlinerShape:
695 			{
696 				aStr = GetXMLToken(XML_PRESENTATION_OUTLINE);
697 				bIsPresShape = sal_True;
698 				break;
699 			}
700 			case XmlShapeTypePresNotesShape:
701 			{
702 				aStr = GetXMLToken(XML_PRESENTATION_NOTES);
703 				bIsPresShape = sal_True;
704 				break;
705 			}
706 			case XmlShapeTypePresHeaderShape:
707 			{
708 				aStr = GetXMLToken(XML_HEADER);
709 				bIsPresShape = sal_True;
710 				break;
711 			}
712 			case XmlShapeTypePresFooterShape:
713 			{
714 				aStr = GetXMLToken(XML_FOOTER);
715 				bIsPresShape = sal_True;
716 				break;
717 			}
718 			case XmlShapeTypePresSlideNumberShape:
719 			{
720 				aStr = GetXMLToken(XML_PAGE_NUMBER);
721 				bIsPresShape = sal_True;
722 				break;
723 			}
724 			case XmlShapeTypePresDateTimeShape:
725 			{
726 				aStr = GetXMLToken(XML_DATE_TIME);
727 				bIsPresShape = sal_True;
728 				break;
729 			}
730 			default:
731 				break;
732 		}
733 
734 		// Transformation
735 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
736 
737 		if(bIsPresShape)
738 			bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, aStr );
739 
740 
741 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
742 		SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
743 								  XML_FRAME, bCreateNewline, sal_True );
744 
745 		// evtl. corner radius?
746 		sal_Int32 nCornerRadius(0L);
747 		xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
748 		if(nCornerRadius)
749 		{
750 			OUStringBuffer sStringBuffer;
751 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
752 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
753 		}
754 
755 		{
756 			// write text-box
757 			SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_TEXT_BOX, sal_True, sal_True);
758 			if(!bIsEmptyPresObj)
759 				ImpExportText( xShape );
760 		}
761 
762 		ImpExportDescription( xShape ); // #i68101#
763 		ImpExportEvents( xShape );
764 		ImpExportGluePoints( xShape );
765 	}
766 }
767 
768 //////////////////////////////////////////////////////////////////////////////
769 
770 void XMLShapeExport::ImpExportRectangleShape(
771 	const uno::Reference< drawing::XShape >& xShape,
772 	XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
773 {
774 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
775 	if(xPropSet.is())
776 	{
777 		// Transformation
778 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
779 
780 		// evtl. corner radius?
781 		sal_Int32 nCornerRadius(0L);
782 		xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
783 		if(nCornerRadius)
784 		{
785 			OUStringBuffer sStringBuffer;
786 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
787 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
788 		}
789 
790 		// write rectangle
791 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
792 		SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_RECT, bCreateNewline, sal_True);
793 
794 		ImpExportDescription( xShape ); // #i68101#
795 		ImpExportEvents( xShape );
796 		ImpExportGluePoints( xShape );
797 		ImpExportText( xShape );
798 	}
799 }
800 
801 //////////////////////////////////////////////////////////////////////////////
802 
803 void XMLShapeExport::ImpExportLineShape(
804 	const uno::Reference< drawing::XShape >& xShape,
805 	XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
806 {
807 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
808 	if(xPropSet.is())
809 	{
810 		OUString aStr;
811 		OUStringBuffer sStringBuffer;
812 		awt::Point aStart(0,0);
813 		awt::Point aEnd(1,1);
814 
815 		// #85920# use 'Geometry' to get the points of the line
816 		// since this slot take anchor pos into account.
817 
818 		// get matrix
819 		::basegfx::B2DHomMatrix aMatrix;
820 		ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
821 
822 		// decompose and correct about pRefPoint
823 		::basegfx::B2DTuple aTRScale;
824 		double fTRShear(0.0);
825 		double fTRRotate(0.0);
826 		::basegfx::B2DTuple aTRTranslate;
827 		ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
828 
829 		// create base position
830 		awt::Point aBasePosition(FRound(aTRTranslate.getX()), FRound(aTRTranslate.getY()));
831 
832 		// get the two points
833 		uno::Any aAny(xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))));
834 		drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue();
835 
836 		if(pSourcePolyPolygon)
837 		{
838 		    drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
839 			if(pOuterSequence)
840 			{
841 		        drawing::PointSequence* pInnerSequence = pOuterSequence++;
842 				if(pInnerSequence)
843 				{
844 				    awt::Point* pArray = pInnerSequence->getArray();
845 					if(pArray)
846 					{
847 						if(pInnerSequence->getLength() > 0)
848 						{
849 							aStart = awt::Point(
850 								pArray->X + aBasePosition.X,
851 								pArray->Y + aBasePosition.Y);
852 							pArray++;
853 						}
854 
855 						if(pInnerSequence->getLength() > 1)
856 						{
857 							aEnd = awt::Point(
858 								pArray->X + aBasePosition.X,
859 								pArray->Y + aBasePosition.Y);
860 						}
861 					}
862 				}
863 			}
864 		}
865 
866 		if( nFeatures & SEF_EXPORT_X )
867 		{
868 			// svg: x1
869 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
870 			aStr = sStringBuffer.makeStringAndClear();
871 			mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
872 		}
873 		else
874 		{
875 			aEnd.X -= aStart.X;
876 		}
877 
878 		if( nFeatures & SEF_EXPORT_Y )
879 		{
880 			// svg: y1
881 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
882 			aStr = sStringBuffer.makeStringAndClear();
883 			mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
884 		}
885 		else
886 		{
887 			aEnd.Y -= aStart.Y;
888 		}
889 
890 		// svg: x2
891 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
892 		aStr = sStringBuffer.makeStringAndClear();
893 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
894 
895 		// svg: y2
896 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
897 		aStr = sStringBuffer.makeStringAndClear();
898 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
899 
900 		// write line
901 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
902 		SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_LINE, bCreateNewline, sal_True);
903 
904 		ImpExportDescription( xShape ); // #i68101#
905 		ImpExportEvents( xShape );
906 		ImpExportGluePoints( xShape );
907 		ImpExportText( xShape );
908 	}
909 }
910 
911 //////////////////////////////////////////////////////////////////////////////
912 
913 void XMLShapeExport::ImpExportEllipseShape(
914 	const uno::Reference< drawing::XShape >& xShape,
915 	XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
916 {
917 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
918 	if(xPropSet.is())
919 	{
920 		// get size to decide between Circle and Ellipse
921 		awt::Size aSize = xShape->getSize();
922 		sal_Int32 nRx((aSize.Width + 1) / 2);
923 		sal_Int32 nRy((aSize.Height + 1) / 2);
924 		sal_Bool bCircle(nRx == nRy);
925 
926 		// Transformation
927 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
928 
929 		drawing::CircleKind eKind = drawing::CircleKind_FULL;
930 		xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")) ) >>= eKind;
931 		if( eKind != drawing::CircleKind_FULL )
932 		{
933 			OUStringBuffer sStringBuffer;
934 			sal_Int32 nStartAngle = 0;
935 			sal_Int32 nEndAngle = 0;
936 			xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")) ) >>= nStartAngle;
937 			xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")) ) >>= nEndAngle;
938 
939 			const double dStartAngle = nStartAngle / 100.0;
940 			const double dEndAngle = nEndAngle / 100.0;
941 
942 			// export circle kind
943 			SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eKind, aXML_CircleKind_EnumMap );
944 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_KIND, sStringBuffer.makeStringAndClear() );
945 
946 			// export start angle
947 			SvXMLUnitConverter::convertDouble( sStringBuffer, dStartAngle );
948 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_ANGLE, sStringBuffer.makeStringAndClear() );
949 
950 			// export end angle
951 			SvXMLUnitConverter::convertDouble( sStringBuffer, dEndAngle );
952 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_ANGLE, sStringBuffer.makeStringAndClear() );
953 		}
954 
955 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
956 
957         // prepare name (with most used)
958         enum ::xmloff::token::XMLTokenEnum eName(XML_CIRCLE);
959 
960         if(bCircle)
961         {
962             // name already set
963         }
964         else
965         {
966             // set name
967             eName = XML_ELLIPSE;
968         }
969 
970         // write ellipse or circle
971         SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, eName, bCreateNewline, sal_True);
972 
973         ImpExportDescription( xShape ); // #i68101#
974         ImpExportEvents( xShape );
975         ImpExportGluePoints( xShape );
976         ImpExportText( xShape );
977     }
978 }
979 
980 //////////////////////////////////////////////////////////////////////////////
981 
982 void XMLShapeExport::ImpExportPolygonShape(
983 	const uno::Reference< drawing::XShape >& xShape,
984 	XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
985 {
986 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
987 	if(xPropSet.is())
988 	{
989 		sal_Bool bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape
990 			|| eShapeType == XmlShapeTypeDrawOpenBezierShape);
991 
992 		// get matrix
993 		::basegfx::B2DHomMatrix aMatrix;
994 		ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
995 
996 		// decompose and correct abour pRefPoint
997 		::basegfx::B2DTuple aTRScale;
998 		double fTRShear(0.0);
999 		double fTRRotate(0.0);
1000 		::basegfx::B2DTuple aTRTranslate;
1001 		ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
1002 
1003 		// use features and write
1004 		ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
1005 
1006 		// create and export ViewBox
1007 		awt::Point aPoint(0, 0);
1008 		awt::Size aSize(FRound(aTRScale.getX()), FRound(aTRScale.getY()));
1009 		SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
1010 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
1011 
1012 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1013 
1014         // prepare name (with most used)
1015         enum ::xmloff::token::XMLTokenEnum eName(XML_PATH);
1016 
1017         if(bBezier)
1018         {
1019             // get PolygonBezier
1020             uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) );
1021             const basegfx::B2DPolyPolygon aPolyPolygon(
1022                 basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*(drawing::PolyPolygonBezierCoords*)aAny.getValue()));
1023 
1024             if(aPolyPolygon.count())
1025             {
1026                 // complex polygon shape, write as svg:d
1027                 const ::rtl::OUString aPolygonString(
1028                     basegfx::tools::exportToSvgD(
1029                         aPolyPolygon,
1030                         true,       // bUseRelativeCoordinates
1031                         false,      // bDetectQuadraticBeziers: not used in old, but maybe activated now
1032                         true));     // bHandleRelativeNextPointCompatible
1033 
1034                 // write point array
1035                 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
1036             }
1037         }
1038         else
1039         {
1040             // get non-bezier polygon
1041             uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) );
1042             const basegfx::B2DPolyPolygon aPolyPolygon(
1043                 basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*(drawing::PointSequenceSequence*)aAny.getValue()));
1044 
1045             if(!aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count())
1046             {
1047                 // simple polygon shape, can be written as svg:points sequence
1048                 const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0));
1049                 const ::rtl::OUString aPointString(basegfx::tools::exportToSvgPoints(aPolygon));
1050 
1051                 // write point array
1052                 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString);
1053 
1054                 // set name
1055                 eName = aPolygon.isClosed() ? XML_POLYGON : XML_POLYLINE;
1056             }
1057             else
1058             {
1059                 // complex polygon shape, write as svg:d
1060                 const ::rtl::OUString aPolygonString(
1061                     basegfx::tools::exportToSvgD(
1062                         aPolyPolygon,
1063                         true,       // bUseRelativeCoordinates
1064                         false,      // bDetectQuadraticBeziers: not used in old, but maybe activated now
1065                         true));     // bHandleRelativeNextPointCompatible
1066 
1067                 // write point array
1068                 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
1069             }
1070         }
1071 
1072         // write object, but after attributes are added since this call will
1073         // consume all of these added attributes and the destructor will close the
1074         // scope. Also before text is added; this may add sub-scopes as needed
1075         SvXMLElementExport aOBJ(
1076             mrExport,
1077             XML_NAMESPACE_DRAW,
1078             eName,
1079             bCreateNewline,
1080             sal_True);
1081 
1082         ImpExportDescription( xShape ); // #i68101#
1083         ImpExportEvents( xShape );
1084         ImpExportGluePoints( xShape );
1085         ImpExportText( xShape );
1086     }
1087 }
1088 
1089 //////////////////////////////////////////////////////////////////////////////
1090 
1091 void XMLShapeExport::ImpExportGraphicObjectShape(
1092     const uno::Reference< drawing::XShape >& xShape,
1093     XmlShapeType eShapeType,
1094     sal_Int32 nFeatures,
1095     awt::Point* pRefPoint )
1096 {
1097     const uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
1098     if ( xPropSet.is() )
1099     {
1100         sal_Bool bIsEmptyPresObj = sal_False;
1101         uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1102 
1103         // Transformation
1104         ImpExportNewTrans( xPropSet, nFeatures, pRefPoint );
1105 
1106         OUString sImageURL;
1107 
1108         if ( eShapeType == XmlShapeTypePresGraphicObjectShape )
1109             bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken( XML_PRESENTATION_GRAPHIC ) );
1110 
1111         sal_Bool bCreateNewline( ( nFeatures & SEF_EXPORT_NO_WS ) == 0 ); // #86116#/#92210#
1112         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_FRAME, bCreateNewline, sal_True );
1113 
1114         const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
1115 
1116         if ( !bIsEmptyPresObj || bSaveBackwardsCompatible )
1117         {
1118             if ( !bIsEmptyPresObj )
1119             {
1120                 OUString aReplacementUrl;
1121                 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("ReplacementGraphicURL"))) >>= aReplacementUrl;
1122 
1123                 // If there is no url, then then graphic is empty
1124                 if ( aReplacementUrl.getLength() )
1125                 {
1126                     const OUString aStr = mrExport.AddEmbeddedGraphicObject(aReplacementUrl);
1127 
1128                     if(aStr.getLength())
1129                     {
1130                         mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr);
1131                         mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1132                         mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1133                         mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1134 
1135                         // xlink:href for replacement, only written for Svg content
1136                         SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, sal_True, sal_True);
1137 
1138                         // optional office:binary-data
1139                         mrExport.AddEmbeddedGraphicObjectAsBase64(aReplacementUrl);
1140                     }
1141                 }
1142 
1143                 OUString aStreamURL;
1144                 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicStreamURL" ) ) ) >>= aStreamURL;
1145                 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ) ) >>= sImageURL;
1146 
1147                 OUString aResolveURL( sImageURL );
1148                 const rtl::OUString sPackageURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
1149 
1150                 // sj: trying to preserve the filename for embedded images which already have its stream inside the package
1151                 bool bIsEmbeddedImageWithExistingStreamInPackage = false;
1152                 if ( aStreamURL.match( sPackageURL, 0 ) )
1153                 {
1154                     bIsEmbeddedImageWithExistingStreamInPackage = true;
1155 
1156                     rtl::OUString sRequestedName( aStreamURL.copy( sPackageURL.getLength(), aStreamURL.getLength() - sPackageURL.getLength() ) );
1157                     sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1;
1158                     if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) )
1159                         sRequestedName = sRequestedName.copy( nLastIndex, sRequestedName.getLength() - nLastIndex );
1160                     nLastIndex = sRequestedName.lastIndexOf( '.' );
1161                     if ( nLastIndex >= 0 )
1162                         sRequestedName = sRequestedName.copy( 0, nLastIndex );
1163                     if ( sRequestedName.getLength() )
1164                     {
1165                         aResolveURL = aResolveURL.concat( OUString( RTL_CONSTASCII_USTRINGPARAM( "?requestedName=" ) ) );
1166                         aResolveURL = aResolveURL.concat( sRequestedName );
1167                     }
1168                 }
1169 
1170                 const OUString aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL );
1171                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
1172 
1173                 if ( !aStr.isEmpty() )
1174                 {
1175                     // apply possible changed stream URL to embedded image object
1176                     if ( bIsEmbeddedImageWithExistingStreamInPackage )
1177                     {
1178                         aStreamURL = sPackageURL;
1179                         if ( aStr[0] == '#' )
1180                         {
1181                             aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) );
1182                         }
1183                         else
1184                         {
1185                             aStreamURL = aStreamURL.concat( aStr );
1186                         }
1187 
1188                         uno::Any aAny;
1189                         aAny <<= aStreamURL;
1190                         xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicStreamURL" ) ), aAny );
1191                     }
1192 
1193                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1194                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1195                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1196                 }
1197             }
1198             else
1199             {
1200                 OUString aStr;
1201                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
1202                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1203                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1204                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1205             }
1206 
1207             {
1208                 SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, sal_True, sal_True );
1209 
1210                 if ( sImageURL.getLength() )
1211                 {
1212                     // optional office:binary-data
1213                     mrExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
1214                 }
1215                 if ( !bIsEmptyPresObj )
1216                     ImpExportText( xShape );
1217             }
1218         }
1219 
1220         ImpExportEvents( xShape );
1221         ImpExportGluePoints( xShape );
1222 
1223         // image map
1224         GetExport().GetImageMapExport().Export( xPropSet );
1225         ImpExportDescription( xShape ); // #i68101#
1226     }
1227 }
1228 
1229 //////////////////////////////////////////////////////////////////////////////
1230 
1231 void XMLShapeExport::ImpExportChartShape(
1232 	const uno::Reference< drawing::XShape >& xShape,
1233 	XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint,
1234     SvXMLAttributeList* pAttrList )
1235 {
1236 	ImpExportOLE2Shape( xShape, eShapeType, nFeatures, pRefPoint, pAttrList );
1237 }
1238 
1239 //////////////////////////////////////////////////////////////////////////////
1240 
1241 void XMLShapeExport::ImpExportControlShape(
1242 	const uno::Reference< drawing::XShape >& xShape,
1243 	XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1244 {
1245 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1246 	if(xPropSet.is())
1247 	{
1248 		// Transformation
1249 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1250 	}
1251 
1252 	uno::Reference< drawing::XControlShape > xControl( xShape, uno::UNO_QUERY );
1253 	DBG_ASSERT( xControl.is(), "Control shape is not supporting XControlShape" );
1254 	if( xControl.is() )
1255 	{
1256 		uno::Reference< beans::XPropertySet > xControlModel( xControl->getControl(), uno::UNO_QUERY );
1257 		DBG_ASSERT( xControlModel.is(), "Control shape has not XControlModel" );
1258 		if( xControlModel.is() )
1259 		{
1260 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONTROL, mrExport.GetFormExport()->getControlId( xControlModel ) );
1261 		}
1262 	}
1263 
1264 	sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1265 	SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONTROL, bCreateNewline, sal_True);
1266 
1267 	ImpExportDescription( xShape ); // #i68101#
1268 }
1269 
1270 //////////////////////////////////////////////////////////////////////////////
1271 
1272 void XMLShapeExport::ImpExportConnectorShape(
1273 	const uno::Reference< drawing::XShape >& xShape,
1274 	XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1275 {
1276 	uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
1277 
1278 	OUString aStr;
1279 	OUStringBuffer sStringBuffer;
1280 
1281 	// export connection kind
1282 	drawing::ConnectorType eType = drawing::ConnectorType_STANDARD;
1283 	uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")));
1284 	aAny >>= eType;
1285 
1286 	if( eType != drawing::ConnectorType_STANDARD )
1287 	{
1288 		SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap );
1289 		aStr = sStringBuffer.makeStringAndClear();
1290 		mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TYPE, aStr);
1291 	}
1292 
1293 	// export line skew
1294 	sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0;
1295 
1296 	aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")));
1297 	aAny >>= nDelta1;
1298 	aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")));
1299 	aAny >>= nDelta2;
1300 	aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")));
1301 	aAny >>= nDelta3;
1302 
1303 	if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 )
1304 	{
1305 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta1);
1306 		if( nDelta2 != 0 || nDelta3 != 0 )
1307 		{
1308 			const char aSpace = ' ';
1309 			sStringBuffer.appendAscii( &aSpace, 1 );
1310 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta2);
1311 			if( nDelta3 != 0 )
1312 			{
1313 				sStringBuffer.appendAscii( &aSpace, 1 );
1314 				mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta3);
1315 			}
1316 		}
1317 
1318 		aStr = sStringBuffer.makeStringAndClear();
1319 		mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LINE_SKEW, aStr);
1320 	}
1321 
1322 	// export start and end point
1323 	awt::Point aStart(0,0);
1324 	awt::Point aEnd(1,1);
1325 
1326     // --> OD 2004-08-09 #i36248# - Get <StartPositionInHoriL2R> and
1327     // <EndPositionInHoriL2R>, if they exist and if the document is exported
1328     // into the OpenOffice.org file format.
1329     // These properties only exist at service com::sun::star::text::Shape - the
1330     // Writer UNO service for shapes.
1331     // This code is needed, because the positioning attributes in the
1332     // OpenOffice.org file format are given in horizontal left-to-right layout
1333     // regardless the layout direction the shape is in. In the OASIS Open Office
1334     // file format the positioning attributes are correctly given in the layout
1335     // direction the shape is in. Thus, this code provides the conversion from
1336     // the OASIS Open Office file format to the OpenOffice.org file format.
1337     if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
1338          xProps->getPropertySetInfo()->hasPropertyByName(
1339             OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) &&
1340          xProps->getPropertySetInfo()->hasPropertyByName(
1341             OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) )
1342     {
1343         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) >>= aStart;
1344         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) >>= aEnd;
1345     }
1346     else
1347     {
1348         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) >>= aStart;
1349         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) >>= aEnd;
1350     }
1351     // <--
1352 
1353 	if( pRefPoint )
1354 	{
1355 		aStart.X -= pRefPoint->X;
1356 		aStart.Y -= pRefPoint->Y;
1357 		aEnd.X -= pRefPoint->X;
1358 		aEnd.Y -= pRefPoint->Y;
1359 	}
1360 
1361 	if( nFeatures & SEF_EXPORT_X )
1362 	{
1363 		// svg: x1
1364 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
1365 		aStr = sStringBuffer.makeStringAndClear();
1366 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
1367 	}
1368 	else
1369 	{
1370 		aEnd.X -= aStart.X;
1371 	}
1372 
1373 	if( nFeatures & SEF_EXPORT_Y )
1374 	{
1375 		// svg: y1
1376 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
1377 		aStr = sStringBuffer.makeStringAndClear();
1378 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
1379 	}
1380 	else
1381 	{
1382 		aEnd.Y -= aStart.Y;
1383 	}
1384 
1385 	// svg: x2
1386 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
1387 	aStr = sStringBuffer.makeStringAndClear();
1388 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
1389 
1390 	// svg: y2
1391 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
1392 	aStr = sStringBuffer.makeStringAndClear();
1393 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
1394 
1395 	// #i39320#
1396 	uno::Reference< uno::XInterface > xRefS;
1397 	uno::Reference< uno::XInterface > xRefE;
1398 
1399 	// export start connection
1400 	xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartShape") ) ) >>= xRefS;
1401 	if( xRefS.is() )
1402 	{
1403 		const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefS );
1404 		mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_SHAPE, rShapeId);
1405 
1406 		aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")) );
1407 		sal_Int32 nGluePointId = 0;
1408 		if( aAny >>= nGluePointId )
1409 		{
1410 			if( nGluePointId != -1 )
1411 			{
1412 				mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_GLUE_POINT, OUString::valueOf( nGluePointId ));
1413 			}
1414 		}
1415 	}
1416 
1417 	// export end connection
1418 	xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndShape")) ) >>= xRefE;
1419 	if( xRefE.is() )
1420 	{
1421 		const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefE );
1422 		mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_SHAPE, rShapeId);
1423 
1424 		aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")) );
1425 		sal_Int32 nGluePointId = 0;
1426 		if( aAny >>= nGluePointId )
1427 		{
1428 			if( nGluePointId != -1 )
1429 			{
1430 				mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_GLUE_POINT, OUString::valueOf( nGluePointId ));
1431 			}
1432 		}
1433 	}
1434 
1435     if( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ) ) >>= aAny )
1436     {
1437         // get PolygonBezier
1438         drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = (drawing::PolyPolygonBezierCoords*)aAny.getValue();
1439 
1440         if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
1441         {
1442             const basegfx::B2DPolyPolygon aPolyPolygon(
1443                 basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
1444                     *pSourcePolyPolygon));
1445             const ::rtl::OUString aPolygonString(
1446                 basegfx::tools::exportToSvgD(
1447                     aPolyPolygon,
1448                     true,           // bUseRelativeCoordinates
1449                     false,          // bDetectQuadraticBeziers: not used in old, but maybe activated now
1450                     true));         // bHandleRelativeNextPointCompatible
1451 
1452             // write point array
1453             mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
1454         }
1455     }
1456 
1457 	// write connector shape. Add Export later.
1458 	sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1459 	SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONNECTOR, bCreateNewline, sal_True);
1460 
1461 	ImpExportDescription( xShape ); // #i68101#
1462 	ImpExportEvents( xShape );
1463 	ImpExportGluePoints( xShape );
1464 	ImpExportText( xShape );
1465 }
1466 
1467 //////////////////////////////////////////////////////////////////////////////
1468 
1469 void XMLShapeExport::ImpExportMeasureShape(
1470 	const uno::Reference< drawing::XShape >& xShape,
1471 	XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1472 {
1473 	uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
1474 
1475 	OUString aStr;
1476 	OUStringBuffer sStringBuffer;
1477 
1478 	// export start and end point
1479 	awt::Point aStart(0,0);
1480 	awt::Point aEnd(1,1);
1481 
1482     // --> OD 2004-08-09 #i36248# - Get <StartPositionInHoriL2R> and
1483     // <EndPositionInHoriL2R>, if they exist and if the document is exported
1484     // into the OpenOffice.org file format.
1485     // These properties only exist at service com::sun::star::text::Shape - the
1486     // Writer UNO service for shapes.
1487     // This code is needed, because the positioning attributes in the
1488     // OpenOffice.org file format are given in horizontal left-to-right layout
1489     // regardless the layout direction the shape is in. In the OASIS Open Office
1490     // file format the positioning attributes are correctly given in the layout
1491     // direction the shape is in. Thus, this code provides the conversion from
1492     // the OASIS Open Office file format to the OpenOffice.org file format.
1493     if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
1494          xProps->getPropertySetInfo()->hasPropertyByName(
1495             OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) &&
1496          xProps->getPropertySetInfo()->hasPropertyByName(
1497             OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) )
1498     {
1499         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) >>= aStart;
1500         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) >>= aEnd;
1501     }
1502     else
1503     {
1504         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) >>= aStart;
1505         xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) >>= aEnd;
1506     }
1507     // <--
1508 
1509 	if( pRefPoint )
1510 	{
1511 		aStart.X -= pRefPoint->X;
1512 		aStart.Y -= pRefPoint->Y;
1513 		aEnd.X -= pRefPoint->X;
1514 		aEnd.Y -= pRefPoint->Y;
1515 	}
1516 
1517 	if( nFeatures & SEF_EXPORT_X )
1518 	{
1519 		// svg: x1
1520 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
1521 		aStr = sStringBuffer.makeStringAndClear();
1522 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
1523 	}
1524 	else
1525 	{
1526 		aEnd.X -= aStart.X;
1527 	}
1528 
1529 	if( nFeatures & SEF_EXPORT_Y )
1530 	{
1531 		// svg: y1
1532 		mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
1533 		aStr = sStringBuffer.makeStringAndClear();
1534 		mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
1535 	}
1536 	else
1537 	{
1538 		aEnd.Y -= aStart.Y;
1539 	}
1540 
1541 	// svg: x2
1542 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
1543 	aStr = sStringBuffer.makeStringAndClear();
1544 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
1545 
1546 	// svg: y2
1547 	mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
1548 	aStr = sStringBuffer.makeStringAndClear();
1549 	mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
1550 
1551 	// write measure shape
1552 	sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1553 	SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_MEASURE, bCreateNewline, sal_True);
1554 
1555 	ImpExportDescription( xShape ); // #i68101#
1556 	ImpExportEvents( xShape );
1557 	ImpExportGluePoints( xShape );
1558 
1559 	uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
1560 	if( xText.is() )
1561 		mrExport.GetTextParagraphExport()->exportText( xText );
1562 }
1563 
1564 //////////////////////////////////////////////////////////////////////////////
1565 
1566 void XMLShapeExport::ImpExportOLE2Shape(
1567 	const uno::Reference< drawing::XShape >& xShape,
1568 	XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */,
1569     SvXMLAttributeList* pAttrList /* = NULL */ )
1570 {
1571 	uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1572 	uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY);
1573 
1574 	DBG_ASSERT( xPropSet.is() && xNamed.is(), "ole shape is not implementing needed interfaces");
1575 	if(xPropSet.is() && xNamed.is())
1576 	{
1577 		// Transformation
1578 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1579 
1580 		sal_Bool bIsEmptyPresObj = sal_False;
1581 
1582 		// presentation settings
1583 		if(eShapeType == XmlShapeTypePresOLE2Shape)
1584 			bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_OBJECT) );
1585 		else if(eShapeType == XmlShapeTypePresChartShape)
1586 			bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_CHART) );
1587 		else if(eShapeType == XmlShapeTypePresSheetShape)
1588 			bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
1589 
1590 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1591 		sal_Bool bExportEmbedded(0 != (mrExport.getExportFlags() & EXPORT_EMBEDDED));
1592 		OUString sPersistName;
1593 		SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1594 								  XML_FRAME, bCreateNewline, sal_True );
1595 
1596 		const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
1597 
1598 		if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
1599 		{
1600             if (pAttrList)
1601             {
1602                 mrExport.AddAttributeList(pAttrList);
1603             }
1604 
1605 			OUString sClassId;
1606 			OUString sURL;
1607 			sal_Bool bInternal = false;
1608 			xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsInternal"))) >>= bInternal;
1609 
1610 			if( !bIsEmptyPresObj )
1611 			{
1612 
1613 				if ( bInternal )
1614 				{
1615 					// OOo internal links have no storage persistance, URL is stored in the XML file
1616 					// the result LinkURL is empty in case the object is not a link
1617 					xPropSet->getPropertyValue( OUString::createFromAscii( "LinkURL" ) ) >>= sURL;
1618 				}
1619 
1620 				xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ) ) >>= sPersistName;
1621 				if ( !sURL.getLength() )
1622 				{
1623 					if( sPersistName.getLength() )
1624 					{
1625 						sURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
1626 						sURL += sPersistName;
1627 					}
1628 				}
1629 
1630 				if( !bInternal )
1631 					xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) >>= sClassId;
1632 
1633 				if( sClassId.getLength() )
1634 					mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CLASS_ID, sClassId );
1635 				if(!bExportEmbedded)
1636 				{
1637 					// xlink:href
1638 					if( sURL.getLength() )
1639 					{
1640 						// #96717# in theorie, if we don't have a url we shouldn't even
1641 						// export this ole shape. But practical its to risky right now
1642 						// to change this so we better dispose this on load
1643 						sURL = mrExport.AddEmbeddedObject( sURL );
1644 
1645 						mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
1646 						mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1647 						mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1648 						mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1649 					}
1650 				}
1651 			}
1652 			else
1653 			{
1654 				// export empty href for empty placeholders to be valid odf
1655 				OUString sEmptyURL;
1656 
1657 				mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sEmptyURL );
1658 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1659 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1660 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1661 			}
1662 
1663 			enum XMLTokenEnum eElem = sClassId.getLength() ? XML_OBJECT_OLE : XML_OBJECT;
1664 			SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, eElem, sal_True, sal_True );
1665 
1666             // #i118485# Add text export, the draw OLE shape allows text now
1667             ImpExportText( xShape );
1668 
1669 			if(bExportEmbedded && !bIsEmptyPresObj)
1670 			{
1671 				// #100592#
1672 				if(bInternal)
1673 				{
1674 					// embedded XML
1675 					uno::Reference< lang::XComponent > xComp;
1676 					xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
1677 					DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
1678 					mrExport.ExportEmbeddedOwnObject( xComp );
1679 				}
1680 				else
1681 				{
1682 					// embed as Base64
1683 					// this is an alien object ( currently MSOLE is the only supported type of such objects )
1684 					// in case it is not an OASIS format the object should be asked to store replacement image if possible
1685 
1686 					::rtl::OUString sURLRequest( sURL );
1687     				if ( ( mrExport.getExportFlags() & EXPORT_OASIS ) == 0 )
1688 						sURLRequest += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "?oasis=false" ) );
1689 					mrExport.AddEmbeddedObjectAsBase64( sURLRequest );
1690 				}
1691 			}
1692 		}
1693 		if( !bIsEmptyPresObj )
1694 		{
1695 			OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
1696 			sURL += sPersistName;
1697 			if( !bExportEmbedded )
1698 			{
1699 				sURL = GetExport().AddEmbeddedObject( sURL );
1700 				mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
1701 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1702 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1703 				mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1704 			}
1705 
1706 			SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
1707 									  XML_IMAGE, sal_False, sal_True );
1708 
1709 			if( bExportEmbedded )
1710 				GetExport().AddEmbeddedObjectAsBase64( sURL );
1711 		}
1712 
1713         ImpExportEvents( xShape );
1714 		ImpExportGluePoints( xShape );
1715 		ImpExportDescription( xShape ); // #i68101#
1716 	}
1717 }
1718 
1719 //////////////////////////////////////////////////////////////////////////////
1720 
1721 void XMLShapeExport::ImpExportPageShape(
1722 	const uno::Reference< drawing::XShape >& xShape,
1723 	XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1724 {
1725 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1726 	if(xPropSet.is())
1727 	{
1728 		// #86163# Transformation
1729 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1730 
1731 		// export page number used for this page
1732 		uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1733 		const OUString aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
1734 		if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
1735 		{
1736 			sal_Int32 nPageNumber = 0;
1737 			xPropSet->getPropertyValue(aPageNumberStr) >>= nPageNumber;
1738 			if( nPageNumber )
1739 				mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_PAGE_NUMBER, OUString::valueOf(nPageNumber));
1740 		}
1741 
1742 		// a presentation page shape, normally used on notes pages only. If
1743 		// it is used not as presentation shape, it may have been created with
1744 		// copy-paste exchange between draw and impress (this IS possible...)
1745 		if(eShapeType == XmlShapeTypePresPageShape)
1746 		{
1747 			mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS,
1748                                  XML_PRESENTATION_PAGE);
1749 		}
1750 
1751 		// write Page shape
1752 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1753 		SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, bCreateNewline, sal_True);
1754 	}
1755 }
1756 
1757 //////////////////////////////////////////////////////////////////////////////
1758 
1759 void XMLShapeExport::ImpExportCaptionShape(
1760 	const uno::Reference< drawing::XShape >& xShape,
1761 	XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1762 {
1763 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1764 	if(xPropSet.is())
1765 	{
1766 		// Transformation
1767 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1768 
1769 		// evtl. corner radius?
1770 		sal_Int32 nCornerRadius(0L);
1771 		xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
1772 		if(nCornerRadius)
1773 		{
1774 			OUStringBuffer sStringBuffer;
1775 			mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
1776 			mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
1777 		}
1778 
1779 		awt::Point aCaptionPoint;
1780 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ) ) ) >>= aCaptionPoint;
1781 
1782 		mrExport.GetMM100UnitConverter().convertMeasure(msBuffer, aCaptionPoint.X);
1783 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_X, msBuffer.makeStringAndClear() );
1784 		mrExport.GetMM100UnitConverter().convertMeasure(msBuffer, aCaptionPoint.Y);
1785 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_Y, msBuffer.makeStringAndClear() );
1786 
1787 		// write Caption shape. Add export later.
1788 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1789 		sal_Bool bAnnotation( (nFeatures & SEF_EXPORT_ANNOTATION) == SEF_EXPORT_ANNOTATION );
1790 
1791         SvXMLElementExport aObj( mrExport,
1792 								 (bAnnotation ? XML_NAMESPACE_OFFICE
1793 								 			  : XML_NAMESPACE_DRAW),
1794 								 (bAnnotation ?	XML_ANNOTATION : XML_CAPTION),
1795 								 bCreateNewline, sal_True );
1796 
1797 		ImpExportDescription( xShape ); // #i68101#
1798 		ImpExportEvents( xShape );
1799 		ImpExportGluePoints( xShape );
1800 		if( bAnnotation )
1801 			mrExport.exportAnnotationMeta( xShape );
1802 		ImpExportText( xShape );
1803 	}
1804 }
1805 
1806 //////////////////////////////////////////////////////////////////////////////
1807 
1808 void XMLShapeExport::ImpExportFrameShape(
1809 	const uno::Reference< drawing::XShape >& xShape,
1810 	XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1811 {
1812 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1813 	if(xPropSet.is())
1814 	{
1815 		// Transformation
1816 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1817 
1818 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1819 		SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1820 								  XML_FRAME, bCreateNewline, sal_True );
1821 
1822 		// export frame url
1823 		OUString aStr;
1824 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ) ) >>= aStr;
1825         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1826         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1827         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1828         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1829 
1830 		// export name
1831 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ) ) >>= aStr;
1832 		if( aStr.getLength() )
1833 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
1834 
1835 		// write floating frame
1836 		{
1837 			SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_FLOATING_FRAME, sal_True, sal_True);
1838 		}
1839 	}
1840 }
1841 
1842 //////////////////////////////////////////////////////////////////////////////
1843 
1844 void XMLShapeExport::ImpExportAppletShape(
1845 	const uno::Reference< drawing::XShape >& xShape,
1846 	XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1847 {
1848 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1849 	if(xPropSet.is())
1850 	{
1851 		// Transformation
1852 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1853 
1854 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1855 		SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1856 								  XML_FRAME, bCreateNewline, sal_True );
1857 
1858 		// export frame url
1859 		OUString aStr;
1860 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ) ) >>= aStr;
1861         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1862         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1863         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1864         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1865 
1866 		// export draw:applet-name
1867 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ) ) >>= aStr;
1868 		if( aStr.getLength() )
1869 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
1870 
1871 		// export draw:code
1872 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ) ) >>= aStr;
1873 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
1874 
1875 		// export draw:may-script
1876 		sal_Bool bIsScript = false;
1877 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ) ) >>= bIsScript;
1878 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bIsScript ? XML_TRUE : XML_FALSE );
1879 
1880 		{
1881 			// write applet
1882 			SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_APPLET, sal_True, sal_True);
1883 
1884 			// export parameters
1885 			uno::Sequence< beans::PropertyValue > aCommands;
1886 			xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ) ) >>= aCommands;
1887 			const sal_Int32 nCount = aCommands.getLength();
1888 			for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1889 			{
1890 				aCommands[nIndex].Value >>= aStr;
1891 				mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
1892 				mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
1893 				SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
1894 			}
1895 		}
1896 	}
1897 }
1898 
1899 //////////////////////////////////////////////////////////////////////////////
1900 
1901 void XMLShapeExport::ImpExportPluginShape(
1902 	const uno::Reference< drawing::XShape >& xShape,
1903 	XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1904 {
1905 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1906 	if(xPropSet.is())
1907 	{
1908 		// Transformation
1909 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1910 
1911 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1912 		SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1913 								  XML_FRAME, bCreateNewline, sal_True );
1914 
1915 		// export plugin url
1916 		OUString aStr;
1917 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ) ) >>= aStr;
1918         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1919         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1920         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1921         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1922 
1923 
1924 		// export mime-type
1925 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ) ) >>= aStr;
1926 		if(aStr.getLength())
1927 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
1928 
1929 		{
1930 			// write plugin
1931 			SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, sal_True, sal_True);
1932 
1933 			// export parameters
1934 			uno::Sequence< beans::PropertyValue > aCommands;
1935 			xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ) ) >>= aCommands;
1936 			const sal_Int32 nCount = aCommands.getLength();
1937 			for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1938 			{
1939 				aCommands[nIndex].Value >>= aStr;
1940 				mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
1941 				mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
1942 				SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
1943 			}
1944 		}
1945 	}
1946 }
1947 
1948 //////////////////////////////////////////////////////////////////////////////
1949 
1950 void XMLShapeExport::ImpExportMediaShape(
1951 	const uno::Reference< drawing::XShape >& xShape,
1952 	XmlShapeType eShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1953 {
1954 	const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1955 	if(xPropSet.is())
1956 	{
1957 		// Transformation
1958 		ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1959 
1960 		if(eShapeType == XmlShapeTypePresMediaShape)
1961 			ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_OBJECT) );
1962 
1963 		sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1964 		SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1965 								  XML_FRAME, bCreateNewline, sal_True );
1966 
1967 		// export media url
1968 		OUString aMediaURL;
1969 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ) ) >>= aMediaURL;
1970         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( aMediaURL ) );
1971         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1972         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1973         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1974 
1975 		// export mime-type
1976 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.media" ) ) );
1977 
1978 		// write plugin
1979 		SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, !( nFeatures & SEF_EXPORT_NO_WS ), sal_True);
1980 
1981 		// export parameters
1982 		const OUString aFalseStr( RTL_CONSTASCII_USTRINGPARAM( "false" ) ), aTrueStr( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
1983 
1984 		sal_Bool bLoop = false;
1985 		const OUString aLoopStr( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) );
1986 		xPropSet->getPropertyValue( aLoopStr ) >>= bLoop;
1987 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aLoopStr );
1988 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bLoop ? aTrueStr : aFalseStr );
1989 		delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
1990 
1991 		sal_Bool bMute = false;
1992 		const OUString aMuteStr( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) );
1993 		xPropSet->getPropertyValue( aMuteStr ) >>= bMute;
1994 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aMuteStr );
1995 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bMute ? aTrueStr : aFalseStr );
1996 		delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
1997 
1998 		sal_Int16 nVolumeDB = 0;
1999 		const OUString aVolumeDBStr( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) );
2000 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ) ) >>= nVolumeDB;
2001 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aVolumeDBStr );
2002 		mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, OUString::valueOf( static_cast< sal_Int32 >( nVolumeDB ) ) );
2003 		delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
2004 
2005 		media::ZoomLevel eZoom;
2006 		const OUString aZoomStr( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) );
2007 		OUString aZoomValue;
2008 		xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ) ) >>= eZoom;
2009 		switch( eZoom )
2010 		{
2011 			case( media::ZoomLevel_ZOOM_1_TO_4 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "25%" ) ); break;
2012 			case( media::ZoomLevel_ZOOM_1_TO_2 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "50%" ) ); break;
2013 			case( media::ZoomLevel_ORIGINAL ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "100%" ) ); break;
2014 			case( media::ZoomLevel_ZOOM_2_TO_1 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "200%" ) ); break;
2015 			case( media::ZoomLevel_ZOOM_4_TO_1 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "400%" ) ); break;
2016 		    case( media::ZoomLevel_FIT_TO_WINDOW ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fit" ) ); break;
2017 		    case( media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fixedfit" ) ); break;
2018 		    case( media::ZoomLevel_FULLSCREEN ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fullscreen" ) ); break;
2019 
2020 			default:
2021 			break;
2022 		}
2023 
2024 		if( aZoomValue.getLength() )
2025 		{
2026 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aZoomStr );
2027 			mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aZoomValue );
2028 			delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
2029 		}
2030 	}
2031 }
2032