1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapeexport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "unointerfacetouniqueidentifiermapper.hxx"
34 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
35 #include <com/sun/star/container/XChild.hpp>
36 #include <com/sun/star/text/XText.hpp>
37 #include <com/sun/star/chart/XChartDocument.hpp>
38 #include <com/sun/star/drawing/XControlShape.hpp>
39 #include <com/sun/star/style/XStyle.hpp>
40 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
41 #include <com/sun/star/container/XIdentifierAccess.hpp>
42 #include <com/sun/star/drawing/GluePoint2.hpp>
43 #include <com/sun/star/drawing/Alignment.hpp>
44 #include <com/sun/star/drawing/EscapeDirection.hpp>
45 #include <com/sun/star/table/XColumnRowRange.hpp>
46 #include <xmloff/xmluconv.hxx>
47 #include "PropertySetMerger.hxx"
49 #ifndef _XMLOFF_SHAPEEXPORT_HXX
50 #include <xmloff/shapeexport.hxx>
52 #include "sdpropls.hxx"
53 #include "sdxmlexp_impl.hxx"
54 #include <xmloff/families.hxx>
55 #include <tools/debug.hxx>
56 #include <xmloff/contextid.hxx>
57 #include <xmloff/xmltoken.hxx>
58 #include <tools/string.hxx>
59 #include <sot/clsids.hxx>
60 #include <tools/globname.hxx>
61 #include <com/sun/star/beans/XPropertyState.hpp>
63 #include <comphelper/processfactory.hxx>
64 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
65 #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
67 #include "xmlnmspe.hxx"
69 using ::rtl::OUString
;
70 using ::rtl::OUStringBuffer
;
72 using namespace ::com::sun::star
;
73 using namespace ::xmloff::token
;
75 //////////////////////////////////////////////////////////////////////////////
77 XMLShapeExport::XMLShapeExport(SvXMLExport
& rExp
,
78 SvXMLExportPropertyMapper
*pExtMapper
)
80 mnNextUniqueShapeId(1),
81 mbExportLayer( sal_False
),
82 // #88546# init to FALSE
83 mbHandleProgressBar( sal_False
),
84 msZIndex( RTL_CONSTASCII_USTRINGPARAM("ZOrder") ),
85 msEmptyPres( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ),
86 msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ),
87 msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ),
88 msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") ),
89 msOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") ),
90 msEventType( RTL_CONSTASCII_USTRINGPARAM("EventType") ),
91 msPresentation( RTL_CONSTASCII_USTRINGPARAM("Presentation") ),
92 msMacroName( RTL_CONSTASCII_USTRINGPARAM("MacroName") ),
93 msScript( RTL_CONSTASCII_USTRINGPARAM("Script") ),
94 msLibrary( RTL_CONSTASCII_USTRINGPARAM("Library") ),
95 msClickAction( RTL_CONSTASCII_USTRINGPARAM("ClickAction") ),
96 msBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") ),
97 msEffect( RTL_CONSTASCII_USTRINGPARAM("Effect") ),
98 msPlayFull( RTL_CONSTASCII_USTRINGPARAM("PlayFull") ),
99 msVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") ),
100 msSoundURL( RTL_CONSTASCII_USTRINGPARAM("SoundURL") ),
101 msSpeed( RTL_CONSTASCII_USTRINGPARAM("Speed") ),
102 msStarBasic( RTL_CONSTASCII_USTRINGPARAM("StarBasic") )
104 // construct PropertyHandlerFactory
105 mxSdPropHdlFactory
= new XMLSdPropHdlFactory( mrExport
.GetModel(), rExp
);
106 // construct PropertySetMapper
107 mxPropertySetMapper
= CreateShapePropMapper( mrExport
);
110 UniReference
< SvXMLExportPropertyMapper
> xExtMapper( pExtMapper
);
111 mxPropertySetMapper
->ChainExportMapper( xExtMapper
);
115 // chain text attributes
116 xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
119 mrExport
.GetAutoStylePool()->AddFamily(
120 XML_STYLE_FAMILY_SD_GRAPHICS_ID
,
121 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME
)),
122 GetPropertySetMapper(),
123 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX
)));
124 mrExport
.GetAutoStylePool()->AddFamily(
125 XML_STYLE_FAMILY_SD_PRESENTATION_ID
,
126 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME
)),
127 GetPropertySetMapper(),
128 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX
)));
130 maCurrentInfo
= maShapeInfos
.end();
132 // create table export helper and let him add his families in time
133 GetShapeTableExport();
136 ///////////////////////////////////////////////////////////////////////
138 XMLShapeExport::~XMLShapeExport()
142 ///////////////////////////////////////////////////////////////////////
144 // sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format
145 uno::Reference
< drawing::XShape
> XMLShapeExport::checkForCustomShapeReplacement( const uno::Reference
< drawing::XShape
>& xShape
)
147 uno::Reference
< drawing::XShape
> xCustomShapeReplacement
;
149 if( ( GetExport().getExportFlags() & EXPORT_OASIS
) == 0 )
151 String
aType( (OUString
)xShape
->getShapeType() );
152 if( aType
.EqualsAscii( (const sal_Char
*)"com.sun.star.drawing.CustomShape" ) )
154 uno::Reference
< beans::XPropertySet
> xSet( xShape
, uno::UNO_QUERY
);
157 rtl::OUString aEngine
;
158 xSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeEngine" ) ) ) >>= aEngine
;
159 if ( !aEngine
.getLength() )
160 aEngine
= OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) );
162 uno::Reference
< lang::XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
164 uno::Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pCustomShape );
166 aXShape = new SvxCustomShape( (SdrObjCustomShape*)pCustomShape );
168 if ( aEngine
.getLength() && xFactory
.is() )
170 uno::Sequence
< uno::Any
> aArgument( 1 );
171 uno::Sequence
< beans::PropertyValue
> aPropValues( 2 );
172 aPropValues
[ 0 ].Name
= rtl::OUString::createFromAscii( "CustomShape" );
173 aPropValues
[ 0 ].Value
<<= xShape
;
174 sal_Bool bForceGroupWithText
= sal_True
;
175 aPropValues
[ 1 ].Name
= rtl::OUString::createFromAscii( "ForceGroupWithText" );
176 aPropValues
[ 1 ].Value
<<= bForceGroupWithText
;
177 aArgument
[ 0 ] <<= aPropValues
;
178 uno::Reference
< uno::XInterface
> xInterface( xFactory
->createInstanceWithArguments( aEngine
, aArgument
) );
179 if ( xInterface
.is() )
181 uno::Reference
< drawing::XCustomShapeEngine
> xCustomShapeEngine(
182 uno::Reference
< drawing::XCustomShapeEngine
>( xInterface
, uno::UNO_QUERY
) );
183 if ( xCustomShapeEngine
.is() )
184 xCustomShapeReplacement
= xCustomShapeEngine
->render();
190 return xCustomShapeReplacement
;
193 // This method collects all automatic styles for the given XShape
194 void XMLShapeExport::collectShapeAutoStyles(const uno::Reference
< drawing::XShape
>& xShape
)
196 if( maCurrentShapesIter
== maShapesInfos
.end() )
198 DBG_ERROR( "XMLShapeExport::collectShapeAutoStyles(): no call to seekShapes()!" );
201 sal_Int32 nZIndex
= 0;
202 uno::Reference
< beans::XPropertySet
> xSet( xShape
, uno::UNO_QUERY
);
204 xSet
->getPropertyValue(msZIndex
) >>= nZIndex
;
206 ImplXMLShapeExportInfoVector
& aShapeInfoVector
= (*maCurrentShapesIter
).second
;
208 if( (sal_Int32
)aShapeInfoVector
.size() <= nZIndex
)
210 DBG_ERROR( "XMLShapeExport::collectShapeAutoStyles(): no shape info allocated for a given shape" );
214 ImplXMLShapeExportInfo
& aShapeInfo
= aShapeInfoVector
[nZIndex
];
216 uno::Reference
< drawing::XShape
> xCustomShapeReplacement
= checkForCustomShapeReplacement( xShape
);
217 if ( xCustomShapeReplacement
.is() )
218 aShapeInfo
.xCustomShapeReplacement
= xCustomShapeReplacement
;
220 // -----------------------------
221 // first compute the shapes type
222 // -----------------------------
223 ImpCalcShapeType(xShape
, aShapeInfo
.meShapeType
);
225 const bool bObjSupportsText
=
226 // aShapeInfo.meShapeType != XmlShapeTypeDrawControlShape &&
227 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawChartShape
&&
228 aShapeInfo
.meShapeType
!= XmlShapeTypePresChartShape
&&
229 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawOLE2Shape
&&
230 aShapeInfo
.meShapeType
!= XmlShapeTypePresOLE2Shape
&&
231 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawSheetShape
&&
232 aShapeInfo
.meShapeType
!= XmlShapeTypePresSheetShape
&&
233 aShapeInfo
.meShapeType
!= XmlShapeTypeDraw3DSceneObject
&&
234 aShapeInfo
.meShapeType
!= XmlShapeTypeDraw3DCubeObject
&&
235 aShapeInfo
.meShapeType
!= XmlShapeTypeDraw3DSphereObject
&&
236 aShapeInfo
.meShapeType
!= XmlShapeTypeDraw3DLatheObject
&&
237 aShapeInfo
.meShapeType
!= XmlShapeTypeDraw3DExtrudeObject
&&
238 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawPageShape
&&
239 aShapeInfo
.meShapeType
!= XmlShapeTypePresPageShape
&&
240 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawGroupShape
;
242 const bool bObjSupportsStyle
=
243 aShapeInfo
.meShapeType
!= XmlShapeTypeDrawGroupShape
;
245 sal_Bool bIsEmptyPresObj
= sal_False
;
247 uno::Reference
< beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
248 if ( aShapeInfo
.xCustomShapeReplacement
.is() )
254 if( xPropSet
.is() && bObjSupportsText
)
256 uno::Reference
< text::XText
> xText(xShape
, uno::UNO_QUERY
);
257 if(xText
.is() && xText
->getString().getLength())
259 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
261 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName(msEmptyPres
) )
263 uno::Any aAny
= xPropSet
->getPropertyValue(msEmptyPres
);
264 aAny
>>= bIsEmptyPresObj
;
269 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText
);
274 // ------------------------------
275 // compute the shape parent style
276 // ------------------------------
279 uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo( xPropSet
->getPropertySetInfo() );
281 OUString aParentName
;
282 uno::Reference
< style::XStyle
> xStyle
;
284 if( bObjSupportsStyle
)
286 if( xPropertySetInfo
.is() && xPropertySetInfo
->hasPropertyByName( OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))) )
287 xPropSet
->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))) >>= xStyle
;
292 uno::Reference
< beans::XPropertySet
> xStylePropSet(xStyle
, uno::UNO_QUERY
);
293 DBG_ASSERT( xStylePropSet
.is(), "style without a XPropertySet?" );
296 if(xStylePropSet
.is())
298 OUString aFamilyName
;
299 xStylePropSet
->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Family"))) >>= aFamilyName
;
300 if(aFamilyName
.getLength() && !aFamilyName
.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("graphics"))))
301 aShapeInfo
.mnFamily
= XML_STYLE_FAMILY_SD_PRESENTATION_ID
;
304 catch(beans::UnknownPropertyException aException
)
308 "XMLShapeExport::collectShapeAutoStyles: style has no 'Family' property");
311 // get parent-style name
312 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID
== aShapeInfo
.mnFamily
)
314 aParentName
= msPresentationStylePrefix
;
317 aParentName
+= xStyle
->getName();
322 std::vector
< XMLPropertyState
> xPropStates
;
324 sal_Int32 nCount
= 0;
325 if( (!bIsEmptyPresObj
|| (aShapeInfo
.meShapeType
!= XmlShapeTypePresPageShape
)) )
327 xPropStates
= GetPropertySetMapper()->Filter( xPropSet
);
329 if (XmlShapeTypeDrawControlShape
== aShapeInfo
.meShapeType
)
331 // for control shapes, we additionally need the number format style (if any)
332 uno::Reference
< drawing::XControlShape
> xControl(xShape
, uno::UNO_QUERY
);
333 DBG_ASSERT(xControl
.is(), "XMLShapeExport::collectShapeAutoStyles: ShapeType control, but no XControlShape!");
336 uno::Reference
< beans::XPropertySet
> xControlModel(xControl
->getControl(), uno::UNO_QUERY
);
337 DBG_ASSERT(xControlModel
.is(), "XMLShapeExport::collectShapeAutoStyles: no control model on the control shape!");
339 ::rtl::OUString sNumberStyle
= mrExport
.GetFormExport()->getControlNumberStyle(xControlModel
);
340 if (0 != sNumberStyle
.getLength())
342 sal_Int32 nIndex
= GetPropertySetMapper()->getPropertySetMapper()->FindEntryIndex(CTF_SD_CONTROL_SHAPE_DATA_STYLE
);
343 // TODO : this retrieval of the index could be moved into the ctor, holding the index
344 // as member, thus saving time.
345 DBG_ASSERT(-1 != nIndex
, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for our context id!");
347 XMLPropertyState
aNewState(nIndex
, uno::makeAny(sNumberStyle
));
348 xPropStates
.push_back(aNewState
);
353 std::vector
< XMLPropertyState
>::iterator aIter
= xPropStates
.begin();
354 std::vector
< XMLPropertyState
>::iterator aEnd
= xPropStates
.end();
355 while( aIter
!= aEnd
)
357 if( aIter
->mnIndex
!= -1 )
365 // no hard attributes, use parent style name for export
366 aShapeInfo
.msStyleName
= aParentName
;
370 // there are filtered properties -> hard attributes
371 // try to find this style in AutoStylePool
372 aShapeInfo
.msStyleName
= mrExport
.GetAutoStylePool()->Find(aShapeInfo
.mnFamily
, aParentName
, xPropStates
);
374 if(!aShapeInfo
.msStyleName
.getLength())
376 // Style did not exist, add it to AutoStalePool
377 aShapeInfo
.msStyleName
= mrExport
.GetAutoStylePool()->Add(aShapeInfo
.mnFamily
, aParentName
, xPropStates
);
381 // optionaly generate auto style for text attributes
382 if( (!bIsEmptyPresObj
|| (aShapeInfo
.meShapeType
!= XmlShapeTypePresPageShape
)) && bObjSupportsText
)
384 xPropStates
= GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet
);
386 // ----------------------------------------------------------------------
387 // yet more additionally, we need to care for the ParaAdjust property
388 if ( XmlShapeTypeDrawControlShape
== aShapeInfo
.meShapeType
)
390 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
391 uno::Reference
< beans::XPropertyState
> xPropState( xPropSet
, uno::UNO_QUERY
);
392 if ( xPropSetInfo
.is() && xPropState
.is() )
395 // * if controls shapes have a ParaAdjust property, then this is the Align property of the control model
396 // * control models are allowed to have an Align of "void"
397 // * the Default for control model's Align is TextAlign_LEFT
398 // * defaults for style properties are not written, but we need to write the "left",
399 // because we need to distiguish this "left" from the case where not align attribute
400 // is present which means "void"
401 // 102407 - 2002-11-01 - fs@openoffice.org
402 static const ::rtl::OUString
s_sParaAdjustPropertyName( RTL_CONSTASCII_USTRINGPARAM( "ParaAdjust" ) );
403 if ( xPropSetInfo
->hasPropertyByName( s_sParaAdjustPropertyName
)
404 && ( beans::PropertyState_DEFAULT_VALUE
== xPropState
->getPropertyState( s_sParaAdjustPropertyName
) )
407 sal_Int32 nIndex
= GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST
);
408 // TODO : this retrieval of the index should be moved into the ctor, holding the index
409 // as member, thus saving time.
410 DBG_ASSERT(-1 != nIndex
, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for the ParaAdjust context id!");
412 uno::Any aParaAdjustValue
= xPropSet
->getPropertyValue( s_sParaAdjustPropertyName
);
413 XMLPropertyState
aAlignDefaultState( nIndex
, aParaAdjustValue
);
415 xPropStates
.push_back( aAlignDefaultState
);
419 // ----------------------------------------------------------------------
422 std::vector
< XMLPropertyState
>::iterator aIter
= xPropStates
.begin();
423 std::vector
< XMLPropertyState
>::iterator aEnd
= xPropStates
.end();
424 while( aIter
!= aEnd
)
426 if( aIter
->mnIndex
!= -1 )
433 const OUString aEmpty
;
434 aShapeInfo
.msTextStyleName
= mrExport
.GetAutoStylePool()->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, aEmpty
, xPropStates
);
435 if(!aShapeInfo
.msTextStyleName
.getLength())
437 // Style did not exist, add it to AutoStalePool
438 aShapeInfo
.msTextStyleName
= mrExport
.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TEXT_PARAGRAPH
, aEmpty
, xPropStates
);
444 // ----------------------------------------
445 // prepare animation informations if needed
446 // ----------------------------------------
447 if( mxAnimationsExporter
.is() )
448 mxAnimationsExporter
->prepare( xShape
, mrExport
);
450 // check for special shapes
452 switch( aShapeInfo
.meShapeType
)
454 case XmlShapeTypeDrawConnectorShape
:
456 uno::Reference
< uno::XInterface
> xConnection
;
458 // create shape ids for export later
459 xPropSet
->getPropertyValue( msStartShape
) >>= xConnection
;
460 if( xConnection
.is() )
461 mrExport
.getInterfaceToIdentifierMapper().registerReference( xConnection
);
463 xPropSet
->getPropertyValue( msEndShape
) >>= xConnection
;
464 if( xConnection
.is() )
465 mrExport
.getInterfaceToIdentifierMapper().registerReference( xConnection
);
468 case XmlShapeTypeDrawTableShape
:
472 uno::Reference
< table::XColumnRowRange
> xRange( xSet
->getPropertyValue( msModel
), uno::UNO_QUERY_THROW
);
473 GetShapeTableExport()->collectTableAutoStyles( xRange
);
475 catch( uno::Exception
& )
477 DBG_ERROR( "XMLShapeExport::collectShapeAutoStyles(): exception caught while collection auto styles for a table!" );
485 maShapeInfos
.push_back( aShapeInfo
);
486 maCurrentInfo
= maShapeInfos
.begin();
488 // -----------------------------------------------------
489 // check for shape collections (group shape or 3d scene)
490 // and collect contained shapes style infos
491 // -----------------------------------------------------
492 const uno::Reference
< drawing::XShape
>& xCollection
= aShapeInfo
.xCustomShapeReplacement
.is()
493 ? aShapeInfo
.xCustomShapeReplacement
: xShape
;
495 uno::Reference
< drawing::XShapes
> xShapes( xCollection
, uno::UNO_QUERY
);
498 collectShapesAutoStyles( xShapes
);
503 ///////////////////////////////////////////////////////////////////////
505 // --> OD 2008-05-08 #refactorlists#
508 class NewTextListsHelper
511 NewTextListsHelper( SvXMLExport
& rExp
)
514 mrExport
.GetTextParagraphExport()->PushNewTextListsHelper();
517 ~NewTextListsHelper()
519 mrExport
.GetTextParagraphExport()->PopTextListsHelper();
523 SvXMLExport
& mrExport
;
526 // This method exports the given XShape
527 void XMLShapeExport::exportShape(const uno::Reference
< drawing::XShape
>& xShape
,
528 sal_Int32 nFeatures
/* = SEF_DEFAULT */,
529 com::sun::star::awt::Point
* pRefPoint
/* = NULL */,
530 SvXMLAttributeList
* pAttrList
/* = NULL */ )
532 if( maCurrentShapesIter
== maShapesInfos
.end() )
534 DBG_ERROR( "XMLShapeExport::exportShape(): no auto styles where collected before export" );
537 sal_Int32 nZIndex
= 0;
538 uno::Reference
< beans::XPropertySet
> xSet( xShape
, uno::UNO_QUERY
);
540 xSet
->getPropertyValue(msZIndex
) >>= nZIndex
;
542 ImplXMLShapeExportInfoVector
& aShapeInfoVector
= (*maCurrentShapesIter
).second
;
544 if( (sal_Int32
)aShapeInfoVector
.size() <= nZIndex
)
546 DBG_ERROR( "XMLShapeExport::exportShape(): no shape info collected for a given shape" );
550 // --> OD 2008-05-08 #refactorlists#
551 NewTextListsHelper
aNewTextListsHelper( mrExport
);
554 const ImplXMLShapeExportInfo
& aShapeInfo
= aShapeInfoVector
[nZIndex
];
558 // ---------------------------------------
559 // check if this is the correct ShapesInfo
560 // ---------------------------------------
561 uno::Reference
< container::XChild
> xChild( xShape
, uno::UNO_QUERY
);
564 uno::Reference
< drawing::XShapes
> xParent( xChild
->getParent(), uno::UNO_QUERY
);
565 DBG_ASSERT( xParent
.is() && xParent
.get() == (*maCurrentShapesIter
).first
.get(), "XMLShapeExport::exportShape(): Wrong call to XMLShapeExport::seekShapes()" );
568 // -----------------------------
569 // first compute the shapes type
570 // -----------------------------
572 XmlShapeType
eShapeType(XmlShapeTypeNotYetSet
);
573 ImpCalcShapeType(xShape
, eShapeType
);
575 DBG_ASSERT( eShapeType
== aShapeInfo
.meShapeType
, "exportShape callings do not correspond to collectShapeAutoStyles calls!" );
579 // ----------------------------------------
580 // collect animation informations if needed
581 // ----------------------------------------
582 if( mxAnimationsExporter
.is() )
583 mxAnimationsExporter
->collect( xShape
, mrExport
);
585 // -------------------------------
586 // export shapes name if he has one
587 // --> OD 2006-03-13 #i51726#
588 // Export of the shape name for text documents only if the OpenDocument
589 // file format is written - exceptions are group shapes.
590 // Note: Writer documents in OpenOffice.org file format doesn't contain
591 // any names for shapes, except for group shapes.
592 // -------------------------------
594 // --> OD 2006-03-10 #i51726#
595 if ( ( GetExport().GetModelType() != SvtModuleOptions::E_WRITER
&&
596 GetExport().GetModelType() != SvtModuleOptions::E_WRITERWEB
&&
597 GetExport().GetModelType() != SvtModuleOptions::E_WRITERGLOBAL
) ||
598 ( GetExport().getExportFlags() & EXPORT_OASIS
) != 0 ||
599 aShapeInfo
.meShapeType
== XmlShapeTypeDrawGroupShape
||
600 ( aShapeInfo
.meShapeType
== XmlShapeTypeDrawCustomShape
&&
601 aShapeInfo
.xCustomShapeReplacement
.is() ) )
603 uno::Reference
< container::XNamed
> xNamed( xShape
, uno::UNO_QUERY
);
606 const OUString
aName( xNamed
->getName() );
607 if( aName
.getLength() )
608 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_NAME
, aName
);
614 // ------------------
616 // ------------------
617 if( aShapeInfo
.msStyleName
.getLength() != 0 )
619 if(XML_STYLE_FAMILY_SD_GRAPHICS_ID
== aShapeInfo
.mnFamily
)
620 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_STYLE_NAME
, mrExport
.EncodeStyleName( aShapeInfo
.msStyleName
) );
622 mrExport
.AddAttribute(XML_NAMESPACE_PRESENTATION
, XML_STYLE_NAME
, mrExport
.EncodeStyleName( aShapeInfo
.msStyleName
) );
625 // ------------------
626 // export text style name
627 // ------------------
628 if( aShapeInfo
.msTextStyleName
.getLength() != 0 )
630 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_TEXT_STYLE_NAME
, aShapeInfo
.msTextStyleName
);
633 // --------------------------
634 // export shapes id if needed
635 // --------------------------
637 uno::Reference
< uno::XInterface
> xRef( xShape
, uno::UNO_QUERY
);
638 const OUString
& rShapeId
= mrExport
.getInterfaceToIdentifierMapper().getIdentifier( xRef
);
639 if( rShapeId
.getLength() )
640 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_ID
, rShapeId
);
643 // --------------------------
644 // export layer information
645 // --------------------------
646 if( IsLayerExportEnabled() )
648 // check for group or scene shape and not export layer if this is one
649 uno::Reference
< drawing::XShapes
> xShapes( xShape
, uno::UNO_QUERY
);
654 uno::Reference
< beans::XPropertySet
> xProps( xShape
, uno::UNO_QUERY
);
656 xProps
->getPropertyValue( OUString::createFromAscii( "LayerName" ) ) >>= aLayerName
;
657 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_LAYER
, aLayerName
);
660 catch( uno::Exception e
)
662 DBG_ERROR( "could not export layer name for shape!" );
667 // #82003# test export count
668 // #91587# ALWAYS increment since now ALL to be exported shapes are counted.
669 if(mrExport
.GetShapeExport()->IsHandleProgressBarEnabled())
671 mrExport
.GetProgressBarHelper()->Increment();
676 // --------------------
677 // export shape element
678 // --------------------
679 switch(aShapeInfo
.meShapeType
)
681 case XmlShapeTypeDrawRectangleShape
:
683 ImpExportRectangleShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
686 case XmlShapeTypeDrawEllipseShape
:
688 ImpExportEllipseShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
691 case XmlShapeTypeDrawLineShape
:
693 ImpExportLineShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
696 case XmlShapeTypeDrawPolyPolygonShape
: // closed PolyPolygon
697 case XmlShapeTypeDrawPolyLineShape
: // open PolyPolygon
698 case XmlShapeTypeDrawClosedBezierShape
: // closed PolyPolygon containing curves
699 case XmlShapeTypeDrawOpenBezierShape
: // open PolyPolygon containing curves
701 ImpExportPolygonShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
705 case XmlShapeTypeDrawTextShape
:
706 case XmlShapeTypePresTitleTextShape
:
707 case XmlShapeTypePresOutlinerShape
:
708 case XmlShapeTypePresSubtitleShape
:
709 case XmlShapeTypePresNotesShape
:
710 case XmlShapeTypePresHeaderShape
:
711 case XmlShapeTypePresFooterShape
:
712 case XmlShapeTypePresSlideNumberShape
:
713 case XmlShapeTypePresDateTimeShape
:
715 ImpExportTextBoxShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
719 case XmlShapeTypeDrawGraphicObjectShape
:
720 case XmlShapeTypePresGraphicObjectShape
:
722 ImpExportGraphicObjectShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
726 case XmlShapeTypeDrawChartShape
:
727 case XmlShapeTypePresChartShape
:
729 ImpExportChartShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
, pAttrList
);
733 case XmlShapeTypeDrawControlShape
:
735 ImpExportControlShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
739 case XmlShapeTypeDrawConnectorShape
:
741 ImpExportConnectorShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
745 case XmlShapeTypeDrawMeasureShape
:
747 ImpExportMeasureShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
751 case XmlShapeTypeDrawOLE2Shape
:
752 case XmlShapeTypePresOLE2Shape
:
753 case XmlShapeTypeDrawSheetShape
:
754 case XmlShapeTypePresSheetShape
:
756 ImpExportOLE2Shape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
760 case XmlShapeTypeDrawTableShape
:
762 ImpExportTableShape( xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
766 case XmlShapeTypeDrawPageShape
:
767 case XmlShapeTypePresPageShape
:
768 case XmlShapeTypeHandoutShape
:
770 ImpExportPageShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
774 case XmlShapeTypeDrawCaptionShape
:
776 ImpExportCaptionShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
780 case XmlShapeTypeDraw3DCubeObject
:
781 case XmlShapeTypeDraw3DSphereObject
:
782 case XmlShapeTypeDraw3DLatheObject
:
783 case XmlShapeTypeDraw3DExtrudeObject
:
785 ImpExport3DShape(xShape
, aShapeInfo
.meShapeType
);
789 case XmlShapeTypeDraw3DSceneObject
:
791 ImpExport3DSceneShape( xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
795 case XmlShapeTypeDrawGroupShape
:
798 ImpExportGroupShape( xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
802 case XmlShapeTypeDrawFrameShape
:
804 ImpExportFrameShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
808 case XmlShapeTypeDrawAppletShape
:
810 ImpExportAppletShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
814 case XmlShapeTypeDrawPluginShape
:
816 ImpExportPluginShape(xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
820 case XmlShapeTypeDrawCustomShape
:
822 if ( aShapeInfo
.xCustomShapeReplacement
.is() )
823 ImpExportGroupShape( aShapeInfo
.xCustomShapeReplacement
, XmlShapeTypeDrawGroupShape
, nFeatures
, pRefPoint
);
825 ImpExportCustomShape( xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
829 case XmlShapeTypeDrawMediaShape
:
831 ImpExportMediaShape( xShape
, aShapeInfo
.meShapeType
, nFeatures
, pRefPoint
);
835 case XmlShapeTypePresOrgChartShape
:
836 case XmlShapeTypeUnknown
:
837 case XmlShapeTypeNotYetSet
:
840 // this should never happen and is an error
841 DBG_ERROR("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
847 // if there was an error and no element for the shape was exported
848 // we need to clear the attribute list or the attributes will be
849 // set on the next exported element, which can result in corrupt
850 // xml files due to duplicate attributes
852 mrExport
.CheckAttrList(); // asserts in non pro if we have attributes left
853 mrExport
.ClearAttrList(); // clears the attributes
856 ///////////////////////////////////////////////////////////////////////
858 // This method collects all automatic styles for the shapes inside the given XShapes collection
859 void XMLShapeExport::collectShapesAutoStyles( const uno::Reference
< drawing::XShapes
>& xShapes
)
861 ShapesInfos::iterator aOldCurrentShapesIter
= maCurrentShapesIter
;
862 seekShapes( xShapes
);
864 uno::Reference
< drawing::XShape
> xShape
;
865 const sal_Int32
nShapeCount(xShapes
->getCount());
866 for(sal_Int32 nShapeId
= 0; nShapeId
< nShapeCount
; nShapeId
++)
868 xShapes
->getByIndex(nShapeId
) >>= xShape
;
869 DBG_ASSERT( xShape
.is(), "Shape without a XShape?" );
873 collectShapeAutoStyles( xShape
);
876 maCurrentShapesIter
= aOldCurrentShapesIter
;
879 ///////////////////////////////////////////////////////////////////////
881 // This method exports all XShape inside the given XShapes collection
882 void XMLShapeExport::exportShapes( const uno::Reference
< drawing::XShapes
>& xShapes
, sal_Int32 nFeatures
/* = SEF_DEFAULT */, awt::Point
* pRefPoint
/* = NULL */ )
884 ShapesInfos::iterator aOldCurrentShapesIter
= maCurrentShapesIter
;
885 seekShapes( xShapes
);
887 uno::Reference
< drawing::XShape
> xShape
;
888 const sal_Int32
nShapeCount(xShapes
->getCount());
889 for(sal_Int32 nShapeId
= 0; nShapeId
< nShapeCount
; nShapeId
++)
891 xShapes
->getByIndex(nShapeId
) >>= xShape
;
892 DBG_ASSERT( xShape
.is(), "Shape without a XShape?" );
896 exportShape( xShape
, nFeatures
, pRefPoint
);
899 maCurrentShapesIter
= aOldCurrentShapesIter
;
902 ///////////////////////////////////////////////////////////////////////
904 void XMLShapeExport::seekShapes( const uno::Reference
< drawing::XShapes
>& xShapes
) throw()
908 maCurrentShapesIter
= maShapesInfos
.find( xShapes
);
909 if( maCurrentShapesIter
== maShapesInfos
.end() )
911 ImplXMLShapeExportInfoVector aNewInfoVector
;
912 aNewInfoVector
.resize( (ShapesInfos::size_type
) xShapes
->getCount() );
913 maShapesInfos
[ xShapes
] = aNewInfoVector
;
915 maCurrentShapesIter
= maShapesInfos
.find( xShapes
);
917 DBG_ASSERT( maCurrentShapesIter
!= maShapesInfos
.end(), "XMLShapeExport::seekShapes(): insert into stl::map failed" );
920 DBG_ASSERT( (*maCurrentShapesIter
).second
.size() == (ShapesInfos::size_type
)xShapes
->getCount(), "XMLShapeExport::seekShapes(): XShapes size varied between calls" );
925 maCurrentShapesIter
= maShapesInfos
.end();
929 ///////////////////////////////////////////////////////////////////////
931 void XMLShapeExport::exportAutoStyles()
933 // export all autostyle infos
936 // if(IsFamilyGraphicUsed())
938 GetExport().GetAutoStylePool()->exportXML(
939 XML_STYLE_FAMILY_SD_GRAPHICS_ID
940 , GetExport().GetDocHandler(),
941 GetExport().GetMM100UnitConverter(),
942 GetExport().GetNamespaceMap()
946 // ...for presentation
947 // if(IsFamilyPresentationUsed())
949 GetExport().GetAutoStylePool()->exportXML(
950 XML_STYLE_FAMILY_SD_PRESENTATION_ID
951 , GetExport().GetDocHandler(),
952 GetExport().GetMM100UnitConverter(),
953 GetExport().GetNamespaceMap()
957 if( mxShapeTableExport
.is() )
958 mxShapeTableExport
->exportAutoStyles();
961 ///////////////////////////////////////////////////////////////////////
963 /// returns the export property mapper for external chaining
964 SvXMLExportPropertyMapper
* XMLShapeExport::CreateShapePropMapper(
965 SvXMLExport
& rExport
)
967 UniReference
< XMLPropertyHandlerFactory
> xFactory
= new XMLSdPropHdlFactory( rExport
.GetModel(), rExport
);
968 UniReference
< XMLPropertySetMapper
> xMapper
= new XMLShapePropertySetMapper( xFactory
);
969 SvXMLExportPropertyMapper
* pResult
=
970 new XMLShapeExportPropertyMapper( xMapper
,
971 (XMLTextListAutoStylePool
*)&rExport
.GetTextParagraphExport()->GetListAutoStylePool(),
973 // chain text attributes
977 ///////////////////////////////////////////////////////////////////////
979 void XMLShapeExport::ImpCalcShapeType(const uno::Reference
< drawing::XShape
>& xShape
,
980 XmlShapeType
& eShapeType
)
982 // set in every case, so init here
983 eShapeType
= XmlShapeTypeUnknown
;
985 uno::Reference
< drawing::XShapeDescriptor
> xShapeDescriptor(xShape
, uno::UNO_QUERY
);
986 if(xShapeDescriptor
.is())
988 String
aType((OUString
)xShapeDescriptor
->getShapeType());
990 if(aType
.EqualsAscii((const sal_Char
*)"com.sun.star.", 0, 13))
992 if(aType
.EqualsAscii("drawing.", 13, 8))
995 if (aType
.EqualsAscii("Rectangle", 21, 9)) { eShapeType
= XmlShapeTypeDrawRectangleShape
; }
997 // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6.
998 // As can be seen at the other compares, the appendix "Shape" is left out of the comparison.
999 else if(aType
.EqualsAscii("Custom", 21, 6)) { eShapeType
= XmlShapeTypeDrawCustomShape
; }
1001 else if(aType
.EqualsAscii("Ellipse", 21, 7)) { eShapeType
= XmlShapeTypeDrawEllipseShape
; }
1002 else if(aType
.EqualsAscii("Control", 21, 7)) { eShapeType
= XmlShapeTypeDrawControlShape
; }
1003 else if(aType
.EqualsAscii("Connector", 21, 9)) { eShapeType
= XmlShapeTypeDrawConnectorShape
; }
1004 else if(aType
.EqualsAscii("Measure", 21, 7)) { eShapeType
= XmlShapeTypeDrawMeasureShape
; }
1005 else if(aType
.EqualsAscii("Line", 21, 4)) { eShapeType
= XmlShapeTypeDrawLineShape
; }
1007 // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape
1008 else if(aType
.EqualsAscii("PolyPolygon", 21, 11)) { eShapeType
= XmlShapeTypeDrawPolyPolygonShape
; }
1010 // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape
1011 else if(aType
.EqualsAscii("PolyLine", 21, 8)) { eShapeType
= XmlShapeTypeDrawPolyLineShape
; }
1013 else if(aType
.EqualsAscii("OpenBezier", 21, 10)) { eShapeType
= XmlShapeTypeDrawOpenBezierShape
; }
1014 else if(aType
.EqualsAscii("ClosedBezier", 21, 12)) { eShapeType
= XmlShapeTypeDrawClosedBezierShape
; }
1016 // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and
1017 // ClosedFreeHandShape respectively. Represent them as bezier shapes
1018 else if(aType
.EqualsAscii("OpenFreeHand", 21, 12)) { eShapeType
= XmlShapeTypeDrawOpenBezierShape
; }
1019 else if(aType
.EqualsAscii("ClosedFreeHand", 21, 14)) { eShapeType
= XmlShapeTypeDrawClosedBezierShape
; }
1021 else if(aType
.EqualsAscii("GraphicObject", 21, 13)) { eShapeType
= XmlShapeTypeDrawGraphicObjectShape
; }
1022 else if(aType
.EqualsAscii("Group", 21, 5)) { eShapeType
= XmlShapeTypeDrawGroupShape
; }
1023 else if(aType
.EqualsAscii("Text", 21, 4)) { eShapeType
= XmlShapeTypeDrawTextShape
; }
1024 else if(aType
.EqualsAscii("OLE2", 21, 4))
1026 eShapeType
= XmlShapeTypeDrawOLE2Shape
;
1028 // get info about presentation shape
1029 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
1033 rtl::OUString sCLSID
;
1034 if(xPropSet
->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) >>= sCLSID
)
1036 if (sCLSID
.equals(mrExport
.GetChartExport()->getChartCLSID()))
1038 eShapeType
= XmlShapeTypeDrawChartShape
;
1041 sCLSID
.equals(rtl::OUString( SvGlobalName( SO3_SC_CLASSID
).GetHexName()))
1043 // same reaction for binfilter
1044 || sCLSID
.equals(rtl::OUString( SvGlobalName( BF_SO3_SC_CLASSID
).GetHexName()))
1047 eShapeType
= XmlShapeTypeDrawSheetShape
;
1051 // general OLE2 Object
1056 else if(aType
.EqualsAscii("Page", 21, 4)) { eShapeType
= XmlShapeTypeDrawPageShape
; }
1057 else if(aType
.EqualsAscii("Frame", 21, 5)) { eShapeType
= XmlShapeTypeDrawFrameShape
; }
1058 else if(aType
.EqualsAscii("Caption", 21, 7)) { eShapeType
= XmlShapeTypeDrawCaptionShape
; }
1059 else if(aType
.EqualsAscii("Plugin", 21, 6)) { eShapeType
= XmlShapeTypeDrawPluginShape
; }
1060 else if(aType
.EqualsAscii("Applet", 21, 6)) { eShapeType
= XmlShapeTypeDrawAppletShape
; }
1061 else if(aType
.EqualsAscii("MediaShape", 21, 10)) { eShapeType
= XmlShapeTypeDrawMediaShape
; }
1062 else if(aType
.EqualsAscii("TableShape", 21, 10)) { eShapeType
= XmlShapeTypeDrawTableShape
; }
1065 else if(aType
.EqualsAscii("Scene", 21 + 7, 5)) { eShapeType
= XmlShapeTypeDraw3DSceneObject
; }
1066 else if(aType
.EqualsAscii("Cube", 21 + 7, 4)) { eShapeType
= XmlShapeTypeDraw3DCubeObject
; }
1067 else if(aType
.EqualsAscii("Sphere", 21 + 7, 6)) { eShapeType
= XmlShapeTypeDraw3DSphereObject
; }
1068 else if(aType
.EqualsAscii("Lathe", 21 + 7, 5)) { eShapeType
= XmlShapeTypeDraw3DLatheObject
; }
1069 else if(aType
.EqualsAscii("Extrude", 21 + 7, 7)) { eShapeType
= XmlShapeTypeDraw3DExtrudeObject
; }
1071 else if(aType
.EqualsAscii("presentation.", 13, 13))
1073 // presentation shapes
1074 if (aType
.EqualsAscii("TitleText", 26, 9)) { eShapeType
= XmlShapeTypePresTitleTextShape
; }
1075 else if(aType
.EqualsAscii("Outliner", 26, 8)) { eShapeType
= XmlShapeTypePresOutlinerShape
; }
1076 else if(aType
.EqualsAscii("Subtitle", 26, 8)) { eShapeType
= XmlShapeTypePresSubtitleShape
; }
1077 else if(aType
.EqualsAscii("GraphicObject", 26, 13)) { eShapeType
= XmlShapeTypePresGraphicObjectShape
; }
1078 else if(aType
.EqualsAscii("Page", 26, 4)) { eShapeType
= XmlShapeTypePresPageShape
; }
1079 else if(aType
.EqualsAscii("OLE2", 26, 4))
1081 eShapeType
= XmlShapeTypePresOLE2Shape
;
1083 // get info about presentation shape
1084 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
1088 rtl::OUString sCLSID
;
1089 if(xPropSet
->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) >>= sCLSID
)
1091 if( sCLSID
.equals(rtl::OUString( SvGlobalName( SO3_SC_CLASSID
).GetHexName())) ||
1092 sCLSID
.equals(rtl::OUString( SvGlobalName( BF_SO3_SC_CLASSID
).GetHexName())) )
1094 eShapeType
= XmlShapeTypePresSheetShape
;
1099 else if(aType
.EqualsAscii("Chart", 26, 5)) { eShapeType
= XmlShapeTypePresChartShape
; }
1100 else if(aType
.EqualsAscii("OrgChart", 26, 8)) { eShapeType
= XmlShapeTypePresOrgChartShape
; }
1101 else if(aType
.EqualsAscii("TableShape", 26, 10)) { eShapeType
= XmlShapeTypePresSheetShape
; }
1102 else if(aType
.EqualsAscii("Notes", 26, 5)) { eShapeType
= XmlShapeTypePresNotesShape
; }
1103 else if(aType
.EqualsAscii("HandoutShape", 26, 12)) { eShapeType
= XmlShapeTypeHandoutShape
; }
1104 else if(aType
.EqualsAscii("HeaderShape", 26, 11)) { eShapeType
= XmlShapeTypePresHeaderShape
; }
1105 else if(aType
.EqualsAscii("FooterShape", 26, 11)) { eShapeType
= XmlShapeTypePresFooterShape
; }
1106 else if(aType
.EqualsAscii("SlideNumberShape", 26, 16)) { eShapeType
= XmlShapeTypePresSlideNumberShape
; }
1107 else if(aType
.EqualsAscii("DateTimeShape", 26, 13)) { eShapeType
= XmlShapeTypePresDateTimeShape
; }
1113 ///////////////////////////////////////////////////////////////////////
1115 extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap
[];
1116 extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap
[];
1118 /** exports all user defined glue points */
1119 void XMLShapeExport::ImpExportGluePoints( const uno::Reference
< drawing::XShape
>& xShape
)
1121 uno::Reference
< drawing::XGluePointsSupplier
> xSupplier( xShape
, uno::UNO_QUERY
);
1122 if( !xSupplier
.is() )
1125 uno::Reference
< container::XIdentifierAccess
> xGluePoints( xSupplier
->getGluePoints(), uno::UNO_QUERY
);
1126 if( !xGluePoints
.is() )
1129 drawing::GluePoint2 aGluePoint
;
1131 uno::Sequence
< sal_Int32
> aIdSequence( xGluePoints
->getIdentifiers() );
1133 const sal_Int32 nCount
= aIdSequence
.getLength();
1134 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
1136 const sal_Int32 nIdentifier
= aIdSequence
[nIndex
];
1137 if( (xGluePoints
->getByIdentifier( nIdentifier
) >>= aGluePoint
) && aGluePoint
.IsUserDefined
)
1139 // export only user defined glue points
1141 const OUString
sId( OUString::valueOf( nIdentifier
) );
1142 mrExport
.AddAttribute(XML_NAMESPACE_DRAW
, XML_ID
, sId
);
1144 mrExport
.GetMM100UnitConverter().convertMeasure(msBuffer
, aGluePoint
.Position
.X
);
1145 mrExport
.AddAttribute(XML_NAMESPACE_SVG
, XML_X
, msBuffer
.makeStringAndClear());
1147 mrExport
.GetMM100UnitConverter().convertMeasure(msBuffer
, aGluePoint
.Position
.Y
);
1148 mrExport
.AddAttribute(XML_NAMESPACE_SVG
, XML_Y
, msBuffer
.makeStringAndClear());
1150 if( !aGluePoint
.IsRelative
)
1152 SvXMLUnitConverter::convertEnum( msBuffer
, aGluePoint
.PositionAlignment
, aXML_GlueAlignment_EnumMap
);
1153 mrExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_ALIGN
, msBuffer
.makeStringAndClear() );
1156 if( aGluePoint
.Escape
!= drawing::EscapeDirection_SMART
)
1158 SvXMLUnitConverter::convertEnum( msBuffer
, aGluePoint
.Escape
, aXML_GlueEscapeDirection_EnumMap
);
1159 mrExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_ESCAPE_DIRECTION
, msBuffer
.makeStringAndClear() );
1162 SvXMLElementExport
aEventsElemt(mrExport
, XML_NAMESPACE_DRAW
, XML_GLUE_POINT
, sal_True
, sal_True
);
1167 void XMLShapeExport::ExportGraphicDefaults()
1169 XMLStyleExport
aStEx(mrExport
, OUString(), mrExport
.GetAutoStylePool().get());
1171 // construct PropertySetMapper
1172 UniReference
< SvXMLExportPropertyMapper
> xPropertySetMapper( CreateShapePropMapper( mrExport
) );
1173 ((XMLShapeExportPropertyMapper
*)xPropertySetMapper
.get())->SetAutoStyles( sal_False
);
1175 // chain text attributes
1176 xPropertySetMapper
->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(mrExport
));
1178 // chain special Writer/text frame default attributes
1179 xPropertySetMapper
->ChainExportMapper(XMLTextParagraphExport::CreateParaDefaultExtPropMapper(mrExport
));
1181 // write graphic family default style
1182 uno::Reference
< lang::XMultiServiceFactory
> xFact( mrExport
.GetModel(), uno::UNO_QUERY
);
1187 uno::Reference
< beans::XPropertySet
> xDefaults( xFact
->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), uno::UNO_QUERY
);
1188 if( xDefaults
.is() )
1190 aStEx
.exportDefaultStyle( xDefaults
, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME
)), xPropertySetMapper
);
1192 // write graphic family styles
1193 aStEx
.exportStyleFamily("graphics", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME
)), xPropertySetMapper
, FALSE
, XML_STYLE_FAMILY_SD_GRAPHICS_ID
);
1196 catch( lang::ServiceNotRegisteredException
& )
1202 void XMLShapeExport::onExport( const com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
>& )
1206 const rtl::Reference
< XMLTableExport
>& XMLShapeExport::GetShapeTableExport()
1208 if( !mxShapeTableExport
.is() )
1210 rtl::Reference
< XMLPropertyHandlerFactory
> xFactory( new XMLSdPropHdlFactory( mrExport
.GetModel(), mrExport
) );
1211 UniReference
< XMLPropertySetMapper
> xMapper( new XMLShapePropertySetMapper( xFactory
.get() ) );
1212 rtl::Reference
< SvXMLExportPropertyMapper
> xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper
, (XMLTextListAutoStylePool
*)&mrExport
.GetTextParagraphExport()->GetListAutoStylePool(), mrExport
) );
1213 mxShapeTableExport
= new XMLTableExport( mrExport
, xPropertySetMapper
, xFactory
);
1216 return mxShapeTableExport
;