xref: /AOO41X/main/xmloff/source/draw/sdxmlexp.cxx (revision 63bba73cc51e0afb45f8a8d578158724bb5afee8)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "unointerfacetouniqueidentifiermapper.hxx"
27 #include <xmloff/nmspmap.hxx>
28 #include "xmloff/xmlnmspe.hxx"
29 #include <xmloff/xmluconv.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmlmetae.hxx>
32 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
33 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
34 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
35 #include <com/sun/star/geometry/RealPoint2D.hpp>
36 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
37 #include <com/sun/star/office/XAnnotationAccess.hpp>
38 #include <com/sun/star/lang/Locale.hpp>
39 #include <com/sun/star/uno/Any.hxx>
40 #include "sdxmlexp_impl.hxx"
41 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
42 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
43 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
44 #include <com/sun/star/container/XIndexContainer.hpp>
45 #include <com/sun/star/view/PaperOrientation.hpp>
46 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
47 #include <com/sun/star/style/XStyle.hpp>
48 
49 #include <com/sun/star/form/XFormsSupplier2.hpp>
50 #include <com/sun/star/presentation/XPresentationPage.hpp>
51 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
52 #include <com/sun/star/text/XText.hpp>
53 #include <com/sun/star/chart/XChartDocument.hpp>
54 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
55 #include <com/sun/star/container/XNamed.hpp>
56 #include <rtl/ustrbuf.hxx>
57 #include <tools/gen.hxx>
58 #include <tools/debug.hxx>
59 #include <xmloff/xmlaustp.hxx>
60 #include <xmloff/families.hxx>
61 #include <xmloff/styleexp.hxx>
62 #include "sdpropls.hxx"
63 #include <xmloff/xmlexppr.hxx>
64 #include <com/sun/star/beans/XPropertyState.hpp>
65 #include "xexptran.hxx"
66 
67 #ifndef _CPPUHELPER_IMPLBASE1_HXX
68 #include <cppuhelper/implbase1.hxx>
69 #endif
70 #include <comphelper/extract.hxx>
71 #include <com/sun/star/lang/XServiceInfo.hpp>
72 #include "PropertySetMerger.hxx"
73 #include "layerexp.hxx"
74 
75 
76 #include "xmloff/VisAreaExport.hxx"
77 #include "XMLNumberStylesExport.hxx"
78 #include <tools/list.hxx>
79 #include <tools/string.hxx>
80 
81 #include "animationexport.hxx"
82 
83 #include <com/sun/star/document/XDocumentProperties.hpp>
84 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
85 
86 using ::rtl::OUString;
87 using ::rtl::OUStringBuffer;
88 
89 using namespace ::com::sun::star;
90 using namespace ::com::sun::star::uno;
91 using namespace ::com::sun::star::beans;
92 using namespace ::com::sun::star::util;
93 using namespace ::com::sun::star::container;
94 using namespace ::com::sun::star::drawing;
95 using namespace ::com::sun::star::office;
96 using namespace ::com::sun::star::presentation;
97 using namespace ::com::sun::star::geometry;
98 using namespace ::com::sun::star::text;
99 using namespace ::xmloff::token;
100 
101 
102 //////////////////////////////////////////////////////////////////////////////
103 
104 class ImpXMLEXPPageMasterInfo
105 {
106     sal_Int32                   mnBorderBottom;
107     sal_Int32                   mnBorderLeft;
108     sal_Int32                   mnBorderRight;
109     sal_Int32                   mnBorderTop;
110     sal_Int32                   mnWidth;
111     sal_Int32                   mnHeight;
112     view::PaperOrientation      meOrientation;
113     OUString                    msName;
114     OUString                    msMasterPageName;
115 
116 public:
117     ImpXMLEXPPageMasterInfo(const SdXMLExport& rExp, const Reference<XDrawPage>& xPage);
118     sal_Bool operator==(const ImpXMLEXPPageMasterInfo& rInfo) const;
119     void SetName(const OUString& rStr);
120 
GetName() const121     const OUString& GetName() const { return msName; }
GetMasterPageName() const122     const OUString& GetMasterPageName() const { return msMasterPageName; }
123 
GetBorderBottom() const124     sal_Int32 GetBorderBottom() const { return mnBorderBottom; }
GetBorderLeft() const125     sal_Int32 GetBorderLeft() const { return mnBorderLeft; }
GetBorderRight() const126     sal_Int32 GetBorderRight() const { return mnBorderRight; }
GetBorderTop() const127     sal_Int32 GetBorderTop() const { return mnBorderTop; }
GetWidth() const128     sal_Int32 GetWidth() const { return mnWidth; }
GetHeight() const129     sal_Int32 GetHeight() const { return mnHeight; }
GetOrientation() const130     view::PaperOrientation GetOrientation() const { return meOrientation; }
131 };
132 
ImpXMLEXPPageMasterInfo(const SdXMLExport & rExp,const Reference<XDrawPage> & xPage)133 ImpXMLEXPPageMasterInfo::ImpXMLEXPPageMasterInfo(
134     const SdXMLExport& rExp,
135     const Reference<XDrawPage>& xPage)
136 :   mnBorderBottom(0),
137     mnBorderLeft(0),
138     mnBorderRight(0),
139     mnBorderTop(0),
140     mnWidth(0),
141     mnHeight(0),
142     meOrientation(rExp.IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
143 {
144     Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
145     if(xPropSet.is())
146     {
147         Any aAny;
148 
149         Reference< beans::XPropertySetInfo > xPropsInfo( xPropSet->getPropertySetInfo() );
150         if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom") )))
151         {
152             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom")));
153             aAny >>= mnBorderBottom;
154 
155             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderLeft")));
156             aAny >>= mnBorderLeft;
157 
158             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderRight")));
159             aAny >>= mnBorderRight;
160 
161             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderTop")));
162             aAny >>= mnBorderTop;
163         }
164 
165         if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("Width") )))
166         {
167             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")));
168             aAny >>= mnWidth;
169 
170             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Height")));
171             aAny >>= mnHeight;
172         }
173 
174         if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation") )))
175         {
176             aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation")));
177             aAny >>= meOrientation;
178         }
179     }
180 
181     Reference <container::XNamed> xMasterNamed(xPage, UNO_QUERY);
182     if(xMasterNamed.is())
183     {
184         msMasterPageName = xMasterNamed->getName();
185     }
186 }
187 
operator ==(const ImpXMLEXPPageMasterInfo & rInfo) const188 sal_Bool ImpXMLEXPPageMasterInfo::operator==(const ImpXMLEXPPageMasterInfo& rInfo) const
189 {
190     return ((mnBorderBottom == rInfo.mnBorderBottom)
191         && (mnBorderLeft == rInfo.mnBorderLeft)
192         && (mnBorderRight == rInfo.mnBorderRight)
193         && (mnBorderTop == rInfo.mnBorderTop)
194         && (mnWidth == rInfo.mnWidth)
195         && (mnHeight == rInfo.mnHeight)
196         && (meOrientation == rInfo.meOrientation));
197 }
198 
SetName(const OUString & rStr)199 void ImpXMLEXPPageMasterInfo::SetName(const OUString& rStr)
200 {
201     msName = rStr;
202 }
203 
204 DECLARE_LIST(ImpXMLEXPPageMasterList, ImpXMLEXPPageMasterInfo*)
205 
206 //////////////////////////////////////////////////////////////////////////////
207 
208 #define IMP_AUTOLAYOUT_INFO_MAX         (35L)
209 
210 class ImpXMLAutoLayoutInfo
211 {
212     sal_uInt16                  mnType;
213     ImpXMLEXPPageMasterInfo*    mpPageMasterInfo;
214     OUString                    msLayoutName;
215     Rectangle                   maTitleRect;
216     Rectangle                   maPresRect;
217     sal_Int32                   mnGapX;
218     sal_Int32                   mnGapY;
219 
220 public:
221     ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf);
222 
223     sal_Bool operator==(const ImpXMLAutoLayoutInfo& rInfo) const;
224 
GetLayoutType() const225     sal_uInt16 GetLayoutType() const { return mnType; }
GetGapX() const226     sal_Int32 GetGapX() const { return mnGapX; }
GetGapY() const227     sal_Int32 GetGapY() const { return mnGapY; }
228 
GetLayoutName() const229     const OUString& GetLayoutName() const { return msLayoutName; }
SetLayoutName(const OUString & rNew)230     void SetLayoutName(const OUString& rNew) { msLayoutName = rNew; }
231 
GetTitleRectangle() const232     const Rectangle& GetTitleRectangle() const { return maTitleRect; }
GetPresRectangle() const233     const Rectangle& GetPresRectangle() const { return maPresRect; }
234 
235     static sal_Bool IsCreateNecessary(sal_uInt16 nTyp);
236 };
237 
IsCreateNecessary(sal_uInt16 nTyp)238 sal_Bool ImpXMLAutoLayoutInfo::IsCreateNecessary(sal_uInt16 nTyp)
239 {
240     if(nTyp == 5 /* AUTOLAYOUT_ORG */
241         || nTyp == 20 /* AUTOLAYOUT_NONE */
242         || nTyp >= IMP_AUTOLAYOUT_INFO_MAX)
243         return sal_False;
244     return sal_True;
245 }
246 
operator ==(const ImpXMLAutoLayoutInfo & rInfo) const247 sal_Bool ImpXMLAutoLayoutInfo::operator==(const ImpXMLAutoLayoutInfo& rInfo) const
248 {
249     return ((mnType == rInfo.mnType
250         && mpPageMasterInfo == rInfo.mpPageMasterInfo));
251 }
252 
ImpXMLAutoLayoutInfo(sal_uInt16 nTyp,ImpXMLEXPPageMasterInfo * pInf)253 ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
254 :   mnType(nTyp),
255     mpPageMasterInfo(pInf)
256 {
257     // create full info (initialze with typical values)
258     Point aPagePos(0,0);
259     Size aPageSize(28000, 21000);
260     Size aPageInnerSize(28000, 21000);
261 
262     if(mpPageMasterInfo)
263     {
264         aPagePos = Point(mpPageMasterInfo->GetBorderLeft(), mpPageMasterInfo->GetBorderTop());
265         aPageSize = Size(mpPageMasterInfo->GetWidth(), mpPageMasterInfo->GetHeight());
266         aPageInnerSize = aPageSize;
267         aPageInnerSize.Width() -= mpPageMasterInfo->GetBorderLeft() + mpPageMasterInfo->GetBorderRight();
268         aPageInnerSize.Height() -= mpPageMasterInfo->GetBorderTop() + mpPageMasterInfo->GetBorderBottom();
269     }
270 
271     // title rectangle aligning
272     Point aTitlePos(aPagePos);
273     Size aTitleSize(aPageInnerSize);
274 
275     if(mnType == 21 /* AUTOLAYOUT_NOTES */)
276     {
277         aTitleSize.Height() = (long) (aTitleSize.Height() / 2.5);
278         Point aPos = aTitlePos;
279         aPos.Y() += long( aTitleSize.Height() * 0.083 );
280         Size aPartArea = aTitleSize;
281         Size aSize;
282 
283         // tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
284         double fH = (double) aPartArea.Width()  / aPageSize.Width();
285         double fV = (double) aPartArea.Height() / aPageSize.Height();
286 
287         if ( fH > fV )
288             fH = fV;
289         aSize.Width()  = (long) (fH * aPageSize.Width());
290         aSize.Height() = (long) (fH * aPageSize.Height());
291 
292         aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
293         aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
294 
295         aTitlePos = aPos;
296         aTitleSize = aSize;
297     }
298     else if(mnType == 27 || mnType == 28)
299     {
300         // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART or
301         // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
302         Point aClassicTPos(
303             aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
304             aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
305         Size aClassicTSize(
306             long( aTitleSize.Width() * 0.854 ),
307             long( aTitleSize.Height() * 0.167 ));
308         Point aLPos(aPagePos);
309         Size aLSize(aPageInnerSize);
310         Point aClassicLPos(
311             aLPos.X() + long( aLSize.Width() * 0.0735 ),
312             aLPos.Y() + long( aLSize.Height() * 0.472 ));
313         Size aClassicLSize(
314             long( aLSize.Width() * 0.854 ),
315             long( aLSize.Height() * 0.444 ));
316 
317         aTitlePos.X() = (aClassicTPos.X() + aClassicTSize.Width()) - aClassicTSize.Height();
318         aTitlePos.Y() = aClassicTPos.Y();
319         aTitleSize.Width() = aClassicTSize.Height();
320         aTitleSize.Height() = (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y();
321     }
322     else
323     {
324         aTitlePos.X() += long( aTitleSize.Width() * 0.0735 );
325         aTitlePos.Y() += long( aTitleSize.Height() * 0.083 );
326         aTitleSize.Width() = long( aTitleSize.Width() * 0.854 );
327         aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
328     }
329 
330     maTitleRect.SetPos(aTitlePos);
331     maTitleRect.SetSize(aTitleSize);
332 
333     // layout rectangle aligning
334     Point aLayoutPos(aPagePos);
335     Size aLayoutSize(aPageInnerSize);
336 
337     if(mnType == 21 /* AUTOLAYOUT_NOTES */)
338     {
339         aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
340         aLayoutPos.Y() += long( aLayoutSize.Height() * 0.472 );
341         aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
342         aLayoutSize.Height() = long( aLayoutSize.Height() * 0.444 );
343     }
344     else if((mnType >= 22 && mnType <= 26) || (mnType == 31)) // AUTOLAYOUT_HANDOUT
345     {
346         // keep info for inner area in maPresRect, put info for gap size
347         // to maTitleRect position
348         mnGapX = (aPageSize.Width() - aPageInnerSize.Width()) / 2;
349         mnGapY = (aPageSize.Height() - aPageInnerSize.Height()) / 2;
350 
351         if(!mnGapX)
352             mnGapX = aPageSize.Width() / 10;
353 
354         if(!mnGapY)
355             mnGapY = aPageSize.Height() / 10;
356 
357         if(mnGapX < aPageInnerSize.Width() / 10)
358             mnGapX = aPageInnerSize.Width() / 10;
359 
360         if(mnGapY < aPageInnerSize.Height() / 10)
361             mnGapY = aPageInnerSize.Height() / 10;
362     }
363     else if(mnType == 27 || mnType == 28)
364     {
365         // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART or
366         // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
367         Point aClassicTPos(
368             aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
369             aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
370         Size aClassicTSize(
371             long( aTitleSize.Width() * 0.854 ),
372             long( aTitleSize.Height() * 0.167 ));
373         Point aClassicLPos(
374             aLayoutPos.X() + long( aLayoutSize.Width() * 0.0735 ),
375             aLayoutPos.Y() + long( aLayoutSize.Height() * 0.472 ));
376         Size aClassicLSize(
377             long( aLayoutSize.Width() * 0.854 ),
378             long( aLayoutSize.Height() * 0.444 ));
379 
380         aLayoutPos.X() = aClassicLPos.X();
381         aLayoutPos.Y() = aClassicTPos.Y();
382         aLayoutSize.Width() = (aClassicLPos.X() + aClassicLSize.Width())
383             - (aClassicTSize.Height() + (aClassicLPos.Y() - (aClassicTPos.Y() + aClassicTSize.Height())));
384         aLayoutSize.Height() = (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y();
385     }
386     else if( mnType == 32 )
387     {
388         // AUTOLAYOUT_ONLY_TEXT
389         aLayoutPos = aTitlePos;
390         aLayoutSize.Width() = aTitleSize.Width();
391         aLayoutSize.Height() = long( aLayoutSize.Height() * 0.825 );
392     }
393     else
394     {
395         aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
396         aLayoutPos.Y() += long( aLayoutSize.Height() * 0.278 );
397         aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
398         aLayoutSize.Height() = long( aLayoutSize.Height() * 0.630 );
399     }
400 
401     maPresRect.SetPos(aLayoutPos);
402     maPresRect.SetSize(aLayoutSize);
403 }
404 
DECLARE_LIST(ImpXMLAutoLayoutInfoList,ImpXMLAutoLayoutInfo *)405 DECLARE_LIST(ImpXMLAutoLayoutInfoList, ImpXMLAutoLayoutInfo*)
406 
407 //////////////////////////////////////////////////////////////////////////////
408 
409 // #110680#
410 SdXMLExport::SdXMLExport(
411     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
412     sal_Bool bIsDraw, sal_uInt16 nExportFlags )
413 :   SvXMLExport( xServiceFactory, MAP_CM, bIsDraw ? XML_DRAWING : XML_PRESENTATION, nExportFlags ),
414     mnDocMasterPageCount(0L),
415     mnDocDrawPageCount(0L),
416     mnShapeStyleInfoIndex(0L),
417     mnObjectCount(0L),
418     mpPageMasterInfoList(new ImpXMLEXPPageMasterList(1, 4, 4)),
419     mpPageMasterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)),
420     mpNotesPageMasterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)),
421     mpHandoutPageMaster(NULL),
422     mpAutoLayoutInfoList(new ImpXMLAutoLayoutInfoList(1, 4, 4)),
423     mpSdPropHdlFactory(0L),
424     mpPropertySetMapper(0L),
425     mpPresPagePropsMapper(0L),
426     mbIsDraw(bIsDraw),
427     mbFamilyGraphicUsed(sal_False),
428     mbFamilyPresentationUsed(sal_False),
429     msZIndex( GetXMLToken(XML_ZINDEX) ),
430     msEmptyPres( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ),
431     msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ),
432     msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ),
433     msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") ),
434     msPageLayoutNames( RTL_CONSTASCII_USTRINGPARAM("PageLayoutNames") )
435 {
436 
437 
438 }
439 
440 // XExporter
setSourceDocument(const Reference<lang::XComponent> & xDoc)441 void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent >& xDoc )
442     throw(lang::IllegalArgumentException, uno::RuntimeException)
443 {
444     SvXMLExport::setSourceDocument( xDoc );
445 
446     const OUString aEmpty;
447 
448     // prepare factory parts
449     mpSdPropHdlFactory = new XMLSdPropHdlFactory( GetModel(), *this );
450     if(mpSdPropHdlFactory)
451     {
452         // set lock to avoid deletion
453         mpSdPropHdlFactory->acquire();
454 
455         // build one ref
456         const UniReference< XMLPropertyHandlerFactory > aFactoryRef = mpSdPropHdlFactory;
457 
458         // construct PropertySetMapper
459         UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( aFactoryRef);
460 
461         mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&GetTextParagraphExport()->GetListAutoStylePool(), *this );
462         // set lock to avoid deletion
463         mpPropertySetMapper->acquire();
464 
465         // chain text attributes
466         mpPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
467 
468         // construct PresPagePropsMapper
469         xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, aFactoryRef);
470 
471         mpPresPagePropsMapper = new XMLPageExportPropertyMapper( xMapper, *this  );
472         if(mpPresPagePropsMapper)
473         {
474             // set lock to avoid deletion
475             mpPresPagePropsMapper->acquire();
476         }
477     }
478 
479     // add family name
480     GetAutoStylePool()->AddFamily(
481         XML_STYLE_FAMILY_SD_GRAPHICS_ID,
482         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)),
483         GetPropertySetMapper(),
484         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX)));
485     GetAutoStylePool()->AddFamily(
486         XML_STYLE_FAMILY_SD_PRESENTATION_ID,
487         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)),
488         GetPropertySetMapper(),
489         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX)));
490     GetAutoStylePool()->AddFamily(
491         XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID,
492         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)),
493         GetPresPagePropsMapper(),
494         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_PREFIX)));
495     // prepare access to styles
496     Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), UNO_QUERY );
497     if(xFamSup.is())
498     {
499         mxDocStyleFamilies = xFamSup->getStyleFamilies();
500     }
501 
502     // prepare access to master pages
503     Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), UNO_QUERY);
504     if(xMasterPagesSupplier.is())
505     {
506         mxDocMasterPages = mxDocMasterPages.query( xMasterPagesSupplier->getMasterPages() );
507         if(mxDocMasterPages.is())
508         {
509             mnDocMasterPageCount = mxDocMasterPages->getCount();
510             maMasterPagesStyleNames.insert( maMasterPagesStyleNames.begin(), mnDocMasterPageCount, aEmpty );
511         }
512     }
513 
514     // prepare access to draw pages
515     Reference <XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), UNO_QUERY);
516     if(xDrawPagesSupplier.is())
517     {
518         mxDocDrawPages = mxDocDrawPages.query( xDrawPagesSupplier->getDrawPages() );
519         if(mxDocDrawPages.is())
520         {
521             mnDocDrawPageCount = mxDocDrawPages->getCount();
522             maDrawPagesStyleNames.insert( maDrawPagesStyleNames.begin(), mnDocDrawPageCount, aEmpty );
523             maDrawNotesPagesStyleNames.insert( maDrawNotesPagesStyleNames.begin(), mnDocDrawPageCount, aEmpty );
524             if( !mbIsDraw )
525                 maDrawPagesAutoLayoutNames.realloc( mnDocDrawPageCount + 1 );
526 
527             HeaderFooterPageSettingsImpl aEmptySettings;
528             maDrawPagesHeaderFooterSettings.insert( maDrawPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
529             maDrawNotesPagesHeaderFooterSettings.insert( maDrawNotesPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
530         }
531     }
532 
533     // #82003# count all draw objects for use with progress bar.
534     // #88245# init mnObjectCount once, use counter itself as flag. It
535     // is initialized to 0.
536     if(!mnObjectCount)
537     {
538         if( IsImpress() )
539         {
540             // #91587# add handout master count
541             Reference<presentation::XHandoutMasterSupplier> xHandoutSupp(GetModel(), UNO_QUERY);
542             if(xHandoutSupp.is())
543             {
544                 Reference<XDrawPage> xHandoutPage(xHandoutSupp->getHandoutMasterPage());
545                 if(xHandoutPage.is())
546                 {
547                     Reference<drawing::XShapes> xShapes(xHandoutPage, UNO_QUERY);
548                     if(xShapes.is() && xShapes->getCount())
549                     {
550                         mnObjectCount += ImpRecursiveObjectCount(xShapes);
551                     }
552                 }
553             }
554         }
555 
556         if(mxDocMasterPages.is())
557         {
558             for(sal_Int32 a(0); a < mnDocMasterPageCount; a++)
559             {
560                 Any aAny(mxDocMasterPages->getByIndex(a));
561                 Reference< drawing::XShapes > xMasterPage;
562 
563                 if((aAny >>= xMasterPage) && xMasterPage.is())
564                 {
565                     mnObjectCount += ImpRecursiveObjectCount(xMasterPage);
566                 }
567 
568                 if( IsImpress() )
569                 {
570                     // #91587# take notes pages from master pages into account
571                     Reference<presentation::XPresentationPage> xPresPage;
572                     if((aAny >>= xPresPage) && xPresPage.is())
573                     {
574                         Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
575                         if(xNotesPage.is())
576                         {
577                             Reference<drawing::XShapes> xShapes(xNotesPage, UNO_QUERY);
578                             if(xShapes.is() && xShapes->getCount())
579                             {
580                                 mnObjectCount += ImpRecursiveObjectCount(xShapes);
581                             }
582                         }
583                     }
584                 }
585             }
586         }
587 
588         if(mxDocDrawPages.is())
589         {
590             for(sal_Int32 a(0); a < mnDocDrawPageCount; a++)
591             {
592                 Any aAny(mxDocDrawPages->getByIndex(a));
593                 Reference< drawing::XShapes > xPage;
594 
595                 if((aAny >>= xPage) && xPage.is())
596                 {
597                     mnObjectCount += ImpRecursiveObjectCount(xPage);
598                 }
599 
600                 if( IsImpress() )
601                 {
602                     // #91587# take notes pages from draw pages into account
603                     Reference<presentation::XPresentationPage> xPresPage;
604                     if((aAny >>= xPresPage) && xPresPage.is())
605                     {
606                         Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
607                         if(xNotesPage.is())
608                         {
609                             Reference<drawing::XShapes> xShapes(xNotesPage, UNO_QUERY);
610                             if(xShapes.is() && xShapes->getCount())
611                             {
612                                 mnObjectCount += ImpRecursiveObjectCount(xShapes);
613                             }
614                         }
615                     }
616                 }
617             }
618         }
619 
620         // #82003# init progress bar
621         GetProgressBarHelper()->SetReference(mnObjectCount);
622     }
623 
624     // add namespaces
625     _GetNamespaceMap().Add(
626         GetXMLToken(XML_NP_PRESENTATION),
627         GetXMLToken(XML_N_PRESENTATION),
628         XML_NAMESPACE_PRESENTATION);
629 
630     _GetNamespaceMap().Add(
631         GetXMLToken(XML_NP_SMIL),
632         GetXMLToken(XML_N_SMIL_COMPAT),
633         XML_NAMESPACE_SMIL);
634 
635     _GetNamespaceMap().Add(
636         GetXMLToken(XML_NP_ANIMATION),
637         GetXMLToken(XML_N_ANIMATION),
638         XML_NAMESPACE_ANIMATION);
639 
640     if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
641     {
642         _GetNamespaceMap().Add(
643             GetXMLToken(XML_NP_OFFICE_EXT),
644             GetXMLToken(XML_N_OFFICE_EXT),
645             XML_NAMESPACE_OFFICE_EXT);
646 
647         _GetNamespaceMap().Add(
648             GetXMLToken(XML_NP_DRAW_EXT),
649             GetXMLToken(XML_N_DRAW_EXT),
650             XML_NAMESPACE_DRAW_EXT);
651     }
652 
653     GetShapeExport()->enableLayerExport();
654 
655     // #88546# enable progress bar increments
656     GetShapeExport()->enableHandleProgressBar();
657 }
658 
659 //////////////////////////////////////////////////////////////////////////////
660 // #82003# helper function for recursive object count
ImpRecursiveObjectCount(Reference<drawing::XShapes> xShapes)661 sal_uInt32 SdXMLExport::ImpRecursiveObjectCount(Reference< drawing::XShapes > xShapes)
662 {
663     sal_uInt32 nRetval(0L);
664 
665     if(xShapes.is())
666     {
667         sal_Int32 nCount = xShapes->getCount();
668 
669         for(sal_Int32 a(0L); a < nCount; a++)
670         {
671             Any aAny(xShapes->getByIndex(a));
672             Reference< drawing::XShapes > xGroup;
673 
674             if((aAny >>= xGroup) && xGroup.is())
675             {
676                 // #93180# count group objects, too.
677                 nRetval += 1 + ImpRecursiveObjectCount(xGroup);
678             }
679             else
680             {
681                 nRetval++;
682             }
683         }
684     }
685 
686     return nRetval;
687 }
688 
689 //////////////////////////////////////////////////////////////////////////////
690 
~SdXMLExport()691 __EXPORT SdXMLExport::~SdXMLExport()
692 {
693     // cleanup factory, decrease refcount. Should lead to destruction.
694     if(mpSdPropHdlFactory)
695     {
696         mpSdPropHdlFactory->release();
697         mpSdPropHdlFactory = 0L;
698     }
699 
700     // cleanup mapper, decrease refcount. Should lead to destruction.
701     if(mpPropertySetMapper)
702     {
703         mpPropertySetMapper->release();
704         mpPropertySetMapper = 0L;
705     }
706 
707     // cleanup presPage mapper, decrease refcount. Should lead to destruction.
708     if(mpPresPagePropsMapper)
709     {
710         mpPresPagePropsMapper->release();
711         mpPresPagePropsMapper = 0L;
712     }
713 
714     // clear evtl. temporary page master infos
715     if(mpPageMasterInfoList)
716     {
717         while(mpPageMasterInfoList->Count())
718             delete mpPageMasterInfoList->Remove(mpPageMasterInfoList->Count() - 1L);
719         delete mpPageMasterInfoList;
720         mpPageMasterInfoList = 0L;
721     }
722     if(mpPageMasterUsageList)
723     {
724         delete mpPageMasterUsageList;
725         mpPageMasterUsageList = 0L;
726     }
727     if(mpNotesPageMasterUsageList)
728     {
729         delete mpNotesPageMasterUsageList;
730         mpNotesPageMasterUsageList = 0L;
731     }
732 
733     // clear auto-layout infos
734     if(mpAutoLayoutInfoList)
735     {
736         while(mpAutoLayoutInfoList->Count())
737             delete mpAutoLayoutInfoList->Remove(mpAutoLayoutInfoList->Count() - 1L);
738         delete mpAutoLayoutInfoList;
739         mpAutoLayoutInfoList = 0L;
740     }
741 
742 // #82003# status indicator stop is called exclusively
743 // from SdXMLFilter::Export() now.
744 //
745 // stop progress view
746 //  if(GetStatusIndicator().is())
747 //  {
748 //      GetStatusIndicator()->end();
749 //      GetStatusIndicator()->reset();
750 //  }
751 }
752 
753 //////////////////////////////////////////////////////////////////////////////
754 // to get default values in XPropertySet use this wrapper class
755 
756 class ImpDefaultMapper : public ::cppu::WeakAggImplHelper1< beans::XPropertySet >
757 {
758     Reference< beans::XPropertyState >      mxState;
759     Reference< beans::XPropertySet >        mxSet;
760 
761 public:
762     ImpDefaultMapper( Reference< beans::XPropertyState >& rxState );
763 
764     // Methods
765     virtual Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(uno::RuntimeException);
766     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
767     virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
768 
769     // empty implementations
770     virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
771     virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
772     virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
773     virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
774 };
775 
ImpDefaultMapper(Reference<beans::XPropertyState> & rxState)776 ImpDefaultMapper::ImpDefaultMapper( Reference< beans::XPropertyState >& rxState )
777 :   mxState( rxState ),
778     mxSet( rxState, UNO_QUERY )
779 {
780 }
781 
getPropertySetInfo()782 Reference< beans::XPropertySetInfo > SAL_CALL ImpDefaultMapper::getPropertySetInfo() throw(uno::RuntimeException)
783 {
784     return mxSet->getPropertySetInfo();
785 }
786 
setPropertyValue(const OUString & aPropertyName,const Any &)787 void SAL_CALL ImpDefaultMapper::setPropertyValue( const OUString& aPropertyName, const Any& /*aValue*/ ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
788 {
789     mxState->setPropertyToDefault( aPropertyName /*, aValue */ );
790 }
791 
getPropertyValue(const OUString & PropertyName)792 Any SAL_CALL ImpDefaultMapper::getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
793 {
794     return mxState->getPropertyDefault(  PropertyName  );
795 }
796 
797 // empty implementations
addPropertyChangeListener(const OUString &,const Reference<beans::XPropertyChangeListener> &)798 void SAL_CALL ImpDefaultMapper::addPropertyChangeListener( const OUString&, const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
removePropertyChangeListener(const OUString &,const Reference<beans::XPropertyChangeListener> &)799 void SAL_CALL ImpDefaultMapper::removePropertyChangeListener( const OUString&, const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
addVetoableChangeListener(const OUString &,const Reference<beans::XVetoableChangeListener> &)800 void SAL_CALL ImpDefaultMapper::addVetoableChangeListener( const OUString&, const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
removeVetoableChangeListener(const OUString &,const Reference<beans::XVetoableChangeListener> &)801 void SAL_CALL ImpDefaultMapper::removeVetoableChangeListener( const OUString&, const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
802 
803 //////////////////////////////////////////////////////////////////////////////
804 
805 /* moved to shapeexport.cxx
806 void SdXMLExport::ImpWriteObjGraphicStyleInfos()
807 {
808     XMLStyleExport aStEx(*this, OUString(), GetAutoStylePool().get());
809     const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
810 
811     // write graphic family default style
812     Reference< lang::XMultiServiceFactory > xFact( GetModel(), UNO_QUERY );
813     if( xFact.is() )
814     {
815         try
816         {
817             Reference< beans::XPropertySet > xDefaults( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY );
818             if( xDefaults.is() )
819             {
820                 aStEx.exportDefaultStyle( xDefaults, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), aMapperRef );
821 
822                 // write graphic family styles
823                 aStEx.exportStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_NAME, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), aMapperRef, sal_False, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
824             }
825         }
826         catch( lang::ServiceNotRegisteredException& )
827         {
828         }
829     }
830 }
831 */
832 //////////////////////////////////////////////////////////////////////////////
833 
ImpPrepAutoLayoutInfos()834 void SdXMLExport::ImpPrepAutoLayoutInfos()
835 {
836     if(IsImpress())
837     {
838         OUString aStr;
839 
840         Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
841         if( xHandoutSupp.is() )
842         {
843             Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
844             if( xHandoutPage.is() )
845             {
846                 if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr))
847                     maDrawPagesAutoLayoutNames[0] = aStr;
848             }
849         }
850 
851         // prepare name creation
852         for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
853         {
854             Any aAny(mxDocDrawPages->getByIndex(nCnt));
855             Reference<XDrawPage> xDrawPage;
856 
857             if((aAny >>= xDrawPage) && xDrawPage.is())
858             {
859                 if(ImpPrepAutoLayoutInfo(xDrawPage, aStr))
860                     maDrawPagesAutoLayoutNames[nCnt+1] = aStr;
861             }
862         }
863     }
864 }
865 
ImpPrepAutoLayoutInfo(const Reference<XDrawPage> & xPage,OUString & rName)866 sal_Bool SdXMLExport::ImpPrepAutoLayoutInfo(const Reference<XDrawPage>& xPage, OUString& rName)
867 {
868     rName = OUString();
869     sal_Bool bRetval(sal_False);
870 
871     Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
872     if(xPropSet.is())
873     {
874         sal_uInt16 nType = sal_uInt16();
875         Any aAny;
876 
877         aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Layout")));
878         if(aAny >>= nType)
879         {
880             if(ImpXMLAutoLayoutInfo::IsCreateNecessary(nType))
881             {
882                 ImpXMLEXPPageMasterInfo* pInfo = 0L;
883 
884                 // get master-page info
885                 Reference < drawing::XMasterPageTarget > xMasterPageInt(xPage, UNO_QUERY);
886                 if(xMasterPageInt.is())
887                 {
888                     Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
889                     if(xUsedMasterPage.is())
890                     {
891                         Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
892                         if(xMasterNamed.is())
893                         {
894                             OUString sMasterPageName = xMasterNamed->getName();
895                             pInfo = ImpGetPageMasterInfoByName(sMasterPageName);
896                         }
897                     }
898                 }
899 
900                 // create entry and look for existance
901                 ImpXMLAutoLayoutInfo* pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
902                 sal_Bool bDidExist(sal_False);
903 
904                 for(sal_uInt32 nCnt = 0L; !bDidExist && nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
905                 {
906                     if(*mpAutoLayoutInfoList->GetObject(nCnt) == *pNew)
907                     {
908                         delete pNew;
909                         pNew = mpAutoLayoutInfoList->GetObject(nCnt);
910                         bDidExist = sal_True;
911                     }
912                 }
913 
914                 if(!bDidExist)
915                 {
916                     mpAutoLayoutInfoList->Insert(pNew, LIST_APPEND);
917                     OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("AL"));
918                     sNewName += OUString::valueOf(sal_Int32(mpAutoLayoutInfoList->Count() - 1));
919                     sNewName += OUString(RTL_CONSTASCII_USTRINGPARAM("T"));
920                     sNewName += OUString::valueOf(sal_Int32(nType));
921                     pNew->SetLayoutName(sNewName);
922                 }
923 
924                 rName = pNew->GetLayoutName();
925                 bRetval = sal_True;
926             }
927         }
928     }
929 
930     return bRetval;
931 }
932 
933 //////////////////////////////////////////////////////////////////////////////
934 
ImpWriteAutoLayoutInfos()935 void SdXMLExport::ImpWriteAutoLayoutInfos()
936 {
937     if(mpAutoLayoutInfoList->Count())
938     {
939         for(sal_uInt32 nCnt = 0L; nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
940         {
941             ImpXMLAutoLayoutInfo* pInfo = mpAutoLayoutInfoList->GetObject(nCnt);
942             if(pInfo)
943             {
944                 // prepare presentation-page layout attributes, style-name
945                 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, pInfo->GetLayoutName());
946 
947                 // write draw-style attributes
948                 SvXMLElementExport aDSE(*this, XML_NAMESPACE_STYLE, XML_PRESENTATION_PAGE_LAYOUT, sal_True, sal_True);
949 
950                 // write presentation placeholders
951                 switch(pInfo->GetLayoutType())
952                 {
953                     case 0 : // AUTOLAYOUT_TITLE
954                     {
955                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
956                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
957                         break;
958                     }
959                     case 1 : // AUTOLAYOUT_ENUM
960                     {
961                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
962                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, pInfo->GetPresRectangle());
963                         break;
964                     }
965                     case 2 : // AUTOLAYOUT_CHART
966                     {
967                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
968                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, pInfo->GetPresRectangle());
969                         break;
970                     }
971                     case 3 : // AUTOLAYOUT_2TEXT
972                     {
973                         Rectangle aLeft(pInfo->GetPresRectangle());
974                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
975                         Rectangle aRight(aLeft);
976                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
977 
978                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
979                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
980                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
981                         break;
982                     }
983                     case 4 : // AUTOLAYOUT_TEXTCHART
984                     {
985                         Rectangle aLeft(pInfo->GetPresRectangle());
986                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
987                         Rectangle aRight(aLeft);
988                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
989 
990                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
991                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
992                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aRight);
993                         break;
994                     }
995                     case 6 : // AUTOLAYOUT_TEXTCLIP
996                     {
997                         Rectangle aLeft(pInfo->GetPresRectangle());
998                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
999                         Rectangle aRight(aLeft);
1000                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1001 
1002                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1003                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1004                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aRight);
1005                         break;
1006                     }
1007                     case 7 : // AUTOLAYOUT_CHARTTEXT
1008                     {
1009                         Rectangle aLeft(pInfo->GetPresRectangle());
1010                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1011                         Rectangle aRight(aLeft);
1012                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1013 
1014                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1015                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aLeft);
1016                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1017                         break;
1018                     }
1019                     case 8 : // AUTOLAYOUT_TAB
1020                     {
1021                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1022                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTable, pInfo->GetPresRectangle());
1023                         break;
1024                     }
1025                     case 9 : // AUTOLAYOUT_CLIPTEXT
1026                     {
1027                         Rectangle aLeft(pInfo->GetPresRectangle());
1028                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1029                         Rectangle aRight(aLeft);
1030                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1031 
1032                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1033                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
1034                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1035                         break;
1036                     }
1037                     case 10 : // AUTOLAYOUT_TEXTOBJ
1038                     {
1039                         Rectangle aLeft(pInfo->GetPresRectangle());
1040                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1041                         Rectangle aRight(aLeft);
1042                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1043 
1044                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1045                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1046                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRight);
1047                         break;
1048                     }
1049                     case 11 : // AUTOLAYOUT_OBJ
1050                     {
1051                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1052                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, pInfo->GetPresRectangle());
1053                         break;
1054                     }
1055                     case 12 : // AUTOLAYOUT_TEXT2OBJ
1056                     {
1057                         Rectangle aLeft(pInfo->GetPresRectangle());
1058                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1059                         Rectangle aRightTop(aLeft);
1060                         aRightTop.Left() = long(aRightTop.Left() + aRightTop.GetWidth() * 1.05);
1061                         aRightTop.setHeight(long(aRightTop.GetHeight() * 0.477));
1062                         Rectangle aRightBottom(aRightTop);
1063                         aRightBottom.Top() = long(aRightBottom.Top() + aRightBottom.GetHeight() * 1.095);
1064 
1065                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1066                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1067                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightTop);
1068                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightBottom);
1069                         break;
1070                     }
1071                     case 13 : // AUTOLAYOUT_OBJTEXT
1072                     {
1073                         Rectangle aLeft(pInfo->GetPresRectangle());
1074                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1075                         Rectangle aRight(aLeft);
1076                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1077 
1078                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1079                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeft);
1080                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1081                         break;
1082                     }
1083                     case 14 : // AUTOLAYOUT_OBJOVERTEXT
1084                     {
1085                         Rectangle aTop(pInfo->GetPresRectangle());
1086                         aTop.setHeight(long(aTop.GetHeight() * 0.477));
1087                         Rectangle aBottom(aTop);
1088                         aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1089 
1090                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1091                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTop);
1092                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
1093                         break;
1094                     }
1095                     case 15 : // AUTOLAYOUT_2OBJTEXT
1096                     {
1097                         Rectangle aLeftTop(pInfo->GetPresRectangle());
1098                         aLeftTop.setWidth(long(aLeftTop.GetWidth() * 0.488));
1099                         Rectangle aRight(aLeftTop);
1100                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1101                         aLeftTop.setHeight(long(aLeftTop.GetHeight() * 0.477));
1102                         Rectangle aLeftBottom(aLeftTop);
1103                         aLeftBottom.Top() = long(aLeftBottom.Top() + aLeftBottom.GetHeight() * 1.095);
1104 
1105                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1106                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftTop);
1107                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftBottom);
1108                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1109                         break;
1110                     }
1111                     case 16 : // AUTOLAYOUT_2OBJOVERTEXT
1112                     {
1113                         Rectangle aTopLeft(pInfo->GetPresRectangle());
1114                         aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1115                         Rectangle aBottom(aTopLeft);
1116                         aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1117                         aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1118                         Rectangle aTopRight(aTopLeft);
1119                         aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1120 
1121                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1122                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
1123                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
1124                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
1125                         break;
1126                     }
1127                     case 17 : // AUTOLAYOUT_TEXTOVEROBJ
1128                     {
1129                         Rectangle aTop(pInfo->GetPresRectangle());
1130                         aTop.setHeight(long(aTop.GetHeight() * 0.477));
1131                         Rectangle aBottom(aTop);
1132                         aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1133 
1134                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1135                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aTop);
1136                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottom);
1137                         break;
1138                     }
1139                     case 18 : // AUTOLAYOUT_4OBJ
1140                     {
1141                         Rectangle aTopLeft(pInfo->GetPresRectangle());
1142                         aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1143                         aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1144                         Rectangle aBottomLeft(aTopLeft);
1145                         aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1146                         Rectangle aTopRight(aTopLeft);
1147                         aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1148                         Rectangle aBottomRight(aTopRight);
1149                         aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1150 
1151                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1152                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
1153                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
1154                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomLeft);
1155                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomRight);
1156                         break;
1157                     }
1158                     case 19 : // AUTOLAYOUT_ONLY_TITLE
1159                     {
1160                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1161                         break;
1162                     }
1163                     case 21 : // AUTOLAYOUT_NOTES
1164                     {
1165                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderPage, pInfo->GetTitleRectangle());
1166                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderNotes, pInfo->GetPresRectangle());
1167                         break;
1168                     }
1169                     case 22 : // AUTOLAYOUT_HANDOUT1
1170                     case 23 : // AUTOLAYOUT_HANDOUT2
1171                     case 24 : // AUTOLAYOUT_HANDOUT3
1172                     case 25 : // AUTOLAYOUT_HANDOUT4
1173                     case 26 : // AUTOLAYOUT_HANDOUT6
1174                     case 31 : // AUTOLAYOUT_HANDOUT9
1175                     {
1176                         sal_Int32 nColCnt, nRowCnt;
1177                         sal_Int32 nGapX = pInfo->GetGapX();
1178                         sal_Int32 nGapY = pInfo->GetGapY();
1179 
1180                         switch(pInfo->GetLayoutType())
1181                         {
1182                             case 22 : nColCnt = 1; nRowCnt = 1; break;
1183                             case 23 : nColCnt = 1; nRowCnt = 2; break;
1184                             case 24 : nColCnt = 1; nRowCnt = 3; break;
1185                             case 25 : nColCnt = 2; nRowCnt = 2; break;
1186                             case 26 : nColCnt = 3; nRowCnt = 2; break;
1187                             case 31 : nColCnt = 3; nRowCnt = 3; break;
1188                             default:  nColCnt = 0; nRowCnt = 0; break;  // FIXME - What is correct values?
1189                         }
1190 
1191                         Size aPartSize(pInfo->GetTitleRectangle().GetSize());
1192                         Point aPartPos(pInfo->GetTitleRectangle().TopLeft());
1193 
1194                         if(aPartSize.Width() > aPartSize.Height())
1195                         {
1196                             sal_Int32 nZwi(nColCnt);
1197                             nColCnt = nRowCnt;
1198                             nRowCnt = nZwi;
1199                         }
1200 
1201                         aPartSize.Width() = (aPartSize.Width() - ((nColCnt - 1) * nGapX)) / nColCnt;
1202                         aPartSize.Height() = (aPartSize.Height() - ((nRowCnt - 1) * nGapY)) / nRowCnt;
1203 
1204                         Point aTmpPos(aPartPos);
1205 
1206                         for (sal_Int32 a = 0; a < nRowCnt; a++)
1207                         {
1208                             aTmpPos.X() = aPartPos.X();
1209 
1210                             for (sal_Int32 b = 0; b < nColCnt; b++)
1211                             {
1212                                 Rectangle aTmpRect(aTmpPos, aPartSize);
1213 
1214                                 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderHandout, aTmpRect);
1215                                 aTmpPos.X() += aPartSize.Width() + nGapX;
1216                             }
1217 
1218                             aTmpPos.Y() += aPartSize.Height() + nGapY;
1219                         }
1220                         break;
1221                     }
1222                     case 27 : // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1223                     {
1224                         Rectangle aTop(pInfo->GetPresRectangle());
1225                         aTop.setHeight(long(aTop.GetHeight() * 0.488));
1226                         Rectangle aBottom(aTop);
1227                         aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.05);
1228 
1229                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1230                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aTop);
1231                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aBottom);
1232                         break;
1233                     }
1234                     case 28 : // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1235                     {
1236                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1237                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1238                         break;
1239                     }
1240                     case 29 : // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1241                     {
1242                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1243                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1244                         break;
1245                     }
1246                     case 30 : // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1247                     {
1248                         Rectangle aLeft(pInfo->GetPresRectangle());
1249                         aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1250                         Rectangle aRight(aLeft);
1251                         aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1252 
1253                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1254                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
1255                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aRight);
1256                         break;
1257                     }
1258                     case 32 : // AUTOLAYOUT_TITLE
1259                     {
1260                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
1261                         break;
1262                     }
1263 
1264                     case 33 : // AUTOLAYOUT_4CLIPART
1265                     {
1266                         Rectangle aTopLeft(pInfo->GetPresRectangle());
1267                         aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1268                         aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1269                         Rectangle aBottomLeft(aTopLeft);
1270                         aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1271                         Rectangle aTopRight(aTopLeft);
1272                         aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1273                         Rectangle aBottomRight(aTopRight);
1274                         aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1275 
1276                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1277                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1278                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1279                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1280                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1281                         break;
1282                     }
1283 
1284                     case 34 : // AUTOLAYOUT_6CLIPART
1285                     {
1286                         Rectangle aTopLeft(pInfo->GetPresRectangle());
1287                         aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1288                         aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.322));
1289                         Rectangle aTopCenter(aTopLeft);
1290                         aTopCenter.Left() = long(aTopCenter.Left() + aTopCenter.GetWidth() * 1.05);
1291                         Rectangle aTopRight(aTopLeft);
1292                         aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 2 * 1.05);
1293 
1294                         Rectangle aBottomLeft(aTopLeft);
1295                         aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1296                         Rectangle aBottomCenter(aTopCenter);
1297                         aBottomCenter.Top() = long(aBottomCenter.Top() + aBottomCenter.GetHeight() * 1.095);
1298                         Rectangle aBottomRight(aTopRight);
1299                         aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1300 
1301                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1302                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1303                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopCenter);
1304                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1305                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1306                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomCenter);
1307                         ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1308                         break;
1309                     }
1310                     default:
1311                     {
1312                         DBG_ERROR("XMLEXP: unknown autolayout export");
1313                         break;
1314                     }
1315                 }
1316             }
1317         }
1318     }
1319 }
1320 
1321 //////////////////////////////////////////////////////////////////////////////
1322 
ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl,const Rectangle & rRect)1323 void SdXMLExport::ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl, const Rectangle& rRect)
1324 {
1325     OUString aStr;
1326     OUStringBuffer sStringBuffer;
1327 
1328     // prepare presentation-placeholder attributes, presentation:object
1329     switch(ePl)
1330     {
1331         case XmlPlaceholderTitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("title")); break;
1332         case XmlPlaceholderOutline: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("outline")); break;
1333         case XmlPlaceholderSubtitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("subtitle")); break;
1334         case XmlPlaceholderText: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("text")); break;
1335         case XmlPlaceholderGraphic: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("graphic")); break;
1336         case XmlPlaceholderObject: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("object")); break;
1337         case XmlPlaceholderChart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("chart")); break;
1338         case XmlPlaceholderOrgchart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("orgchart")); break;
1339         case XmlPlaceholderTable: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("table")); break;
1340         case XmlPlaceholderPage: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("page")); break;
1341         case XmlPlaceholderNotes: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("notes")); break;
1342         case XmlPlaceholderHandout: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("handout")); break;
1343         case XmlPlaceholderVerticalTitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_title")); break;
1344         case XmlPlaceholderVerticalOutline: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_outline")); break;
1345     }
1346 
1347     AddAttribute(XML_NAMESPACE_PRESENTATION, XML_OBJECT, aStr);
1348 
1349     // svg:x,y,width,height
1350     GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Left());
1351     aStr = sStringBuffer.makeStringAndClear();
1352     AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
1353 
1354     GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Top());
1355     aStr = sStringBuffer.makeStringAndClear();
1356     AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
1357 
1358     GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetWidth());
1359     aStr = sStringBuffer.makeStringAndClear();
1360     AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
1361 
1362     GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetHeight());
1363     aStr = sStringBuffer.makeStringAndClear();
1364     AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
1365 
1366     // write presentation-placeholder
1367     SvXMLElementExport aPPL(*this, XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, sal_True, sal_True);
1368 }
1369 
1370 //////////////////////////////////////////////////////////////////////////////
1371 
ImpGetOrCreatePageMasterInfo(Reference<XDrawPage> xMasterPage)1372 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetOrCreatePageMasterInfo( Reference< XDrawPage > xMasterPage )
1373 {
1374     bool bDoesExist = false;
1375 
1376     ImpXMLEXPPageMasterInfo* pNewInfo = new ImpXMLEXPPageMasterInfo(*this, xMasterPage);
1377 
1378     // compare with prev page-master infos
1379     for(sal_uInt32 a = 0; !bDoesExist && a < mpPageMasterInfoList->Count(); a++)
1380     {
1381         if(mpPageMasterInfoList->GetObject(a)
1382             && *mpPageMasterInfoList->GetObject(a) == *pNewInfo)
1383         {
1384             delete pNewInfo;
1385             pNewInfo = mpPageMasterInfoList->GetObject(a);
1386             bDoesExist = true;
1387         }
1388     }
1389     // add entry when not found same page-master infos
1390     if(!bDoesExist)
1391         mpPageMasterInfoList->Insert(pNewInfo, LIST_APPEND);
1392 
1393     return pNewInfo;
1394 }
1395 
ImpPrepPageMasterInfos()1396 void SdXMLExport::ImpPrepPageMasterInfos()
1397 {
1398     if( IsImpress() )
1399     {
1400         // create page master info for handout master page
1401 
1402         Reference< XHandoutMasterSupplier > xHMS( GetModel(), UNO_QUERY );
1403         if( xHMS.is() )
1404         {
1405             Reference< XDrawPage > xMasterPage( xHMS->getHandoutMasterPage() );
1406             if( xMasterPage.is() )
1407                 mpHandoutPageMaster = ImpGetOrCreatePageMasterInfo(xMasterPage);
1408         }
1409     }
1410 
1411     // create page master infos for master pages
1412     if(mnDocMasterPageCount)
1413     {
1414         // look for needed page-masters, create these
1415         for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
1416         {
1417             Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
1418             ImpXMLEXPPageMasterInfo* pNewInfo = 0L;
1419 
1420             if(xMasterPage.is())
1421                 pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage);
1422 
1423             mpPageMasterUsageList->Insert(pNewInfo, LIST_APPEND);
1424 
1425             // look for page master of handout page
1426             if(IsImpress())
1427             {
1428                 pNewInfo = NULL;
1429                 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
1430                 if(xPresPage.is())
1431                 {
1432                     Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
1433                     if(xNotesPage.is())
1434                     {
1435                         pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage);
1436                     }
1437                 }
1438                 mpNotesPageMasterUsageList->Insert( pNewInfo, LIST_APPEND );
1439             }
1440         }
1441     }
1442 }
1443 
1444 //////////////////////////////////////////////////////////////////////////////
1445 
ImpWritePageMasterInfos()1446 void SdXMLExport::ImpWritePageMasterInfos()
1447 {
1448     // write created page-masters, create names for these
1449     for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
1450     {
1451         ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
1452         if(pInfo)
1453         {
1454             // create name
1455             OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("PM"));
1456 
1457             sNewName += OUString::valueOf((sal_Int32)nCnt);
1458             pInfo->SetName(sNewName);
1459 
1460             // prepare page-master attributes
1461             OUString sString;
1462             OUStringBuffer sStringBuffer;
1463 
1464             sString = sNewName;
1465             AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sString);
1466 
1467             // write page-layout
1468             SvXMLElementExport aPME(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT, sal_True, sal_True);
1469 
1470             // prepare style:properties inside page-master
1471             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderTop());
1472             sString = sStringBuffer.makeStringAndClear();
1473             AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_TOP, sString);
1474 
1475             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderBottom());
1476             sString = sStringBuffer.makeStringAndClear();
1477             AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, sString);
1478 
1479             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderLeft());
1480             sString = sStringBuffer.makeStringAndClear();
1481             AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_LEFT, sString);
1482 
1483             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderRight());
1484             sString = sStringBuffer.makeStringAndClear();
1485             AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_RIGHT, sString);
1486 
1487             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetWidth());
1488             sString = sStringBuffer.makeStringAndClear();
1489             AddAttribute(XML_NAMESPACE_FO, XML_PAGE_WIDTH, sString);
1490 
1491             GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetHeight());
1492             sString = sStringBuffer.makeStringAndClear();
1493             AddAttribute(XML_NAMESPACE_FO, XML_PAGE_HEIGHT, sString);
1494 
1495             if(pInfo->GetOrientation() == view::PaperOrientation_PORTRAIT)
1496                 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_PORTRAIT);
1497             else
1498                 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_LANDSCAPE);
1499 
1500             // write style:properties
1501             SvXMLElementExport aPMF(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_PROPERTIES, sal_True, sal_True);
1502         }
1503     }
1504 }
1505 
1506 //////////////////////////////////////////////////////////////////////////////
1507 
ImpGetPageMasterInfoByName(const OUString & rName)1508 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(const OUString& rName)
1509 {
1510     if(rName.getLength() && mpPageMasterInfoList->Count())
1511     {
1512         for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
1513         {
1514             ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
1515             if(pInfo)
1516             {
1517                 if(pInfo->GetMasterPageName().getLength() && rName.equals(pInfo->GetMasterPageName()))
1518                 {
1519                     return pInfo;
1520                 }
1521             }
1522         }
1523     }
1524     return 0L;
1525 }
1526 
1527 //////////////////////////////////////////////////////////////////////////////
1528 
ImpPrepDrawPageInfos()1529 void SdXMLExport::ImpPrepDrawPageInfos()
1530 {
1531     // create draw:style-name entries for page export
1532     // containing presentation page attributes AND background attributes
1533     // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1534 
1535     sal_Int32 nCnt;
1536     for(nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
1537     {
1538         Reference<XDrawPage> xDrawPage;
1539         mxDocDrawPages->getByIndex(nCnt) >>= xDrawPage;
1540         maDrawPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1541 
1542         Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
1543         if(xPresPage.is())
1544         {
1545             maDrawNotesPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xPresPage->getNotesPage(), false );
1546 
1547             maDrawPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xDrawPage );
1548             maDrawNotesPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xPresPage->getNotesPage() );
1549         }
1550     }
1551 }
1552 
1553 //////////////////////////////////////////////////////////////////////////////
1554 
findOrAppendImpl(std::vector<OUString> & rVector,const OUString & rText,const sal_Char * pPrefix)1555 static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, const sal_Char* pPrefix )
1556 {
1557     // search rVector if there is already a string that equals rText
1558     std::vector< OUString >::iterator aIter;
1559     sal_Int32 nIndex;
1560     for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); aIter++, nIndex++ )
1561     {
1562         if( (*aIter) == rText )
1563             break;
1564     }
1565 
1566     // if nothing is found, append the string at the end of rVector
1567     if( aIter == rVector.end() )
1568         rVector.push_back( rText );
1569 
1570     // create a reference string with pPrefix and the index of the
1571     // found or created rText
1572     OUString aStr( OUString::createFromAscii( pPrefix ) );
1573     aStr += OUString::valueOf( nIndex );
1574     return aStr;
1575 }
1576 
findOrAppendImpl(std::vector<DateTimeDeclImpl> & rVector,const OUString & rText,sal_Bool bFixed,sal_Int32 nFormat,const sal_Char * pPrefix)1577 static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, sal_Bool bFixed, sal_Int32 nFormat, const sal_Char* pPrefix )
1578 {
1579     // search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
1580     std::vector< DateTimeDeclImpl >::iterator aIter;
1581     sal_Int32 nIndex;
1582     for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); aIter++, nIndex++ )
1583     {
1584         const DateTimeDeclImpl& rDecl = (*aIter);
1585         if( (rDecl.mbFixed == bFixed ) &&
1586             (!bFixed || rDecl.maStrText == rText) &&
1587             (bFixed || (rDecl.mnFormat == nFormat) ) )
1588             break;
1589     }
1590 
1591     // if nothing is found, append a new DateTimeDeclImpl
1592     if( aIter == rVector.end() )
1593     {
1594         DateTimeDeclImpl aDecl;
1595         aDecl.maStrText = rText;
1596         aDecl.mbFixed = bFixed;
1597         aDecl.mnFormat = nFormat;
1598         rVector.push_back( aDecl );
1599     }
1600 
1601     // create a reference string with pPrefix and the index of the
1602     // found or created DateTimeDeclImpl
1603     OUString aStr( OUString::createFromAscii( pPrefix ) );
1604     aStr += OUString::valueOf( nIndex );
1605     return aStr;
1606 
1607 }
1608 
1609 static const sal_Char* gpStrHeaderTextPrefix = "hdr";
1610 static const sal_Char* gpStrFooterTextPrefix = "ftr";
1611 static const sal_Char* gpStrDateTimeTextPrefix = "dtd";
1612 
ImpPrepDrawPageHeaderFooterDecls(const Reference<XDrawPage> & xDrawPage)1613 HeaderFooterPageSettingsImpl SdXMLExport::ImpPrepDrawPageHeaderFooterDecls( const Reference<XDrawPage>& xDrawPage )
1614 {
1615     HeaderFooterPageSettingsImpl aSettings;
1616 
1617     if( xDrawPage.is() ) try
1618     {
1619         Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
1620         Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
1621 
1622         OUString aStrText;
1623 
1624         const OUString aStrHeaderTextProp( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) );
1625         if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
1626         {
1627             xSet->getPropertyValue( aStrHeaderTextProp  ) >>= aStrText;
1628             if( aStrText.getLength() )
1629                 aSettings.maStrHeaderDeclName = findOrAppendImpl( maHeaderDeclsVector, aStrText, gpStrHeaderTextPrefix );
1630         }
1631 
1632         const OUString aStrFooterTextProp( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) );
1633         if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
1634         {
1635             xSet->getPropertyValue( aStrFooterTextProp ) >>= aStrText;
1636             if( aStrText.getLength() )
1637                 aSettings.maStrFooterDeclName = findOrAppendImpl( maFooterDeclsVector, aStrText, gpStrFooterTextPrefix );
1638         }
1639 
1640         const OUString aStrDateTimeTextProp( RTL_CONSTASCII_USTRINGPARAM( "DateTimeText" ) );
1641         if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
1642         {
1643             sal_Bool bFixed = false;
1644             sal_Int32 nFormat = 0;
1645             xSet->getPropertyValue( aStrDateTimeTextProp ) >>= aStrText;
1646             xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDateTimeFixed" ) ) ) >>= bFixed;
1647             xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DateTimeFormat" ) ) ) >>= nFormat;
1648 
1649             if( !bFixed || aStrText.getLength() )
1650             {
1651                 aSettings.maStrDateTimeDeclName = findOrAppendImpl( maDateTimeDeclsVector, aStrText, bFixed, nFormat, gpStrDateTimeTextPrefix );
1652                 if( !bFixed )
1653                     addDataStyle( nFormat );
1654             }
1655         }
1656     }
1657     catch( Exception& e )
1658     {
1659         (void)e;
1660         DBG_ERROR( "SdXMLExport::ImpPrepDrawPageHeaderFooterDecls(), unexpected exception cought!" );
1661     }
1662 
1663     return aSettings;
1664 }
1665 
1666 //////////////////////////////////////////////////////////////////////////////
1667 
ImpWriteHeaderFooterDecls()1668 void SdXMLExport::ImpWriteHeaderFooterDecls()
1669 {
1670     OUStringBuffer sBuffer;
1671 
1672     if( !maHeaderDeclsVector.empty() )
1673     {
1674         // export header decls
1675         const OUString aPrefix( OUString::createFromAscii( gpStrHeaderTextPrefix ) );
1676         std::vector< OUString >::iterator aIter;
1677         sal_Int32 nIndex;
1678         for( nIndex = 1, aIter = maHeaderDeclsVector.begin(); aIter != maHeaderDeclsVector.end(); aIter++, nIndex++ )
1679         {
1680             sBuffer.append( aPrefix );
1681             sBuffer.append( nIndex );
1682             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1683 
1684             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, sal_True, sal_True);
1685             Characters((*aIter));
1686         }
1687     }
1688 
1689     if( !maFooterDeclsVector.empty() )
1690     {
1691         // export footer decls
1692         const OUString aPrefix( OUString::createFromAscii( gpStrFooterTextPrefix ) );
1693         std::vector< OUString >::iterator aIter;
1694         sal_Int32 nIndex;
1695         for( nIndex = 1, aIter = maFooterDeclsVector.begin(); aIter != maFooterDeclsVector.end(); aIter++, nIndex++ )
1696         {
1697             sBuffer.append( aPrefix );
1698             sBuffer.append( nIndex );
1699             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1700 
1701             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, sal_False, sal_False);
1702             Characters((*aIter));
1703         }
1704     }
1705 
1706     if( !maDateTimeDeclsVector.empty() )
1707     {
1708         // export footer decls
1709         const OUString aPrefix( OUString::createFromAscii( gpStrDateTimeTextPrefix ) );
1710         std::vector< DateTimeDeclImpl >::iterator aIter;
1711         sal_Int32 nIndex;
1712         for( nIndex = 1, aIter = maDateTimeDeclsVector.begin(); aIter != maDateTimeDeclsVector.end(); aIter++, nIndex++ )
1713         {
1714             const DateTimeDeclImpl& rDecl = (*aIter);
1715 
1716             sBuffer.append( aPrefix );
1717             sBuffer.append( nIndex );
1718             AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1719 
1720             AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE );
1721 
1722             if( !rDecl.mbFixed )
1723                 AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) );
1724 
1725             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, sal_False, sal_False);
1726             if( rDecl.mbFixed )
1727                 Characters(rDecl.maStrText);
1728         }
1729     }
1730 }
1731 
ImplExportHeaderFooterDeclAttributes(const HeaderFooterPageSettingsImpl & aSettings)1732 void SdXMLExport::ImplExportHeaderFooterDeclAttributes( const HeaderFooterPageSettingsImpl& aSettings )
1733 {
1734     if( aSettings.maStrHeaderDeclName.getLength() )
1735         AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, aSettings.maStrHeaderDeclName );
1736 
1737     if( aSettings.maStrFooterDeclName.getLength() )
1738         AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, aSettings.maStrFooterDeclName );
1739 
1740     if( aSettings.maStrDateTimeDeclName.getLength() )
1741         AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, aSettings.maStrDateTimeDeclName );
1742 }
1743 
1744 //////////////////////////////////////////////////////////////////////////////
1745 
ImpCreatePresPageStyleName(Reference<XDrawPage> xDrawPage,bool bExportBackground)1746 OUString SdXMLExport::ImpCreatePresPageStyleName( Reference<XDrawPage> xDrawPage, bool bExportBackground /* = true */ )
1747 {
1748     // create name
1749     OUString sStyleName;
1750 
1751     // create style for this page and add to auto style pool
1752 
1753     Reference< beans::XPropertySet > xPropSet1(xDrawPage, UNO_QUERY);
1754     if(xPropSet1.is())
1755     {
1756         Reference< beans::XPropertySet > xPropSet;
1757 
1758         if( bExportBackground )
1759         {
1760             // since the background items are in a different propertyset
1761             // which itself is a property of the pages property set
1762             // we now merge these two propertysets if possible to simulate
1763             // a single propertyset with all draw page properties
1764             const OUString aBackground(RTL_CONSTASCII_USTRINGPARAM("Background"));
1765             Reference< beans::XPropertySet > xPropSet2;
1766             Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
1767             if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
1768             {
1769                 Any aAny( xPropSet1->getPropertyValue( aBackground ) );
1770                 aAny >>= xPropSet2;
1771             }
1772 
1773             if( xPropSet2.is() )
1774                 xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xPropSet2 );
1775             else
1776                 xPropSet = xPropSet1;
1777         }
1778         else
1779         {
1780             xPropSet = xPropSet1;
1781         }
1782 
1783         const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );
1784 
1785         std::vector< XMLPropertyState > xPropStates( aMapperRef->Filter( xPropSet ) );
1786 
1787         if( !xPropStates.empty() )
1788         {
1789             // there are filtered properties -> hard attributes
1790             // try to find this style in AutoStylePool
1791             sStyleName = GetAutoStylePool()->Find(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
1792 
1793             if(!sStyleName.getLength())
1794             {
1795                 // Style did not exist, add it to AutoStalePool
1796                 sStyleName = GetAutoStylePool()->Add(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
1797             }
1798         }
1799     }
1800 
1801     return sStyleName;
1802 }
1803 
1804 //////////////////////////////////////////////////////////////////////////////
1805 
ImpPrepMasterPageInfos()1806 void SdXMLExport::ImpPrepMasterPageInfos()
1807 {
1808     // create draw:style-name entries for master page export
1809     // containing only background attributes
1810     // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1811 
1812     sal_Int32 nCnt;
1813     for( nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
1814     {
1815         Reference<XDrawPage> xDrawPage;
1816         mxDocMasterPages->getByIndex(nCnt) >>= xDrawPage;
1817         maMasterPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1818     }
1819 
1820     if( IsImpress() )
1821     {
1822         Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
1823         if( xHandoutSupp.is() )
1824         {
1825             Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
1826             if( xHandoutPage.is() )
1827             {
1828                 maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage );
1829                 maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false );
1830             }
1831         }
1832     }
1833 }
1834 
1835 //////////////////////////////////////////////////////////////////////////////
ImpWritePresentationStyles()1836 void SdXMLExport::ImpWritePresentationStyles()
1837 {
1838     if(IsImpress())
1839     {
1840         for (sal_Int32 nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
1841         {
1842             Any aAny(mxDocMasterPages->getByIndex(nCnt));
1843             Reference<container::XNamed> xNamed;
1844 
1845             if(aAny >>= xNamed)
1846             {
1847                 // write presentation styles (ONLY if presentation)
1848                 if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
1849                 {
1850                     XMLStyleExport aStEx(*this, OUString(), GetAutoStylePool().get());
1851                     const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
1852 
1853                     OUString aPrefix( xNamed->getName() );
1854 
1855                     aPrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
1856                     aStEx.exportStyleFamily(xNamed->getName(),
1857                         OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)),
1858                         aMapperRef, sal_False,
1859                         XML_STYLE_FAMILY_SD_PRESENTATION_ID, &aPrefix);
1860                 }
1861             }
1862         }
1863     }
1864 }
1865 
1866 //////////////////////////////////////////////////////////////////////////////
1867 
SetProgress(sal_Int32 nProg)1868 void SdXMLExport::SetProgress(sal_Int32 nProg)
1869 {
1870     // set progress view
1871     if(GetStatusIndicator().is())
1872         GetStatusIndicator()->setValue(nProg);
1873 }
1874 
1875 //////////////////////////////////////////////////////////////////////////////
1876 // #82003#
1877 
_ExportMeta()1878 void SdXMLExport::_ExportMeta()
1879 {
1880     uno::Sequence<beans::NamedValue> stats(1);
1881     stats[0] = beans::NamedValue(::rtl::OUString::createFromAscii("ObjectCount"),
1882                 uno::makeAny(mnObjectCount));
1883 
1884     // update document statistics at the model
1885     uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(GetModel(),
1886         uno::UNO_QUERY_THROW);
1887     uno::Reference<document::XDocumentProperties> xDocProps(
1888         xPropSup->getDocumentProperties());
1889     if (xDocProps.is()) {
1890         xDocProps->setDocumentStatistics(stats);
1891     }
1892 
1893     // call parent
1894     SvXMLExport::_ExportMeta();
1895 }
1896 
1897 //////////////////////////////////////////////////////////////////////////////
1898 
_ExportContent()1899 void SdXMLExport::_ExportContent()
1900 {
1901     // export <pres:header-decl>, <pres:footer-decl> and <pres:date-time-decl> elements
1902     ImpWriteHeaderFooterDecls();
1903 
1904     // page export
1905     for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
1906     {
1907         uno::Reference<drawing::XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), uno::UNO_QUERY );
1908 
1909         SetProgress(((nPageInd + 1) * 100) / mnDocDrawPageCount);
1910 
1911         if(xDrawPage.is())
1912         {
1913             // prepare page attributes, name of page
1914             Reference < container::XNamed > xNamed(xDrawPage, UNO_QUERY);
1915             if(xNamed.is())
1916                 AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, xNamed->getName());
1917 
1918             // draw:style-name (presentation page attributes AND background attributes)
1919             if( maDrawPagesStyleNames[nPageInd].getLength() )
1920                 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
1921                         maDrawPagesStyleNames[nPageInd]);
1922 
1923             // draw:master-page-name
1924             Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
1925             if(xMasterPageInt.is())
1926             {
1927                 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
1928                 if(xUsedMasterPage.is())
1929                 {
1930                     Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
1931                     if(xMasterNamed.is())
1932                     {
1933                         AddAttribute(XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME,
1934                             EncodeStyleName( xMasterNamed->getName()) );
1935                     }
1936                 }
1937             }
1938 
1939             // presentation:page-layout-name
1940             if( IsImpress() && maDrawPagesAutoLayoutNames[nPageInd+1].getLength())
1941             {
1942                 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, maDrawPagesAutoLayoutNames[nPageInd+1] );
1943             }
1944 
1945             Reference< beans::XPropertySet > xProps( xDrawPage, UNO_QUERY );
1946             if( xProps.is() )
1947             {
1948                 try
1949                 {
1950                     OUString aBookmarkURL;
1951                     xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "BookmarkURL" ) ) ) >>= aBookmarkURL;
1952 
1953                     if( aBookmarkURL.getLength() )
1954                     {
1955                         sal_Int32 nIndex = aBookmarkURL.lastIndexOf( (sal_Unicode)'#' );
1956                         if( nIndex != -1 )
1957                         {
1958                             OUString aFileName( aBookmarkURL.copy( 0, nIndex ) );
1959                             OUString aBookmarkName( aBookmarkURL.copy( nIndex+1 ) );
1960 
1961                             aBookmarkURL = GetRelativeReference( aFileName );
1962                             aBookmarkURL += String( '#' );
1963                             aBookmarkURL += aBookmarkName;
1964                         }
1965 
1966                         AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, aBookmarkURL);
1967                         AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1968                         AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_REPLACE );
1969                         AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
1970                     }
1971                 }
1972                 catch( Exception& )
1973                 {
1974                     DBG_ERROR(" no \"BookmarkURL\" property at page?" );
1975                 }
1976             }
1977 
1978             if( IsImpress() )
1979                 ImplExportHeaderFooterDeclAttributes( maDrawPagesHeaderFooterSettings[nPageInd] );
1980 
1981 
1982             OUString sNavigationOrder( getNavigationOrder( xDrawPage ) );
1983             if( sNavigationOrder.getLength() != 0 )
1984                 AddAttribute ( XML_NAMESPACE_DRAW, XML_NAV_ORDER, sNavigationOrder );
1985 
1986             UniReference< xmloff::AnimationsExporter >  xAnimationsExporter;
1987             uno::Reference< ::com::sun::star::animations::XAnimationNodeSupplier > xAnimNodeSupplier;
1988 
1989             // prepare animation export
1990             if(IsImpress())
1991             {
1992                 if( getExportFlags() & EXPORT_OASIS )
1993                 {
1994                     // export new animations for oasis format
1995                     xAnimNodeSupplier.set( xDrawPage, UNO_QUERY );
1996 
1997                     // prepare animations exporter if impress
1998                     if(xAnimNodeSupplier.is())
1999                     {
2000                         xAnimationsExporter = new xmloff::AnimationsExporter( *this, xProps );
2001                         xAnimationsExporter->prepare( xAnimNodeSupplier->getAnimationNode() );
2002                     }
2003                 }
2004                 else
2005                 {
2006                     // export old animations for ooo format
2007                     UniReference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter( GetShapeExport().get() );
2008                     GetShapeExport()->setAnimationsExporter( xAnimExport );
2009                 }
2010             }
2011 
2012             // write draw:id
2013             const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage );
2014             if( aPageId.getLength() != 0 )
2015             {
2016                 AddAttributeIdLegacy(XML_NAMESPACE_DRAW, aPageId);
2017             }
2018 
2019             // write page
2020             SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, sal_True, sal_True);
2021 
2022             // write optional office:forms
2023             exportFormsElement( xDrawPage );
2024 
2025             // write graphic objects on this page (if any)
2026             Reference< drawing::XShapes > xExportShapes(xDrawPage, UNO_QUERY);
2027             if(xExportShapes.is() && xExportShapes->getCount())
2028                 GetShapeExport()->exportShapes( xExportShapes );
2029 
2030             // write animations and presentation notes (ONLY if presentation)
2031             if(IsImpress())
2032             {
2033                 if(xAnimNodeSupplier.is())
2034                 {
2035                     xAnimationsExporter->exportAnimations( xAnimNodeSupplier->getAnimationNode() );
2036                 }
2037                 else
2038                 {
2039                     // animations
2040                     UniReference< XMLAnimationsExporter > xAnimExport( GetShapeExport()->getAnimationsExporter() );
2041                     if( xAnimExport.is() )
2042                         xAnimExport->exportAnimations( *this );
2043 
2044                     xAnimExport = NULL;
2045                     GetShapeExport()->setAnimationsExporter( xAnimExport );
2046                 }
2047 
2048                 // presentations
2049                 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
2050                 if(xPresPage.is())
2051                 {
2052                     Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2053                     if(xNotesPage.is())
2054                     {
2055                         Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2056                         if(xShapes.is())
2057                         {
2058                             if( maDrawNotesPagesStyleNames[nPageInd].getLength() )
2059                                 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maDrawNotesPagesStyleNames[nPageInd]);
2060 
2061                             ImplExportHeaderFooterDeclAttributes( maDrawNotesPagesHeaderFooterSettings[nPageInd] );
2062 
2063                             // write presentation notes
2064                             SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, sal_True, sal_True);
2065 
2066                             // write optional office:forms
2067                             exportFormsElement( xNotesPage );
2068 
2069                             // write shapes per se
2070                             GetShapeExport()->exportShapes( xShapes );
2071                         }
2072                     }
2073                 }
2074             }
2075 
2076             exportAnnotations( xDrawPage );
2077         }
2078     }
2079 
2080     if( IsImpress() )
2081         exportPresentationSettings();
2082 }
2083 
2084 //////////////////////////////////////////////////////////////////////////////
2085 
exportPresentationSettings()2086 void SdXMLExport::exportPresentationSettings()
2087 {
2088     try
2089     {
2090         Reference< XPresentationSupplier > xPresSupplier( GetModel(), UNO_QUERY );
2091         if( !xPresSupplier.is() )
2092             return;
2093 
2094         Reference< XPropertySet > xPresProps( xPresSupplier->getPresentation(), UNO_QUERY );
2095         if( !xPresProps.is() )
2096             return;
2097 
2098         sal_Bool bHasAttr = sal_False;
2099 
2100         sal_Bool bTemp = false;
2101 
2102         // export range
2103         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsShowAll" ) ) ) >>= bTemp;
2104         if( !bTemp )
2105         {
2106             OUString aFirstPage;
2107             xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPage" ) ) ) >>= aFirstPage;
2108             if( aFirstPage.getLength() )
2109             {
2110                 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_PAGE, aFirstPage );
2111                 bHasAttr = sal_True;
2112             }
2113             else
2114             {
2115                 OUString aCustomShow;
2116                 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CustomShow" ) ) ) >>= aCustomShow;
2117                 if( aCustomShow.getLength() )
2118                 {
2119                     AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW, aCustomShow );
2120                     bHasAttr = sal_True;
2121                 }
2122             }
2123         }
2124 
2125         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsEndless" ) ) ) >>= bTemp;
2126         if( bTemp )
2127         {
2128             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ENDLESS, XML_TRUE );
2129             bHasAttr = sal_True;
2130 
2131             sal_Int32 nPause = 0;
2132             xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Pause" ) ) ) >>= nPause;
2133 
2134             util::DateTime aTime( 0, (sal_uInt16)nPause, 0, 0, 0, 0, 0 );
2135 
2136             OUStringBuffer aOut;
2137             SvXMLUnitConverter::convertTime( aOut, aTime );
2138             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAUSE, aOut.makeStringAndClear() );
2139         }
2140 
2141         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowAnimations" ) ) ) >>= bTemp;
2142         if( !bTemp )
2143         {
2144             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, XML_DISABLED );
2145             bHasAttr = sal_True;
2146         }
2147 
2148         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAlwaysOnTop" ) ) ) >>= bTemp;
2149         if( bTemp )
2150         {
2151             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STAY_ON_TOP, XML_TRUE );
2152             bHasAttr = sal_True;
2153         }
2154 
2155         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ) ) >>= bTemp;
2156         if( bTemp )
2157         {
2158             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FORCE_MANUAL, XML_TRUE );
2159             bHasAttr = sal_True;
2160         }
2161 
2162         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFullScreen" ) ) ) >>= bTemp;
2163         if( !bTemp )
2164         {
2165             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FULL_SCREEN, XML_FALSE );
2166             bHasAttr = sal_True;
2167         }
2168 
2169         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsMouseVisible" ) ) ) >>= bTemp;
2170         if( !bTemp )
2171         {
2172             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_VISIBLE, XML_FALSE );
2173             bHasAttr = sal_True;
2174         }
2175 
2176         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "StartWithNavigator" ) ) ) >>= bTemp;
2177         if( bTemp )
2178         {
2179             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_WITH_NAVIGATOR, XML_TRUE );
2180             bHasAttr = sal_True;
2181         }
2182 
2183         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "UsePen" ) ) ) >>= bTemp;
2184         if( bTemp )
2185         {
2186             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_AS_PEN, XML_TRUE );
2187             bHasAttr = sal_True;
2188         }
2189 
2190         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTransitionOnClick" ) ) ) >>= bTemp;
2191         if( !bTemp )
2192         {
2193             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_TRANSITION_ON_CLICK, XML_DISABLED );
2194             bHasAttr = sal_True;
2195         }
2196 
2197         xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsShowLogo" ) ) ) >>= bTemp;
2198         if( bTemp )
2199         {
2200             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW_LOGO, XML_TRUE );
2201             bHasAttr = sal_True;
2202         }
2203 
2204         Reference< container::XNameContainer > xShows;
2205         Sequence< OUString > aShowNames;
2206         const OUString* pShowNames = NULL;
2207         sal_Int32 nShowCount = 0;
2208 
2209         Reference< XCustomPresentationSupplier > xSup( GetModel(), UNO_QUERY );
2210         if( xSup.is() )
2211         {
2212             xShows = xSup->getCustomPresentations();
2213             if( xShows.is() )
2214             {
2215                 aShowNames = xShows->getElementNames();
2216                 pShowNames = aShowNames.getArray();
2217                 nShowCount = aShowNames.getLength();
2218             }
2219         }
2220 
2221         if( bHasAttr || nShowCount != 0 )
2222         {
2223             SvXMLElementExport aSettings(*this, XML_NAMESPACE_PRESENTATION, XML_SETTINGS, sal_True, sal_True);
2224 
2225             if( nShowCount == 0 )
2226                 return;
2227 
2228             Reference< XIndexContainer > xShow;
2229             Reference< XNamed > xPageName;
2230 
2231             OUStringBuffer sTmp;
2232 
2233             for( sal_Int32 nIndex = 0; nIndex < nShowCount; nIndex++, pShowNames++ )
2234             {
2235                 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, *pShowNames );
2236 
2237                 xShows->getByName( *pShowNames ) >>= xShow;
2238                 DBG_ASSERT( xShow.is(), "invalid custom show!" );
2239                 if( !xShow.is() )
2240                     continue;
2241 
2242                 const sal_Int32 nPageCount = xShow->getCount();
2243                 for( sal_Int32 nPage = 0; nPage < nPageCount; nPage++ )
2244                 {
2245                     xShow->getByIndex( nPage ) >>= xPageName;
2246 
2247                     if( !xPageName.is() )
2248                         continue;
2249 
2250                     if( sTmp.getLength() != 0 )
2251                         sTmp.append( sal_Unicode( ',' ) );
2252                     sTmp.append( xPageName->getName() );
2253 
2254                 }
2255 
2256                 if( sTmp.getLength() )
2257                     AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAGES, sTmp.makeStringAndClear() );
2258 
2259                 SvXMLElementExport aShows(*this, XML_NAMESPACE_PRESENTATION, XML_SHOW, sal_True, sal_True);
2260             }
2261         }
2262     }
2263     catch( uno::Exception )
2264     {
2265         DBG_ERROR( "uno::Exception while exporting <presentation:settings>" );
2266     }
2267 }
2268 
2269 //////////////////////////////////////////////////////////////////////////////
2270 
_ExportStyles(sal_Bool bUsed)2271 void SdXMLExport::_ExportStyles(sal_Bool bUsed)
2272 {
2273     GetPropertySetMapper()->SetAutoStyles( sal_False );
2274 
2275     // export fill styles
2276     SvXMLExport::_ExportStyles( bUsed );
2277 
2278     // write draw:style-name for object graphic-styles
2279     GetShapeExport()->ExportGraphicDefaults();
2280 
2281     // do not export in ODF 1.1 or older
2282     if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
2283         GetShapeExport()->GetShapeTableExport()->exportTableStyles();
2284 
2285     // write presentation styles
2286     ImpWritePresentationStyles();
2287 
2288     // prepare draw:auto-layout-name for page export
2289     ImpPrepAutoLayoutInfos();
2290 
2291     // write draw:auto-layout-name for page export
2292     ImpWriteAutoLayoutInfos();
2293 
2294     Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2295     if( xInfoSet.is() )
2296     {
2297         Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2298 
2299         Any aAny;
2300 
2301         if( xInfoSetInfo->hasPropertyByName( msPageLayoutNames ) )
2302         {
2303             aAny <<= maDrawPagesAutoLayoutNames;
2304             xInfoSet->setPropertyValue( msPageLayoutNames, aAny );
2305         }
2306     }
2307 }
2308 
2309 //////////////////////////////////////////////////////////////////////////////
2310 
_ExportAutoStyles()2311 void SdXMLExport::_ExportAutoStyles()
2312 {
2313     Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2314     if( xInfoSet.is() )
2315     {
2316         Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2317 
2318         if( xInfoSetInfo->hasPropertyByName( msPageLayoutNames ) )
2319         {
2320             xInfoSet->getPropertyValue( msPageLayoutNames ) >>= maDrawPagesAutoLayoutNames;
2321         }
2322     }
2323 
2324     GetPropertySetMapper()->SetAutoStyles( sal_True );
2325 
2326     if( getExportFlags() & EXPORT_STYLES )
2327     {
2328         // #80012# PageMaster export moved from _ExportStyles
2329         // prepare page-master infos
2330         ImpPrepPageMasterInfos();
2331 
2332         // write page-master infos
2333         ImpWritePageMasterInfos();
2334 
2335         // prepare draw:style-name for master page export
2336         ImpPrepMasterPageInfos();
2337     }
2338 
2339     if( getExportFlags() & EXPORT_CONTENT )
2340     {
2341         // prepare draw:style-name for page export
2342         ImpPrepDrawPageInfos();
2343     }
2344 
2345     // export draw-page styles
2346     GetAutoStylePool()->exportXML(
2347         XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID
2348         , GetDocHandler(),
2349         GetMM100UnitConverter(),
2350         GetNamespaceMap()
2351         );
2352 
2353     if( getExportFlags() & EXPORT_STYLES )
2354     {
2355         // create auto style infos for shapes on master handout page
2356         if( IsImpress() )
2357         {
2358             Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2359             if( xHandoutSupp.is() )
2360             {
2361                 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2362                 if( xHandoutPage.is() )
2363                 {
2364                     Reference< drawing::XShapes > xShapes(xHandoutPage, UNO_QUERY);
2365                     if(xShapes.is() && xShapes->getCount())
2366                         GetShapeExport()->collectShapesAutoStyles( xShapes );
2367                 }
2368             }
2369         }
2370 
2371         // create auto style infos for objects on master pages
2372         for(sal_Int32 nMPageId(0L); nMPageId < mnDocMasterPageCount; nMPageId++)
2373         {
2374             Reference< XDrawPage > xMasterPage(mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2375 
2376             if( xMasterPage.is() )
2377             {
2378                 // collect layer information
2379                 GetFormExport()->examineForms( xMasterPage );
2380 
2381                 // get MasterPage Name
2382                 OUString aMasterPageNamePrefix;
2383                 Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2384                 if(xNamed.is())
2385                 {
2386                     aMasterPageNamePrefix = xNamed->getName();
2387                 }
2388                 if(aMasterPageNamePrefix.getLength())
2389                 {
2390                     aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
2391                 }
2392                 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2393 
2394                 Reference< drawing::XShapes > xMasterShapes(xMasterPage, UNO_QUERY);
2395                 if(xMasterShapes.is() && xMasterShapes->getCount())
2396                     GetShapeExport()->collectShapesAutoStyles( xMasterShapes );
2397 
2398                 if(IsImpress())
2399                 {
2400                     Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2401                     if(xPresPage.is())
2402                     {
2403                         Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2404                         if(xNotesPage.is())
2405                         {
2406                             // collect layer information
2407                             GetFormExport()->examineForms( xNotesPage );
2408 
2409                             Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2410                             if(xShapes.is() && xShapes->getCount())
2411                                 GetShapeExport()->collectShapesAutoStyles( xShapes );
2412                         }
2413                     }
2414                 }
2415                 collectAnnotationAutoStyles(xMasterPage);
2416             }
2417         }
2418     }
2419 
2420     if( getExportFlags() & EXPORT_CONTENT )
2421     {
2422         // prepare animations exporter if impress
2423         if(IsImpress() && ((getExportFlags() & EXPORT_OASIS) == 0) )
2424         {
2425             UniReference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter( GetShapeExport().get() );
2426             GetShapeExport()->setAnimationsExporter( xAnimExport );
2427         }
2428 
2429         // create auto style infos for objects on pages
2430         for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
2431         {
2432             Reference<XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), UNO_QUERY );
2433             if( xDrawPage.is() )
2434             {
2435                 // collect layer information
2436                 GetFormExport()->examineForms( xDrawPage );
2437 
2438                 // get MasterPage Name
2439                 OUString aMasterPageNamePrefix;
2440                 Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
2441                 if(xMasterPageInt.is())
2442                 {
2443                     Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
2444                     if(xUsedMasterPage.is())
2445                     {
2446                         Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
2447                         if(xMasterNamed.is())
2448                         {
2449                             aMasterPageNamePrefix = xMasterNamed->getName();
2450                         }
2451                     }
2452                 }
2453                 if(aMasterPageNamePrefix.getLength())
2454                 {
2455                     aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
2456                 }
2457 
2458                 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2459 
2460                 // prepare object infos
2461                 Reference< drawing::XShapes > xDrawShapes(xDrawPage, UNO_QUERY);
2462                 if(xDrawShapes.is() && xDrawShapes->getCount())
2463                     GetShapeExport()->collectShapesAutoStyles( xDrawShapes );
2464 
2465                 // prepare presentation notes page object infos (ONLY if presentation)
2466                 if(IsImpress())
2467                 {
2468                     Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
2469                     if(xPresPage.is())
2470                     {
2471                         Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2472                         if(xNotesPage.is())
2473                         {
2474                             // collect layer information
2475                             GetFormExport()->examineForms( xNotesPage );
2476 
2477                             Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2478                             if(xShapes.is() && xShapes->getCount())
2479                                 GetShapeExport()->collectShapesAutoStyles( xShapes );
2480                         }
2481                     }
2482                 }
2483 
2484                 collectAnnotationAutoStyles( xDrawPage );
2485             }
2486         }
2487         if(IsImpress())
2488         {
2489             UniReference< XMLAnimationsExporter > xAnimExport;
2490             GetShapeExport()->setAnimationsExporter( xAnimExport );
2491         }
2492     }
2493 
2494     exportAutoDataStyles();
2495 
2496     GetShapeExport()->exportAutoStyles();
2497 
2498     sal_uInt16 nContentAutostyles = EXPORT_CONTENT | EXPORT_AUTOSTYLES;
2499     if ( ( getExportFlags() & nContentAutostyles ) == nContentAutostyles )
2500         GetFormExport()->exportAutoStyles( );
2501 
2502     // ...for text
2503     GetTextParagraphExport()->exportTextAutoStyles();
2504 }
2505 
2506 //////////////////////////////////////////////////////////////////////////////
2507 
_ExportMasterStyles()2508 void SdXMLExport::_ExportMasterStyles()
2509 {
2510     // export layer
2511     SdXMLayerExporter::exportLayer( *this );
2512 
2513     // export handout master page if impress
2514     if( IsImpress() )
2515     {
2516         Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2517         if( xHandoutSupp.is() )
2518         {
2519             Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2520             if( xHandoutPage.is() )
2521             {
2522                 // presentation:page-layout-name
2523                 if( IsImpress() && maDrawPagesAutoLayoutNames[0].getLength())
2524                 {
2525                     AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, EncodeStyleName( maDrawPagesAutoLayoutNames[0] ));
2526                 }
2527 
2528                 ImpXMLEXPPageMasterInfo* pInfo = mpHandoutPageMaster;
2529                 if(pInfo)
2530                 {
2531                     OUString sString = pInfo->GetName();
2532                     AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2533                 }
2534 
2535                 // draw:style-name
2536                 if( maHandoutMasterStyleName.getLength() )
2537                     AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maHandoutMasterStyleName);
2538 
2539                 ImplExportHeaderFooterDeclAttributes( maHandoutPageHeaderFooterSettings );
2540 
2541                 // write masterpage
2542                 SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_HANDOUT_MASTER, sal_True, sal_True);
2543 
2544                 // write graphic objects on this master page (if any)
2545                 Reference< drawing::XShapes > xShapes(xHandoutPage, UNO_QUERY);
2546                 if(xShapes.is() && xShapes->getCount())
2547                     GetShapeExport()->exportShapes( xShapes );
2548             }
2549         }
2550     }
2551 
2552     // export MasterPages in master-styles section
2553     for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
2554     {
2555         Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2556         if(xMasterPage.is())
2557         {
2558             // prepare masterpage attributes
2559             OUString sMasterPageName;
2560             Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2561             if(xNamed.is())
2562             {
2563                 sal_Bool bEncoded = sal_False;
2564                 sMasterPageName = xNamed->getName();
2565                 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME,
2566                     EncodeStyleName( sMasterPageName, &bEncoded ));
2567                 if( bEncoded )
2568                     AddAttribute(
2569                         XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
2570                         sMasterPageName );
2571             }
2572 
2573             ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterUsageList->GetObject(nMPageId);
2574             if(pInfo)
2575             {
2576                 OUString sString = pInfo->GetName();
2577                 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2578             }
2579 
2580             // draw:style-name (background attributes)
2581             if( maMasterPagesStyleNames[nMPageId].getLength() )
2582                 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2583                         maMasterPagesStyleNames[nMPageId]);
2584 
2585             // write masterpage
2586             SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_MASTER_PAGE, sal_True, sal_True);
2587 
2588             // write optional office:forms
2589             exportFormsElement( xMasterPage );
2590 
2591             // write graphic objects on this master page (if any)
2592             Reference< drawing::XShapes > xMasterShapes(xMasterPage, UNO_QUERY);
2593             if(xMasterShapes.is() && xMasterShapes->getCount())
2594                 GetShapeExport()->exportShapes( xMasterShapes );
2595 
2596             // write presentation notes (ONLY if presentation)
2597             if(IsImpress())
2598             {
2599                 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2600                 if(xPresPage.is())
2601                 {
2602                     Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2603                     if(xNotesPage.is())
2604                     {
2605                         Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2606                         if(xShapes.is())
2607                         {
2608                             ImpXMLEXPPageMasterInfo* pMasterInfo = mpNotesPageMasterUsageList->GetObject(nMPageId);
2609                             if(pMasterInfo)
2610                             {
2611                                 OUString sString = pMasterInfo->GetName();
2612                                 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString);
2613                             }
2614 
2615                             // write presentation notes
2616                             SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, sal_True, sal_True);
2617 
2618                             // write optional office:forms
2619                             exportFormsElement( xNotesPage );
2620 
2621                             // write shapes per se
2622                             GetShapeExport()->exportShapes( xShapes );
2623                         }
2624                     }
2625                 }
2626             }
2627             exportAnnotations( xMasterPage );
2628         }
2629     }
2630 }
2631 
exportFormsElement(Reference<XDrawPage> xDrawPage)2632 void SdXMLExport::exportFormsElement( Reference< XDrawPage > xDrawPage )
2633 {
2634     if( xDrawPage.is() )
2635     {
2636         Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY );
2637         if ( xFormsSupplier.is() && xFormsSupplier->hasForms() )
2638         {
2639             // write masterpage
2640             ::xmloff::OOfficeFormsExport aForms(*this);
2641             GetFormExport()->exportForms( xDrawPage );
2642         }
2643 
2644         if(! GetFormExport()->seekPage( xDrawPage ) )
2645         {
2646             DBG_ERROR( "OFormLayerXMLExport::seekPage failed!" );
2647         }
2648     }
2649 }
2650 
GetViewSettings(uno::Sequence<beans::PropertyValue> & rProps)2651 void SdXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
2652 {
2653     rProps.realloc(4);
2654     beans::PropertyValue* pProps = rProps.getArray();
2655     if(pProps)
2656     {
2657 //      SvXMLElementExport aViewSettingsElem(*this, XML_NAMESPACE_DRAW, XML_VIEW_SETTINGS, sal_True, sal_True);
2658 
2659         Reference< beans::XPropertySet > xPropSet( GetModel(), UNO_QUERY );
2660         if( !xPropSet.is() )
2661             return;
2662 
2663         awt::Rectangle aVisArea;
2664         xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ) ) >>= aVisArea;
2665 /*
2666         sal_Int16 nMapUnit;
2667         xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MapUnit" ) ) ) >>= nMapUnit;
2668 */
2669 
2670         sal_uInt16 i = 0;
2671         pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaTop"));
2672         pProps[i++].Value <<= aVisArea.Y;
2673         pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaLeft"));
2674         pProps[i++].Value <<= aVisArea.X;
2675         pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaWidth"));
2676         pProps[i++].Value <<= aVisArea.Width;
2677         pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaHeight"));
2678         pProps[i++].Value <<= aVisArea.Height;
2679     }
2680 }
2681 
GetConfigurationSettings(uno::Sequence<beans::PropertyValue> & rProps)2682 void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
2683 {
2684     Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
2685     if( xFac.is() )
2686     {
2687         Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY );
2688         if( xProps.is() )
2689             SvXMLUnitConverter::convertPropertySet( rProps, xProps );
2690     }
2691 }
2692 
2693 //////////////////////////////////////////////////////////////////////////////
2694 
addDataStyle(const sal_Int32 nNumberFormat,sal_Bool bTimeFormat)2695 void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat )
2696 {
2697     sal_Int32 nFormat = nNumberFormat;
2698     if( (nNumberFormat > 1) && (nNumberFormat <= 0x0f) )
2699         nFormat -= 2;
2700 
2701     if( bTimeFormat )
2702     {
2703         if( maUsedTimeStyles.count( nFormat ) == 0 )
2704             maUsedTimeStyles.insert( nFormat );
2705     }
2706     else
2707     {
2708         if( maUsedDateStyles.count( nFormat ) == 0 )
2709             maUsedDateStyles.insert( nFormat );
2710     }
2711 }
2712 
2713 //////////////////////////////////////////////////////////////////////////////
2714 
exportDataStyles()2715 void SdXMLExport::exportDataStyles()
2716 {
2717     // there are no data styles to export in draw/impress yet
2718 }
2719 
2720 //////////////////////////////////////////////////////////////////////////////
2721 
exportAutoDataStyles()2722 void SdXMLExport::exportAutoDataStyles()
2723 {
2724     SdXMLFormatMap::iterator aIter( maUsedDateStyles.begin() );
2725     SdXMLFormatMap::iterator aEnd( maUsedDateStyles.end() );
2726 
2727     while( aIter != aEnd )
2728         SdXMLNumberStylesExporter::exportDateStyle( *this, (*aIter++) );
2729 
2730     aIter = maUsedTimeStyles.begin();
2731     aEnd = maUsedTimeStyles.end();
2732     while( aIter != aEnd )
2733         SdXMLNumberStylesExporter::exportTimeStyle( *this, (*aIter++) );
2734 
2735     if(HasFormExport())
2736         GetFormExport()->exportAutoControlNumberStyles();
2737 }
2738 
2739 //////////////////////////////////////////////////////////////////////////////
2740 
getDataStyleName(const sal_Int32 nNumberFormat,sal_Bool bTimeFormat) const2741 OUString SdXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat ) const
2742 {
2743     if( bTimeFormat )
2744     {
2745         return SdXMLNumberStylesExporter::getTimeStyleName( nNumberFormat );
2746     }
2747     else
2748     {
2749         return SdXMLNumberStylesExporter::getDateStyleName( nNumberFormat );
2750     }
2751 }
2752 
getNavigationOrder(const Reference<XDrawPage> & xDrawPage)2753 OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPage )
2754 {
2755     OUStringBuffer sNavOrder;
2756     try
2757     {
2758         Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
2759         Reference< XIndexAccess > xNavOrder( xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "NavigationOrder" ) ) ), UNO_QUERY_THROW );
2760 
2761         Reference< XIndexAccess > xZOrderAccess( xDrawPage, UNO_QUERY );
2762 
2763         // only export navigation order if it is different from the z-order
2764         if( (xNavOrder.get() != xZOrderAccess.get()) && (xNavOrder->getCount() == xDrawPage->getCount())  )
2765         {
2766             sal_Int32 nIndex;
2767             const sal_Int32 nCount = xNavOrder->getCount();
2768             for( nIndex = 0; nIndex < nCount; ++nIndex )
2769             {
2770                 OUString sId( getInterfaceToIdentifierMapper().registerReference( Reference< XInterface >( xNavOrder->getByIndex( nIndex ), UNO_QUERY ) ) );
2771                 if( sId.getLength() != 0 )
2772                 {
2773                     if( sNavOrder.getLength() != 0 )
2774                         sNavOrder.append( (sal_Unicode)' ' );
2775                     sNavOrder.append( sId );
2776                 }
2777             }
2778         }
2779     }
2780     catch( Exception& )
2781     {
2782     }
2783     return sNavOrder.makeStringAndClear();
2784 }
2785 
2786 //////////////////////////////////////////////////////////////////////////////
2787 
collectAnnotationAutoStyles(const Reference<XDrawPage> & xDrawPage)2788 void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage )
2789 {
2790     Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2791     if( xAnnotationAccess.is() ) try
2792     {
2793         Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2794         if( xAnnotationEnumeration.is() )
2795         {
2796             while( xAnnotationEnumeration->hasMoreElements() )
2797             {
2798                 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW );
2799                 Reference< XText > xText( xAnnotation->getTextRange() );
2800                 if(xText.is() && xText->getString().getLength())
2801                     GetTextParagraphExport()->collectTextAutoStyles( xText );
2802             }
2803         }
2804     }
2805     catch( Exception& )
2806     {
2807         DBG_ERROR("SdXMLExport::collectAnnotationAutoStyles(), exception caught during export of annotation auto styles");
2808     }
2809 }
2810 
exportAnnotations(const Reference<XDrawPage> & xDrawPage)2811 void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
2812 {
2813     // do not export in ODF 1.2 or older
2814     if( getDefaultVersion() <= SvtSaveOptions::ODFVER_012 )
2815         return;
2816 
2817     Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2818     if( xAnnotationAccess.is() ) try
2819     {
2820         Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2821         if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() )
2822         {
2823             OUStringBuffer sStringBuffer;
2824             do
2825             {
2826                 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW );
2827 
2828                 RealPoint2D aPosition( xAnnotation->getPosition() );
2829 
2830                 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.X * 100 ) );
2831                 AddAttribute(XML_NAMESPACE_SVG, XML_X, sStringBuffer.makeStringAndClear());
2832 
2833                 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.Y * 100 ) );
2834                 AddAttribute(XML_NAMESPACE_SVG, XML_Y, sStringBuffer.makeStringAndClear());
2835 
2836                 RealSize2D aSize( xAnnotation->getSize() );
2837 
2838                 if( aSize.Width || aSize.Height )
2839                 {
2840                     GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Width * 100 ) );
2841                     AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, sStringBuffer.makeStringAndClear());
2842                     GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Height * 100 ) );
2843                     AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, sStringBuffer.makeStringAndClear());
2844                 }
2845 
2846                 // annotation element + content
2847                 SvXMLElementExport aElem(*this, XML_NAMESPACE_OFFICE_EXT, XML_ANNOTATION, sal_False, sal_True);
2848 
2849                 // author
2850                 OUString aAuthor( xAnnotation->getAuthor() );
2851                 if( aAuthor.getLength() )
2852                 {
2853                     SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, sal_True, sal_False );
2854                     this->Characters(aAuthor);
2855                 }
2856 
2857                 {
2858                     // date time
2859                     DateTime aDate( xAnnotation->getDateTime() );
2860                     GetMM100UnitConverter().convertDateTime(sStringBuffer, aDate, sal_True);
2861                     SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, sal_True, sal_False );
2862                     Characters(sStringBuffer.makeStringAndClear());
2863                 }
2864 
2865                 com::sun::star::uno::Reference < com::sun::star::text::XText > xText( xAnnotation->getTextRange() );
2866                 if( xText.is() )
2867                     this->GetTextParagraphExport()->exportText( xText );
2868             }
2869             while( xAnnotationEnumeration->hasMoreElements() );
2870         }
2871     }
2872     catch( Exception& )
2873     {
2874         DBG_ERROR("SdXMLExport::exportAnnotations(), exception caught during export of annotations");
2875     }
2876 }
2877 
2878 //////////////////////////////////////////////////////////////////////////////
2879 
2880 #define SERVICE( classname, servicename, implementationname, draw, flags )\
2881 uno::Sequence< OUString > SAL_CALL classname##_getSupportedServiceNames() throw()\
2882 {\
2883     const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( servicename ) );\
2884     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );\
2885     return aSeq;\
2886 }\
2887 OUString SAL_CALL classname##_getImplementationName() throw()\
2888 {\
2889     return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationname ) );\
2890 }\
2891 uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )\
2892 {\
2893     return (cppu::OWeakObject*)new SdXMLExport( rSMgr, draw, flags );\
2894 }
2895 
2896 SERVICE( XMLImpressExportOasis, "com.sun.star.comp.Impress.XMLOasisExporter", "XMLImpressExportOasis", sal_False, EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2897 SERVICE( XMLImpressStylesExportOasis, "com.sun.star.comp.Impress.XMLOasisStylesExporter", "XMLImpressStylesExportOasis", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2898 SERVICE( XMLImpressContentExportOasis, "com.sun.star.comp.Impress.XMLOasisContentExporter", "XMLImpressContentExportOasis", sal_False, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2899 SERVICE( XMLImpressMetaExportOasis, "com.sun.star.comp.Impress.XMLOasisMetaExporter", "XMLImpressMetaExportOasis", sal_False, EXPORT_OASIS|EXPORT_META );
2900 SERVICE( XMLImpressSettingsExportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsExporter", "XMLImpressSettingsExportOasis", sal_False, EXPORT_OASIS|EXPORT_SETTINGS );
2901 
2902 SERVICE( XMLImpressExportOOO, "com.sun.star.comp.Impress.XMLExporter", "XMLImpressExportOOO", sal_False, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2903 SERVICE( XMLImpressStylesExportOOO, "com.sun.star.comp.Impress.XMLStylesExporter", "XMLImpressStylesExportOOO", sal_False, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2904 SERVICE( XMLImpressContentExportOOO, "com.sun.star.comp.Impress.XMLContentExporter", "XMLImpressContentExportOOO", sal_False, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2905 SERVICE( XMLImpressMetaExportOOO, "com.sun.star.comp.Impress.XMLMetaExporter", "XMLImpressMetaExportOOO", sal_False, EXPORT_META );
2906 SERVICE( XMLImpressSettingsExportOOO, "com.sun.star.comp.Impress.XMLSettingsExporter", "XMLImpressSettingsExportOOO", sal_False, EXPORT_SETTINGS );
2907 
2908 SERVICE( XMLDrawExportOasis, "com.sun.star.comp.Draw.XMLOasisExporter", "XMLDrawExportOasis", sal_True, EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2909 SERVICE( XMLDrawStylesExportOasis, "com.sun.star.comp.Draw.XMLOasisStylesExporter", "XMLDrawStylesExportOasis", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2910 SERVICE( XMLDrawContentExportOasis, "com.sun.star.comp.Draw.XMLOasisContentExporter", "XMLDrawContentExportOasis", sal_True, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2911 SERVICE( XMLDrawMetaExportOasis, "com.sun.star.comp.Draw.XMLOasisMetaExporter", "XMLDrawMetaExportOasis", sal_True, EXPORT_OASIS|EXPORT_META );
2912 SERVICE( XMLDrawSettingsExportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsExporter", "XMLDrawSettingsExportOasis", sal_True, EXPORT_OASIS|EXPORT_SETTINGS );
2913 
2914 SERVICE( XMLDrawExportOOO, "com.sun.star.comp.Draw.XMLExporter", "XMLDrawExportOOO", sal_True, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2915 SERVICE( XMLDrawStylesExportOOO, "com.sun.star.comp.Draw.XMLStylesExporter", "XMLDrawStylesExportOOO", sal_True, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2916 SERVICE( XMLDrawContentExportOOO, "com.sun.star.comp.Draw.XMLContentExporter", "XMLDrawContentExportOOO", sal_True, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2917 SERVICE( XMLDrawMetaExportOOO, "com.sun.star.comp.Draw.XMLMetaExporter", "XMLDrawMetaExportOOO", sal_True, EXPORT_META );
2918 SERVICE( XMLDrawSettingsExportOOO, "com.sun.star.comp.Draw.XMLSettingsExporter", "XMLDrawSettingsExportOOO", sal_True, EXPORT_SETTINGS );
2919 
2920 SERVICE( XMLDrawingLayerExport, "com.sun.star.comp.DrawingLayer.XMLExporter", "XMLDrawingLayerExport", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2921 SERVICE( XMLImpressClipboardExport, "com.sun.star.comp.Impress.XMLClipboardExporter", "XMLImpressClipboardExport", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2922 
2923 // XServiceInfo
getImplementationName()2924 OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeException )
2925 {
2926     if( IsDraw())
2927     {
2928         // Draw
2929 
2930         switch( getExportFlags())
2931         {
2932             case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2933                 return XMLDrawExportOOO_getImplementationName();
2934             case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2935                 return XMLDrawStylesExportOOO_getImplementationName();
2936             case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2937                 return XMLDrawContentExportOOO_getImplementationName();
2938             case EXPORT_META:
2939                 return XMLDrawMetaExportOOO_getImplementationName();
2940             case EXPORT_SETTINGS:
2941                 return XMLDrawSettingsExportOOO_getImplementationName();
2942 
2943             case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2944                 return XMLDrawExportOasis_getImplementationName();
2945             case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2946                 return XMLDrawStylesExportOasis_getImplementationName();
2947             case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2948                 return XMLDrawContentExportOasis_getImplementationName();
2949             case EXPORT_OASIS|EXPORT_META:
2950                 return XMLDrawMetaExportOasis_getImplementationName();
2951             case EXPORT_OASIS|EXPORT_SETTINGS:
2952                 return XMLDrawSettingsExportOasis_getImplementationName();
2953 
2954             default:
2955                 return XMLDrawExportOOO_getImplementationName();
2956         }
2957     }
2958     else
2959     {
2960         // Impress
2961 
2962         switch( getExportFlags())
2963         {
2964             case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2965                 return XMLImpressExportOOO_getImplementationName();
2966             case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2967                 return XMLImpressStylesExportOOO_getImplementationName();
2968             case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2969                 return XMLImpressContentExportOOO_getImplementationName();
2970             case EXPORT_META:
2971                 return XMLImpressMetaExportOOO_getImplementationName();
2972             case EXPORT_SETTINGS:
2973                 return XMLImpressSettingsExportOOO_getImplementationName();
2974             case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2975                 return XMLImpressExportOasis_getImplementationName();
2976             case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2977                 return XMLImpressStylesExportOasis_getImplementationName();
2978             case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2979                 return XMLImpressContentExportOasis_getImplementationName();
2980             case EXPORT_OASIS|EXPORT_META:
2981                 return XMLImpressMetaExportOasis_getImplementationName();
2982             case EXPORT_OASIS|EXPORT_SETTINGS:
2983                 return XMLImpressSettingsExportOasis_getImplementationName();
2984 
2985             default:
2986                 return XMLImpressExportOOO_getImplementationName();
2987         }
2988     }
2989 }
2990