merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / draw / shapeexport2.cxx
blob1386982c5284dfd30e3ac4f41010a520b68b854e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapeexport2.cxx,v $
10 * $Revision: 1.66 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "unointerfacetouniqueidentifiermapper.hxx"
34 #include <com/sun/star/text/XText.hpp>
35 #include <com/sun/star/container/XNamed.hpp>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/chart/XChartDocument.hpp>
38 #include <com/sun/star/drawing/CircleKind.hpp>
39 #include <com/sun/star/drawing/ConnectorType.hpp>
40 #include <com/sun/star/drawing/XControlShape.hpp>
41 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
42 #include <com/sun/star/document/XEventsSupplier.hpp>
43 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
44 #include <com/sun/star/media/ZoomLevel.hpp>
45 #include "anim.hxx"
47 #ifndef _XMLOFF_SHAPEEXPORT_HXX
48 #include <xmloff/shapeexport.hxx>
49 #endif
50 #include "sdpropls.hxx"
51 #include <tools/debug.hxx>
52 #include <tools/urlobj.hxx>
53 #include <rtl/ustrbuf.hxx>
54 #include <xmloff/xmlexp.hxx>
55 #include <xmloff/xmluconv.hxx>
56 #include "XMLImageMapExport.hxx"
57 #include "xexptran.hxx"
58 #include <vcl/salbtype.hxx> // FRound
59 #include <xmloff/xmltoken.hxx>
60 #include <xmloff/nmspmap.hxx>
62 #include "xmlnmspe.hxx"
63 #include <basegfx/matrix/b2dhommatrix.hxx>
64 #include <basegfx/tuple/b2dtuple.hxx>
66 using ::rtl::OUString;
67 using ::rtl::OUStringBuffer;
69 using namespace ::com::sun::star;
70 using namespace ::xmloff::token;
73 //////////////////////////////////////////////////////////////////////////////
75 void XMLShapeExport::ImpExportNewTrans(const uno::Reference< beans::XPropertySet >& xPropSet,
76 sal_Int32 nFeatures, awt::Point* pRefPoint)
78 // get matrix
79 ::basegfx::B2DHomMatrix aMatrix;
80 ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
82 // decompose and correct abour pRefPoint
83 ::basegfx::B2DTuple aTRScale;
84 double fTRShear(0.0);
85 double fTRRotate(0.0);
86 ::basegfx::B2DTuple aTRTranslate;
87 ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
89 // use features and write
90 ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
93 void XMLShapeExport::ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix,
94 const uno::Reference< beans::XPropertySet >& xPropSet)
96 // --> OD 2004-08-09 #i28749# - Get <TransformationInHoriL2R>, if it exist
97 // and if the document is exported into the OpenOffice.org file format.
98 // This property only exists at service com::sun::star::text::Shape - the
99 // Writer UNO service for shapes.
100 // This code is needed, because the positioning attributes in the
101 // OpenOffice.org file format are given in horizontal left-to-right layout
102 // regardless the layout direction the shape is in. In the OASIS Open Office
103 // file format the positioning attributes are correctly given in the layout
104 // direction the shape is in. Thus, this code provides the conversion from
105 // the OASIS Open Office file format to the OpenOffice.org file format.
106 uno::Any aAny;
107 if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
108 xPropSet->getPropertySetInfo()->hasPropertyByName(
109 OUString(RTL_CONSTASCII_USTRINGPARAM("TransformationInHoriL2R"))) )
111 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TransformationInHoriL2R")));
113 else
115 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")));
117 // <--
118 drawing::HomogenMatrix3 aMatrix;
119 aAny >>= aMatrix;
121 rMatrix.set(0, 0, aMatrix.Line1.Column1);
122 rMatrix.set(0, 1, aMatrix.Line1.Column2);
123 rMatrix.set(0, 2, aMatrix.Line1.Column3);
124 rMatrix.set(1, 0, aMatrix.Line2.Column1);
125 rMatrix.set(1, 1, aMatrix.Line2.Column2);
126 rMatrix.set(1, 2, aMatrix.Line2.Column3);
127 rMatrix.set(2, 0, aMatrix.Line3.Column1);
128 rMatrix.set(2, 1, aMatrix.Line3.Column2);
129 rMatrix.set(2, 2, aMatrix.Line3.Column3);
132 void XMLShapeExport::ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMatrix, ::basegfx::B2DTuple& rTRScale,
133 double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, com::sun::star::awt::Point* pRefPoint)
135 // decompose matrix
136 rMatrix.decompose(rTRScale, rTRTranslate, fTRRotate, fTRShear);
138 // correct translation about pRefPoint
139 if(pRefPoint)
141 rTRTranslate -= ::basegfx::B2DTuple(pRefPoint->X, pRefPoint->Y);
145 void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTRScale, double fTRShear,
146 double fTRRotate, ::basegfx::B2DTuple& rTRTranslate, const sal_Int32 nFeatures)
148 // allways write Size (rTRScale) since this statement carries the union
149 // of the object
150 OUString aStr;
151 OUStringBuffer sStringBuffer;
152 ::basegfx::B2DTuple aTRScale(rTRScale);
154 // svg: width
155 if(!(nFeatures & SEF_EXPORT_WIDTH))
157 aTRScale.setX(1.0);
159 else
161 if( aTRScale.getX() > 0.0 )
162 aTRScale.setX(aTRScale.getX() - 1.0);
163 else if( aTRScale.getX() < 0.0 )
164 aTRScale.setX(aTRScale.getX() + 1.0);
167 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getX()));
168 aStr = sStringBuffer.makeStringAndClear();
169 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
171 // svg: height
172 if(!(nFeatures & SEF_EXPORT_HEIGHT))
174 aTRScale.setY(1.0);
176 else
178 if( aTRScale.getY() > 0.0 )
179 aTRScale.setY(aTRScale.getY() - 1.0);
180 else if( aTRScale.getY() < 0.0 )
181 aTRScale.setY(aTRScale.getY() + 1.0);
184 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(aTRScale.getY()));
185 aStr = sStringBuffer.makeStringAndClear();
186 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
188 // decide if transformation is neccessary
189 BOOL bTransformationIsNeccessary(fTRShear != 0.0 || fTRRotate != 0.0);
191 if(bTransformationIsNeccessary)
193 // write transformation, but WITHOUT scale which is exported as size above
194 SdXMLImExTransform2D aTransform;
196 aTransform.AddSkewX(atan(fTRShear));
198 // #i78696#
199 // fTRRotate is mathematically correct, but due to the error
200 // we export/import it mirrored. Since the API implementation is fixed and
201 // uses the correctly oriented angle, it is necessary for compatibility to
202 // mirror the angle here to stay at the old behaviour. There is a follow-up
203 // task (#i78698#) to fix this in the next ODF FileFormat version
204 aTransform.AddRotate(-fTRRotate);
206 aTransform.AddTranslate(rTRTranslate);
208 // does transformation need to be exported?
209 if(aTransform.NeedsAction())
210 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
212 else
214 // no shear, no rotate; just add object position to export and we are done
215 if(nFeatures & SEF_EXPORT_X)
217 // svg: x
218 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getX()));
219 aStr = sStringBuffer.makeStringAndClear();
220 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
223 if(nFeatures & SEF_EXPORT_Y)
225 // svg: y
226 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, FRound(rTRTranslate.getY()));
227 aStr = sStringBuffer.makeStringAndClear();
228 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
233 //////////////////////////////////////////////////////////////////////////////
235 sal_Bool XMLShapeExport::ImpExportPresentationAttributes( const uno::Reference< beans::XPropertySet >& xPropSet, const rtl::OUString& rClass )
237 sal_Bool bIsEmpty = sal_False;
239 OUStringBuffer sStringBuffer;
241 // write presentation class entry
242 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS, rClass);
244 if( xPropSet.is() )
246 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
248 sal_Bool bTemp = false;
250 // is empty pes shape?
251 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
253 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))) >>= bIsEmpty;
254 if( bIsEmpty )
255 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, XML_TRUE);
258 // is user-transformed?
259 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))))
261 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))) >>= bTemp;
262 if(!bTemp)
263 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_USER_TRANSFORMED, XML_TRUE);
267 return bIsEmpty;
270 //////////////////////////////////////////////////////////////////////////////
272 void XMLShapeExport::ImpExportText( const uno::Reference< drawing::XShape >& xShape )
274 uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
275 if( xText.is() )
277 uno::Reference< container::XEnumerationAccess > xEnumAccess( xShape, uno::UNO_QUERY );
278 if( xEnumAccess.is() && xEnumAccess->hasElements() )
279 mrExport.GetTextParagraphExport()->exportText( xText );
283 //////////////////////////////////////////////////////////////////////////////
284 #include <com/sun/star/presentation/ClickAction.hpp>
285 #include <com/sun/star/presentation/AnimationSpeed.hpp>
287 namespace {
289 const sal_Int32 FOUND_CLICKACTION = 0x00000001;
290 const sal_Int32 FOUND_BOOKMARK = 0x00000002;
291 const sal_Int32 FOUND_EFFECT = 0x00000004;
292 const sal_Int32 FOUND_PLAYFULL = 0x00000008;
293 const sal_Int32 FOUND_VERB = 0x00000010;
294 const sal_Int32 FOUND_SOUNDURL = 0x00000020;
295 const sal_Int32 FOUND_SPEED = 0x00000040;
296 const sal_Int32 FOUND_CLICKEVENTTYPE = 0x00000080;
297 const sal_Int32 FOUND_MACRO = 0x00000100;
298 const sal_Int32 FOUND_LIBRARY = 0x00000200;
299 const sal_Int32 FOUND_ACTIONEVENTTYPE = 0x00000400;
301 } // namespace
303 void XMLShapeExport::ImpExportEvents( const uno::Reference< drawing::XShape >& xShape )
305 uno::Reference< document::XEventsSupplier > xEventsSupplier( xShape, uno::UNO_QUERY );
306 if( !xEventsSupplier.is() )
307 return;
309 uno::Reference< container::XNameAccess > xEvents( xEventsSupplier->getEvents(), uno::UNO_QUERY );
310 DBG_ASSERT( xEvents.is(), "XEventsSupplier::getEvents() returned NULL" );
311 if( !xEvents.is() )
312 return;
314 sal_Int32 nFound = 0;
316 // extract properties from "OnClick" event --------------------------------
318 OUString aClickEventType;
319 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
320 presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
321 presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_SLOW;
322 OUString aStrSoundURL;
323 sal_Bool bPlayFull = false;
324 sal_Int32 nVerb = 0;
325 OUString aStrMacro;
326 OUString aStrLibrary;
327 OUString aStrBookmark;
329 uno::Sequence< beans::PropertyValue > aClickProperties;
330 if( xEvents->hasByName( msOnClick ) && (xEvents->getByName( msOnClick ) >>= aClickProperties) )
332 const beans::PropertyValue* pProperty = aClickProperties.getConstArray();
333 const beans::PropertyValue* pPropertyEnd = pProperty + aClickProperties.getLength();
334 for( ; pProperty != pPropertyEnd; ++pProperty )
336 if( ( ( nFound & FOUND_CLICKEVENTTYPE ) == 0 ) && pProperty->Name == msEventType )
338 if( pProperty->Value >>= aClickEventType )
339 nFound |= FOUND_CLICKEVENTTYPE;
341 else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperty->Name == msClickAction )
343 if( pProperty->Value >>= eClickAction )
344 nFound |= FOUND_CLICKACTION;
346 else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperty->Name == msMacroName || pProperty->Name == msScript ) )
348 if( pProperty->Value >>= aStrMacro )
349 nFound |= FOUND_MACRO;
351 else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperty->Name == msLibrary )
353 if( pProperty->Value >>= aStrLibrary )
354 nFound |= FOUND_LIBRARY;
356 else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperty->Name == msEffect )
358 if( pProperty->Value >>= eEffect )
359 nFound |= FOUND_EFFECT;
361 else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperty->Name == msBookmark )
363 if( pProperty->Value >>= aStrBookmark )
364 nFound |= FOUND_BOOKMARK;
366 else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperty->Name == msSpeed )
368 if( pProperty->Value >>= eSpeed )
369 nFound |= FOUND_SPEED;
371 else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperty->Name == msSoundURL )
373 if( pProperty->Value >>= aStrSoundURL )
374 nFound |= FOUND_SOUNDURL;
376 else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperty->Name == msPlayFull )
378 if( pProperty->Value >>= bPlayFull )
379 nFound |= FOUND_PLAYFULL;
381 else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperty->Name == msVerb )
383 if( pProperty->Value >>= nVerb )
384 nFound |= FOUND_VERB;
389 // create the XML elements
391 if( aClickEventType == msPresentation )
393 if( ((nFound & FOUND_CLICKACTION) == 0) || (eClickAction == presentation::ClickAction_NONE) )
394 return;
396 SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
398 enum XMLTokenEnum eStrAction;
400 switch( eClickAction )
402 case presentation::ClickAction_PREVPAGE: eStrAction = XML_PREVIOUS_PAGE; break;
403 case presentation::ClickAction_NEXTPAGE: eStrAction = XML_NEXT_PAGE; break;
404 case presentation::ClickAction_FIRSTPAGE: eStrAction = XML_FIRST_PAGE; break;
405 case presentation::ClickAction_LASTPAGE: eStrAction = XML_LAST_PAGE; break;
406 case presentation::ClickAction_INVISIBLE: eStrAction = XML_HIDE; break;
407 case presentation::ClickAction_STOPPRESENTATION:eStrAction = XML_STOP; break;
408 case presentation::ClickAction_PROGRAM: eStrAction = XML_EXECUTE; break;
409 case presentation::ClickAction_BOOKMARK: eStrAction = XML_SHOW; break;
410 case presentation::ClickAction_DOCUMENT: eStrAction = XML_SHOW; break;
411 case presentation::ClickAction_MACRO: eStrAction = XML_EXECUTE_MACRO; break;
412 case presentation::ClickAction_VERB: eStrAction = XML_VERB; break;
413 case presentation::ClickAction_VANISH: eStrAction = XML_FADE_OUT; break;
414 case presentation::ClickAction_SOUND: eStrAction = XML_SOUND; break;
415 default:
416 DBG_ERROR( "unknown presentation::ClickAction found!" );
417 eStrAction = XML_UNKNOWN;
420 OUString aEventQName(
421 mrExport.GetNamespaceMap().GetQNameByKey(
422 XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
423 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
424 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_ACTION, eStrAction );
426 if( eClickAction == presentation::ClickAction_VANISH )
428 if( nFound & FOUND_EFFECT )
430 XMLEffect eKind;
431 XMLEffectDirection eDirection;
432 sal_Int16 nStartScale;
433 sal_Bool bIn;
435 SdXMLImplSetEffect( eEffect, eKind, eDirection, nStartScale, bIn );
437 if( eKind != EK_none )
439 SvXMLUnitConverter::convertEnum( msBuffer, eKind, aXML_AnimationEffect_EnumMap );
440 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, msBuffer.makeStringAndClear() );
443 if( eDirection != ED_none )
445 SvXMLUnitConverter::convertEnum( msBuffer, eDirection, aXML_AnimationDirection_EnumMap );
446 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, msBuffer.makeStringAndClear() );
449 if( nStartScale != -1 )
451 SvXMLUnitConverter::convertPercent( msBuffer, nStartScale );
452 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, msBuffer.makeStringAndClear() );
456 if( nFound & FOUND_SPEED && eEffect != presentation::AnimationEffect_NONE )
458 if( eSpeed != presentation::AnimationSpeed_MEDIUM )
460 SvXMLUnitConverter::convertEnum( msBuffer, eSpeed, aXML_AnimationSpeed_EnumMap );
461 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, msBuffer.makeStringAndClear() );
466 if( eClickAction == presentation::ClickAction_PROGRAM ||
467 eClickAction == presentation::ClickAction_BOOKMARK ||
468 eClickAction == presentation::ClickAction_DOCUMENT )
470 if( eClickAction == presentation::ClickAction_BOOKMARK )
471 msBuffer.append( sal_Unicode('#') );
473 msBuffer.append( aStrBookmark );
474 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(msBuffer.makeStringAndClear()) );
475 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
476 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
477 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
480 if( ( nFound & FOUND_VERB ) && eClickAction == presentation::ClickAction_VERB )
482 msBuffer.append( nVerb );
483 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_VERB, msBuffer.makeStringAndClear());
486 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_PRESENTATION, XML_EVENT_LISTENER, sal_True, sal_True);
488 if( eClickAction == presentation::ClickAction_VANISH || eClickAction == presentation::ClickAction_SOUND )
490 if( ( nFound & FOUND_SOUNDURL ) && aStrSoundURL.getLength() != 0 )
492 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStrSoundURL) );
493 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
494 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
495 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
496 if( nFound & FOUND_PLAYFULL && bPlayFull )
497 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
499 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True );
503 else if( aClickEventType == msStarBasic )
505 if( nFound & FOUND_MACRO )
507 SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
509 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE,
510 mrExport.GetNamespaceMap().GetQNameByKey(
511 XML_NAMESPACE_OOO,
512 OUString( RTL_CONSTASCII_USTRINGPARAM(
513 "starbasic" ) ) ) );
514 OUString aEventQName(
515 mrExport.GetNamespaceMap().GetQNameByKey(
516 XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
517 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
519 if( nFound & FOUND_LIBRARY )
521 OUString sLocation( GetXMLToken(
522 (aStrLibrary.equalsIgnoreAsciiCaseAscii("StarOffice") ||
523 aStrLibrary.equalsIgnoreAsciiCaseAscii("application") ) ? XML_APPLICATION
524 : XML_DOCUMENT ) );
525 OUStringBuffer sTmp( sLocation.getLength() + aStrMacro.getLength() + 1 );
526 sTmp = sLocation;
527 sTmp.append( sal_Unicode( ':' ) );
528 sTmp.append( aStrMacro );
529 mrExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME,
530 sTmp.makeStringAndClear());
532 else
534 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, aStrMacro );
537 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, sal_True, sal_True);
540 else if( aClickEventType == msScript )
542 if( nFound & FOUND_MACRO )
544 SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, sal_True, sal_True);
545 if ( nFound & FOUND_MACRO )
547 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, mrExport.GetNamespaceMap().GetQNameByKey(
548 XML_NAMESPACE_OOO, GetXMLToken(XML_SCRIPT) ) );
549 OUString aEventQName(
550 mrExport.GetNamespaceMap().GetQNameByKey(
551 XML_NAMESPACE_DOM, OUString( RTL_CONSTASCII_USTRINGPARAM( "click" ) ) ) );
552 mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
553 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStrMacro );
555 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, sal_True, sal_True);
561 //////////////////////////////////////////////////////////////////////////////
563 /** #i68101# export shape Title and Description */
564 void XMLShapeExport::ImpExportDescription( const uno::Reference< drawing::XShape >& xShape )
568 OUString aTitle;
569 OUString aDescription;
571 uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW );
572 xProps->getPropertyValue( OUString::createFromAscii( "Title" ) ) >>= aTitle;
573 xProps->getPropertyValue( OUString::createFromAscii( "Description" ) ) >>= aDescription;
575 if(aTitle.getLength())
577 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_TITLE, sal_True, sal_False);
578 mrExport.Characters( aTitle );
581 if(aDescription.getLength())
583 SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_DESC, sal_True, sal_False );
584 mrExport.Characters( aDescription );
587 catch( uno::Exception& )
589 DBG_ERROR( "could not export Title and/or Description for shape!" );
593 //////////////////////////////////////////////////////////////////////////////
595 void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
597 uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
598 if(xShapes.is() && xShapes->getCount())
600 // write group shape
601 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
602 SvXMLElementExport aPGR(mrExport, XML_NAMESPACE_DRAW, XML_G, bCreateNewline, sal_True);
604 ImpExportDescription( xShape ); // #i68101#
605 ImpExportEvents( xShape );
606 ImpExportGluePoints( xShape );
608 // #89764# if export of position is supressed for group shape,
609 // positions of contained objects should be written relative to
610 // the upper left edge of the group.
611 awt::Point aUpperLeft;
613 if(!(nFeatures & SEF_EXPORT_POSITION))
615 nFeatures |= SEF_EXPORT_POSITION;
616 aUpperLeft = xShape->getPosition();
617 pRefPoint = &aUpperLeft;
620 // write members
621 exportShapes( xShapes, nFeatures, pRefPoint );
625 //////////////////////////////////////////////////////////////////////////////
627 void XMLShapeExport::ImpExportTextBoxShape(
628 const uno::Reference< drawing::XShape >& xShape,
629 XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
631 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
632 if(xPropSet.is())
634 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
636 // presentation attribute (if presentation)
637 sal_Bool bIsPresShape(FALSE);
638 sal_Bool bIsEmptyPresObj(FALSE);
639 OUString aStr;
641 switch(eShapeType)
643 case XmlShapeTypePresSubtitleShape:
645 aStr = GetXMLToken(XML_PRESENTATION_SUBTITLE);
646 bIsPresShape = TRUE;
647 break;
649 case XmlShapeTypePresTitleTextShape:
651 aStr = GetXMLToken(XML_PRESENTATION_TITLE);
652 bIsPresShape = TRUE;
653 break;
655 case XmlShapeTypePresOutlinerShape:
657 aStr = GetXMLToken(XML_PRESENTATION_OUTLINE);
658 bIsPresShape = TRUE;
659 break;
661 case XmlShapeTypePresNotesShape:
663 aStr = GetXMLToken(XML_PRESENTATION_NOTES);
664 bIsPresShape = TRUE;
665 break;
667 case XmlShapeTypePresHeaderShape:
669 aStr = GetXMLToken(XML_HEADER);
670 bIsPresShape = TRUE;
671 break;
673 case XmlShapeTypePresFooterShape:
675 aStr = GetXMLToken(XML_FOOTER);
676 bIsPresShape = TRUE;
677 break;
679 case XmlShapeTypePresSlideNumberShape:
681 aStr = GetXMLToken(XML_PAGE_NUMBER);
682 bIsPresShape = TRUE;
683 break;
685 case XmlShapeTypePresDateTimeShape:
687 aStr = GetXMLToken(XML_DATE_TIME);
688 bIsPresShape = TRUE;
689 break;
691 default:
692 break;
695 // Transformation
696 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
698 if(bIsPresShape)
699 bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, aStr );
702 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
703 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
704 XML_FRAME, bCreateNewline, sal_True );
706 // evtl. corner radius?
707 sal_Int32 nCornerRadius(0L);
708 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
709 if(nCornerRadius)
711 OUStringBuffer sStringBuffer;
712 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
713 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
717 // write text-box
718 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_TEXT_BOX, sal_True, sal_True);
719 if(!bIsEmptyPresObj)
720 ImpExportText( xShape );
723 ImpExportDescription( xShape ); // #i68101#
724 ImpExportEvents( xShape );
725 ImpExportGluePoints( xShape );
729 //////////////////////////////////////////////////////////////////////////////
731 void XMLShapeExport::ImpExportRectangleShape(
732 const uno::Reference< drawing::XShape >& xShape,
733 XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
735 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
736 if(xPropSet.is())
738 // Transformation
739 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
741 // evtl. corner radius?
742 sal_Int32 nCornerRadius(0L);
743 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
744 if(nCornerRadius)
746 OUStringBuffer sStringBuffer;
747 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
748 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
751 // write rectangle
752 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
753 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_RECT, bCreateNewline, sal_True);
755 ImpExportDescription( xShape ); // #i68101#
756 ImpExportEvents( xShape );
757 ImpExportGluePoints( xShape );
758 ImpExportText( xShape );
762 //////////////////////////////////////////////////////////////////////////////
764 void XMLShapeExport::ImpExportLineShape(
765 const uno::Reference< drawing::XShape >& xShape,
766 XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
768 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
769 if(xPropSet.is())
771 OUString aStr;
772 OUStringBuffer sStringBuffer;
773 awt::Point aStart(0,0);
774 awt::Point aEnd(1,1);
776 // #85920# use 'Geometry' to get the points of the line
777 // since this slot take anchor pos into account.
779 // get matrix
780 ::basegfx::B2DHomMatrix aMatrix;
781 ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
783 // decompose and correct about pRefPoint
784 ::basegfx::B2DTuple aTRScale;
785 double fTRShear(0.0);
786 double fTRRotate(0.0);
787 ::basegfx::B2DTuple aTRTranslate;
788 ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
790 // create base position
791 awt::Point aBasePosition(FRound(aTRTranslate.getX()), FRound(aTRTranslate.getY()));
793 // get the two points
794 uno::Any aAny(xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))));
795 drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue();
797 if(pSourcePolyPolygon)
799 drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
800 if(pOuterSequence)
802 drawing::PointSequence* pInnerSequence = pOuterSequence++;
803 if(pInnerSequence)
805 awt::Point* pArray = pInnerSequence->getArray();
806 if(pArray)
808 if(pInnerSequence->getLength() > 0)
810 aStart = awt::Point(
811 pArray->X + aBasePosition.X,
812 pArray->Y + aBasePosition.Y);
813 pArray++;
816 if(pInnerSequence->getLength() > 1)
818 aEnd = awt::Point(
819 pArray->X + aBasePosition.X,
820 pArray->Y + aBasePosition.Y);
827 if( nFeatures & SEF_EXPORT_X )
829 // svg: x1
830 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
831 aStr = sStringBuffer.makeStringAndClear();
832 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
834 else
836 aEnd.X -= aStart.X;
839 if( nFeatures & SEF_EXPORT_Y )
841 // svg: y1
842 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
843 aStr = sStringBuffer.makeStringAndClear();
844 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
846 else
848 aEnd.Y -= aStart.Y;
851 // svg: x2
852 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
853 aStr = sStringBuffer.makeStringAndClear();
854 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
856 // svg: y2
857 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
858 aStr = sStringBuffer.makeStringAndClear();
859 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
861 // write line
862 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
863 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_LINE, bCreateNewline, sal_True);
865 ImpExportDescription( xShape ); // #i68101#
866 ImpExportEvents( xShape );
867 ImpExportGluePoints( xShape );
868 ImpExportText( xShape );
872 //////////////////////////////////////////////////////////////////////////////
874 void XMLShapeExport::ImpExportEllipseShape(
875 const uno::Reference< drawing::XShape >& xShape,
876 XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
878 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
879 if(xPropSet.is())
881 // get size to decide between Circle and Ellipse
882 awt::Size aSize = xShape->getSize();
883 sal_Int32 nRx((aSize.Width + 1) / 2);
884 sal_Int32 nRy((aSize.Height + 1) / 2);
885 BOOL bCircle(nRx == nRy);
887 // Transformation
888 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
890 drawing::CircleKind eKind = drawing::CircleKind_FULL;
891 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")) ) >>= eKind;
892 if( eKind != drawing::CircleKind_FULL )
894 OUStringBuffer sStringBuffer;
895 sal_Int32 nStartAngle = 0;
896 sal_Int32 nEndAngle = 0;
897 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")) ) >>= nStartAngle;
898 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")) ) >>= nEndAngle;
900 const double dStartAngle = nStartAngle / 100.0;
901 const double dEndAngle = nEndAngle / 100.0;
903 // export circle kind
904 SvXMLUnitConverter::convertEnum( sStringBuffer, (USHORT)eKind, aXML_CircleKind_EnumMap );
905 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_KIND, sStringBuffer.makeStringAndClear() );
907 // export start angle
908 SvXMLUnitConverter::convertDouble( sStringBuffer, dStartAngle );
909 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_ANGLE, sStringBuffer.makeStringAndClear() );
911 // export end angle
912 SvXMLUnitConverter::convertDouble( sStringBuffer, dEndAngle );
913 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_ANGLE, sStringBuffer.makeStringAndClear() );
916 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
918 if(bCircle)
920 // write circle
921 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CIRCLE, bCreateNewline, sal_True);
923 ImpExportDescription( xShape ); // #i68101#
924 ImpExportEvents( xShape );
925 ImpExportGluePoints( xShape );
926 ImpExportText( xShape );
928 else
930 // write ellipse
931 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_ELLIPSE, bCreateNewline, sal_True);
933 ImpExportDescription( xShape ); // #i68101#
934 ImpExportEvents( xShape );
935 ImpExportGluePoints( xShape );
936 ImpExportText( xShape );
941 //////////////////////////////////////////////////////////////////////////////
943 void XMLShapeExport::ImpExportPolygonShape(
944 const uno::Reference< drawing::XShape >& xShape,
945 XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
947 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
948 if(xPropSet.is())
950 BOOL bClosed(eShapeType == XmlShapeTypeDrawPolyPolygonShape
951 || eShapeType == XmlShapeTypeDrawClosedBezierShape);
952 BOOL bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape
953 || eShapeType == XmlShapeTypeDrawOpenBezierShape);
955 // get matrix
956 ::basegfx::B2DHomMatrix aMatrix;
957 ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
959 // decompose and correct abour pRefPoint
960 ::basegfx::B2DTuple aTRScale;
961 double fTRShear(0.0);
962 double fTRRotate(0.0);
963 ::basegfx::B2DTuple aTRTranslate;
964 ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
966 // use features and write
967 ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
969 // create and export ViewBox
970 awt::Point aPoint(0, 0);
971 awt::Size aSize(FRound(aTRScale.getX()), FRound(aTRScale.getY()));
972 SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
973 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
975 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
977 if(bBezier)
979 // get PolygonBezier
980 uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) );
981 drawing::PolyPolygonBezierCoords* pSourcePolyPolygon =
982 (drawing::PolyPolygonBezierCoords*)aAny.getValue();
984 if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
986 sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength());
987 drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray();
988 drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray();
990 if(pOuterSequence && pOuterFlags)
992 // prepare svx:d element export
993 SdXMLImExSvgDElement aSvgDElement(aViewBox);
995 for(sal_Int32 a(0L); a < nOuterCnt; a++)
997 drawing::PointSequence* pSequence = pOuterSequence++;
998 drawing::FlagSequence* pFlags = pOuterFlags++;
1000 if(pSequence && pFlags)
1002 aSvgDElement.AddPolygon(pSequence, pFlags,
1003 aPoint, aSize, bClosed);
1007 // write point array
1008 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
1011 // write object now
1012 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PATH, bCreateNewline, sal_True);
1014 ImpExportDescription( xShape ); // #i68101#
1015 ImpExportEvents( xShape );
1016 ImpExportGluePoints( xShape );
1017 ImpExportText( xShape );
1020 else
1022 // get non-bezier polygon
1023 uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry"))) );
1024 drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue();
1026 if(pSourcePolyPolygon && pSourcePolyPolygon->getLength())
1028 sal_Int32 nOuterCnt(pSourcePolyPolygon->getLength());
1030 if(1L == nOuterCnt && !bBezier)
1032 // simple polygon shape, can be written as svg:points sequence
1033 drawing::PointSequence* pSequence = pSourcePolyPolygon->getArray();
1034 if(pSequence)
1036 SdXMLImExPointsElement aPoints(pSequence, aViewBox, aPoint, aSize,
1037 // #96328#
1038 bClosed);
1040 // write point array
1041 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPoints.GetExportString());
1044 // write object now
1045 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW,
1046 bClosed ? XML_POLYGON : XML_POLYLINE , bCreateNewline, sal_True);
1048 ImpExportDescription( xShape ); // #i68101#
1049 ImpExportEvents( xShape );
1050 ImpExportGluePoints( xShape );
1051 ImpExportText( xShape );
1053 else
1055 // polypolygon or bezier, needs to be written as a svg:path sequence
1056 drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
1057 if(pOuterSequence)
1059 // prepare svx:d element export
1060 SdXMLImExSvgDElement aSvgDElement(aViewBox);
1062 for(sal_Int32 a(0L); a < nOuterCnt; a++)
1064 drawing::PointSequence* pSequence = pOuterSequence++;
1065 if(pSequence)
1067 aSvgDElement.AddPolygon(pSequence, 0L, aPoint,
1068 aSize, bClosed);
1072 // write point array
1073 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
1076 // write object now
1077 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PATH, bCreateNewline, sal_True);
1079 ImpExportDescription( xShape ); // #i68101#
1080 ImpExportEvents( xShape );
1081 ImpExportGluePoints( xShape );
1082 ImpExportText( xShape );
1089 //////////////////////////////////////////////////////////////////////////////
1091 void XMLShapeExport::ImpExportGraphicObjectShape(
1092 const uno::Reference< drawing::XShape >& xShape,
1093 XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1095 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1096 if(xPropSet.is())
1098 sal_Bool bIsEmptyPresObj = sal_False;
1099 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1101 // Transformation
1102 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1104 OUString sImageURL;
1106 if(eShapeType == XmlShapeTypePresGraphicObjectShape)
1107 bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_GRAPHIC) );
1109 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1110 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1111 XML_FRAME, bCreateNewline, sal_True );
1113 const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
1115 if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
1117 if( !bIsEmptyPresObj )
1119 OUString aStreamURL;
1120 OUString aStr;
1122 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aStreamURL;
1123 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= sImageURL;
1125 OUString aResolveURL( sImageURL );
1126 const rtl::OUString sPackageURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:") );
1128 // sj: trying to preserve the filename
1129 if ( aStreamURL.match( sPackageURL, 0 ) )
1131 rtl::OUString sRequestedName( aStreamURL.copy( sPackageURL.getLength(), aStreamURL.getLength() - sPackageURL.getLength() ) );
1132 sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1;
1133 if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) )
1134 sRequestedName = sRequestedName.copy( nLastIndex, sRequestedName.getLength() - nLastIndex );
1135 nLastIndex = sRequestedName.lastIndexOf( '.' );
1136 if ( nLastIndex >= 0 )
1137 sRequestedName = sRequestedName.copy( 0, nLastIndex );
1138 if ( sRequestedName.getLength() )
1140 aResolveURL = aResolveURL.concat( OUString(RTL_CONSTASCII_USTRINGPARAM("?requestedName=")));
1141 aResolveURL = aResolveURL.concat( sRequestedName );
1145 aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL );
1146 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
1148 if( aStr.getLength() )
1150 if( aStr[ 0 ] == '#' )
1152 aStreamURL = OUString::createFromAscii( "vnd.sun.star.Package:" );
1153 aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) );
1156 // update stream URL for load on demand
1157 uno::Any aAny;
1158 aAny <<= aStreamURL;
1159 xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL")), aAny );
1161 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1162 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1163 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1166 else
1168 OUString aStr;
1169 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
1170 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1171 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1172 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1176 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, sal_True, sal_True);
1178 if( sImageURL.getLength() )
1180 // optional office:binary-data
1181 mrExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
1183 if( !bIsEmptyPresObj )
1184 ImpExportText( xShape );
1188 ImpExportEvents( xShape );
1189 ImpExportGluePoints( xShape );
1191 // image map
1192 GetExport().GetImageMapExport().Export( xPropSet );
1193 ImpExportDescription( xShape ); // #i68101#
1197 //////////////////////////////////////////////////////////////////////////////
1199 void XMLShapeExport::ImpExportChartShape(
1200 const uno::Reference< drawing::XShape >& xShape,
1201 XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint,
1202 SvXMLAttributeList* pAttrList )
1204 ImpExportOLE2Shape( xShape, eShapeType, nFeatures, pRefPoint, pAttrList );
1206 // Transformation
1207 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1209 uno::Reference< chart::XChartDocument > xChartDoc;
1210 if( !bIsEmptyPresObj )
1211 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xChartDoc;
1213 if( xChartDoc.is() )
1215 // export chart data if the flag is not set (default)
1216 sal_Bool bExportOwnData = ( nFeatures & SEF_EXPORT_NO_CHART_DATA ) == 0;
1217 mrExport.GetChartExport()->exportChart( xChartDoc, bExportOwnData );
1219 else
1221 // write chart object (fake for now, replace later)
1222 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_CHART, XML_CHART, sal_True, sal_True);
1228 //////////////////////////////////////////////////////////////////////////////
1230 void XMLShapeExport::ImpExportControlShape(
1231 const uno::Reference< drawing::XShape >& xShape,
1232 XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1234 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1235 if(xPropSet.is())
1237 // Transformation
1238 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1241 uno::Reference< drawing::XControlShape > xControl( xShape, uno::UNO_QUERY );
1242 DBG_ASSERT( xControl.is(), "Control shape is not supporting XControlShape" );
1243 if( xControl.is() )
1245 uno::Reference< beans::XPropertySet > xControlModel( xControl->getControl(), uno::UNO_QUERY );
1246 DBG_ASSERT( xControlModel.is(), "Control shape has not XControlModel" );
1247 if( xControlModel.is() )
1249 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONTROL, mrExport.GetFormExport()->getControlId( xControlModel ) );
1253 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1254 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONTROL, bCreateNewline, sal_True);
1256 ImpExportDescription( xShape ); // #i68101#
1259 //////////////////////////////////////////////////////////////////////////////
1261 void XMLShapeExport::ImpExportConnectorShape(
1262 const uno::Reference< drawing::XShape >& xShape,
1263 XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1265 uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
1267 OUString aStr;
1268 OUStringBuffer sStringBuffer;
1270 // export connection kind
1271 drawing::ConnectorType eType = drawing::ConnectorType_STANDARD;
1272 uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")));
1273 aAny >>= eType;
1275 if( eType != drawing::ConnectorType_STANDARD )
1277 SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap );
1278 aStr = sStringBuffer.makeStringAndClear();
1279 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TYPE, aStr);
1282 // export line skew
1283 sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0;
1285 aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")));
1286 aAny >>= nDelta1;
1287 aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")));
1288 aAny >>= nDelta2;
1289 aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")));
1290 aAny >>= nDelta3;
1292 if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 )
1294 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta1);
1295 if( nDelta2 != 0 || nDelta3 != 0 )
1297 const char aSpace = ' ';
1298 sStringBuffer.appendAscii( &aSpace, 1 );
1299 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta2);
1300 if( nDelta3 != 0 )
1302 sStringBuffer.appendAscii( &aSpace, 1 );
1303 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta3);
1307 aStr = sStringBuffer.makeStringAndClear();
1308 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LINE_SKEW, aStr);
1311 // export start and end point
1312 awt::Point aStart(0,0);
1313 awt::Point aEnd(1,1);
1315 // --> OD 2004-08-09 #i36248# - Get <StartPositionInHoriL2R> and
1316 // <EndPositionInHoriL2R>, if they exist and if the document is exported
1317 // into the OpenOffice.org file format.
1318 // These properties only exist at service com::sun::star::text::Shape - the
1319 // Writer UNO service for shapes.
1320 // This code is needed, because the positioning attributes in the
1321 // OpenOffice.org file format are given in horizontal left-to-right layout
1322 // regardless the layout direction the shape is in. In the OASIS Open Office
1323 // file format the positioning attributes are correctly given in the layout
1324 // direction the shape is in. Thus, this code provides the conversion from
1325 // the OASIS Open Office file format to the OpenOffice.org file format.
1326 if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
1327 xProps->getPropertySetInfo()->hasPropertyByName(
1328 OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) &&
1329 xProps->getPropertySetInfo()->hasPropertyByName(
1330 OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) )
1332 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) >>= aStart;
1333 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) >>= aEnd;
1335 else
1337 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) >>= aStart;
1338 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) >>= aEnd;
1340 // <--
1342 if( pRefPoint )
1344 aStart.X -= pRefPoint->X;
1345 aStart.Y -= pRefPoint->Y;
1346 aEnd.X -= pRefPoint->X;
1347 aEnd.Y -= pRefPoint->Y;
1350 if( nFeatures & SEF_EXPORT_X )
1352 // svg: x1
1353 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
1354 aStr = sStringBuffer.makeStringAndClear();
1355 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
1357 else
1359 aEnd.X -= aStart.X;
1362 if( nFeatures & SEF_EXPORT_Y )
1364 // svg: y1
1365 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
1366 aStr = sStringBuffer.makeStringAndClear();
1367 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
1369 else
1371 aEnd.Y -= aStart.Y;
1374 // svg: x2
1375 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
1376 aStr = sStringBuffer.makeStringAndClear();
1377 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
1379 // svg: y2
1380 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
1381 aStr = sStringBuffer.makeStringAndClear();
1382 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
1384 // #i39320#
1385 uno::Reference< uno::XInterface > xRefS;
1386 uno::Reference< uno::XInterface > xRefE;
1388 // export start connection
1389 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartShape") ) ) >>= xRefS;
1390 if( xRefS.is() )
1392 const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefS );
1393 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_SHAPE, rShapeId);
1395 aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")) );
1396 sal_Int32 nGluePointId = 0;
1397 if( aAny >>= nGluePointId )
1399 if( nGluePointId != -1 )
1401 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_GLUE_POINT, OUString::valueOf( nGluePointId ));
1406 // export end connection
1407 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndShape")) ) >>= xRefE;
1408 if( xRefE.is() )
1410 const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefE );
1411 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_SHAPE, rShapeId);
1413 aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")) );
1414 sal_Int32 nGluePointId = 0;
1415 if( aAny >>= nGluePointId )
1417 if( nGluePointId != -1 )
1419 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_GLUE_POINT, OUString::valueOf( nGluePointId ));
1424 if( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ) ) >>= aAny )
1426 // get PolygonBezier
1427 drawing::PolyPolygonBezierCoords* pSourcePolyPolygon =
1428 (drawing::PolyPolygonBezierCoords*)aAny.getValue();
1430 if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
1432 sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength());
1433 drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray();
1434 drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray();
1436 if(pOuterSequence && pOuterFlags)
1438 // prepare svx:d element export
1439 awt::Point aPoint( 0, 0 );
1440 awt::Size aSize( 1, 1 );
1441 SdXMLImExViewBox aViewBox( 0, 0, 1, 1 );
1442 SdXMLImExSvgDElement aSvgDElement(aViewBox);
1444 for(sal_Int32 a(0L); a < nOuterCnt; a++)
1446 drawing::PointSequence* pSequence = pOuterSequence++;
1447 drawing::FlagSequence* pFlags = pOuterFlags++;
1449 if(pSequence && pFlags)
1451 aSvgDElement.AddPolygon(pSequence, pFlags,
1452 aPoint, aSize, sal_False );
1456 // write point array
1457 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
1462 // write connector shape. Add Export later.
1463 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1464 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONNECTOR, bCreateNewline, sal_True);
1466 ImpExportDescription( xShape ); // #i68101#
1467 ImpExportEvents( xShape );
1468 ImpExportGluePoints( xShape );
1469 ImpExportText( xShape );
1472 //////////////////////////////////////////////////////////////////////////////
1474 void XMLShapeExport::ImpExportMeasureShape(
1475 const uno::Reference< drawing::XShape >& xShape,
1476 XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1478 uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
1480 OUString aStr;
1481 OUStringBuffer sStringBuffer;
1483 // export start and end point
1484 awt::Point aStart(0,0);
1485 awt::Point aEnd(1,1);
1487 // --> OD 2004-08-09 #i36248# - Get <StartPositionInHoriL2R> and
1488 // <EndPositionInHoriL2R>, if they exist and if the document is exported
1489 // into the OpenOffice.org file format.
1490 // These properties only exist at service com::sun::star::text::Shape - the
1491 // Writer UNO service for shapes.
1492 // This code is needed, because the positioning attributes in the
1493 // OpenOffice.org file format are given in horizontal left-to-right layout
1494 // regardless the layout direction the shape is in. In the OASIS Open Office
1495 // file format the positioning attributes are correctly given in the layout
1496 // direction the shape is in. Thus, this code provides the conversion from
1497 // the OASIS Open Office file format to the OpenOffice.org file format.
1498 if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
1499 xProps->getPropertySetInfo()->hasPropertyByName(
1500 OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) &&
1501 xProps->getPropertySetInfo()->hasPropertyByName(
1502 OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) )
1504 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPositionInHoriL2R"))) >>= aStart;
1505 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPositionInHoriL2R"))) >>= aEnd;
1507 else
1509 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) >>= aStart;
1510 xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) >>= aEnd;
1512 // <--
1514 if( pRefPoint )
1516 aStart.X -= pRefPoint->X;
1517 aStart.Y -= pRefPoint->Y;
1518 aEnd.X -= pRefPoint->X;
1519 aEnd.Y -= pRefPoint->Y;
1522 if( nFeatures & SEF_EXPORT_X )
1524 // svg: x1
1525 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
1526 aStr = sStringBuffer.makeStringAndClear();
1527 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
1529 else
1531 aEnd.X -= aStart.X;
1534 if( nFeatures & SEF_EXPORT_Y )
1536 // svg: y1
1537 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
1538 aStr = sStringBuffer.makeStringAndClear();
1539 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
1541 else
1543 aEnd.Y -= aStart.Y;
1546 // svg: x2
1547 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
1548 aStr = sStringBuffer.makeStringAndClear();
1549 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
1551 // svg: y2
1552 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
1553 aStr = sStringBuffer.makeStringAndClear();
1554 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
1556 // write measure shape
1557 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1558 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_MEASURE, bCreateNewline, sal_True);
1560 ImpExportDescription( xShape ); // #i68101#
1561 ImpExportEvents( xShape );
1562 ImpExportGluePoints( xShape );
1564 uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
1565 if( xText.is() )
1566 mrExport.GetTextParagraphExport()->exportText( xText );
1569 //////////////////////////////////////////////////////////////////////////////
1571 void XMLShapeExport::ImpExportOLE2Shape(
1572 const uno::Reference< drawing::XShape >& xShape,
1573 XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */,
1574 SvXMLAttributeList* pAttrList /* = NULL */ )
1576 uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1577 uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY);
1579 DBG_ASSERT( xPropSet.is() && xNamed.is(), "ole shape is not implementing needed interfaces");
1580 if(xPropSet.is() && xNamed.is())
1582 // Transformation
1583 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1585 sal_Bool bIsEmptyPresObj = sal_False;
1587 // presentation settings
1588 if(eShapeType == XmlShapeTypePresOLE2Shape)
1589 bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_OBJECT) );
1590 else if(eShapeType == XmlShapeTypePresChartShape)
1591 bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_CHART) );
1592 else if(eShapeType == XmlShapeTypePresSheetShape)
1593 bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
1595 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1596 sal_Bool bExportEmbedded(0 != (mrExport.getExportFlags() & EXPORT_EMBEDDED));
1597 OUString sPersistName;
1598 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1599 XML_FRAME, bCreateNewline, sal_True );
1601 const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
1603 if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
1605 if (pAttrList)
1607 mrExport.AddAttributeList(pAttrList);
1610 OUString sClassId;
1611 OUString sURL;
1612 sal_Bool bInternal = false;
1613 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsInternal"))) >>= bInternal;
1615 if( !bIsEmptyPresObj )
1618 if ( bInternal )
1620 // OOo internal links have no storage persistance, URL is stored in the XML file
1621 // the result LinkURL is empty in case the object is not a link
1622 xPropSet->getPropertyValue( OUString::createFromAscii( "LinkURL" ) ) >>= sURL;
1625 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ) ) >>= sPersistName;
1626 if ( !sURL.getLength() )
1628 if( sPersistName.getLength() )
1630 sURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
1631 sURL += sPersistName;
1635 if( !bInternal )
1636 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) >>= sClassId;
1638 if( sClassId.getLength() )
1639 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CLASS_ID, sClassId );
1640 if(!bExportEmbedded)
1642 // xlink:href
1643 if( sURL.getLength() )
1645 // #96717# in theorie, if we don't have a url we shouldn't even
1646 // export this ole shape. But practical its to risky right now
1647 // to change this so we better dispose this on load
1648 sURL = mrExport.AddEmbeddedObject( sURL );
1650 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
1651 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1652 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1653 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1657 else
1659 // export empty href for empty placeholders to be valid odf
1660 OUString sEmptyURL;
1662 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sEmptyURL );
1663 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1664 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1665 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1668 enum XMLTokenEnum eElem = sClassId.getLength() ? XML_OBJECT_OLE : XML_OBJECT;
1669 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, eElem, sal_True, sal_True );
1671 if(bExportEmbedded && !bIsEmptyPresObj)
1673 // #100592#
1674 if(bInternal)
1676 // embedded XML
1677 uno::Reference< lang::XComponent > xComp;
1678 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
1679 DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
1680 mrExport.ExportEmbeddedOwnObject( xComp );
1682 else
1684 // embed as Base64
1685 // this is an alien object ( currently MSOLE is the only supported type of such objects )
1686 // in case it is not an OASIS format the object should be asked to store replacement image if possible
1688 ::rtl::OUString sURLRequest( sURL );
1689 if ( ( mrExport.getExportFlags() & EXPORT_OASIS ) == 0 )
1690 sURLRequest += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "?oasis=false" ) );
1691 mrExport.AddEmbeddedObjectAsBase64( sURLRequest );
1695 if( !bIsEmptyPresObj )
1697 OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
1698 sURL += sPersistName;
1699 if( !bExportEmbedded )
1701 sURL = GetExport().AddEmbeddedObject( sURL );
1702 mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
1703 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1704 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1705 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1708 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
1709 XML_IMAGE, sal_False, sal_True );
1711 if( bExportEmbedded )
1712 GetExport().AddEmbeddedObjectAsBase64( sURL );
1715 ImpExportEvents( xShape );
1716 ImpExportGluePoints( xShape );
1717 ImpExportDescription( xShape ); // #i68101#
1721 //////////////////////////////////////////////////////////////////////////////
1723 void XMLShapeExport::ImpExportPageShape(
1724 const uno::Reference< drawing::XShape >& xShape,
1725 XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1727 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1728 if(xPropSet.is())
1730 // #86163# Transformation
1731 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1733 // export page number used for this page
1734 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1735 const OUString aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
1736 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
1738 sal_Int32 nPageNumber = 0;
1739 xPropSet->getPropertyValue(aPageNumberStr) >>= nPageNumber;
1740 if( nPageNumber )
1741 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_PAGE_NUMBER, OUString::valueOf(nPageNumber));
1744 // a presentation page shape, normally used on notes pages only. If
1745 // it is used not as presentation shape, it may have been created with
1746 // copy-paste exchange between draw and impress (this IS possible...)
1747 if(eShapeType == XmlShapeTypePresPageShape)
1749 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS,
1750 XML_PRESENTATION_PAGE);
1753 // write Page shape
1754 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1755 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, bCreateNewline, sal_True);
1759 //////////////////////////////////////////////////////////////////////////////
1761 void XMLShapeExport::ImpExportCaptionShape(
1762 const uno::Reference< drawing::XShape >& xShape,
1763 XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
1765 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1766 if(xPropSet.is())
1768 // Transformation
1769 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1771 // evtl. corner radius?
1772 sal_Int32 nCornerRadius(0L);
1773 xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius;
1774 if(nCornerRadius)
1776 OUStringBuffer sStringBuffer;
1777 mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
1778 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
1781 awt::Point aCaptionPoint;
1782 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ) ) ) >>= aCaptionPoint;
1784 mrExport.GetMM100UnitConverter().convertMeasure(msBuffer, aCaptionPoint.X);
1785 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_X, msBuffer.makeStringAndClear() );
1786 mrExport.GetMM100UnitConverter().convertMeasure(msBuffer, aCaptionPoint.Y);
1787 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_Y, msBuffer.makeStringAndClear() );
1789 // write Caption shape. Add export later.
1790 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1791 sal_Bool bAnnotation( (nFeatures & SEF_EXPORT_ANNOTATION) == SEF_EXPORT_ANNOTATION );
1793 SvXMLElementExport aObj( mrExport,
1794 (bAnnotation ? XML_NAMESPACE_OFFICE
1795 : XML_NAMESPACE_DRAW),
1796 (bAnnotation ? XML_ANNOTATION : XML_CAPTION),
1797 bCreateNewline, sal_True );
1799 ImpExportDescription( xShape ); // #i68101#
1800 ImpExportEvents( xShape );
1801 ImpExportGluePoints( xShape );
1802 if( bAnnotation )
1803 mrExport.exportAnnotationMeta( xShape );
1804 ImpExportText( xShape );
1808 //////////////////////////////////////////////////////////////////////////////
1810 void XMLShapeExport::ImpExportFrameShape(
1811 const uno::Reference< drawing::XShape >& xShape,
1812 XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1814 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1815 if(xPropSet.is())
1817 // Transformation
1818 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1820 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1821 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1822 XML_FRAME, bCreateNewline, sal_True );
1824 // export frame url
1825 OUString aStr;
1826 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ) ) >>= aStr;
1827 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1828 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1829 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1830 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1832 // export name
1833 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ) ) >>= aStr;
1834 if( aStr.getLength() )
1835 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
1837 // write floating frame
1839 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_FLOATING_FRAME, sal_True, sal_True);
1844 //////////////////////////////////////////////////////////////////////////////
1846 void XMLShapeExport::ImpExportAppletShape(
1847 const uno::Reference< drawing::XShape >& xShape,
1848 XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1850 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1851 if(xPropSet.is())
1853 // Transformation
1854 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1856 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1857 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1858 XML_FRAME, bCreateNewline, sal_True );
1860 // export frame url
1861 OUString aStr;
1862 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ) ) >>= aStr;
1863 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1864 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1865 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1866 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1868 // export draw:applet-name
1869 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ) ) >>= aStr;
1870 if( aStr.getLength() )
1871 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
1873 // export draw:code
1874 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ) ) >>= aStr;
1875 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
1877 // export draw:may-script
1878 sal_Bool bIsScript = false;
1879 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ) ) >>= bIsScript;
1880 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bIsScript ? XML_TRUE : XML_FALSE );
1883 // write applet
1884 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_APPLET, sal_True, sal_True);
1886 // export parameters
1887 uno::Sequence< beans::PropertyValue > aCommands;
1888 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ) ) >>= aCommands;
1889 const sal_Int32 nCount = aCommands.getLength();
1890 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1892 aCommands[nIndex].Value >>= aStr;
1893 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
1894 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
1895 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
1901 //////////////////////////////////////////////////////////////////////////////
1903 void XMLShapeExport::ImpExportPluginShape(
1904 const uno::Reference< drawing::XShape >& xShape,
1905 XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1907 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1908 if(xPropSet.is())
1910 // Transformation
1911 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1913 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1914 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
1915 XML_FRAME, bCreateNewline, sal_True );
1917 // export plugin url
1918 OUString aStr;
1919 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ) ) >>= aStr;
1920 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
1921 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1922 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1923 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1926 // export mime-type
1927 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ) ) >>= aStr;
1928 if(aStr.getLength())
1929 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
1932 // write plugin
1933 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, sal_True, sal_True);
1935 // export parameters
1936 uno::Sequence< beans::PropertyValue > aCommands;
1937 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ) ) >>= aCommands;
1938 const sal_Int32 nCount = aCommands.getLength();
1939 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1941 aCommands[nIndex].Value >>= aStr;
1942 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
1943 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
1944 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
1950 //////////////////////////////////////////////////////////////////////////////
1952 void XMLShapeExport::ImpExportMediaShape(
1953 const uno::Reference< drawing::XShape >& xShape,
1954 XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1956 const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1957 if(xPropSet.is())
1959 // Transformation
1960 ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1962 sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1963 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1964 XML_FRAME, bCreateNewline, sal_True );
1966 // export media url
1967 OUString aMediaURL;
1968 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ) ) >>= aMediaURL;
1969 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( aMediaURL ) );
1970 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1971 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1972 mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1974 // export mime-type
1975 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.media" ) ) );
1977 // write plugin
1978 SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, !( nFeatures & SEF_EXPORT_NO_WS ), sal_True);
1980 // export parameters
1981 const OUString aFalseStr( RTL_CONSTASCII_USTRINGPARAM( "false" ) ), aTrueStr( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
1983 sal_Bool bLoop = false;
1984 const OUString aLoopStr( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) );
1985 xPropSet->getPropertyValue( aLoopStr ) >>= bLoop;
1986 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aLoopStr );
1987 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bLoop ? aTrueStr : aFalseStr );
1988 delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
1990 sal_Bool bMute = false;
1991 const OUString aMuteStr( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) );
1992 xPropSet->getPropertyValue( aMuteStr ) >>= bMute;
1993 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aMuteStr );
1994 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bMute ? aTrueStr : aFalseStr );
1995 delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
1997 sal_Int16 nVolumeDB = 0;
1998 const OUString aVolumeDBStr( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) );
1999 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ) ) >>= nVolumeDB;
2000 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aVolumeDBStr );
2001 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, OUString::valueOf( static_cast< sal_Int32 >( nVolumeDB ) ) );
2002 delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );
2004 media::ZoomLevel eZoom;
2005 const OUString aZoomStr( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) );
2006 OUString aZoomValue;
2007 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ) ) >>= eZoom;
2008 switch( eZoom )
2010 case( media::ZoomLevel_ZOOM_1_TO_4 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "25%" ) ); break;
2011 case( media::ZoomLevel_ZOOM_1_TO_2 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "50%" ) ); break;
2012 case( media::ZoomLevel_ORIGINAL ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "100%" ) ); break;
2013 case( media::ZoomLevel_ZOOM_2_TO_1 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "200%" ) ); break;
2014 case( media::ZoomLevel_ZOOM_4_TO_1 ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "400%" ) ); break;
2015 case( media::ZoomLevel_FIT_TO_WINDOW ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fit" ) ); break;
2016 case( media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fixedfit" ) ); break;
2017 case( media::ZoomLevel_FULLSCREEN ): aZoomValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "fullscreen" ) ); break;
2019 default:
2020 break;
2023 if( aZoomValue.getLength() )
2025 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aZoomStr );
2026 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aZoomValue );
2027 delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ) );