merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / draw / sdxmlexp.cxx
blobf75107c6e288a7f48151d367d5428cf3ac48313b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdxmlexp.cxx,v $
10 * $Revision: 1.119 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "unointerfacetouniqueidentifiermapper.hxx"
34 #include <xmloff/nmspmap.hxx>
35 #include "xmlnmspe.hxx"
36 #include <xmloff/xmluconv.hxx>
37 #include <xmloff/xmltoken.hxx>
38 #include <xmloff/xmlmetae.hxx>
39 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
40 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
41 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
42 #include <com/sun/star/geometry/RealPoint2D.hpp>
43 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
44 #include <com/sun/star/office/XAnnotationAccess.hpp>
45 #include <com/sun/star/lang/Locale.hpp>
46 #include <com/sun/star/uno/Any.hxx>
47 #include "sdxmlexp_impl.hxx"
48 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
49 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
50 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
51 #include <com/sun/star/container/XIndexContainer.hpp>
52 #include <com/sun/star/view/PaperOrientation.hpp>
53 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
54 #include <com/sun/star/style/XStyle.hpp>
56 #include <com/sun/star/form/XFormsSupplier2.hpp>
57 #include <com/sun/star/presentation/XPresentationPage.hpp>
58 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
59 #include <com/sun/star/text/XText.hpp>
60 #include <com/sun/star/chart/XChartDocument.hpp>
61 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
62 #include <com/sun/star/container/XNamed.hpp>
63 #include <rtl/ustrbuf.hxx>
64 #include <tools/gen.hxx>
65 #include <tools/debug.hxx>
66 #include <xmloff/xmlaustp.hxx>
67 #include <xmloff/families.hxx>
68 #include <xmloff/styleexp.hxx>
69 #include "sdpropls.hxx"
70 #include <xmloff/xmlexppr.hxx>
71 #include <com/sun/star/beans/XPropertyState.hpp>
72 #include "xexptran.hxx"
74 #ifndef _CPPUHELPER_IMPLBASE1_HXX
75 #include <cppuhelper/implbase1.hxx>
76 #endif
77 #include <comphelper/extract.hxx>
78 #include <com/sun/star/lang/XServiceInfo.hpp>
79 #include "PropertySetMerger.hxx"
80 #include "layerexp.hxx"
83 #include "VisAreaExport.hxx"
84 #include "XMLNumberStylesExport.hxx"
85 #include <tools/list.hxx>
86 #include <tools/string.hxx>
88 #include "animationexport.hxx"
90 #include <com/sun/star/document/XDocumentProperties.hpp>
91 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
93 using ::rtl::OUString;
94 using ::rtl::OUStringBuffer;
96 using namespace ::com::sun::star;
97 using namespace ::com::sun::star::uno;
98 using namespace ::com::sun::star::beans;
99 using namespace ::com::sun::star::util;
100 using namespace ::com::sun::star::container;
101 using namespace ::com::sun::star::drawing;
102 using namespace ::com::sun::star::office;
103 using namespace ::com::sun::star::presentation;
104 using namespace ::com::sun::star::geometry;
105 using namespace ::com::sun::star::text;
106 using namespace ::xmloff::token;
109 //////////////////////////////////////////////////////////////////////////////
111 class ImpXMLEXPPageMasterInfo
113 sal_Int32 mnBorderBottom;
114 sal_Int32 mnBorderLeft;
115 sal_Int32 mnBorderRight;
116 sal_Int32 mnBorderTop;
117 sal_Int32 mnWidth;
118 sal_Int32 mnHeight;
119 view::PaperOrientation meOrientation;
120 OUString msName;
121 OUString msMasterPageName;
123 public:
124 ImpXMLEXPPageMasterInfo(const SdXMLExport& rExp, const Reference<XDrawPage>& xPage);
125 BOOL operator==(const ImpXMLEXPPageMasterInfo& rInfo) const;
126 void SetName(const OUString& rStr);
128 const OUString& GetName() const { return msName; }
129 const OUString& GetMasterPageName() const { return msMasterPageName; }
131 sal_Int32 GetBorderBottom() const { return mnBorderBottom; }
132 sal_Int32 GetBorderLeft() const { return mnBorderLeft; }
133 sal_Int32 GetBorderRight() const { return mnBorderRight; }
134 sal_Int32 GetBorderTop() const { return mnBorderTop; }
135 sal_Int32 GetWidth() const { return mnWidth; }
136 sal_Int32 GetHeight() const { return mnHeight; }
137 view::PaperOrientation GetOrientation() const { return meOrientation; }
140 ImpXMLEXPPageMasterInfo::ImpXMLEXPPageMasterInfo(
141 const SdXMLExport& rExp,
142 const Reference<XDrawPage>& xPage)
143 : mnBorderBottom(0),
144 mnBorderLeft(0),
145 mnBorderRight(0),
146 mnBorderTop(0),
147 mnWidth(0),
148 mnHeight(0),
149 meOrientation(rExp.IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
151 Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
152 if(xPropSet.is())
154 Any aAny;
156 Reference< beans::XPropertySetInfo > xPropsInfo( xPropSet->getPropertySetInfo() );
157 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom") )))
159 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom")));
160 aAny >>= mnBorderBottom;
162 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderLeft")));
163 aAny >>= mnBorderLeft;
165 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderRight")));
166 aAny >>= mnBorderRight;
168 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderTop")));
169 aAny >>= mnBorderTop;
172 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("Width") )))
174 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")));
175 aAny >>= mnWidth;
177 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Height")));
178 aAny >>= mnHeight;
181 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation") )))
183 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation")));
184 aAny >>= meOrientation;
188 Reference <container::XNamed> xMasterNamed(xPage, UNO_QUERY);
189 if(xMasterNamed.is())
191 msMasterPageName = xMasterNamed->getName();
195 BOOL ImpXMLEXPPageMasterInfo::operator==(const ImpXMLEXPPageMasterInfo& rInfo) const
197 return ((mnBorderBottom == rInfo.mnBorderBottom)
198 && (mnBorderLeft == rInfo.mnBorderLeft)
199 && (mnBorderRight == rInfo.mnBorderRight)
200 && (mnBorderTop == rInfo.mnBorderTop)
201 && (mnWidth == rInfo.mnWidth)
202 && (mnHeight == rInfo.mnHeight)
203 && (meOrientation == rInfo.meOrientation));
206 void ImpXMLEXPPageMasterInfo::SetName(const OUString& rStr)
208 msName = rStr;
211 DECLARE_LIST(ImpXMLEXPPageMasterList, ImpXMLEXPPageMasterInfo*)
213 //////////////////////////////////////////////////////////////////////////////
215 #define IMP_AUTOLAYOUT_INFO_MAX (35L)
217 class ImpXMLAutoLayoutInfo
219 sal_uInt16 mnType;
220 ImpXMLEXPPageMasterInfo* mpPageMasterInfo;
221 OUString msLayoutName;
222 Rectangle maTitleRect;
223 Rectangle maPresRect;
224 sal_Int32 mnGapX;
225 sal_Int32 mnGapY;
227 public:
228 ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf);
230 BOOL operator==(const ImpXMLAutoLayoutInfo& rInfo) const;
232 sal_uInt16 GetLayoutType() const { return mnType; }
233 sal_Int32 GetGapX() const { return mnGapX; }
234 sal_Int32 GetGapY() const { return mnGapY; }
236 const OUString& GetLayoutName() const { return msLayoutName; }
237 void SetLayoutName(const OUString& rNew) { msLayoutName = rNew; }
239 const Rectangle& GetTitleRectangle() const { return maTitleRect; }
240 const Rectangle& GetPresRectangle() const { return maPresRect; }
242 static BOOL IsCreateNecessary(sal_uInt16 nTyp);
245 BOOL ImpXMLAutoLayoutInfo::IsCreateNecessary(sal_uInt16 nTyp)
247 if(nTyp == 5 /* AUTOLAYOUT_ORG */
248 || nTyp == 20 /* AUTOLAYOUT_NONE */
249 || nTyp >= IMP_AUTOLAYOUT_INFO_MAX)
250 return FALSE;
251 return TRUE;
254 BOOL ImpXMLAutoLayoutInfo::operator==(const ImpXMLAutoLayoutInfo& rInfo) const
256 return ((mnType == rInfo.mnType
257 && mpPageMasterInfo == rInfo.mpPageMasterInfo));
260 ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
261 : mnType(nTyp),
262 mpPageMasterInfo(pInf)
264 // create full info (initialze with typical values)
265 Point aPagePos(0,0);
266 Size aPageSize(28000, 21000);
267 Size aPageInnerSize(28000, 21000);
269 if(mpPageMasterInfo)
271 aPagePos = Point(mpPageMasterInfo->GetBorderLeft(), mpPageMasterInfo->GetBorderTop());
272 aPageSize = Size(mpPageMasterInfo->GetWidth(), mpPageMasterInfo->GetHeight());
273 aPageInnerSize = aPageSize;
274 aPageInnerSize.Width() -= mpPageMasterInfo->GetBorderLeft() + mpPageMasterInfo->GetBorderRight();
275 aPageInnerSize.Height() -= mpPageMasterInfo->GetBorderTop() + mpPageMasterInfo->GetBorderBottom();
278 // title rectangle aligning
279 Point aTitlePos(aPagePos);
280 Size aTitleSize(aPageInnerSize);
282 if(mnType == 21 /* AUTOLAYOUT_NOTES */)
284 aTitleSize.Height() = (long) (aTitleSize.Height() / 2.5);
285 Point aPos = aTitlePos;
286 aPos.Y() += long( aTitleSize.Height() * 0.083 );
287 Size aPartArea = aTitleSize;
288 Size aSize;
290 // tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
291 double fH = (double) aPartArea.Width() / aPageSize.Width();
292 double fV = (double) aPartArea.Height() / aPageSize.Height();
294 if ( fH > fV )
295 fH = fV;
296 aSize.Width() = (long) (fH * aPageSize.Width());
297 aSize.Height() = (long) (fH * aPageSize.Height());
299 aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
300 aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
302 aTitlePos = aPos;
303 aTitleSize = aSize;
305 else if(mnType == 27 || mnType == 28)
307 // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART or
308 // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
309 Point aClassicTPos(
310 aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
311 aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
312 Size aClassicTSize(
313 long( aTitleSize.Width() * 0.854 ),
314 long( aTitleSize.Height() * 0.167 ));
315 Point aLPos(aPagePos);
316 Size aLSize(aPageInnerSize);
317 Point aClassicLPos(
318 aLPos.X() + long( aLSize.Width() * 0.0735 ),
319 aLPos.Y() + long( aLSize.Height() * 0.472 ));
320 Size aClassicLSize(
321 long( aLSize.Width() * 0.854 ),
322 long( aLSize.Height() * 0.444 ));
324 aTitlePos.X() = (aClassicTPos.X() + aClassicTSize.Width()) - aClassicTSize.Height();
325 aTitlePos.Y() = aClassicTPos.Y();
326 aTitleSize.Width() = aClassicTSize.Height();
327 aTitleSize.Height() = (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y();
329 else
331 aTitlePos.X() += long( aTitleSize.Width() * 0.0735 );
332 aTitlePos.Y() += long( aTitleSize.Height() * 0.083 );
333 aTitleSize.Width() = long( aTitleSize.Width() * 0.854 );
334 aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
337 maTitleRect.SetPos(aTitlePos);
338 maTitleRect.SetSize(aTitleSize);
340 // layout rectangle aligning
341 Point aLayoutPos(aPagePos);
342 Size aLayoutSize(aPageInnerSize);
344 if(mnType == 21 /* AUTOLAYOUT_NOTES */)
346 aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
347 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.472 );
348 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
349 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.444 );
351 else if((mnType >= 22 && mnType <= 26) || (mnType == 31)) // AUTOLAYOUT_HANDOUT
353 // keep info for inner area in maPresRect, put info for gap size
354 // to maTitleRect position
355 mnGapX = (aPageSize.Width() - aPageInnerSize.Width()) / 2;
356 mnGapY = (aPageSize.Height() - aPageInnerSize.Height()) / 2;
358 if(!mnGapX)
359 mnGapX = aPageSize.Width() / 10;
361 if(!mnGapY)
362 mnGapY = aPageSize.Height() / 10;
364 if(mnGapX < aPageInnerSize.Width() / 10)
365 mnGapX = aPageInnerSize.Width() / 10;
367 if(mnGapY < aPageInnerSize.Height() / 10)
368 mnGapY = aPageInnerSize.Height() / 10;
370 else if(mnType == 27 || mnType == 28)
372 // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART or
373 // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
374 Point aClassicTPos(
375 aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
376 aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
377 Size aClassicTSize(
378 long( aTitleSize.Width() * 0.854 ),
379 long( aTitleSize.Height() * 0.167 ));
380 Point aClassicLPos(
381 aLayoutPos.X() + long( aLayoutSize.Width() * 0.0735 ),
382 aLayoutPos.Y() + long( aLayoutSize.Height() * 0.472 ));
383 Size aClassicLSize(
384 long( aLayoutSize.Width() * 0.854 ),
385 long( aLayoutSize.Height() * 0.444 ));
387 aLayoutPos.X() = aClassicLPos.X();
388 aLayoutPos.Y() = aClassicTPos.Y();
389 aLayoutSize.Width() = (aClassicLPos.X() + aClassicLSize.Width())
390 - (aClassicTSize.Height() + (aClassicLPos.Y() - (aClassicTPos.Y() + aClassicTSize.Height())));
391 aLayoutSize.Height() = (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y();
393 else if( mnType == 32 )
395 // AUTOLAYOUT_ONLY_TEXT
396 aLayoutPos = aTitlePos;
397 aLayoutSize.Width() = aTitleSize.Width();
398 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.825 );
400 else
402 aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
403 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.278 );
404 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
405 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.630 );
408 maPresRect.SetPos(aLayoutPos);
409 maPresRect.SetSize(aLayoutSize);
412 DECLARE_LIST(ImpXMLAutoLayoutInfoList, ImpXMLAutoLayoutInfo*)
414 //////////////////////////////////////////////////////////////////////////////
416 // #110680#
417 SdXMLExport::SdXMLExport(
418 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
419 sal_Bool bIsDraw, sal_uInt16 nExportFlags )
420 : SvXMLExport( xServiceFactory, MAP_CM, bIsDraw ? XML_DRAWING : XML_PRESENTATION, nExportFlags ),
421 mnDocMasterPageCount(0L),
422 mnDocDrawPageCount(0L),
423 mnShapeStyleInfoIndex(0L),
424 mnObjectCount(0L),
425 mpPageMasterInfoList(new ImpXMLEXPPageMasterList(1, 4, 4)),
426 mpPageMasterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)),
427 mpNotesPageMasterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)),
428 mpHandoutPageMaster(NULL),
429 mpAutoLayoutInfoList(new ImpXMLAutoLayoutInfoList(1, 4, 4)),
430 mpSdPropHdlFactory(0L),
431 mpPropertySetMapper(0L),
432 mpPresPagePropsMapper(0L),
433 mbIsDraw(bIsDraw),
434 mbFamilyGraphicUsed(FALSE),
435 mbFamilyPresentationUsed(FALSE),
436 msZIndex( GetXMLToken(XML_ZINDEX) ),
437 msEmptyPres( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ),
438 msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ),
439 msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ),
440 msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") ),
441 msPageLayoutNames( RTL_CONSTASCII_USTRINGPARAM("PageLayoutNames") )
447 // XExporter
448 void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent >& xDoc )
449 throw(lang::IllegalArgumentException, uno::RuntimeException)
451 SvXMLExport::setSourceDocument( xDoc );
453 const OUString aEmpty;
455 // prepare factory parts
456 mpSdPropHdlFactory = new XMLSdPropHdlFactory( GetModel(), *this );
457 if(mpSdPropHdlFactory)
459 // set lock to avoid deletion
460 mpSdPropHdlFactory->acquire();
462 // build one ref
463 const UniReference< XMLPropertyHandlerFactory > aFactoryRef = mpSdPropHdlFactory;
465 // construct PropertySetMapper
466 UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( aFactoryRef);
468 mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&GetTextParagraphExport()->GetListAutoStylePool(), *this );
469 // set lock to avoid deletion
470 mpPropertySetMapper->acquire();
472 // chain text attributes
473 mpPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
475 // construct PresPagePropsMapper
476 xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, aFactoryRef);
478 mpPresPagePropsMapper = new XMLPageExportPropertyMapper( xMapper, *this );
479 if(mpPresPagePropsMapper)
481 // set lock to avoid deletion
482 mpPresPagePropsMapper->acquire();
486 // add family name
487 GetAutoStylePool()->AddFamily(
488 XML_STYLE_FAMILY_SD_GRAPHICS_ID,
489 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)),
490 GetPropertySetMapper(),
491 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX)));
492 GetAutoStylePool()->AddFamily(
493 XML_STYLE_FAMILY_SD_PRESENTATION_ID,
494 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)),
495 GetPropertySetMapper(),
496 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX)));
497 GetAutoStylePool()->AddFamily(
498 XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID,
499 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)),
500 GetPresPagePropsMapper(),
501 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_PREFIX)));
502 // prepare access to styles
503 Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), UNO_QUERY );
504 if(xFamSup.is())
506 mxDocStyleFamilies = xFamSup->getStyleFamilies();
509 // prepare access to master pages
510 Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), UNO_QUERY);
511 if(xMasterPagesSupplier.is())
513 mxDocMasterPages = mxDocMasterPages.query( xMasterPagesSupplier->getMasterPages() );
514 if(mxDocMasterPages.is())
516 mnDocMasterPageCount = mxDocMasterPages->getCount();
517 maMasterPagesStyleNames.insert( maMasterPagesStyleNames.begin(), mnDocMasterPageCount, aEmpty );
521 // prepare access to draw pages
522 Reference <XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), UNO_QUERY);
523 if(xDrawPagesSupplier.is())
525 mxDocDrawPages = mxDocDrawPages.query( xDrawPagesSupplier->getDrawPages() );
526 if(mxDocDrawPages.is())
528 mnDocDrawPageCount = mxDocDrawPages->getCount();
529 maDrawPagesStyleNames.insert( maDrawPagesStyleNames.begin(), mnDocDrawPageCount, aEmpty );
530 maDrawNotesPagesStyleNames.insert( maDrawNotesPagesStyleNames.begin(), mnDocDrawPageCount, aEmpty );
531 if( !mbIsDraw )
532 maDrawPagesAutoLayoutNames.realloc( mnDocDrawPageCount + 1 );
534 HeaderFooterPageSettingsImpl aEmptySettings;
535 maDrawPagesHeaderFooterSettings.insert( maDrawPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
536 maDrawNotesPagesHeaderFooterSettings.insert( maDrawNotesPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
540 // #82003# count all draw objects for use with progress bar.
541 // #88245# init mnObjectCount once, use counter itself as flag. It
542 // is initialized to 0.
543 if(!mnObjectCount)
545 if( IsImpress() )
547 // #91587# add handout master count
548 Reference<presentation::XHandoutMasterSupplier> xHandoutSupp(GetModel(), UNO_QUERY);
549 if(xHandoutSupp.is())
551 Reference<XDrawPage> xHandoutPage(xHandoutSupp->getHandoutMasterPage());
552 if(xHandoutPage.is())
554 Reference<drawing::XShapes> xShapes(xHandoutPage, UNO_QUERY);
555 if(xShapes.is() && xShapes->getCount())
557 mnObjectCount += ImpRecursiveObjectCount(xShapes);
563 if(mxDocMasterPages.is())
565 for(sal_Int32 a(0); a < mnDocMasterPageCount; a++)
567 Any aAny(mxDocMasterPages->getByIndex(a));
568 Reference< drawing::XShapes > xMasterPage;
570 if((aAny >>= xMasterPage) && xMasterPage.is())
572 mnObjectCount += ImpRecursiveObjectCount(xMasterPage);
575 if( IsImpress() )
577 // #91587# take notes pages from master pages into account
578 Reference<presentation::XPresentationPage> xPresPage;
579 if((aAny >>= xPresPage) && xPresPage.is())
581 Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
582 if(xNotesPage.is())
584 Reference<drawing::XShapes> xShapes(xNotesPage, UNO_QUERY);
585 if(xShapes.is() && xShapes->getCount())
587 mnObjectCount += ImpRecursiveObjectCount(xShapes);
595 if(mxDocDrawPages.is())
597 for(sal_Int32 a(0); a < mnDocDrawPageCount; a++)
599 Any aAny(mxDocDrawPages->getByIndex(a));
600 Reference< drawing::XShapes > xPage;
602 if((aAny >>= xPage) && xPage.is())
604 mnObjectCount += ImpRecursiveObjectCount(xPage);
607 if( IsImpress() )
609 // #91587# take notes pages from draw pages into account
610 Reference<presentation::XPresentationPage> xPresPage;
611 if((aAny >>= xPresPage) && xPresPage.is())
613 Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
614 if(xNotesPage.is())
616 Reference<drawing::XShapes> xShapes(xNotesPage, UNO_QUERY);
617 if(xShapes.is() && xShapes->getCount())
619 mnObjectCount += ImpRecursiveObjectCount(xShapes);
627 // #82003# init progress bar
628 GetProgressBarHelper()->SetReference(mnObjectCount);
631 // add namespaces
632 _GetNamespaceMap().Add(
633 GetXMLToken(XML_NP_PRESENTATION),
634 GetXMLToken(XML_N_PRESENTATION),
635 XML_NAMESPACE_PRESENTATION);
637 _GetNamespaceMap().Add(
638 GetXMLToken(XML_NP_SMIL),
639 GetXMLToken(XML_N_SMIL_COMPAT),
640 XML_NAMESPACE_SMIL);
642 _GetNamespaceMap().Add(
643 GetXMLToken(XML_NP_ANIMATION),
644 GetXMLToken(XML_N_ANIMATION),
645 XML_NAMESPACE_ANIMATION);
647 if( getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST )
649 _GetNamespaceMap().Add(
650 GetXMLToken(XML_NP_OFFICE_EXT),
651 GetXMLToken(XML_N_OFFICE_EXT),
652 XML_NAMESPACE_OFFICE_EXT);
655 GetShapeExport()->enableLayerExport();
657 // #88546# enable progress bar increments
658 GetShapeExport()->enableHandleProgressBar();
661 //////////////////////////////////////////////////////////////////////////////
662 // #82003# helper function for recursive object count
663 sal_uInt32 SdXMLExport::ImpRecursiveObjectCount(Reference< drawing::XShapes > xShapes)
665 sal_uInt32 nRetval(0L);
667 if(xShapes.is())
669 sal_Int32 nCount = xShapes->getCount();
671 for(sal_Int32 a(0L); a < nCount; a++)
673 Any aAny(xShapes->getByIndex(a));
674 Reference< drawing::XShapes > xGroup;
676 if((aAny >>= xGroup) && xGroup.is())
678 // #93180# count group objects, too.
679 nRetval += 1 + ImpRecursiveObjectCount(xGroup);
681 else
683 nRetval++;
688 return nRetval;
691 //////////////////////////////////////////////////////////////////////////////
693 __EXPORT SdXMLExport::~SdXMLExport()
695 // cleanup factory, decrease refcount. Should lead to destruction.
696 if(mpSdPropHdlFactory)
698 mpSdPropHdlFactory->release();
699 mpSdPropHdlFactory = 0L;
702 // cleanup mapper, decrease refcount. Should lead to destruction.
703 if(mpPropertySetMapper)
705 mpPropertySetMapper->release();
706 mpPropertySetMapper = 0L;
709 // cleanup presPage mapper, decrease refcount. Should lead to destruction.
710 if(mpPresPagePropsMapper)
712 mpPresPagePropsMapper->release();
713 mpPresPagePropsMapper = 0L;
716 // clear evtl. temporary page master infos
717 if(mpPageMasterInfoList)
719 while(mpPageMasterInfoList->Count())
720 delete mpPageMasterInfoList->Remove(mpPageMasterInfoList->Count() - 1L);
721 delete mpPageMasterInfoList;
722 mpPageMasterInfoList = 0L;
724 if(mpPageMasterUsageList)
726 delete mpPageMasterUsageList;
727 mpPageMasterUsageList = 0L;
729 if(mpNotesPageMasterUsageList)
731 delete mpNotesPageMasterUsageList;
732 mpNotesPageMasterUsageList = 0L;
735 // clear auto-layout infos
736 if(mpAutoLayoutInfoList)
738 while(mpAutoLayoutInfoList->Count())
739 delete mpAutoLayoutInfoList->Remove(mpAutoLayoutInfoList->Count() - 1L);
740 delete mpAutoLayoutInfoList;
741 mpAutoLayoutInfoList = 0L;
744 // #82003# status indicator stop is called exclusively
745 // from SdXMLFilter::Export() now.
747 // stop progress view
748 // if(GetStatusIndicator().is())
749 // {
750 // GetStatusIndicator()->end();
751 // GetStatusIndicator()->reset();
752 // }
755 //////////////////////////////////////////////////////////////////////////////
756 // to get default values in XPropertySet use this wrapper class
758 class ImpDefaultMapper : public ::cppu::WeakAggImplHelper1< beans::XPropertySet >
760 Reference< beans::XPropertyState > mxState;
761 Reference< beans::XPropertySet > mxSet;
763 public:
764 ImpDefaultMapper( Reference< beans::XPropertyState >& rxState );
766 // Methods
767 virtual Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(uno::RuntimeException);
768 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
769 virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
771 // empty implementations
772 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
773 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
774 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
775 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
778 ImpDefaultMapper::ImpDefaultMapper( Reference< beans::XPropertyState >& rxState )
779 : mxState( rxState ),
780 mxSet( rxState, UNO_QUERY )
784 Reference< beans::XPropertySetInfo > SAL_CALL ImpDefaultMapper::getPropertySetInfo() throw(uno::RuntimeException)
786 return mxSet->getPropertySetInfo();
789 void SAL_CALL ImpDefaultMapper::setPropertyValue( const OUString& aPropertyName, const Any& /*aValue*/ ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
791 mxState->setPropertyToDefault( aPropertyName /*, aValue */ );
794 Any SAL_CALL ImpDefaultMapper::getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
796 return mxState->getPropertyDefault( PropertyName );
799 // empty implementations
800 void SAL_CALL ImpDefaultMapper::addPropertyChangeListener( const OUString&, const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
801 void SAL_CALL ImpDefaultMapper::removePropertyChangeListener( const OUString&, const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
802 void SAL_CALL ImpDefaultMapper::addVetoableChangeListener( const OUString&, const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
803 void SAL_CALL ImpDefaultMapper::removeVetoableChangeListener( const OUString&, const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
805 //////////////////////////////////////////////////////////////////////////////
807 /* moved to shapeexport.cxx
808 void SdXMLExport::ImpWriteObjGraphicStyleInfos()
810 XMLStyleExport aStEx(*this, OUString(), GetAutoStylePool().get());
811 const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
813 // write graphic family default style
814 Reference< lang::XMultiServiceFactory > xFact( GetModel(), UNO_QUERY );
815 if( xFact.is() )
819 Reference< beans::XPropertySet > xDefaults( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY );
820 if( xDefaults.is() )
822 aStEx.exportDefaultStyle( xDefaults, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), aMapperRef );
824 // write graphic family styles
825 aStEx.exportStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_NAME, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), aMapperRef, FALSE, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
828 catch( lang::ServiceNotRegisteredException& )
834 //////////////////////////////////////////////////////////////////////////////
836 void SdXMLExport::ImpPrepAutoLayoutInfos()
838 if(IsImpress())
840 OUString aStr;
842 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
843 if( xHandoutSupp.is() )
845 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
846 if( xHandoutPage.is() )
848 if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr))
849 maDrawPagesAutoLayoutNames[0] = aStr;
853 // prepare name creation
854 for(sal_Int32 nCnt = 0L; nCnt < mnDocDrawPageCount; nCnt++)
856 Any aAny(mxDocDrawPages->getByIndex(nCnt));
857 Reference<XDrawPage> xDrawPage;
859 if((aAny >>= xDrawPage) && xDrawPage.is())
861 if(ImpPrepAutoLayoutInfo(xDrawPage, aStr))
862 maDrawPagesAutoLayoutNames[nCnt+1] = aStr;
868 BOOL SdXMLExport::ImpPrepAutoLayoutInfo(const Reference<XDrawPage>& xPage, OUString& rName)
870 rName = OUString();
871 BOOL bRetval(FALSE);
873 Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
874 if(xPropSet.is())
876 sal_uInt16 nType = sal_uInt16();
877 Any aAny;
879 aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Layout")));
880 if(aAny >>= nType)
882 if(ImpXMLAutoLayoutInfo::IsCreateNecessary(nType))
884 ImpXMLEXPPageMasterInfo* pInfo = 0L;
886 // get master-page info
887 Reference < drawing::XMasterPageTarget > xMasterPageInt(xPage, UNO_QUERY);
888 if(xMasterPageInt.is())
890 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
891 if(xUsedMasterPage.is())
893 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
894 if(xMasterNamed.is())
896 OUString sMasterPageName = xMasterNamed->getName();
897 pInfo = ImpGetPageMasterInfoByName(sMasterPageName);
902 // create entry and look for existance
903 ImpXMLAutoLayoutInfo* pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
904 BOOL bDidExist(FALSE);
906 for(sal_uInt32 nCnt = 0L; !bDidExist && nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
908 if(*mpAutoLayoutInfoList->GetObject(nCnt) == *pNew)
910 delete pNew;
911 pNew = mpAutoLayoutInfoList->GetObject(nCnt);
912 bDidExist = TRUE;
916 if(!bDidExist)
918 mpAutoLayoutInfoList->Insert(pNew, LIST_APPEND);
919 OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("AL"));
920 sNewName += OUString::valueOf(sal_Int32(mpAutoLayoutInfoList->Count() - 1));
921 sNewName += OUString(RTL_CONSTASCII_USTRINGPARAM("T"));
922 sNewName += OUString::valueOf(sal_Int32(nType));
923 pNew->SetLayoutName(sNewName);
926 rName = pNew->GetLayoutName();
927 bRetval = TRUE;
932 return bRetval;
935 //////////////////////////////////////////////////////////////////////////////
937 void SdXMLExport::ImpWriteAutoLayoutInfos()
939 if(mpAutoLayoutInfoList->Count())
941 for(sal_uInt32 nCnt = 0L; nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
943 ImpXMLAutoLayoutInfo* pInfo = mpAutoLayoutInfoList->GetObject(nCnt);
944 if(pInfo)
946 // prepare presentation-page layout attributes, style-name
947 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, pInfo->GetLayoutName());
949 // write draw-style attributes
950 SvXMLElementExport aDSE(*this, XML_NAMESPACE_STYLE, XML_PRESENTATION_PAGE_LAYOUT, sal_True, sal_True);
952 // write presentation placeholders
953 switch(pInfo->GetLayoutType())
955 case 0 : // AUTOLAYOUT_TITLE
957 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
958 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
959 break;
961 case 1 : // AUTOLAYOUT_ENUM
963 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
964 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, pInfo->GetPresRectangle());
965 break;
967 case 2 : // AUTOLAYOUT_CHART
969 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
970 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, pInfo->GetPresRectangle());
971 break;
973 case 3 : // AUTOLAYOUT_2TEXT
975 Rectangle aLeft(pInfo->GetPresRectangle());
976 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
977 Rectangle aRight(aLeft);
978 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
980 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
981 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
982 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
983 break;
985 case 4 : // AUTOLAYOUT_TEXTCHART
987 Rectangle aLeft(pInfo->GetPresRectangle());
988 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
989 Rectangle aRight(aLeft);
990 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
992 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
993 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
994 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aRight);
995 break;
997 case 6 : // AUTOLAYOUT_TEXTCLIP
999 Rectangle aLeft(pInfo->GetPresRectangle());
1000 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1001 Rectangle aRight(aLeft);
1002 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1004 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1005 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1006 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aRight);
1007 break;
1009 case 7 : // AUTOLAYOUT_CHARTTEXT
1011 Rectangle aLeft(pInfo->GetPresRectangle());
1012 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1013 Rectangle aRight(aLeft);
1014 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1016 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1017 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aLeft);
1018 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1019 break;
1021 case 8 : // AUTOLAYOUT_TAB
1023 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1024 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTable, pInfo->GetPresRectangle());
1025 break;
1027 case 9 : // AUTOLAYOUT_CLIPTEXT
1029 Rectangle aLeft(pInfo->GetPresRectangle());
1030 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1031 Rectangle aRight(aLeft);
1032 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1034 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1035 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
1036 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1037 break;
1039 case 10 : // AUTOLAYOUT_TEXTOBJ
1041 Rectangle aLeft(pInfo->GetPresRectangle());
1042 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1043 Rectangle aRight(aLeft);
1044 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1046 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1047 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1048 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRight);
1049 break;
1051 case 11 : // AUTOLAYOUT_OBJ
1053 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1054 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, pInfo->GetPresRectangle());
1055 break;
1057 case 12 : // AUTOLAYOUT_TEXT2OBJ
1059 Rectangle aLeft(pInfo->GetPresRectangle());
1060 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1061 Rectangle aRightTop(aLeft);
1062 aRightTop.Left() = long(aRightTop.Left() + aRightTop.GetWidth() * 1.05);
1063 aRightTop.setHeight(long(aRightTop.GetHeight() * 0.477));
1064 Rectangle aRightBottom(aRightTop);
1065 aRightBottom.Top() = long(aRightBottom.Top() + aRightBottom.GetHeight() * 1.095);
1067 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1068 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
1069 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightTop);
1070 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightBottom);
1071 break;
1073 case 13 : // AUTOLAYOUT_OBJTEXT
1075 Rectangle aLeft(pInfo->GetPresRectangle());
1076 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1077 Rectangle aRight(aLeft);
1078 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1080 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1081 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeft);
1082 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1083 break;
1085 case 14 : // AUTOLAYOUT_OBJOVERTEXT
1087 Rectangle aTop(pInfo->GetPresRectangle());
1088 aTop.setHeight(long(aTop.GetHeight() * 0.477));
1089 Rectangle aBottom(aTop);
1090 aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1092 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1093 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTop);
1094 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
1095 break;
1097 case 15 : // AUTOLAYOUT_2OBJTEXT
1099 Rectangle aLeftTop(pInfo->GetPresRectangle());
1100 aLeftTop.setWidth(long(aLeftTop.GetWidth() * 0.488));
1101 Rectangle aRight(aLeftTop);
1102 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1103 aLeftTop.setHeight(long(aLeftTop.GetHeight() * 0.477));
1104 Rectangle aLeftBottom(aLeftTop);
1105 aLeftBottom.Top() = long(aLeftBottom.Top() + aLeftBottom.GetHeight() * 1.095);
1107 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1108 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftTop);
1109 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftBottom);
1110 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
1111 break;
1113 case 16 : // AUTOLAYOUT_2OBJOVERTEXT
1115 Rectangle aTopLeft(pInfo->GetPresRectangle());
1116 aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1117 Rectangle aBottom(aTopLeft);
1118 aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1119 aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1120 Rectangle aTopRight(aTopLeft);
1121 aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1123 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1124 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
1125 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
1126 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
1127 break;
1129 case 17 : // AUTOLAYOUT_TEXTOVEROBJ
1131 Rectangle aTop(pInfo->GetPresRectangle());
1132 aTop.setHeight(long(aTop.GetHeight() * 0.477));
1133 Rectangle aBottom(aTop);
1134 aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
1136 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1137 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aTop);
1138 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottom);
1139 break;
1141 case 18 : // AUTOLAYOUT_4OBJ
1143 Rectangle aTopLeft(pInfo->GetPresRectangle());
1144 aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1145 aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1146 Rectangle aBottomLeft(aTopLeft);
1147 aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1148 Rectangle aTopRight(aTopLeft);
1149 aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1150 Rectangle aBottomRight(aTopRight);
1151 aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1153 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1154 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
1155 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
1156 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomLeft);
1157 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomRight);
1158 break;
1160 case 19 : // AUTOLAYOUT_ONLY_TITLE
1162 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1163 break;
1165 case 21 : // AUTOLAYOUT_NOTES
1167 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderPage, pInfo->GetTitleRectangle());
1168 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderNotes, pInfo->GetPresRectangle());
1169 break;
1171 case 22 : // AUTOLAYOUT_HANDOUT1
1172 case 23 : // AUTOLAYOUT_HANDOUT2
1173 case 24 : // AUTOLAYOUT_HANDOUT3
1174 case 25 : // AUTOLAYOUT_HANDOUT4
1175 case 26 : // AUTOLAYOUT_HANDOUT6
1176 case 31 : // AUTOLAYOUT_HANDOUT9
1178 sal_Int32 nColCnt, nRowCnt;
1179 sal_Int32 nGapX = pInfo->GetGapX();
1180 sal_Int32 nGapY = pInfo->GetGapY();
1182 switch(pInfo->GetLayoutType())
1184 case 22 : nColCnt = 1; nRowCnt = 1; break;
1185 case 23 : nColCnt = 1; nRowCnt = 2; break;
1186 case 24 : nColCnt = 1; nRowCnt = 3; break;
1187 case 25 : nColCnt = 2; nRowCnt = 2; break;
1188 case 26 : nColCnt = 3; nRowCnt = 2; break;
1189 case 31 : nColCnt = 3; nRowCnt = 3; break;
1190 default: nColCnt = 0; nRowCnt = 0; break; // FIXME - What is correct values?
1193 Size aPartSize(pInfo->GetTitleRectangle().GetSize());
1194 Point aPartPos(pInfo->GetTitleRectangle().TopLeft());
1196 if(aPartSize.Width() > aPartSize.Height())
1198 sal_Int32 nZwi(nColCnt);
1199 nColCnt = nRowCnt;
1200 nRowCnt = nZwi;
1203 aPartSize.Width() = (aPartSize.Width() - ((nColCnt - 1) * nGapX)) / nColCnt;
1204 aPartSize.Height() = (aPartSize.Height() - ((nRowCnt - 1) * nGapY)) / nRowCnt;
1206 Point aTmpPos(aPartPos);
1208 for(sal_Int32 a = 0L; a < nRowCnt; a++)
1210 aTmpPos.X() = aPartPos.X();
1212 for(sal_Int32 b = 0L; b < nColCnt; b++)
1214 Rectangle aTmpRect(aTmpPos, aPartSize);
1216 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderHandout, aTmpRect);
1217 aTmpPos.X() += aPartSize.Width() + nGapX;
1220 aTmpPos.Y() += aPartSize.Height() + nGapY;
1222 break;
1224 case 27 : // AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1226 Rectangle aTop(pInfo->GetPresRectangle());
1227 aTop.setHeight(long(aTop.GetHeight() * 0.488));
1228 Rectangle aBottom(aTop);
1229 aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.05);
1231 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1232 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aTop);
1233 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aBottom);
1234 break;
1236 case 28 : // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1238 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1239 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1240 break;
1242 case 29 : // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1244 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1245 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1246 break;
1248 case 30 : // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1250 Rectangle aLeft(pInfo->GetPresRectangle());
1251 aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
1252 Rectangle aRight(aLeft);
1253 aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
1255 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1256 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
1257 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aRight);
1258 break;
1260 case 32 : // AUTOLAYOUT_TITLE
1262 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
1263 break;
1266 case 33 : // AUTOLAYOUT_4CLIPART
1268 Rectangle aTopLeft(pInfo->GetPresRectangle());
1269 aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1270 aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
1271 Rectangle aBottomLeft(aTopLeft);
1272 aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1273 Rectangle aTopRight(aTopLeft);
1274 aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
1275 Rectangle aBottomRight(aTopRight);
1276 aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1278 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1279 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1280 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1281 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1282 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1283 break;
1286 case 34 : // AUTOLAYOUT_6CLIPART
1288 Rectangle aTopLeft(pInfo->GetPresRectangle());
1289 aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
1290 aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.322));
1291 Rectangle aTopCenter(aTopLeft);
1292 aTopCenter.Left() = long(aTopCenter.Left() + aTopCenter.GetWidth() * 1.05);
1293 Rectangle aTopRight(aTopLeft);
1294 aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 2 * 1.05);
1296 Rectangle aBottomLeft(aTopLeft);
1297 aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
1298 Rectangle aBottomCenter(aTopCenter);
1299 aBottomCenter.Top() = long(aBottomCenter.Top() + aBottomCenter.GetHeight() * 1.095);
1300 Rectangle aBottomRight(aTopRight);
1301 aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);
1303 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1304 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1305 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopCenter);
1306 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1307 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1308 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomCenter);
1309 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1310 break;
1312 default:
1314 DBG_ERROR("XMLEXP: unknown autolayout export");
1315 break;
1323 //////////////////////////////////////////////////////////////////////////////
1325 void SdXMLExport::ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl, const Rectangle& rRect)
1327 OUString aStr;
1328 OUStringBuffer sStringBuffer;
1330 // prepare presentation-placeholder attributes, presentation:object
1331 switch(ePl)
1333 case XmlPlaceholderTitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("title")); break;
1334 case XmlPlaceholderOutline: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("outline")); break;
1335 case XmlPlaceholderSubtitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("subtitle")); break;
1336 case XmlPlaceholderText: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("text")); break;
1337 case XmlPlaceholderGraphic: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("graphic")); break;
1338 case XmlPlaceholderObject: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("object")); break;
1339 case XmlPlaceholderChart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("chart")); break;
1340 case XmlPlaceholderOrgchart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("orgchart")); break;
1341 case XmlPlaceholderTable: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("table")); break;
1342 case XmlPlaceholderPage: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("page")); break;
1343 case XmlPlaceholderNotes: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("notes")); break;
1344 case XmlPlaceholderHandout: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("handout")); break;
1345 case XmlPlaceholderVerticalTitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_title")); break;
1346 case XmlPlaceholderVerticalOutline: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("vertical_outline")); break;
1349 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_OBJECT, aStr);
1351 // svg:x,y,width,height
1352 GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Left());
1353 aStr = sStringBuffer.makeStringAndClear();
1354 AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
1356 GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Top());
1357 aStr = sStringBuffer.makeStringAndClear();
1358 AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
1360 GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetWidth());
1361 aStr = sStringBuffer.makeStringAndClear();
1362 AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
1364 GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetHeight());
1365 aStr = sStringBuffer.makeStringAndClear();
1366 AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
1368 // write presentation-placeholder
1369 SvXMLElementExport aPPL(*this, XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, sal_True, sal_True);
1372 //////////////////////////////////////////////////////////////////////////////
1374 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetOrCreatePageMasterInfo( Reference< XDrawPage > xMasterPage )
1376 bool bDoesExist = false;
1378 ImpXMLEXPPageMasterInfo* pNewInfo = new ImpXMLEXPPageMasterInfo(*this, xMasterPage);
1380 // compare with prev page-master infos
1381 for(sal_uInt32 a = 0; !bDoesExist && a < mpPageMasterInfoList->Count(); a++)
1383 if(mpPageMasterInfoList->GetObject(a)
1384 && *mpPageMasterInfoList->GetObject(a) == *pNewInfo)
1386 delete pNewInfo;
1387 pNewInfo = mpPageMasterInfoList->GetObject(a);
1388 bDoesExist = true;
1391 // add entry when not found same page-master infos
1392 if(!bDoesExist)
1393 mpPageMasterInfoList->Insert(pNewInfo, LIST_APPEND);
1395 return pNewInfo;
1398 void SdXMLExport::ImpPrepPageMasterInfos()
1400 if( IsImpress() )
1402 // create page master info for handout master page
1404 Reference< XHandoutMasterSupplier > xHMS( GetModel(), UNO_QUERY );
1405 if( xHMS.is() )
1407 Reference< XDrawPage > xMasterPage( xHMS->getHandoutMasterPage() );
1408 if( xMasterPage.is() )
1409 mpHandoutPageMaster = ImpGetOrCreatePageMasterInfo(xMasterPage);
1413 // create page master infos for master pages
1414 if(mnDocMasterPageCount)
1416 // look for needed page-masters, create these
1417 for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++)
1419 Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
1420 ImpXMLEXPPageMasterInfo* pNewInfo = 0L;
1422 if(xMasterPage.is())
1423 pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage);
1425 mpPageMasterUsageList->Insert(pNewInfo, LIST_APPEND);
1427 // look for page master of handout page
1428 if(IsImpress())
1430 pNewInfo = NULL;
1431 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
1432 if(xPresPage.is())
1434 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
1435 if(xNotesPage.is())
1437 pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage);
1440 mpNotesPageMasterUsageList->Insert( pNewInfo, LIST_APPEND );
1446 //////////////////////////////////////////////////////////////////////////////
1448 void SdXMLExport::ImpWritePageMasterInfos()
1450 // write created page-masters, create names for these
1451 for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
1453 ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
1454 if(pInfo)
1456 // create name
1457 OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("PM"));
1459 sNewName += OUString::valueOf((sal_Int32)nCnt);
1460 pInfo->SetName(sNewName);
1462 // prepare page-master attributes
1463 OUString sString;
1464 OUStringBuffer sStringBuffer;
1466 sString = sNewName;
1467 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sString);
1469 // write page-layout
1470 SvXMLElementExport aPME(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT, sal_True, sal_True);
1472 // prepare style:properties inside page-master
1473 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderTop());
1474 sString = sStringBuffer.makeStringAndClear();
1475 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_TOP, sString);
1477 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderBottom());
1478 sString = sStringBuffer.makeStringAndClear();
1479 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, sString);
1481 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderLeft());
1482 sString = sStringBuffer.makeStringAndClear();
1483 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_LEFT, sString);
1485 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderRight());
1486 sString = sStringBuffer.makeStringAndClear();
1487 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_RIGHT, sString);
1489 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetWidth());
1490 sString = sStringBuffer.makeStringAndClear();
1491 AddAttribute(XML_NAMESPACE_FO, XML_PAGE_WIDTH, sString);
1493 GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetHeight());
1494 sString = sStringBuffer.makeStringAndClear();
1495 AddAttribute(XML_NAMESPACE_FO, XML_PAGE_HEIGHT, sString);
1497 if(pInfo->GetOrientation() == view::PaperOrientation_PORTRAIT)
1498 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_PORTRAIT);
1499 else
1500 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_LANDSCAPE);
1502 // write style:properties
1503 SvXMLElementExport aPMF(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_PROPERTIES, sal_True, sal_True);
1508 //////////////////////////////////////////////////////////////////////////////
1510 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(const OUString& rName)
1512 if(rName.getLength() && mpPageMasterInfoList->Count())
1514 for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
1516 ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
1517 if(pInfo)
1519 if(pInfo->GetMasterPageName().getLength() && rName.equals(pInfo->GetMasterPageName()))
1521 return pInfo;
1526 return 0L;
1529 //////////////////////////////////////////////////////////////////////////////
1531 void SdXMLExport::ImpPrepDrawPageInfos()
1533 // create draw:style-name entries for page export
1534 // containing presentation page attributes AND background attributes
1535 // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1537 sal_Int32 nCnt;
1538 for(nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
1540 Reference<XDrawPage> xDrawPage;
1541 mxDocDrawPages->getByIndex(nCnt) >>= xDrawPage;
1542 maDrawPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1544 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
1545 if(xPresPage.is())
1547 maDrawNotesPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xPresPage->getNotesPage(), false );
1549 maDrawPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xDrawPage );
1550 maDrawNotesPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xPresPage->getNotesPage() );
1555 //////////////////////////////////////////////////////////////////////////////
1557 static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, const sal_Char* pPrefix )
1559 // search rVector if there is already a string that equals rText
1560 std::vector< OUString >::iterator aIter;
1561 sal_Int32 nIndex;
1562 for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); aIter++, nIndex++ )
1564 if( (*aIter) == rText )
1565 break;
1568 // if nothing is found, append the string at the end of rVector
1569 if( aIter == rVector.end() )
1570 rVector.push_back( rText );
1572 // create a reference string with pPrefix and the index of the
1573 // found or created rText
1574 OUString aStr( OUString::createFromAscii( pPrefix ) );
1575 aStr += OUString::valueOf( nIndex );
1576 return aStr;
1579 static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, sal_Bool bFixed, sal_Int32 nFormat, const sal_Char* pPrefix )
1581 // search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
1582 std::vector< DateTimeDeclImpl >::iterator aIter;
1583 sal_Int32 nIndex;
1584 for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); aIter++, nIndex++ )
1586 const DateTimeDeclImpl& rDecl = (*aIter);
1587 if( (rDecl.mbFixed == bFixed ) &&
1588 (!bFixed || rDecl.maStrText == rText) &&
1589 (bFixed || (rDecl.mnFormat == nFormat) ) )
1590 break;
1593 // if nothing is found, append a new DateTimeDeclImpl
1594 if( aIter == rVector.end() )
1596 DateTimeDeclImpl aDecl;
1597 aDecl.maStrText = rText;
1598 aDecl.mbFixed = bFixed;
1599 aDecl.mnFormat = nFormat;
1600 rVector.push_back( aDecl );
1603 // create a reference string with pPrefix and the index of the
1604 // found or created DateTimeDeclImpl
1605 OUString aStr( OUString::createFromAscii( pPrefix ) );
1606 aStr += OUString::valueOf( nIndex );
1607 return aStr;
1611 static const sal_Char* gpStrHeaderTextPrefix = "hdr";
1612 static const sal_Char* gpStrFooterTextPrefix = "ftr";
1613 static const sal_Char* gpStrDateTimeTextPrefix = "dtd";
1615 HeaderFooterPageSettingsImpl SdXMLExport::ImpPrepDrawPageHeaderFooterDecls( const Reference<XDrawPage>& xDrawPage )
1617 HeaderFooterPageSettingsImpl aSettings;
1619 if( xDrawPage.is() ) try
1621 Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
1622 Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
1624 OUString aStrText;
1626 const OUString aStrHeaderTextProp( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) );
1627 if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
1629 xSet->getPropertyValue( aStrHeaderTextProp ) >>= aStrText;
1630 if( aStrText.getLength() )
1631 aSettings.maStrHeaderDeclName = findOrAppendImpl( maHeaderDeclsVector, aStrText, gpStrHeaderTextPrefix );
1634 const OUString aStrFooterTextProp( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) );
1635 if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
1637 xSet->getPropertyValue( aStrFooterTextProp ) >>= aStrText;
1638 if( aStrText.getLength() )
1639 aSettings.maStrFooterDeclName = findOrAppendImpl( maFooterDeclsVector, aStrText, gpStrFooterTextPrefix );
1642 const OUString aStrDateTimeTextProp( RTL_CONSTASCII_USTRINGPARAM( "DateTimeText" ) );
1643 if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
1645 sal_Bool bFixed = false;
1646 sal_Int32 nFormat = 0;
1647 xSet->getPropertyValue( aStrDateTimeTextProp ) >>= aStrText;
1648 xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDateTimeFixed" ) ) ) >>= bFixed;
1649 xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DateTimeFormat" ) ) ) >>= nFormat;
1651 if( !bFixed || aStrText.getLength() )
1653 aSettings.maStrDateTimeDeclName = findOrAppendImpl( maDateTimeDeclsVector, aStrText, bFixed, nFormat, gpStrDateTimeTextPrefix );
1654 if( !bFixed )
1655 addDataStyle( nFormat );
1659 catch( Exception& e )
1661 (void)e;
1662 DBG_ERROR( "SdXMLExport::ImpPrepDrawPageHeaderFooterDecls(), unexpected exception cought!" );
1665 return aSettings;
1668 //////////////////////////////////////////////////////////////////////////////
1670 void SdXMLExport::ImpWriteHeaderFooterDecls()
1672 OUStringBuffer sBuffer;
1674 if( !maHeaderDeclsVector.empty() )
1676 // export header decls
1677 const OUString aPrefix( OUString::createFromAscii( gpStrHeaderTextPrefix ) );
1678 std::vector< OUString >::iterator aIter;
1679 sal_Int32 nIndex;
1680 for( nIndex = 1, aIter = maHeaderDeclsVector.begin(); aIter != maHeaderDeclsVector.end(); aIter++, nIndex++ )
1682 sBuffer.append( aPrefix );
1683 sBuffer.append( nIndex );
1684 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1686 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, sal_True, sal_True);
1687 Characters((*aIter));
1691 if( !maFooterDeclsVector.empty() )
1693 // export footer decls
1694 const OUString aPrefix( OUString::createFromAscii( gpStrFooterTextPrefix ) );
1695 std::vector< OUString >::iterator aIter;
1696 sal_Int32 nIndex;
1697 for( nIndex = 1, aIter = maFooterDeclsVector.begin(); aIter != maFooterDeclsVector.end(); aIter++, nIndex++ )
1699 sBuffer.append( aPrefix );
1700 sBuffer.append( nIndex );
1701 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1703 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, sal_False, sal_False);
1704 Characters((*aIter));
1708 if( !maDateTimeDeclsVector.empty() )
1710 // export footer decls
1711 const OUString aPrefix( OUString::createFromAscii( gpStrDateTimeTextPrefix ) );
1712 std::vector< DateTimeDeclImpl >::iterator aIter;
1713 sal_Int32 nIndex;
1714 for( nIndex = 1, aIter = maDateTimeDeclsVector.begin(); aIter != maDateTimeDeclsVector.end(); aIter++, nIndex++ )
1716 const DateTimeDeclImpl& rDecl = (*aIter);
1718 sBuffer.append( aPrefix );
1719 sBuffer.append( nIndex );
1720 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1722 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE );
1724 if( !rDecl.mbFixed )
1725 AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) );
1727 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, sal_False, sal_False);
1728 if( rDecl.mbFixed )
1729 Characters(rDecl.maStrText);
1734 void SdXMLExport::ImplExportHeaderFooterDeclAttributes( const HeaderFooterPageSettingsImpl& aSettings )
1736 if( aSettings.maStrHeaderDeclName.getLength() )
1737 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, aSettings.maStrHeaderDeclName );
1739 if( aSettings.maStrFooterDeclName.getLength() )
1740 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, aSettings.maStrFooterDeclName );
1742 if( aSettings.maStrDateTimeDeclName.getLength() )
1743 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, aSettings.maStrDateTimeDeclName );
1746 //////////////////////////////////////////////////////////////////////////////
1748 OUString SdXMLExport::ImpCreatePresPageStyleName( Reference<XDrawPage> xDrawPage, bool bExportBackground /* = true */ )
1750 // create name
1751 OUString sStyleName;
1753 // create style for this page and add to auto style pool
1755 Reference< beans::XPropertySet > xPropSet1(xDrawPage, UNO_QUERY);
1756 if(xPropSet1.is())
1758 Reference< beans::XPropertySet > xPropSet;
1760 if( bExportBackground )
1762 // since the background items are in a different propertyset
1763 // which itself is a property of the pages property set
1764 // we now merge these two propertysets if possible to simulate
1765 // a single propertyset with all draw page properties
1766 const OUString aBackground(RTL_CONSTASCII_USTRINGPARAM("Background"));
1767 Reference< beans::XPropertySet > xPropSet2;
1768 Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
1769 if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
1771 Any aAny( xPropSet1->getPropertyValue( aBackground ) );
1772 aAny >>= xPropSet2;
1775 if( xPropSet2.is() )
1776 xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xPropSet2 );
1777 else
1778 xPropSet = xPropSet1;
1780 else
1782 xPropSet = xPropSet1;
1785 const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );
1787 std::vector< XMLPropertyState > xPropStates( aMapperRef->Filter( xPropSet ) );
1789 if( !xPropStates.empty() )
1791 // there are filtered properties -> hard attributes
1792 // try to find this style in AutoStylePool
1793 sStyleName = GetAutoStylePool()->Find(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
1795 if(!sStyleName.getLength())
1797 // Style did not exist, add it to AutoStalePool
1798 sStyleName = GetAutoStylePool()->Add(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
1803 return sStyleName;
1806 //////////////////////////////////////////////////////////////////////////////
1808 void SdXMLExport::ImpPrepMasterPageInfos()
1810 // create draw:style-name entries for master page export
1811 // containing only background attributes
1812 // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1814 sal_Int32 nCnt;
1815 for( nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
1817 Reference<XDrawPage> xDrawPage;
1818 mxDocMasterPages->getByIndex(nCnt) >>= xDrawPage;
1819 maMasterPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1822 if( IsImpress() )
1824 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
1825 if( xHandoutSupp.is() )
1827 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
1828 if( xHandoutPage.is() )
1830 maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage );
1831 maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false );
1837 //////////////////////////////////////////////////////////////////////////////
1838 void SdXMLExport::ImpWritePresentationStyles()
1840 if(IsImpress())
1842 for(sal_Int32 nCnt = 0L; nCnt < mnDocMasterPageCount; nCnt++)
1844 Any aAny(mxDocMasterPages->getByIndex(nCnt));
1845 Reference<container::XNamed> xNamed;
1847 if(aAny >>= xNamed)
1849 // write presentation styles (ONLY if presentation)
1850 if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
1852 XMLStyleExport aStEx(*this, OUString(), GetAutoStylePool().get());
1853 const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
1855 OUString aPrefix( xNamed->getName() );
1857 aPrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
1858 aStEx.exportStyleFamily(xNamed->getName(),
1859 OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)),
1860 aMapperRef, FALSE,
1861 XML_STYLE_FAMILY_SD_PRESENTATION_ID, &aPrefix);
1868 //////////////////////////////////////////////////////////////////////////////
1870 void SdXMLExport::SetProgress(sal_Int32 nProg)
1872 // set progress view
1873 if(GetStatusIndicator().is())
1874 GetStatusIndicator()->setValue(nProg);
1877 //////////////////////////////////////////////////////////////////////////////
1878 // #82003#
1880 void SdXMLExport::_ExportMeta()
1882 uno::Sequence<beans::NamedValue> stats(1);
1883 stats[0] = beans::NamedValue(::rtl::OUString::createFromAscii("ObjectCount"),
1884 uno::makeAny(mnObjectCount));
1886 // update document statistics at the model
1887 uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(GetModel(),
1888 uno::UNO_QUERY_THROW);
1889 uno::Reference<document::XDocumentProperties> xDocProps(
1890 xPropSup->getDocumentProperties());
1891 if (xDocProps.is()) {
1892 xDocProps->setDocumentStatistics(stats);
1895 // call parent
1896 SvXMLExport::_ExportMeta();
1899 //////////////////////////////////////////////////////////////////////////////
1901 void SdXMLExport::_ExportContent()
1903 // export <pres:header-decl>, <pres:footer-decl> and <pres:date-time-decl> elements
1904 ImpWriteHeaderFooterDecls();
1906 // page export
1907 for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
1909 uno::Reference<drawing::XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), uno::UNO_QUERY );
1911 SetProgress(((nPageInd + 1) * 100) / mnDocDrawPageCount);
1913 if(xDrawPage.is())
1915 // prepare page attributes, name of page
1916 Reference < container::XNamed > xNamed(xDrawPage, UNO_QUERY);
1917 if(xNamed.is())
1918 AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, xNamed->getName());
1920 // draw:style-name (presentation page attributes AND background attributes)
1921 if( maDrawPagesStyleNames[nPageInd].getLength() )
1922 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
1923 maDrawPagesStyleNames[nPageInd]);
1925 // draw:master-page-name
1926 Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
1927 if(xMasterPageInt.is())
1929 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
1930 if(xUsedMasterPage.is())
1932 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
1933 if(xMasterNamed.is())
1935 AddAttribute(XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME,
1936 EncodeStyleName( xMasterNamed->getName()) );
1941 // presentation:page-layout-name
1942 if( IsImpress() && maDrawPagesAutoLayoutNames[nPageInd+1].getLength())
1944 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, maDrawPagesAutoLayoutNames[nPageInd+1] );
1947 Reference< beans::XPropertySet > xProps( xDrawPage, UNO_QUERY );
1948 if( xProps.is() )
1952 OUString aBookmarkURL;
1953 xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "BookmarkURL" ) ) ) >>= aBookmarkURL;
1955 if( aBookmarkURL.getLength() )
1957 sal_Int32 nIndex = aBookmarkURL.lastIndexOf( (sal_Unicode)'#' );
1958 if( nIndex != -1 )
1960 OUString aFileName( aBookmarkURL.copy( 0, nIndex ) );
1961 OUString aBookmarkName( aBookmarkURL.copy( nIndex+1 ) );
1963 aBookmarkURL = GetRelativeReference( aFileName );
1964 aBookmarkURL += String( '#' );
1965 aBookmarkURL += aBookmarkName;
1968 AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, aBookmarkURL);
1969 AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1970 AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_REPLACE );
1971 AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
1974 catch( Exception& )
1976 DBG_ERROR(" no \"BookmarkURL\" property at page?" );
1980 if( IsImpress() )
1981 ImplExportHeaderFooterDeclAttributes( maDrawPagesHeaderFooterSettings[nPageInd] );
1984 OUString sNavigationOrder( getNavigationOrder( xDrawPage ) );
1985 if( sNavigationOrder.getLength() != 0 )
1986 AddAttribute ( XML_NAMESPACE_DRAW, XML_NAV_ORDER, sNavigationOrder );
1988 UniReference< xmloff::AnimationsExporter > xAnimationsExporter;
1989 uno::Reference< ::com::sun::star::animations::XAnimationNodeSupplier > xAnimNodeSupplier;
1991 // prepare animation export
1992 if(IsImpress())
1994 if( getExportFlags() & EXPORT_OASIS )
1996 // export new animations for oasis format
1997 xAnimNodeSupplier.set( xDrawPage, UNO_QUERY );
1999 // prepare animations exporter if impress
2000 if(xAnimNodeSupplier.is())
2002 xAnimationsExporter = new xmloff::AnimationsExporter( *this, xProps );
2003 xAnimationsExporter->prepare( xAnimNodeSupplier->getAnimationNode() );
2006 else
2008 // export old animations for ooo format
2009 UniReference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter( GetShapeExport().get() );
2010 GetShapeExport()->setAnimationsExporter( xAnimExport );
2014 // write draw:id
2015 const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage );
2016 if( aPageId.getLength() != 0 )
2017 AddAttribute ( XML_NAMESPACE_DRAW, XML_ID, aPageId );
2019 // write page
2020 SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, sal_True, sal_True);
2022 // write optional office:forms
2023 exportFormsElement( xDrawPage );
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 );
2030 // write animations and presentation notes (ONLY if presentation)
2031 if(IsImpress())
2033 if(xAnimNodeSupplier.is())
2035 xAnimationsExporter->exportAnimations( xAnimNodeSupplier->getAnimationNode() );
2037 else
2039 // animations
2040 UniReference< XMLAnimationsExporter > xAnimExport( GetShapeExport()->getAnimationsExporter() );
2041 if( xAnimExport.is() )
2042 xAnimExport->exportAnimations( *this );
2044 xAnimExport = NULL;
2045 GetShapeExport()->setAnimationsExporter( xAnimExport );
2048 // presentations
2049 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
2050 if(xPresPage.is())
2052 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2053 if(xNotesPage.is())
2055 Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2056 if(xShapes.is())
2058 if( maDrawNotesPagesStyleNames[nPageInd].getLength() )
2059 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maDrawNotesPagesStyleNames[nPageInd]);
2061 ImplExportHeaderFooterDeclAttributes( maDrawNotesPagesHeaderFooterSettings[nPageInd] );
2063 // write presentation notes
2064 SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, sal_True, sal_True);
2066 // write optional office:forms
2067 exportFormsElement( xNotesPage );
2069 // write shapes per se
2070 GetShapeExport()->exportShapes( xShapes );
2076 exportAnnotations( xDrawPage );
2080 if( IsImpress() )
2081 exportPresentationSettings();
2084 //////////////////////////////////////////////////////////////////////////////
2086 void SdXMLExport::exportPresentationSettings()
2090 Reference< XPresentationSupplier > xPresSupplier( GetModel(), UNO_QUERY );
2091 if( !xPresSupplier.is() )
2092 return;
2094 Reference< XPropertySet > xPresProps( xPresSupplier->getPresentation(), UNO_QUERY );
2095 if( !xPresProps.is() )
2096 return;
2098 sal_Bool bHasAttr = sal_False;
2100 sal_Bool bTemp = false;
2102 // export range
2103 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsShowAll" ) ) ) >>= bTemp;
2104 if( !bTemp )
2106 OUString aFirstPage;
2107 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPage" ) ) ) >>= aFirstPage;
2108 if( aFirstPage.getLength() )
2110 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_PAGE, aFirstPage );
2111 bHasAttr = sal_True;
2113 else
2115 OUString aCustomShow;
2116 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CustomShow" ) ) ) >>= aCustomShow;
2117 if( aCustomShow.getLength() )
2119 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW, aCustomShow );
2120 bHasAttr = sal_True;
2125 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsEndless" ) ) ) >>= bTemp;
2126 if( bTemp )
2128 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ENDLESS, XML_TRUE );
2129 bHasAttr = sal_True;
2131 sal_Int32 nPause = 0;
2132 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Pause" ) ) ) >>= nPause;
2134 util::DateTime aTime( 0, (sal_uInt16)nPause, 0, 0, 0, 0, 0 );
2136 OUStringBuffer aOut;
2137 SvXMLUnitConverter::convertTime( aOut, aTime );
2138 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAUSE, aOut.makeStringAndClear() );
2141 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowAnimations" ) ) ) >>= bTemp;
2142 if( !bTemp )
2144 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, XML_DISABLED );
2145 bHasAttr = sal_True;
2148 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAlwaysOnTop" ) ) ) >>= bTemp;
2149 if( bTemp )
2151 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STAY_ON_TOP, XML_TRUE );
2152 bHasAttr = sal_True;
2155 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ) ) >>= bTemp;
2156 if( bTemp )
2158 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FORCE_MANUAL, XML_TRUE );
2159 bHasAttr = sal_True;
2162 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFullScreen" ) ) ) >>= bTemp;
2163 if( !bTemp )
2165 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FULL_SCREEN, XML_FALSE );
2166 bHasAttr = sal_True;
2169 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsMouseVisible" ) ) ) >>= bTemp;
2170 if( !bTemp )
2172 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_VISIBLE, XML_FALSE );
2173 bHasAttr = sal_True;
2176 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "StartWithNavigator" ) ) ) >>= bTemp;
2177 if( bTemp )
2179 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_WITH_NAVIGATOR, XML_TRUE );
2180 bHasAttr = sal_True;
2183 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "UsePen" ) ) ) >>= bTemp;
2184 if( bTemp )
2186 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_AS_PEN, XML_TRUE );
2187 bHasAttr = sal_True;
2190 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTransitionOnClick" ) ) ) >>= bTemp;
2191 if( !bTemp )
2193 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_TRANSITION_ON_CLICK, XML_DISABLED );
2194 bHasAttr = sal_True;
2197 xPresProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsShowLogo" ) ) ) >>= bTemp;
2198 if( bTemp )
2200 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW_LOGO, XML_TRUE );
2201 bHasAttr = sal_True;
2204 Reference< container::XNameContainer > xShows;
2205 Sequence< OUString > aShowNames;
2206 const OUString* pShowNames = NULL;
2207 sal_Int32 nShowCount = 0;
2209 Reference< XCustomPresentationSupplier > xSup( GetModel(), UNO_QUERY );
2210 if( xSup.is() )
2212 xShows = xSup->getCustomPresentations();
2213 if( xShows.is() )
2215 aShowNames = xShows->getElementNames();
2216 pShowNames = aShowNames.getArray();
2217 nShowCount = aShowNames.getLength();
2221 if( bHasAttr || nShowCount != 0 )
2223 SvXMLElementExport aSettings(*this, XML_NAMESPACE_PRESENTATION, XML_SETTINGS, sal_True, sal_True);
2225 if( nShowCount == 0 )
2226 return;
2228 Reference< XIndexContainer > xShow;
2229 Reference< XNamed > xPageName;
2231 OUStringBuffer sTmp;
2233 for( sal_Int32 nIndex = 0; nIndex < nShowCount; nIndex++, pShowNames++ )
2235 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, *pShowNames );
2237 xShows->getByName( *pShowNames ) >>= xShow;
2238 DBG_ASSERT( xShow.is(), "invalid custom show!" );
2239 if( !xShow.is() )
2240 continue;
2242 const sal_Int32 nPageCount = xShow->getCount();
2243 for( sal_Int32 nPage = 0; nPage < nPageCount; nPage++ )
2245 xShow->getByIndex( nPage ) >>= xPageName;
2247 if( !xPageName.is() )
2248 continue;
2250 if( sTmp.getLength() != 0 )
2251 sTmp.append( sal_Unicode( ',' ) );
2252 sTmp.append( xPageName->getName() );
2256 if( sTmp.getLength() )
2257 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAGES, sTmp.makeStringAndClear() );
2259 SvXMLElementExport aShows(*this, XML_NAMESPACE_PRESENTATION, XML_SHOW, sal_True, sal_True);
2263 catch( uno::Exception )
2265 DBG_ERROR( "uno::Exception while exporting <presentation:settings>" );
2269 //////////////////////////////////////////////////////////////////////////////
2271 void SdXMLExport::_ExportStyles(BOOL bUsed)
2273 GetPropertySetMapper()->SetAutoStyles( sal_False );
2275 // export fill styles
2276 SvXMLExport::_ExportStyles( bUsed );
2278 // write draw:style-name for object graphic-styles
2279 GetShapeExport()->ExportGraphicDefaults();
2281 GetShapeExport()->GetShapeTableExport()->exportTableStyles();
2283 // write presentation styles
2284 ImpWritePresentationStyles();
2286 // prepare draw:auto-layout-name for page export
2287 ImpPrepAutoLayoutInfos();
2289 // write draw:auto-layout-name for page export
2290 ImpWriteAutoLayoutInfos();
2292 Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2293 if( xInfoSet.is() )
2295 Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2297 Any aAny;
2299 if( xInfoSetInfo->hasPropertyByName( msPageLayoutNames ) )
2301 aAny <<= maDrawPagesAutoLayoutNames;
2302 xInfoSet->setPropertyValue( msPageLayoutNames, aAny );
2307 //////////////////////////////////////////////////////////////////////////////
2309 void SdXMLExport::_ExportAutoStyles()
2311 Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2312 if( xInfoSet.is() )
2314 Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2316 if( xInfoSetInfo->hasPropertyByName( msPageLayoutNames ) )
2318 xInfoSet->getPropertyValue( msPageLayoutNames ) >>= maDrawPagesAutoLayoutNames;
2322 GetPropertySetMapper()->SetAutoStyles( sal_True );
2324 if( getExportFlags() & EXPORT_STYLES )
2326 // #80012# PageMaster export moved from _ExportStyles
2327 // prepare page-master infos
2328 ImpPrepPageMasterInfos();
2330 // write page-master infos
2331 ImpWritePageMasterInfos();
2333 // prepare draw:style-name for master page export
2334 ImpPrepMasterPageInfos();
2337 if( getExportFlags() & EXPORT_CONTENT )
2339 // prepare draw:style-name for page export
2340 ImpPrepDrawPageInfos();
2343 // export draw-page styles
2344 GetAutoStylePool()->exportXML(
2345 XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID
2346 , GetDocHandler(),
2347 GetMM100UnitConverter(),
2348 GetNamespaceMap()
2351 if( getExportFlags() & EXPORT_STYLES )
2353 // create auto style infos for shapes on master handout page
2354 if( IsImpress() )
2356 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2357 if( xHandoutSupp.is() )
2359 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2360 if( xHandoutPage.is() )
2362 Reference< drawing::XShapes > xShapes(xHandoutPage, UNO_QUERY);
2363 if(xShapes.is() && xShapes->getCount())
2364 GetShapeExport()->collectShapesAutoStyles( xShapes );
2369 // create auto style infos for objects on master pages
2370 for(sal_Int32 nMPageId(0L); nMPageId < mnDocMasterPageCount; nMPageId++)
2372 Reference< XDrawPage > xMasterPage(mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2374 if( xMasterPage.is() )
2376 // collect layer information
2377 GetFormExport()->examineForms( xMasterPage );
2379 // get MasterPage Name
2380 OUString aMasterPageNamePrefix;
2381 Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2382 if(xNamed.is())
2384 aMasterPageNamePrefix = xNamed->getName();
2386 if(aMasterPageNamePrefix.getLength())
2388 aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
2390 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2392 Reference< drawing::XShapes > xMasterShapes(xMasterPage, UNO_QUERY);
2393 if(xMasterShapes.is() && xMasterShapes->getCount())
2394 GetShapeExport()->collectShapesAutoStyles( xMasterShapes );
2396 if(IsImpress())
2398 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2399 if(xPresPage.is())
2401 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2402 if(xNotesPage.is())
2404 // collect layer information
2405 GetFormExport()->examineForms( xNotesPage );
2407 Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2408 if(xShapes.is() && xShapes->getCount())
2409 GetShapeExport()->collectShapesAutoStyles( xShapes );
2413 collectAnnotationAutoStyles(xMasterPage);
2418 if( getExportFlags() & EXPORT_CONTENT )
2420 // prepare animations exporter if impress
2421 if(IsImpress() && ((getExportFlags() & EXPORT_OASIS) == 0) )
2423 UniReference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter( GetShapeExport().get() );
2424 GetShapeExport()->setAnimationsExporter( xAnimExport );
2427 // create auto style infos for objects on pages
2428 for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
2430 Reference<XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), UNO_QUERY );
2431 if( xDrawPage.is() )
2433 // collect layer information
2434 GetFormExport()->examineForms( xDrawPage );
2436 // get MasterPage Name
2437 OUString aMasterPageNamePrefix;
2438 Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
2439 if(xMasterPageInt.is())
2441 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
2442 if(xUsedMasterPage.is())
2444 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
2445 if(xMasterNamed.is())
2447 aMasterPageNamePrefix = xMasterNamed->getName();
2451 if(aMasterPageNamePrefix.getLength())
2453 aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
2456 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2458 // prepare object infos
2459 Reference< drawing::XShapes > xDrawShapes(xDrawPage, UNO_QUERY);
2460 if(xDrawShapes.is() && xDrawShapes->getCount())
2461 GetShapeExport()->collectShapesAutoStyles( xDrawShapes );
2463 // prepare presentation notes page object infos (ONLY if presentation)
2464 if(IsImpress())
2466 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
2467 if(xPresPage.is())
2469 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2470 if(xNotesPage.is())
2472 // collect layer information
2473 GetFormExport()->examineForms( xNotesPage );
2475 Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2476 if(xShapes.is() && xShapes->getCount())
2477 GetShapeExport()->collectShapesAutoStyles( xShapes );
2482 collectAnnotationAutoStyles( xDrawPage );
2485 if(IsImpress())
2487 UniReference< XMLAnimationsExporter > xAnimExport;
2488 GetShapeExport()->setAnimationsExporter( xAnimExport );
2492 exportAutoDataStyles();
2494 GetShapeExport()->exportAutoStyles();
2496 sal_uInt16 nContentAutostyles = EXPORT_CONTENT | EXPORT_AUTOSTYLES;
2497 if ( ( getExportFlags() & nContentAutostyles ) == nContentAutostyles )
2498 GetFormExport()->exportAutoStyles( );
2500 // ...for text
2501 GetTextParagraphExport()->exportTextAutoStyles();
2504 //////////////////////////////////////////////////////////////////////////////
2506 void SdXMLExport::_ExportMasterStyles()
2508 // export layer
2509 SdXMLayerExporter::exportLayer( *this );
2511 // export handout master page if impress
2512 if( IsImpress() )
2514 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2515 if( xHandoutSupp.is() )
2517 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2518 if( xHandoutPage.is() )
2520 // presentation:page-layout-name
2521 if( IsImpress() && maDrawPagesAutoLayoutNames[0].getLength())
2523 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, EncodeStyleName( maDrawPagesAutoLayoutNames[0] ));
2526 ImpXMLEXPPageMasterInfo* pInfo = mpHandoutPageMaster;
2527 if(pInfo)
2529 OUString sString = pInfo->GetName();
2530 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2533 // draw:style-name
2534 if( maHandoutMasterStyleName.getLength() )
2535 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maHandoutMasterStyleName);
2537 ImplExportHeaderFooterDeclAttributes( maHandoutPageHeaderFooterSettings );
2539 // write masterpage
2540 SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_HANDOUT_MASTER, sal_True, sal_True);
2542 // write graphic objects on this master page (if any)
2543 Reference< drawing::XShapes > xShapes(xHandoutPage, UNO_QUERY);
2544 if(xShapes.is() && xShapes->getCount())
2545 GetShapeExport()->exportShapes( xShapes );
2550 // export MasterPages in master-styles section
2551 for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++)
2553 Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2554 if(xMasterPage.is())
2556 // prepare masterpage attributes
2557 OUString sMasterPageName;
2558 Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2559 if(xNamed.is())
2561 sal_Bool bEncoded = sal_False;
2562 sMasterPageName = xNamed->getName();
2563 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME,
2564 EncodeStyleName( sMasterPageName, &bEncoded ));
2565 if( bEncoded )
2566 AddAttribute(
2567 XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
2568 sMasterPageName );
2571 ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterUsageList->GetObject(nMPageId);
2572 if(pInfo)
2574 OUString sString = pInfo->GetName();
2575 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2578 // draw:style-name (background attributes)
2579 if( maMasterPagesStyleNames[nMPageId].getLength() )
2580 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2581 maMasterPagesStyleNames[nMPageId]);
2583 // write masterpage
2584 SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_MASTER_PAGE, sal_True, sal_True);
2586 // write optional office:forms
2587 exportFormsElement( xMasterPage );
2589 // write graphic objects on this master page (if any)
2590 Reference< drawing::XShapes > xMasterShapes(xMasterPage, UNO_QUERY);
2591 if(xMasterShapes.is() && xMasterShapes->getCount())
2592 GetShapeExport()->exportShapes( xMasterShapes );
2594 // write presentation notes (ONLY if presentation)
2595 if(IsImpress())
2597 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2598 if(xPresPage.is())
2600 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2601 if(xNotesPage.is())
2603 Reference< drawing::XShapes > xShapes(xNotesPage, UNO_QUERY);
2604 if(xShapes.is())
2606 ImpXMLEXPPageMasterInfo* pMasterInfo = mpNotesPageMasterUsageList->GetObject(nMPageId);
2607 if(pMasterInfo)
2609 OUString sString = pMasterInfo->GetName();
2610 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString);
2613 // write presentation notes
2614 SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, sal_True, sal_True);
2616 // write optional office:forms
2617 exportFormsElement( xNotesPage );
2619 // write shapes per se
2620 GetShapeExport()->exportShapes( xShapes );
2625 exportAnnotations( xMasterPage );
2630 void SdXMLExport::exportFormsElement( Reference< XDrawPage > xDrawPage )
2632 if( xDrawPage.is() )
2634 Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY );
2635 if ( xFormsSupplier.is() && xFormsSupplier->hasForms() )
2637 // write masterpage
2638 ::xmloff::OOfficeFormsExport aForms(*this);
2639 GetFormExport()->exportForms( xDrawPage );
2642 if(! GetFormExport()->seekPage( xDrawPage ) )
2644 DBG_ERROR( "OFormLayerXMLExport::seekPage failed!" );
2649 void SdXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
2651 rProps.realloc(4);
2652 beans::PropertyValue* pProps = rProps.getArray();
2653 if(pProps)
2655 // SvXMLElementExport aViewSettingsElem(*this, XML_NAMESPACE_DRAW, XML_VIEW_SETTINGS, sal_True, sal_True);
2657 Reference< beans::XPropertySet > xPropSet( GetModel(), UNO_QUERY );
2658 if( !xPropSet.is() )
2659 return;
2661 awt::Rectangle aVisArea;
2662 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ) ) >>= aVisArea;
2664 sal_Int16 nMapUnit;
2665 xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MapUnit" ) ) ) >>= nMapUnit;
2668 sal_uInt16 i = 0;
2669 pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaTop"));
2670 pProps[i++].Value <<= aVisArea.Y;
2671 pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaLeft"));
2672 pProps[i++].Value <<= aVisArea.X;
2673 pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaWidth"));
2674 pProps[i++].Value <<= aVisArea.Width;
2675 pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaHeight"));
2676 pProps[i++].Value <<= aVisArea.Height;
2680 void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
2682 Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
2683 if( xFac.is() )
2685 Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY );
2686 if( xProps.is() )
2687 SvXMLUnitConverter::convertPropertySet( rProps, xProps );
2691 //////////////////////////////////////////////////////////////////////////////
2693 void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat )
2695 sal_Int32 nFormat = nNumberFormat;
2696 if( (nNumberFormat > 1) && (nNumberFormat <= 0x0f) )
2697 nFormat -= 2;
2699 if( bTimeFormat )
2701 if( maUsedTimeStyles.count( nFormat ) == 0 )
2702 maUsedTimeStyles.insert( nFormat );
2704 else
2706 if( maUsedDateStyles.count( nFormat ) == 0 )
2707 maUsedDateStyles.insert( nFormat );
2711 //////////////////////////////////////////////////////////////////////////////
2713 void SdXMLExport::exportDataStyles()
2715 // there are no data styles to export in draw/impress yet
2718 //////////////////////////////////////////////////////////////////////////////
2720 void SdXMLExport::exportAutoDataStyles()
2722 SdXMLFormatMap::iterator aIter( maUsedDateStyles.begin() );
2723 SdXMLFormatMap::iterator aEnd( maUsedDateStyles.end() );
2725 while( aIter != aEnd )
2726 SdXMLNumberStylesExporter::exportDateStyle( *this, (*aIter++) );
2728 aIter = maUsedTimeStyles.begin();
2729 aEnd = maUsedTimeStyles.end();
2730 while( aIter != aEnd )
2731 SdXMLNumberStylesExporter::exportTimeStyle( *this, (*aIter++) );
2733 if(HasFormExport())
2734 GetFormExport()->exportAutoControlNumberStyles();
2737 //////////////////////////////////////////////////////////////////////////////
2739 OUString SdXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat ) const
2741 if( bTimeFormat )
2743 return SdXMLNumberStylesExporter::getTimeStyleName( nNumberFormat );
2745 else
2747 return SdXMLNumberStylesExporter::getDateStyleName( nNumberFormat );
2751 OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPage )
2753 OUStringBuffer sNavOrder;
2756 Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
2757 Reference< XIndexAccess > xNavOrder( xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "NavigationOrder" ) ) ), UNO_QUERY_THROW );
2759 Reference< XIndexAccess > xZOrderAccess( xDrawPage, UNO_QUERY );
2761 // only export navigation order if it is different from the z-order
2762 if( (xNavOrder.get() != xZOrderAccess.get()) && (xNavOrder->getCount() == xDrawPage->getCount()) )
2764 sal_Int32 nIndex;
2765 const sal_Int32 nCount = xNavOrder->getCount();
2766 for( nIndex = 0; nIndex < nCount; ++nIndex )
2768 OUString sId( getInterfaceToIdentifierMapper().registerReference( Reference< XInterface >( xNavOrder->getByIndex( nIndex ), UNO_QUERY ) ) );
2769 if( sId.getLength() != 0 )
2771 if( sNavOrder.getLength() != 0 )
2772 sNavOrder.append( (sal_Unicode)' ' );
2773 sNavOrder.append( sId );
2778 catch( Exception& )
2781 return sNavOrder.makeStringAndClear();
2784 //////////////////////////////////////////////////////////////////////////////
2786 void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage )
2788 Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2789 if( xAnnotationAccess.is() ) try
2791 Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2792 if( xAnnotationEnumeration.is() )
2794 while( xAnnotationEnumeration->hasMoreElements() )
2796 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW );
2797 Reference< XText > xText( xAnnotation->getTextRange() );
2798 if(xText.is() && xText->getString().getLength())
2799 GetTextParagraphExport()->collectTextAutoStyles( xText );
2803 catch( Exception& )
2805 DBG_ERROR("SdXMLExport::collectAnnotationAutoStyles(), exception caught during export of annotation auto styles");
2809 void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
2811 // do not export in ODF 1.2 or older
2812 if( getDefaultVersion() != SvtSaveOptions::ODFVER_LATEST )
2813 return;
2815 Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2816 if( xAnnotationAccess.is() ) try
2818 Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2819 if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() )
2821 OUStringBuffer sStringBuffer;
2824 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW );
2826 RealPoint2D aPosition( xAnnotation->getPosition() );
2828 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.X * 100 ) );
2829 AddAttribute(XML_NAMESPACE_SVG, XML_X, sStringBuffer.makeStringAndClear());
2831 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.Y * 100 ) );
2832 AddAttribute(XML_NAMESPACE_SVG, XML_Y, sStringBuffer.makeStringAndClear());
2834 RealSize2D aSize( xAnnotation->getSize() );
2836 if( aSize.Width || aSize.Height )
2838 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Width * 100 ) );
2839 AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, sStringBuffer.makeStringAndClear());
2840 GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Height * 100 ) );
2841 AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, sStringBuffer.makeStringAndClear());
2844 // annotation element + content
2845 SvXMLElementExport aElem(*this, XML_NAMESPACE_OFFICE_EXT, XML_ANNOTATION, sal_False, sal_True);
2847 // author
2848 OUString aAuthor( xAnnotation->getAuthor() );
2849 if( aAuthor.getLength() )
2851 SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, sal_True, sal_False );
2852 this->Characters(aAuthor);
2856 // date time
2857 DateTime aDate( xAnnotation->getDateTime() );
2858 GetMM100UnitConverter().convertDateTime(sStringBuffer, aDate, sal_True);
2859 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, sal_True, sal_False );
2860 Characters(sStringBuffer.makeStringAndClear());
2863 com::sun::star::uno::Reference < com::sun::star::text::XText > xText( xAnnotation->getTextRange() );
2864 if( xText.is() )
2865 this->GetTextParagraphExport()->exportText( xText );
2867 while( xAnnotationEnumeration->hasMoreElements() );
2870 catch( Exception& )
2872 DBG_ERROR("SdXMLExport::exportAnnotations(), exception caught during export of annotations");
2876 //////////////////////////////////////////////////////////////////////////////
2878 #define SERVICE( classname, servicename, implementationname, draw, flags )\
2879 uno::Sequence< OUString > SAL_CALL classname##_getSupportedServiceNames() throw()\
2881 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( servicename ) );\
2882 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );\
2883 return aSeq;\
2885 OUString SAL_CALL classname##_getImplementationName() throw()\
2887 return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationname ) );\
2889 uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )\
2891 return (cppu::OWeakObject*)new SdXMLExport( rSMgr, draw, flags );\
2894 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 );
2895 SERVICE( XMLImpressStylesExportOasis, "com.sun.star.comp.Impress.XMLOasisStylesExporter", "XMLImpressStylesExportOasis", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2896 SERVICE( XMLImpressContentExportOasis, "com.sun.star.comp.Impress.XMLOasisContentExporter", "XMLImpressContentExportOasis", sal_False, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2897 SERVICE( XMLImpressMetaExportOasis, "com.sun.star.comp.Impress.XMLOasisMetaExporter", "XMLImpressMetaExportOasis", sal_False, EXPORT_OASIS|EXPORT_META );
2898 SERVICE( XMLImpressSettingsExportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsExporter", "XMLImpressSettingsExportOasis", sal_False, EXPORT_OASIS|EXPORT_SETTINGS );
2900 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 );
2901 SERVICE( XMLImpressStylesExportOOO, "com.sun.star.comp.Impress.XMLStylesExporter", "XMLImpressStylesExportOOO", sal_False, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2902 SERVICE( XMLImpressContentExportOOO, "com.sun.star.comp.Impress.XMLContentExporter", "XMLImpressContentExportOOO", sal_False, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2903 SERVICE( XMLImpressMetaExportOOO, "com.sun.star.comp.Impress.XMLMetaExporter", "XMLImpressMetaExportOOO", sal_False, EXPORT_META );
2904 SERVICE( XMLImpressSettingsExportOOO, "com.sun.star.comp.Impress.XMLSettingsExporter", "XMLImpressSettingsExportOOO", sal_False, EXPORT_SETTINGS );
2906 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 );
2907 SERVICE( XMLDrawStylesExportOasis, "com.sun.star.comp.Draw.XMLOasisStylesExporter", "XMLDrawStylesExportOasis", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2908 SERVICE( XMLDrawContentExportOasis, "com.sun.star.comp.Draw.XMLOasisContentExporter", "XMLDrawContentExportOasis", sal_True, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2909 SERVICE( XMLDrawMetaExportOasis, "com.sun.star.comp.Draw.XMLOasisMetaExporter", "XMLDrawMetaExportOasis", sal_True, EXPORT_OASIS|EXPORT_META );
2910 SERVICE( XMLDrawSettingsExportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsExporter", "XMLDrawSettingsExportOasis", sal_True, EXPORT_OASIS|EXPORT_SETTINGS );
2912 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 );
2913 SERVICE( XMLDrawStylesExportOOO, "com.sun.star.comp.Draw.XMLStylesExporter", "XMLDrawStylesExportOOO", sal_True, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES );
2914 SERVICE( XMLDrawContentExportOOO, "com.sun.star.comp.Draw.XMLContentExporter", "XMLDrawContentExportOOO", sal_True, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS );
2915 SERVICE( XMLDrawMetaExportOOO, "com.sun.star.comp.Draw.XMLMetaExporter", "XMLDrawMetaExportOOO", sal_True, EXPORT_META );
2916 SERVICE( XMLDrawSettingsExportOOO, "com.sun.star.comp.Draw.XMLSettingsExporter", "XMLDrawSettingsExportOOO", sal_True, EXPORT_SETTINGS );
2918 SERVICE( XMLDrawingLayerExport, "com.sun.star.comp.DrawingLayer.XMLExporter", "XMLDrawingLayerExport", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2919 SERVICE( XMLImpressClipboardExport, "com.sun.star.comp.Impress.XMLClipboardExporter", "XMLImpressClipboardExport", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS|EXPORT_EMBEDDED );
2921 // XServiceInfo
2922 OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeException )
2924 if( IsDraw())
2926 // Draw
2928 switch( getExportFlags())
2930 case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2931 return XMLDrawExportOOO_getImplementationName();
2932 case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2933 return XMLDrawStylesExportOOO_getImplementationName();
2934 case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2935 return XMLDrawContentExportOOO_getImplementationName();
2936 case EXPORT_META:
2937 return XMLDrawMetaExportOOO_getImplementationName();
2938 case EXPORT_SETTINGS:
2939 return XMLDrawSettingsExportOOO_getImplementationName();
2941 case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2942 return XMLDrawExportOasis_getImplementationName();
2943 case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2944 return XMLDrawStylesExportOasis_getImplementationName();
2945 case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2946 return XMLDrawContentExportOasis_getImplementationName();
2947 case EXPORT_OASIS|EXPORT_META:
2948 return XMLDrawMetaExportOasis_getImplementationName();
2949 case EXPORT_OASIS|EXPORT_SETTINGS:
2950 return XMLDrawSettingsExportOasis_getImplementationName();
2952 default:
2953 return XMLDrawExportOOO_getImplementationName();
2956 else
2958 // Impress
2960 switch( getExportFlags())
2962 case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2963 return XMLImpressExportOOO_getImplementationName();
2964 case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2965 return XMLImpressStylesExportOOO_getImplementationName();
2966 case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2967 return XMLImpressContentExportOOO_getImplementationName();
2968 case EXPORT_META:
2969 return XMLImpressMetaExportOOO_getImplementationName();
2970 case EXPORT_SETTINGS:
2971 return XMLImpressSettingsExportOOO_getImplementationName();
2972 case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED:
2973 return XMLImpressExportOasis_getImplementationName();
2974 case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES:
2975 return XMLImpressStylesExportOasis_getImplementationName();
2976 case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS:
2977 return XMLImpressContentExportOasis_getImplementationName();
2978 case EXPORT_OASIS|EXPORT_META:
2979 return XMLImpressMetaExportOasis_getImplementationName();
2980 case EXPORT_OASIS|EXPORT_SETTINGS:
2981 return XMLImpressSettingsExportOasis_getImplementationName();
2983 default:
2984 return XMLImpressExportOOO_getImplementationName();