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 :
21 : #include <memory>
22 :
23 : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
24 : #include <com/sun/star/presentation/ClickAction.hpp>
25 : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
26 : #include <com/sun/star/container/XChild.hpp>
27 : #include <com/sun/star/text/XText.hpp>
28 : #include <com/sun/star/chart/XChartDocument.hpp>
29 : #include <com/sun/star/drawing/XControlShape.hpp>
30 : #include <com/sun/star/style/XStyle.hpp>
31 : #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
32 : #include <com/sun/star/container/XIdentifierAccess.hpp>
33 : #include <com/sun/star/drawing/GluePoint2.hpp>
34 : #include <com/sun/star/drawing/Alignment.hpp>
35 : #include <com/sun/star/drawing/EscapeDirection.hpp>
36 : #include <com/sun/star/table/XColumnRowRange.hpp>
37 : #include <xmloff/xmluconv.hxx>
38 : #include "PropertySetMerger.hxx"
39 :
40 : #include <xmloff/shapeexport.hxx>
41 : #include "sdpropls.hxx"
42 : #include "sdxmlexp_impl.hxx"
43 : #include <xmloff/families.hxx>
44 : #include <tools/debug.hxx>
45 : #include <xmloff/contextid.hxx>
46 : #include <xmloff/xmltoken.hxx>
47 : #include <sot/clsids.hxx>
48 : #include <tools/globname.hxx>
49 : #include <com/sun/star/beans/XPropertyState.hpp>
50 :
51 : #include <comphelper/processfactory.hxx>
52 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 : #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
54 :
55 : #include "xmloff/xmlnmspe.hxx"
56 :
57 : using namespace ::com::sun::star;
58 : using namespace ::xmloff::token;
59 :
60 : //////////////////////////////////////////////////////////////////////////////
61 :
62 8 : XMLShapeExport::XMLShapeExport(SvXMLExport& rExp,
63 : SvXMLExportPropertyMapper *pExtMapper )
64 : : mrExport( rExp ),
65 : mnNextUniqueShapeId(1),
66 : maShapesInfos(),
67 8 : maCurrentShapesIter(maShapesInfos.end()),
68 : mbExportLayer( sal_False ),
69 : // #88546# init to sal_False
70 : mbHandleProgressBar( sal_False ),
71 : msZIndex( "ZOrder" ),
72 : msPrintable( "Printable" ),
73 : msVisible( "Visible" ),
74 : msEmptyPres( "IsEmptyPresentationObject" ),
75 : msModel( "Model" ),
76 : msStartShape( "StartShape" ),
77 : msEndShape( "EndShape" ),
78 : msOnClick( "OnClick" ),
79 : msEventType( "EventType" ),
80 : msPresentation( "Presentation" ),
81 : msMacroName( "MacroName" ),
82 : msScript( "Script" ),
83 : msLibrary( "Library" ),
84 : msClickAction( "ClickAction" ),
85 : msBookmark( "Bookmark" ),
86 : msEffect( "Effect" ),
87 : msPlayFull( "PlayFull" ),
88 : msVerb( "Verb" ),
89 : msSoundURL( "SoundURL" ),
90 : msSpeed( "Speed" ),
91 16 : msStarBasic( "StarBasic" )
92 : {
93 : // construct PropertyHandlerFactory
94 8 : mxSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), rExp );
95 : // construct PropertySetMapper
96 8 : mxPropertySetMapper = CreateShapePropMapper( mrExport );
97 8 : if( pExtMapper )
98 : {
99 4 : UniReference < SvXMLExportPropertyMapper > xExtMapper( pExtMapper );
100 4 : mxPropertySetMapper->ChainExportMapper( xExtMapper );
101 : }
102 :
103 : /*
104 : // chain text attributes
105 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
106 : */
107 :
108 : mrExport.GetAutoStylePool()->AddFamily(
109 : XML_STYLE_FAMILY_SD_GRAPHICS_ID,
110 : OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME),
111 : GetPropertySetMapper(),
112 8 : OUString(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX));
113 : mrExport.GetAutoStylePool()->AddFamily(
114 : XML_STYLE_FAMILY_SD_PRESENTATION_ID,
115 : OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
116 : GetPropertySetMapper(),
117 8 : OUString(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX));
118 :
119 8 : maCurrentInfo = maShapeInfos.end();
120 :
121 : // create table export helper and let him add his families in time
122 8 : GetShapeTableExport();
123 8 : }
124 :
125 : ///////////////////////////////////////////////////////////////////////
126 :
127 12 : XMLShapeExport::~XMLShapeExport()
128 : {
129 12 : }
130 :
131 : ///////////////////////////////////////////////////////////////////////
132 :
133 : // sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format
134 0 : uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement( const uno::Reference< drawing::XShape >& xShape )
135 : {
136 0 : uno::Reference< drawing::XShape > xCustomShapeReplacement;
137 :
138 0 : if( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 )
139 : {
140 0 : OUString aType( xShape->getShapeType() );
141 0 : if( aType.equalsAscii( "com.sun.star.drawing.CustomShape" ) )
142 : {
143 0 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
144 0 : if( xSet.is() )
145 : {
146 0 : OUString aEngine;
147 0 : xSet->getPropertyValue( OUString( "CustomShapeEngine" ) ) >>= aEngine;
148 0 : if ( aEngine.isEmpty() )
149 : {
150 0 : aEngine = "com.sun.star.drawing.EnhancedCustomShapeEngine";
151 : }
152 0 : uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
153 :
154 0 : if ( !aEngine.isEmpty() && xFactory.is() )
155 : {
156 0 : uno::Sequence< uno::Any > aArgument( 1 );
157 0 : uno::Sequence< beans::PropertyValue > aPropValues( 2 );
158 0 : aPropValues[ 0 ].Name = rtl::OUString( "CustomShape" );
159 0 : aPropValues[ 0 ].Value <<= xShape;
160 0 : sal_Bool bForceGroupWithText = sal_True;
161 0 : aPropValues[ 1 ].Name = rtl::OUString( "ForceGroupWithText" );
162 0 : aPropValues[ 1 ].Value <<= bForceGroupWithText;
163 0 : aArgument[ 0 ] <<= aPropValues;
164 0 : uno::Reference< uno::XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) );
165 0 : if ( xInterface.is() )
166 : {
167 : uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine(
168 0 : uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) );
169 0 : if ( xCustomShapeEngine.is() )
170 0 : xCustomShapeReplacement = xCustomShapeEngine->render();
171 0 : }
172 0 : }
173 0 : }
174 0 : }
175 : }
176 0 : return xCustomShapeReplacement;
177 : }
178 :
179 : // This method collects all automatic styles for the given XShape
180 0 : void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
181 : {
182 0 : if( maCurrentShapesIter == maShapesInfos.end() )
183 : {
184 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no call to seekShapes()!" );
185 : return;
186 : }
187 0 : sal_Int32 nZIndex = 0;
188 0 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
189 0 : if( xSet.is() )
190 0 : xSet->getPropertyValue(msZIndex) >>= nZIndex;
191 :
192 0 : ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
193 :
194 0 : if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
195 : {
196 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no shape info allocated for a given shape" );
197 : return;
198 : }
199 :
200 0 : ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
201 :
202 0 : uno::Reference< drawing::XShape > xCustomShapeReplacement = checkForCustomShapeReplacement( xShape );
203 0 : if ( xCustomShapeReplacement.is() )
204 0 : aShapeInfo.xCustomShapeReplacement = xCustomShapeReplacement;
205 :
206 : // -----------------------------
207 : // first compute the shapes type
208 : // -----------------------------
209 0 : ImpCalcShapeType(xShape, aShapeInfo.meShapeType);
210 :
211 : // #i118485# enabled XmlShapeTypeDrawChartShape and XmlShapeTypeDrawOLE2Shape
212 : // to have text
213 : const bool bObjSupportsText =
214 : aShapeInfo.meShapeType != XmlShapeTypePresChartShape &&
215 : aShapeInfo.meShapeType != XmlShapeTypePresOLE2Shape &&
216 : aShapeInfo.meShapeType != XmlShapeTypeDrawSheetShape &&
217 : aShapeInfo.meShapeType != XmlShapeTypePresSheetShape &&
218 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DSceneObject &&
219 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DCubeObject &&
220 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DSphereObject &&
221 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DLatheObject &&
222 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DExtrudeObject &&
223 : aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape &&
224 : aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
225 0 : aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
226 :
227 : const bool bObjSupportsStyle =
228 0 : aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
229 :
230 0 : sal_Bool bIsEmptyPresObj = sal_False;
231 :
232 0 : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
233 0 : if ( aShapeInfo.xCustomShapeReplacement.is() )
234 0 : xPropSet.clear();
235 :
236 : // ----------------
237 : // prep text styles
238 : // ----------------
239 0 : if( xPropSet.is() && bObjSupportsText )
240 : {
241 0 : uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
242 0 : if(xText.is() && !xText->getString().isEmpty())
243 : {
244 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
245 :
246 0 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres) )
247 : {
248 0 : uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
249 0 : aAny >>= bIsEmptyPresObj;
250 : }
251 :
252 0 : if(!bIsEmptyPresObj)
253 : {
254 0 : GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
255 0 : }
256 0 : }
257 : }
258 :
259 : // ------------------------------
260 : // compute the shape parent style
261 : // ------------------------------
262 0 : if( xPropSet.is() )
263 : {
264 0 : uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( xPropSet->getPropertySetInfo() );
265 :
266 0 : OUString aParentName;
267 0 : uno::Reference< style::XStyle > xStyle;
268 :
269 0 : if( bObjSupportsStyle )
270 : {
271 0 : if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName( OUString("Style")) )
272 0 : xPropSet->getPropertyValue(OUString("Style")) >>= xStyle;
273 :
274 0 : if(xStyle.is())
275 : {
276 : // get family ID
277 0 : uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY);
278 : DBG_ASSERT( xStylePropSet.is(), "style without a XPropertySet?" );
279 : try
280 : {
281 0 : if(xStylePropSet.is())
282 : {
283 0 : OUString aFamilyName;
284 0 : xStylePropSet->getPropertyValue(OUString("Family")) >>= aFamilyName;
285 0 : if( !aFamilyName.isEmpty() && aFamilyName != "graphics" )
286 0 : aShapeInfo.mnFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
287 : }
288 : }
289 0 : catch(const beans::UnknownPropertyException&)
290 : {
291 : // Ignored.
292 : DBG_ASSERT(false,
293 : "XMLShapeExport::collectShapeAutoStyles: style has no 'Family' property");
294 : }
295 :
296 : // get parent-style name
297 0 : if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == aShapeInfo.mnFamily)
298 : {
299 0 : aParentName = msPresentationStylePrefix;
300 : }
301 :
302 0 : aParentName += xStyle->getName();
303 : }
304 : }
305 :
306 : // filter propset
307 0 : std::vector< XMLPropertyState > xPropStates;
308 :
309 0 : sal_Int32 nCount = 0;
310 0 : if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) )
311 : {
312 0 : xPropStates = GetPropertySetMapper()->Filter( xPropSet );
313 :
314 0 : if (XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType)
315 : {
316 : // for control shapes, we additionally need the number format style (if any)
317 0 : uno::Reference< drawing::XControlShape > xControl(xShape, uno::UNO_QUERY);
318 : DBG_ASSERT(xControl.is(), "XMLShapeExport::collectShapeAutoStyles: ShapeType control, but no XControlShape!");
319 0 : if (xControl.is())
320 : {
321 0 : uno::Reference< beans::XPropertySet > xControlModel(xControl->getControl(), uno::UNO_QUERY);
322 : DBG_ASSERT(xControlModel.is(), "XMLShapeExport::collectShapeAutoStyles: no control model on the control shape!");
323 :
324 0 : ::rtl::OUString sNumberStyle = mrExport.GetFormExport()->getControlNumberStyle(xControlModel);
325 0 : if (!sNumberStyle.isEmpty())
326 : {
327 0 : sal_Int32 nIndex = GetPropertySetMapper()->getPropertySetMapper()->FindEntryIndex(CTF_SD_CONTROL_SHAPE_DATA_STYLE);
328 : // TODO : this retrieval of the index could be moved into the ctor, holding the index
329 : // as member, thus saving time.
330 : DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for our context id!");
331 :
332 0 : XMLPropertyState aNewState(nIndex, uno::makeAny(sNumberStyle));
333 0 : xPropStates.push_back(aNewState);
334 0 : }
335 0 : }
336 : }
337 :
338 0 : std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
339 0 : std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
340 0 : while( aIter != aEnd )
341 : {
342 0 : if( aIter->mnIndex != -1 )
343 0 : nCount++;
344 0 : ++aIter;
345 : }
346 : }
347 :
348 0 : if(nCount == 0)
349 : {
350 : // no hard attributes, use parent style name for export
351 0 : aShapeInfo.msStyleName = aParentName;
352 : }
353 : else
354 : {
355 : // there are filtered properties -> hard attributes
356 : // try to find this style in AutoStylePool
357 0 : aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Find(aShapeInfo.mnFamily, aParentName, xPropStates);
358 :
359 0 : if(aShapeInfo.msStyleName.isEmpty())
360 : {
361 : // Style did not exist, add it to AutoStalePool
362 0 : aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Add(aShapeInfo.mnFamily, aParentName, xPropStates);
363 : }
364 : }
365 :
366 : // optionaly generate auto style for text attributes
367 0 : if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) && bObjSupportsText )
368 : {
369 0 : xPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet );
370 :
371 : // ----------------------------------------------------------------------
372 : // yet more additionally, we need to care for the ParaAdjust property
373 0 : if ( XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType )
374 : {
375 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
376 0 : uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
377 0 : if ( xPropSetInfo.is() && xPropState.is() )
378 : {
379 : // this is because:
380 : // * if controls shapes have a ParaAdjust property, then this is the Align property of the control model
381 : // * control models are allowed to have an Align of "void"
382 : // * the Default for control model's Align is TextAlign_LEFT
383 : // * defaults for style properties are not written, but we need to write the "left",
384 : // because we need to distiguish this "left" from the case where not align attribute
385 : // is present which means "void"
386 0 : static const ::rtl::OUString s_sParaAdjustPropertyName( "ParaAdjust" );
387 0 : if ( xPropSetInfo->hasPropertyByName( s_sParaAdjustPropertyName )
388 0 : && ( beans::PropertyState_DEFAULT_VALUE == xPropState->getPropertyState( s_sParaAdjustPropertyName ) )
389 : )
390 : {
391 0 : sal_Int32 nIndex = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST );
392 : // TODO : this retrieval of the index should be moved into the ctor, holding the index
393 : // as member, thus saving time.
394 : DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for the ParaAdjust context id!");
395 :
396 0 : uno::Any aParaAdjustValue = xPropSet->getPropertyValue( s_sParaAdjustPropertyName );
397 0 : XMLPropertyState aAlignDefaultState( nIndex, aParaAdjustValue );
398 :
399 0 : xPropStates.push_back( aAlignDefaultState );
400 : }
401 0 : }
402 : }
403 : // ----------------------------------------------------------------------
404 :
405 0 : nCount = 0;
406 0 : std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
407 0 : std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
408 0 : while( aIter != aEnd )
409 : {
410 0 : if( aIter->mnIndex != -1 )
411 0 : nCount++;
412 0 : ++aIter;
413 : }
414 :
415 0 : if( nCount )
416 : {
417 0 : const OUString aEmpty;
418 0 : aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates );
419 0 : if(aShapeInfo.msTextStyleName.isEmpty())
420 : {
421 : // Style did not exist, add it to AutoStalePool
422 0 : aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates);
423 0 : }
424 : }
425 0 : }
426 : }
427 :
428 : // ----------------------------------------
429 : // prepare animation informations if needed
430 : // ----------------------------------------
431 0 : if( mxAnimationsExporter.is() )
432 0 : mxAnimationsExporter->prepare( xShape, mrExport );
433 :
434 : // check for special shapes
435 :
436 0 : switch( aShapeInfo.meShapeType )
437 : {
438 : case XmlShapeTypeDrawConnectorShape:
439 : {
440 0 : uno::Reference< uno::XInterface > xConnection;
441 :
442 : // create shape ids for export later
443 0 : xPropSet->getPropertyValue( msStartShape ) >>= xConnection;
444 0 : if( xConnection.is() )
445 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
446 :
447 0 : xPropSet->getPropertyValue( msEndShape ) >>= xConnection;
448 0 : if( xConnection.is() )
449 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
450 0 : break;
451 : }
452 : case XmlShapeTypePresTableShape:
453 : case XmlShapeTypeDrawTableShape:
454 : {
455 : try
456 : {
457 0 : uno::Reference< table::XColumnRowRange > xRange( xSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
458 0 : GetShapeTableExport()->collectTableAutoStyles( xRange );
459 : }
460 0 : catch(const uno::Exception&)
461 : {
462 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): exception caught while collection auto styles for a table!" );
463 : }
464 0 : break;
465 : }
466 : default:
467 0 : break;
468 : }
469 :
470 0 : maShapeInfos.push_back( aShapeInfo );
471 0 : maCurrentInfo = maShapeInfos.begin();
472 :
473 : // -----------------------------------------------------
474 : // check for shape collections (group shape or 3d scene)
475 : // and collect contained shapes style infos
476 : // -----------------------------------------------------
477 0 : const uno::Reference< drawing::XShape >& xCollection = aShapeInfo.xCustomShapeReplacement.is()
478 0 : ? aShapeInfo.xCustomShapeReplacement : xShape;
479 : {
480 0 : uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
481 0 : if( xShapes.is() )
482 : {
483 0 : collectShapesAutoStyles( xShapes );
484 0 : }
485 0 : }
486 : }
487 :
488 : ///////////////////////////////////////////////////////////////////////
489 :
490 : namespace
491 : {
492 : class NewTextListsHelper
493 : {
494 : public:
495 0 : NewTextListsHelper( SvXMLExport& rExp )
496 0 : : mrExport( rExp )
497 : {
498 0 : mrExport.GetTextParagraphExport()->PushNewTextListsHelper();
499 0 : }
500 :
501 0 : ~NewTextListsHelper()
502 : {
503 0 : mrExport.GetTextParagraphExport()->PopTextListsHelper();
504 0 : }
505 :
506 : private:
507 : SvXMLExport& mrExport;
508 : };
509 : }
510 : // This method exports the given XShape
511 0 : void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape,
512 : sal_Int32 nFeatures /* = SEF_DEFAULT */,
513 : com::sun::star::awt::Point* pRefPoint /* = NULL */,
514 : SvXMLAttributeList* pAttrList /* = NULL */ )
515 : {
516 0 : if( maCurrentShapesIter == maShapesInfos.end() )
517 : {
518 : OSL_FAIL( "XMLShapeExport::exportShape(): no auto styles where collected before export" );
519 : return;
520 : }
521 0 : sal_Int32 nZIndex = 0;
522 0 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
523 :
524 :
525 0 : ::std::auto_ptr< SvXMLElementExport > mpHyperlinkElement;
526 :
527 : // export hyperlinks with <a><shape/></a>. Currently only in draw since draw
528 : // does not support document events
529 0 : if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try
530 : {
531 0 : presentation::ClickAction eAction = presentation::ClickAction_NONE;
532 0 : xSet->getPropertyValue(OUString("OnClick")) >>= eAction;
533 :
534 0 : if( (eAction == presentation::ClickAction_DOCUMENT) ||
535 : (eAction == presentation::ClickAction_BOOKMARK) )
536 : {
537 0 : OUString sURL;
538 0 : xSet->getPropertyValue(msBookmark) >>= sURL;
539 :
540 0 : if( !sURL.isEmpty() )
541 : {
542 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
543 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
544 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
545 0 : mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, sal_True, sal_True) );
546 0 : }
547 : }
548 : }
549 0 : catch(const uno::Exception&)
550 : {
551 : OSL_FAIL("XMLShapeExport::exportShape(): exception during hyperlink export");
552 : }
553 :
554 :
555 0 : if( xSet.is() )
556 0 : xSet->getPropertyValue(msZIndex) >>= nZIndex;
557 :
558 0 : ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
559 :
560 0 : if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
561 : {
562 : OSL_FAIL( "XMLShapeExport::exportShape(): no shape info collected for a given shape" );
563 : return;
564 : }
565 :
566 0 : NewTextListsHelper aNewTextListsHelper( mrExport );
567 :
568 0 : const ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
569 :
570 :
571 : #ifdef DBG_UTIL
572 : // ---------------------------------------
573 : // check if this is the correct ShapesInfo
574 : // ---------------------------------------
575 : uno::Reference< container::XChild > xChild( xShape, uno::UNO_QUERY );
576 : if( xChild.is() )
577 : {
578 : uno::Reference< drawing::XShapes > xParent( xChild->getParent(), uno::UNO_QUERY );
579 : DBG_ASSERT( xParent.is() && xParent.get() == (*maCurrentShapesIter).first.get(), "XMLShapeExport::exportShape(): Wrong call to XMLShapeExport::seekShapes()" );
580 : }
581 :
582 : // -----------------------------
583 : // first compute the shapes type
584 : // -----------------------------
585 : {
586 : XmlShapeType eShapeType(XmlShapeTypeNotYetSet);
587 : ImpCalcShapeType(xShape, eShapeType);
588 :
589 : DBG_ASSERT( eShapeType == aShapeInfo.meShapeType, "exportShape callings do not correspond to collectShapeAutoStyles calls!" );
590 : }
591 : #endif
592 :
593 : // ----------------------------------------
594 : // collect animation informations if needed
595 : // ----------------------------------------
596 0 : if( mxAnimationsExporter.is() )
597 0 : mxAnimationsExporter->collect( xShape, mrExport );
598 :
599 : /* Export shapes name if he has one (#i51726#)
600 : Export of the shape name for text documents only if the OpenDocument
601 : file format is written - exceptions are group shapes.
602 : Note: Writer documents in OpenOffice.org file format doesn't contain
603 : any names for shapes, except for group shapes.
604 : */
605 : {
606 0 : if ( ( GetExport().GetModelType() != SvtModuleOptions::E_WRITER &&
607 0 : GetExport().GetModelType() != SvtModuleOptions::E_WRITERWEB &&
608 0 : GetExport().GetModelType() != SvtModuleOptions::E_WRITERGLOBAL ) ||
609 0 : ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 ||
610 : aShapeInfo.meShapeType == XmlShapeTypeDrawGroupShape ||
611 : ( aShapeInfo.meShapeType == XmlShapeTypeDrawCustomShape &&
612 0 : aShapeInfo.xCustomShapeReplacement.is() ) )
613 : {
614 0 : uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
615 0 : if( xNamed.is() )
616 : {
617 0 : const OUString aName( xNamed->getName() );
618 0 : if( !aName.isEmpty() )
619 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, aName );
620 0 : }
621 : }
622 : }
623 :
624 : // ------------------
625 : // export style name
626 : // ------------------
627 0 : if( !aShapeInfo.msStyleName.isEmpty() )
628 : {
629 0 : if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == aShapeInfo.mnFamily)
630 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
631 : else
632 0 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
633 : }
634 :
635 : // ------------------
636 : // export text style name
637 : // ------------------
638 0 : if( !aShapeInfo.msTextStyleName.isEmpty() )
639 : {
640 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME, aShapeInfo.msTextStyleName );
641 : }
642 :
643 : // --------------------------
644 : // export shapes id if needed
645 : // --------------------------
646 : {
647 0 : uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
648 0 : const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef );
649 0 : if( !rShapeId.isEmpty() )
650 : {
651 0 : mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId);
652 0 : }
653 : }
654 :
655 : // --------------------------
656 : // export layer information
657 : // --------------------------
658 0 : if( IsLayerExportEnabled() )
659 : {
660 : // check for group or scene shape and not export layer if this is one
661 0 : uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY );
662 0 : if( !xShapes.is() )
663 : {
664 : try
665 : {
666 0 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
667 0 : OUString aLayerName;
668 0 : xProps->getPropertyValue( OUString( "LayerName" ) ) >>= aLayerName;
669 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LAYER, aLayerName );
670 :
671 : }
672 0 : catch(const uno::Exception&)
673 : {
674 : OSL_FAIL( "could not export layer name for shape!" );
675 : }
676 0 : }
677 : }
678 :
679 : // export draw:display (do not export in ODF 1.2 or older)
680 0 : if( xSet.is() && ( mrExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012 ) )
681 : {
682 0 : if( aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape && aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
683 : aShapeInfo.meShapeType != XmlShapeTypeHandoutShape && aShapeInfo.meShapeType != XmlShapeTypeDrawChartShape )
684 :
685 : try
686 : {
687 0 : sal_Bool bVisible = sal_True;
688 0 : sal_Bool bPrintable = sal_True;
689 :
690 0 : xSet->getPropertyValue(msVisible) >>= bVisible;
691 0 : xSet->getPropertyValue(msPrintable) >>= bPrintable;
692 :
693 0 : XMLTokenEnum eDisplayToken = XML_TOKEN_INVALID;
694 0 : const unsigned short nDisplay = (bVisible ? 2 : 0) | (bPrintable ? 1 : 0);
695 0 : switch( nDisplay )
696 : {
697 0 : case 0: eDisplayToken = XML_NONE; break;
698 0 : case 1: eDisplayToken = XML_PRINTER; break;
699 0 : case 2: eDisplayToken = XML_SCREEN; break;
700 : // case 3: eDisplayToken = XML_ALWAYS break; this is the default
701 : }
702 :
703 0 : if( eDisplayToken != XML_TOKEN_INVALID )
704 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW_EXT, XML_DISPLAY, eDisplayToken );
705 : }
706 0 : catch(const uno::Exception&)
707 : {
708 : OSL_FAIL( "XMLShapeExport::exportShape(), exception caught!" );
709 : }
710 : }
711 :
712 : // #82003# test export count
713 : // #91587# ALWAYS increment since now ALL to be exported shapes are counted.
714 0 : if(mrExport.GetShapeExport()->IsHandleProgressBarEnabled())
715 : {
716 0 : mrExport.GetProgressBarHelper()->Increment();
717 : }
718 :
719 0 : onExport( xShape );
720 :
721 : // --------------------
722 : // export shape element
723 : // --------------------
724 0 : switch(aShapeInfo.meShapeType)
725 : {
726 : case XmlShapeTypeDrawRectangleShape:
727 : {
728 0 : ImpExportRectangleShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
729 0 : break;
730 : }
731 : case XmlShapeTypeDrawEllipseShape:
732 : {
733 0 : ImpExportEllipseShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
734 0 : break;
735 : }
736 : case XmlShapeTypeDrawLineShape:
737 : {
738 0 : ImpExportLineShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
739 0 : break;
740 : }
741 : case XmlShapeTypeDrawPolyPolygonShape: // closed PolyPolygon
742 : case XmlShapeTypeDrawPolyLineShape: // open PolyPolygon
743 : case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves
744 : case XmlShapeTypeDrawOpenBezierShape: // open PolyPolygon containing curves
745 : {
746 0 : ImpExportPolygonShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
747 0 : break;
748 : }
749 :
750 : case XmlShapeTypeDrawTextShape:
751 : case XmlShapeTypePresTitleTextShape:
752 : case XmlShapeTypePresOutlinerShape:
753 : case XmlShapeTypePresSubtitleShape:
754 : case XmlShapeTypePresNotesShape:
755 : case XmlShapeTypePresHeaderShape:
756 : case XmlShapeTypePresFooterShape:
757 : case XmlShapeTypePresSlideNumberShape:
758 : case XmlShapeTypePresDateTimeShape:
759 : {
760 0 : ImpExportTextBoxShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
761 0 : break;
762 : }
763 :
764 : case XmlShapeTypeDrawGraphicObjectShape:
765 : case XmlShapeTypePresGraphicObjectShape:
766 : {
767 0 : ImpExportGraphicObjectShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
768 0 : break;
769 : }
770 :
771 : case XmlShapeTypeDrawChartShape:
772 : case XmlShapeTypePresChartShape:
773 : {
774 0 : ImpExportChartShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint, pAttrList );
775 0 : break;
776 : }
777 :
778 : case XmlShapeTypeDrawControlShape:
779 : {
780 0 : ImpExportControlShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
781 0 : break;
782 : }
783 :
784 : case XmlShapeTypeDrawConnectorShape:
785 : {
786 0 : ImpExportConnectorShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
787 0 : break;
788 : }
789 :
790 : case XmlShapeTypeDrawMeasureShape:
791 : {
792 0 : ImpExportMeasureShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
793 0 : break;
794 : }
795 :
796 : case XmlShapeTypeDrawOLE2Shape:
797 : case XmlShapeTypePresOLE2Shape:
798 : case XmlShapeTypeDrawSheetShape:
799 : case XmlShapeTypePresSheetShape:
800 : {
801 0 : ImpExportOLE2Shape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
802 0 : break;
803 : }
804 :
805 : case XmlShapeTypePresTableShape:
806 : case XmlShapeTypeDrawTableShape:
807 : {
808 0 : ImpExportTableShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
809 0 : break;
810 : }
811 :
812 : case XmlShapeTypeDrawPageShape:
813 : case XmlShapeTypePresPageShape:
814 : case XmlShapeTypeHandoutShape:
815 : {
816 0 : ImpExportPageShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
817 0 : break;
818 : }
819 :
820 : case XmlShapeTypeDrawCaptionShape:
821 : {
822 0 : ImpExportCaptionShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
823 0 : break;
824 : }
825 :
826 : case XmlShapeTypeDraw3DCubeObject:
827 : case XmlShapeTypeDraw3DSphereObject:
828 : case XmlShapeTypeDraw3DLatheObject:
829 : case XmlShapeTypeDraw3DExtrudeObject:
830 : {
831 0 : ImpExport3DShape(xShape, aShapeInfo.meShapeType);
832 0 : break;
833 : }
834 :
835 : case XmlShapeTypeDraw3DSceneObject:
836 : {
837 0 : ImpExport3DSceneShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
838 0 : break;
839 : }
840 :
841 : case XmlShapeTypeDrawGroupShape:
842 : {
843 : // empty group
844 0 : ImpExportGroupShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
845 0 : break;
846 : }
847 :
848 : case XmlShapeTypeDrawFrameShape:
849 : {
850 0 : ImpExportFrameShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
851 0 : break;
852 : }
853 :
854 : case XmlShapeTypeDrawAppletShape:
855 : {
856 0 : ImpExportAppletShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
857 0 : break;
858 : }
859 :
860 : case XmlShapeTypeDrawPluginShape:
861 : {
862 0 : ImpExportPluginShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
863 0 : break;
864 : }
865 :
866 : case XmlShapeTypeDrawCustomShape:
867 : {
868 0 : if ( aShapeInfo.xCustomShapeReplacement.is() )
869 0 : ImpExportGroupShape( aShapeInfo.xCustomShapeReplacement, XmlShapeTypeDrawGroupShape, nFeatures, pRefPoint );
870 : else
871 0 : ImpExportCustomShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
872 0 : break;
873 : }
874 :
875 : case XmlShapeTypePresMediaShape:
876 : case XmlShapeTypeDrawMediaShape:
877 : {
878 0 : ImpExportMediaShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
879 0 : break;
880 : }
881 :
882 : case XmlShapeTypePresOrgChartShape:
883 : case XmlShapeTypeUnknown:
884 : case XmlShapeTypeNotYetSet:
885 : default:
886 : {
887 : // this should never happen and is an error
888 : OSL_FAIL("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
889 0 : break;
890 : }
891 : }
892 :
893 0 : mpHyperlinkElement.reset();
894 :
895 : // #97489# #97111#
896 : // if there was an error and no element for the shape was exported
897 : // we need to clear the attribute list or the attributes will be
898 : // set on the next exported element, which can result in corrupt
899 : // xml files due to duplicate attributes
900 :
901 0 : mrExport.CheckAttrList(); // asserts in non pro if we have attributes left
902 0 : mrExport.ClearAttrList(); // clears the attributes
903 : }
904 :
905 : ///////////////////////////////////////////////////////////////////////
906 :
907 : // This method collects all automatic styles for the shapes inside the given XShapes collection
908 0 : void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
909 : {
910 0 : ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
911 0 : seekShapes( xShapes );
912 :
913 0 : uno::Reference< drawing::XShape > xShape;
914 0 : const sal_Int32 nShapeCount(xShapes->getCount());
915 0 : for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
916 : {
917 0 : xShapes->getByIndex(nShapeId) >>= xShape;
918 : DBG_ASSERT( xShape.is(), "Shape without a XShape?" );
919 0 : if(!xShape.is())
920 0 : continue;
921 :
922 0 : collectShapeAutoStyles( xShape );
923 : }
924 :
925 0 : maCurrentShapesIter = aOldCurrentShapesIter;
926 0 : }
927 :
928 : ///////////////////////////////////////////////////////////////////////
929 :
930 : // This method exports all XShape inside the given XShapes collection
931 0 : void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
932 : {
933 0 : ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
934 0 : seekShapes( xShapes );
935 :
936 0 : uno::Reference< drawing::XShape > xShape;
937 0 : const sal_Int32 nShapeCount(xShapes->getCount());
938 0 : for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
939 : {
940 0 : xShapes->getByIndex(nShapeId) >>= xShape;
941 : DBG_ASSERT( xShape.is(), "Shape without a XShape?" );
942 0 : if(!xShape.is())
943 0 : continue;
944 :
945 0 : exportShape( xShape, nFeatures, pRefPoint );
946 : }
947 :
948 0 : maCurrentShapesIter = aOldCurrentShapesIter;
949 0 : }
950 :
951 : ///////////////////////////////////////////////////////////////////////
952 :
953 8 : void XMLShapeExport::seekShapes( const uno::Reference< drawing::XShapes >& xShapes ) throw()
954 : {
955 8 : if( xShapes.is() )
956 : {
957 8 : maCurrentShapesIter = maShapesInfos.find( xShapes );
958 8 : if( maCurrentShapesIter == maShapesInfos.end() )
959 : {
960 6 : ImplXMLShapeExportInfoVector aNewInfoVector;
961 6 : aNewInfoVector.resize( (ShapesInfos::size_type) xShapes->getCount() );
962 6 : maShapesInfos[ xShapes ] = aNewInfoVector;
963 :
964 6 : maCurrentShapesIter = maShapesInfos.find( xShapes );
965 :
966 6 : DBG_ASSERT( maCurrentShapesIter != maShapesInfos.end(), "XMLShapeExport::seekShapes(): insert into stl::map failed" );
967 : }
968 :
969 : DBG_ASSERT( (*maCurrentShapesIter).second.size() == (ShapesInfos::size_type)xShapes->getCount(), "XMLShapeExport::seekShapes(): XShapes size varied between calls" );
970 :
971 : }
972 : else
973 : {
974 0 : maCurrentShapesIter = maShapesInfos.end();
975 : }
976 8 : }
977 :
978 : ///////////////////////////////////////////////////////////////////////
979 :
980 6 : void XMLShapeExport::exportAutoStyles()
981 : {
982 : // export all autostyle infos
983 :
984 : // ...for graphic
985 : {
986 6 : GetExport().GetAutoStylePool()->exportXML(
987 : XML_STYLE_FAMILY_SD_GRAPHICS_ID
988 6 : , GetExport().GetDocHandler(),
989 6 : GetExport().GetMM100UnitConverter(),
990 6 : GetExport().GetNamespaceMap()
991 6 : );
992 : }
993 :
994 : // ...for presentation
995 : {
996 6 : GetExport().GetAutoStylePool()->exportXML(
997 : XML_STYLE_FAMILY_SD_PRESENTATION_ID
998 6 : , GetExport().GetDocHandler(),
999 6 : GetExport().GetMM100UnitConverter(),
1000 6 : GetExport().GetNamespaceMap()
1001 6 : );
1002 : }
1003 :
1004 6 : if( mxShapeTableExport.is() )
1005 6 : mxShapeTableExport->exportAutoStyles();
1006 6 : }
1007 :
1008 : ///////////////////////////////////////////////////////////////////////
1009 :
1010 : /// returns the export property mapper for external chaining
1011 12 : SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper(
1012 : SvXMLExport& rExport )
1013 : {
1014 12 : UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rExport.GetModel(), rExport );
1015 12 : UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory );
1016 : SvXMLExportPropertyMapper* pResult =
1017 12 : new XMLShapeExportPropertyMapper( xMapper, rExport );
1018 : // chain text attributes
1019 12 : return pResult;
1020 : }
1021 :
1022 : ///////////////////////////////////////////////////////////////////////
1023 :
1024 0 : void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape,
1025 : XmlShapeType& eShapeType)
1026 : {
1027 : // set in every case, so init here
1028 0 : eShapeType = XmlShapeTypeUnknown;
1029 :
1030 0 : uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
1031 0 : if(xShapeDescriptor.is())
1032 : {
1033 0 : OUString aType(xShapeDescriptor->getShapeType());
1034 :
1035 0 : if(aType.match("com.sun.star."))
1036 : {
1037 0 : if(aType.match("drawing.", 13))
1038 : {
1039 : // drawing shapes
1040 0 : if (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; }
1041 :
1042 : // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6.
1043 : // As can be seen at the other compares, the appendix "Shape" is left out of the comparison.
1044 0 : else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; }
1045 :
1046 0 : else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; }
1047 0 : else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; }
1048 0 : else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; }
1049 0 : else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; }
1050 0 : else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; }
1051 :
1052 : // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape
1053 0 : else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; }
1054 :
1055 : // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape
1056 0 : else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; }
1057 :
1058 0 : else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1059 0 : else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1060 :
1061 : // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and
1062 : // ClosedFreeHandShape respectively. Represent them as bezier shapes
1063 0 : else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1064 0 : else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1065 :
1066 0 : else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; }
1067 0 : else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; }
1068 0 : else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; }
1069 0 : else if(aType.match("OLE2", 21))
1070 : {
1071 0 : eShapeType = XmlShapeTypeDrawOLE2Shape;
1072 :
1073 : // get info about presentation shape
1074 0 : uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1075 :
1076 0 : if(xPropSet.is())
1077 : {
1078 0 : rtl::OUString sCLSID;
1079 0 : if(xPropSet->getPropertyValue(OUString("CLSID")) >>= sCLSID)
1080 : {
1081 0 : if (sCLSID.equals(mrExport.GetChartExport()->getChartCLSID()))
1082 : {
1083 0 : eShapeType = XmlShapeTypeDrawChartShape;
1084 : }
1085 0 : else if (
1086 0 : sCLSID.equals(rtl::OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName()))
1087 : // #110680#
1088 : // same reaction for binfilter
1089 0 : || sCLSID.equals(rtl::OUString( SvGlobalName( BF_SO3_SC_CLASSID ).GetHexName()))
1090 : )
1091 : {
1092 0 : eShapeType = XmlShapeTypeDrawSheetShape;
1093 : }
1094 : else
1095 : {
1096 : // general OLE2 Object
1097 : }
1098 0 : }
1099 0 : }
1100 : }
1101 0 : else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; }
1102 0 : else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; }
1103 0 : else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; }
1104 0 : else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; }
1105 0 : else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; }
1106 0 : else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; }
1107 0 : else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; }
1108 :
1109 : // 3D shapes
1110 0 : else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; }
1111 0 : else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; }
1112 0 : else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; }
1113 0 : else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; }
1114 0 : else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; }
1115 : }
1116 0 : else if(aType.match("presentation.", 13))
1117 : {
1118 : // presentation shapes
1119 0 : if (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; }
1120 0 : else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape; }
1121 0 : else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape; }
1122 0 : else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape; }
1123 0 : else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape; }
1124 0 : else if(aType.match("OLE2", 26))
1125 : {
1126 0 : eShapeType = XmlShapeTypePresOLE2Shape;
1127 :
1128 : // get info about presentation shape
1129 0 : uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1130 :
1131 0 : if(xPropSet.is()) try
1132 : {
1133 0 : rtl::OUString sCLSID;
1134 0 : if(xPropSet->getPropertyValue(OUString("CLSID")) >>= sCLSID)
1135 : {
1136 0 : if( sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())) ||
1137 0 : sCLSID.equals(OUString( SvGlobalName( BF_SO3_SC_CLASSID ).GetHexName())) )
1138 : {
1139 0 : eShapeType = XmlShapeTypePresSheetShape;
1140 : }
1141 0 : }
1142 : }
1143 0 : catch(const uno::Exception&)
1144 : {
1145 : OSL_FAIL( "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" );
1146 0 : }
1147 : }
1148 0 : else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape; }
1149 0 : else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape; }
1150 0 : else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; }
1151 0 : else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; }
1152 0 : else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape; }
1153 0 : else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; }
1154 0 : else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; }
1155 0 : else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; }
1156 0 : else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; }
1157 0 : else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; }
1158 0 : else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; }
1159 : }
1160 0 : }
1161 0 : }
1162 0 : }
1163 :
1164 : ///////////////////////////////////////////////////////////////////////
1165 :
1166 : extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[];
1167 : extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[];
1168 :
1169 : /** exports all user defined glue points */
1170 0 : void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape >& xShape )
1171 : {
1172 0 : uno::Reference< drawing::XGluePointsSupplier > xSupplier( xShape, uno::UNO_QUERY );
1173 0 : if( !xSupplier.is() )
1174 : return;
1175 :
1176 0 : uno::Reference< container::XIdentifierAccess > xGluePoints( xSupplier->getGluePoints(), uno::UNO_QUERY );
1177 0 : if( !xGluePoints.is() )
1178 : return;
1179 :
1180 0 : drawing::GluePoint2 aGluePoint;
1181 :
1182 0 : uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() );
1183 :
1184 0 : const sal_Int32 nCount = aIdSequence.getLength();
1185 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1186 : {
1187 0 : const sal_Int32 nIdentifier = aIdSequence[nIndex];
1188 0 : if( (xGluePoints->getByIdentifier( nIdentifier ) >>= aGluePoint) && aGluePoint.IsUserDefined )
1189 : {
1190 : // export only user defined glue points
1191 :
1192 0 : const OUString sId( OUString::valueOf( nIdentifier ) );
1193 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, sId );
1194 :
1195 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1196 0 : aGluePoint.Position.X);
1197 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, msBuffer.makeStringAndClear());
1198 :
1199 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1200 0 : aGluePoint.Position.Y);
1201 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, msBuffer.makeStringAndClear());
1202 :
1203 0 : if( !aGluePoint.IsRelative )
1204 : {
1205 0 : SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.PositionAlignment, aXML_GlueAlignment_EnumMap );
1206 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ALIGN, msBuffer.makeStringAndClear() );
1207 : }
1208 :
1209 0 : if( aGluePoint.Escape != drawing::EscapeDirection_SMART )
1210 : {
1211 0 : SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.Escape, aXML_GlueEscapeDirection_EnumMap );
1212 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ESCAPE_DIRECTION, msBuffer.makeStringAndClear() );
1213 : }
1214 :
1215 0 : SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_DRAW, XML_GLUE_POINT, sal_True, sal_True);
1216 : }
1217 0 : }
1218 : }
1219 :
1220 2 : void XMLShapeExport::ExportGraphicDefaults()
1221 : {
1222 2 : XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
1223 :
1224 : // construct PropertySetMapper
1225 2 : UniReference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( mrExport ) );
1226 2 : ((XMLShapeExportPropertyMapper*)xPropertySetMapper.get())->SetAutoStyles( sal_False );
1227 :
1228 : // chain text attributes
1229 2 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(mrExport));
1230 :
1231 : // chain special Writer/text frame default attributes
1232 2 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaDefaultExtPropMapper(mrExport));
1233 :
1234 : // write graphic family default style
1235 2 : uno::Reference< lang::XMultiServiceFactory > xFact( mrExport.GetModel(), uno::UNO_QUERY );
1236 2 : if( xFact.is() )
1237 : {
1238 : try
1239 : {
1240 2 : uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance( OUString("com.sun.star.drawing.Defaults" ) ), uno::UNO_QUERY );
1241 2 : if( xDefaults.is() )
1242 : {
1243 2 : aStEx.exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
1244 :
1245 : // write graphic family styles
1246 2 : aStEx.exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, sal_False, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
1247 2 : }
1248 : }
1249 0 : catch(const lang::ServiceNotRegisteredException&)
1250 : {
1251 : }
1252 2 : }
1253 2 : }
1254 :
1255 0 : void XMLShapeExport::onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& )
1256 : {
1257 0 : }
1258 :
1259 8 : const rtl::Reference< XMLTableExport >& XMLShapeExport::GetShapeTableExport()
1260 : {
1261 8 : if( !mxShapeTableExport.is() )
1262 : {
1263 8 : rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ) );
1264 8 : UniReference < XMLPropertySetMapper > xMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
1265 8 : rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper, mrExport ) );
1266 8 : mxShapeTableExport = new XMLTableExport( mrExport, xPropertySetMapper, xFactory );
1267 : }
1268 :
1269 8 : return mxShapeTableExport;
1270 : }
1271 :
1272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|