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