Avoid potential negative array index access to cached text.
[LibreOffice.git] / xmloff / source / draw / sdxmlexp.cxx
blob289f1a542ec78c7e0f4d22525b823799a065dfaa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <string_view>
24 #include <xmloff/autolayout.hxx>
25 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
26 #include <xmloff/namespacemap.hxx>
27 #include <xmloff/xmlnamespace.hxx>
28 #include <xmloff/xmluconv.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
32 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
33 #include <com/sun/star/geometry/RealPoint2D.hpp>
34 #include <com/sun/star/office/XAnnotationAccess.hpp>
35 #include <com/sun/star/uno/Any.hxx>
36 #include "sdxmlexp_impl.hxx"
37 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
38 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
39 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
40 #include <com/sun/star/container/XIndexContainer.hpp>
41 #include <com/sun/star/view/PaperOrientation.hpp>
42 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
44 #include <com/sun/star/form/XFormsSupplier2.hpp>
45 #include <com/sun/star/presentation/XPresentationPage.hpp>
46 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
47 #include <com/sun/star/text/XText.hpp>
48 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
49 #include <com/sun/star/container/XNamed.hpp>
50 #include <com/sun/star/util/Duration.hpp>
51 #include <com/sun/star/util/MeasureUnit.hpp>
52 #include <rtl/ustrbuf.hxx>
53 #include <sal/log.hxx>
54 #include <comphelper/diagnose_ex.hxx>
55 #include <tools/gen.hxx>
56 #include <sax/tools/converter.hxx>
57 #include <xmloff/xmlaustp.hxx>
58 #include <xmloff/families.hxx>
59 #include <xmloff/styleexp.hxx>
60 #include <xmloff/settingsstore.hxx>
61 #include <xmloff/table/XMLTableExport.hxx>
62 #include <xmloff/ProgressBarHelper.hxx>
63 #include "sdpropls.hxx"
64 #include <xmloff/xmlexppr.hxx>
66 #include <PropertySetMerger.hxx>
67 #include "layerexp.hxx"
69 #include "XMLNumberStylesExport.hxx"
71 #include <xmloff/animationexport.hxx>
73 #include <com/sun/star/document/XDocumentProperties.hpp>
74 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
75 #include <com/sun/star/util/Color.hpp>
76 #include <docmodel/uno/UnoTheme.hxx>
77 #include <docmodel/theme/Theme.hxx>
78 #include <o3tl/enumrange.hxx>
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::uno;
82 using namespace ::com::sun::star::beans;
83 using namespace ::com::sun::star::util;
84 using namespace ::com::sun::star::container;
85 using namespace ::com::sun::star::drawing;
86 using namespace ::com::sun::star::office;
87 using namespace ::com::sun::star::presentation;
88 using namespace ::com::sun::star::geometry;
89 using namespace ::com::sun::star::text;
90 using namespace ::xmloff::token;
92 class ImpXMLEXPPageMasterInfo
94 sal_Int32 mnBorderBottom;
95 sal_Int32 mnBorderLeft;
96 sal_Int32 mnBorderRight;
97 sal_Int32 mnBorderTop;
98 sal_Int32 mnWidth;
99 sal_Int32 mnHeight;
100 view::PaperOrientation meOrientation;
101 OUString msName;
102 OUString msMasterPageName;
104 public:
105 ImpXMLEXPPageMasterInfo(const SdXMLExport& rExp, const Reference<XDrawPage>& xPage);
106 bool operator==(const ImpXMLEXPPageMasterInfo& rInfo) const;
107 void SetName(const OUString& rStr);
109 const OUString& GetName() const { return msName; }
110 const OUString& GetMasterPageName() const { return msMasterPageName; }
112 sal_Int32 GetBorderBottom() const { return mnBorderBottom; }
113 sal_Int32 GetBorderLeft() const { return mnBorderLeft; }
114 sal_Int32 GetBorderRight() const { return mnBorderRight; }
115 sal_Int32 GetBorderTop() const { return mnBorderTop; }
116 sal_Int32 GetWidth() const { return mnWidth; }
117 sal_Int32 GetHeight() const { return mnHeight; }
118 view::PaperOrientation GetOrientation() const { return meOrientation; }
121 ImpXMLEXPPageMasterInfo::ImpXMLEXPPageMasterInfo(
122 const SdXMLExport& rExp,
123 const Reference<XDrawPage>& xPage)
124 : mnBorderBottom(0),
125 mnBorderLeft(0),
126 mnBorderRight(0),
127 mnBorderTop(0),
128 mnWidth(0),
129 mnHeight(0),
130 meOrientation(rExp.IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
132 Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
133 if(xPropSet.is())
135 Any aAny;
137 Reference< beans::XPropertySetInfo > xPropsInfo( xPropSet->getPropertySetInfo() );
138 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("BorderBottom"))
140 aAny = xPropSet->getPropertyValue("BorderBottom");
141 aAny >>= mnBorderBottom;
143 aAny = xPropSet->getPropertyValue("BorderLeft");
144 aAny >>= mnBorderLeft;
146 aAny = xPropSet->getPropertyValue("BorderRight");
147 aAny >>= mnBorderRight;
149 aAny = xPropSet->getPropertyValue("BorderTop");
150 aAny >>= mnBorderTop;
153 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("Width"))
155 aAny = xPropSet->getPropertyValue("Width");
156 aAny >>= mnWidth;
158 aAny = xPropSet->getPropertyValue("Height");
159 aAny >>= mnHeight;
162 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("Orientation"))
164 aAny = xPropSet->getPropertyValue("Orientation");
165 aAny >>= meOrientation;
169 Reference <container::XNamed> xMasterNamed(xPage, UNO_QUERY);
170 if(xMasterNamed.is())
172 msMasterPageName = xMasterNamed->getName();
176 bool ImpXMLEXPPageMasterInfo::operator==(const ImpXMLEXPPageMasterInfo& rInfo) const
178 return ((mnBorderBottom == rInfo.mnBorderBottom)
179 && (mnBorderLeft == rInfo.mnBorderLeft)
180 && (mnBorderRight == rInfo.mnBorderRight)
181 && (mnBorderTop == rInfo.mnBorderTop)
182 && (mnWidth == rInfo.mnWidth)
183 && (mnHeight == rInfo.mnHeight)
184 && (meOrientation == rInfo.meOrientation));
187 void ImpXMLEXPPageMasterInfo::SetName(const OUString& rStr)
189 msName = rStr;
192 #define IMP_AUTOLAYOUT_INFO_MAX (35L)
194 class ImpXMLAutoLayoutInfo
196 sal_uInt16 mnType;
197 ImpXMLEXPPageMasterInfo* mpPageMasterInfo;
198 OUString msLayoutName;
199 tools::Rectangle maTitleRect;
200 tools::Rectangle maPresRect;
201 sal_Int32 mnGapX;
202 sal_Int32 mnGapY;
204 public:
205 ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf);
207 sal_uInt16 GetLayoutType() const { return mnType; }
208 ImpXMLEXPPageMasterInfo* GetPageMasterInfo() const { return mpPageMasterInfo; }
209 sal_Int32 GetGapX() const { return mnGapX; }
210 sal_Int32 GetGapY() const { return mnGapY; }
212 const OUString& GetLayoutName() const { return msLayoutName; }
213 void SetLayoutName(const OUString& rNew) { msLayoutName = rNew; }
215 const tools::Rectangle& GetTitleRectangle() const { return maTitleRect; }
216 const tools::Rectangle& GetPresRectangle() const { return maPresRect; }
218 static bool IsCreateNecessary(sal_uInt16 nTyp);
221 bool ImpXMLAutoLayoutInfo::IsCreateNecessary(sal_uInt16 nTyp)
223 if(nTyp == 5 /* AUTOLAYOUT_ORG */
224 || nTyp == 20 /* AUTOLAYOUT_NONE */
225 || nTyp >= IMP_AUTOLAYOUT_INFO_MAX)
226 return false;
227 return true;
230 ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
231 : mnType(nTyp)
232 , mpPageMasterInfo(pInf)
233 , mnGapX(0)
234 , mnGapY(0)
236 // create full info (initialize with typical values)
237 Point aPagePos(0,0);
238 Size aPageSize(28000, 21000);
239 Size aPageInnerSize(28000, 21000);
241 if(mpPageMasterInfo)
243 aPagePos = Point(mpPageMasterInfo->GetBorderLeft(), mpPageMasterInfo->GetBorderTop());
244 aPageSize = Size(mpPageMasterInfo->GetWidth(), mpPageMasterInfo->GetHeight());
245 aPageInnerSize = aPageSize;
246 aPageInnerSize.AdjustWidth(-(mpPageMasterInfo->GetBorderLeft() + mpPageMasterInfo->GetBorderRight()));
247 aPageInnerSize.AdjustHeight(-(mpPageMasterInfo->GetBorderTop() + mpPageMasterInfo->GetBorderBottom()));
250 // title rectangle aligning
251 Point aTitlePos(aPagePos);
252 Size aTitleSize(aPageInnerSize);
254 if(mnType == 21 /* AUTOLAYOUT_NOTES */)
256 aTitleSize.setHeight(static_cast<tools::Long>(aTitleSize.Height() / 2.5));
257 Point aPos = aTitlePos;
258 aPos.AdjustY( tools::Long( aTitleSize.Height() * 0.083 ) );
259 Size aPartArea = aTitleSize;
260 Size aSize;
262 // scale handout rectangle using actual page size
263 double fH = static_cast<double>(aPartArea.Width()) / aPageSize.Width();
264 double fV = static_cast<double>(aPartArea.Height()) / aPageSize.Height();
266 if ( fH > fV )
267 fH = fV;
268 aSize.setWidth( static_cast<tools::Long>(fH * aPageSize.Width()) );
269 aSize.setHeight( static_cast<tools::Long>(fH * aPageSize.Height()) );
271 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2);
272 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2);
274 aTitlePos = aPos;
275 aTitleSize = aSize;
277 else if(mnType == AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT || mnType == AUTOLAYOUT_VTITLE_VCONTENT)
279 Point aClassicTPos(
280 aTitlePos.X() + tools::Long( aTitleSize.Width() * 0.0735 ),
281 aTitlePos.Y() + tools::Long( aTitleSize.Height() * 0.083 ));
282 Size aClassicTSize(
283 tools::Long( aTitleSize.Width() * 0.854 ),
284 tools::Long( aTitleSize.Height() * 0.167 ));
285 Point aLPos(aPagePos);
286 Size aLSize(aPageInnerSize);
287 Point aClassicLPos(
288 aLPos.X() + tools::Long( aLSize.Width() * 0.0735 ),
289 aLPos.Y() + tools::Long( aLSize.Height() * 0.472 ));
290 Size aClassicLSize(
291 tools::Long( aLSize.Width() * 0.854 ),
292 tools::Long( aLSize.Height() * 0.444 ));
294 aTitlePos.setX( (aClassicTPos.X() + aClassicTSize.Width()) - aClassicTSize.Height() );
295 aTitlePos.setY( aClassicTPos.Y() );
296 aTitleSize.setWidth( aClassicTSize.Height() );
297 aTitleSize.setHeight( (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y() );
299 else
301 aTitlePos.AdjustX( tools::Long( aTitleSize.Width() * 0.0735 ) );
302 aTitlePos.AdjustY( tools::Long( aTitleSize.Height() * 0.083 ) );
303 aTitleSize.setWidth( tools::Long( aTitleSize.Width() * 0.854 ) );
304 aTitleSize.setHeight( tools::Long( aTitleSize.Height() * 0.167 ) );
307 maTitleRect.SetPos(aTitlePos);
308 maTitleRect.SetSize(aTitleSize);
310 // layout rectangle aligning
311 Point aLayoutPos(aPagePos);
312 Size aLayoutSize(aPageInnerSize);
314 if(mnType == 21 /* AUTOLAYOUT_NOTES */)
316 aLayoutPos.AdjustX( tools::Long( aLayoutSize.Width() * 0.0735 ) );
317 aLayoutPos.AdjustY( tools::Long( aLayoutSize.Height() * 0.472 ) );
318 aLayoutSize.setWidth( tools::Long( aLayoutSize.Width() * 0.854 ) );
319 aLayoutSize.setHeight( tools::Long( aLayoutSize.Height() * 0.444 ) );
321 else if((mnType >= 22 && mnType <= 26) || (mnType == 31)) // AUTOLAYOUT_HANDOUT*
323 // keep info for inner area in maPresRect, put info for gap size
324 // to maTitleRect position
325 mnGapX = (aPageSize.Width() - aPageInnerSize.Width()) / 2;
326 mnGapY = (aPageSize.Height() - aPageInnerSize.Height()) / 2;
328 if(!mnGapX)
329 mnGapX = aPageSize.Width() / 10;
331 if(!mnGapY)
332 mnGapY = aPageSize.Height() / 10;
334 if(mnGapX < aPageInnerSize.Width() / 10)
335 mnGapX = aPageInnerSize.Width() / 10;
337 if(mnGapY < aPageInnerSize.Height() / 10)
338 mnGapY = aPageInnerSize.Height() / 10;
340 else if(mnType == AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT || mnType == AUTOLAYOUT_VTITLE_VCONTENT)
342 Point aClassicTPos(
343 aTitlePos.X() + tools::Long( aTitleSize.Width() * 0.0735 ),
344 aTitlePos.Y() + tools::Long( aTitleSize.Height() * 0.083 ));
345 Size aClassicTSize(
346 tools::Long( aTitleSize.Width() * 0.854 ),
347 tools::Long( aTitleSize.Height() * 0.167 ));
348 Point aClassicLPos(
349 aLayoutPos.X() + tools::Long( aLayoutSize.Width() * 0.0735 ),
350 aLayoutPos.Y() + tools::Long( aLayoutSize.Height() * 0.472 ));
351 Size aClassicLSize(
352 tools::Long( aLayoutSize.Width() * 0.854 ),
353 tools::Long( aLayoutSize.Height() * 0.444 ));
355 aLayoutPos.setX( aClassicLPos.X() );
356 aLayoutPos.setY( aClassicTPos.Y() );
357 aLayoutSize.setWidth( (aClassicLPos.X() + aClassicLSize.Width())
358 - (aClassicTSize.Height() + (aClassicLPos.Y() - (aClassicTPos.Y() + aClassicTSize.Height()))));
359 aLayoutSize.setHeight( (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y() );
361 else if( mnType == AUTOLAYOUT_ONLY_TEXT )
363 aLayoutPos = aTitlePos;
364 aLayoutSize.setWidth( aTitleSize.Width() );
365 aLayoutSize.setHeight( tools::Long( aLayoutSize.Height() * 0.825 ) );
367 else
369 aLayoutPos.AdjustX( tools::Long( aLayoutSize.Width() * 0.0735 ) );
370 aLayoutPos.AdjustY( tools::Long( aLayoutSize.Height() * 0.278 ) );
371 aLayoutSize.setWidth( tools::Long( aLayoutSize.Width() * 0.854 ) );
372 aLayoutSize.setHeight( tools::Long( aLayoutSize.Height() * 0.630 ) );
375 maPresRect.SetPos(aLayoutPos);
376 maPresRect.SetSize(aLayoutSize);
379 constexpr OUString gsPageLayoutNames( u"PageLayoutNames"_ustr );
381 SdXMLExport::SdXMLExport(
382 const css::uno::Reference< css::uno::XComponentContext >& xContext,
383 OUString const & implementationName,
384 bool bIsDraw, SvXMLExportFlags nExportFlags )
385 : SvXMLExport( xContext, implementationName, util::MeasureUnit::CM,
386 bIsDraw ? XML_GRAPHICS : XML_PRESENTATION, nExportFlags ),
387 mnDocMasterPageCount(0),
388 mnDocDrawPageCount(0),
389 mnObjectCount(0),
390 mpHandoutPageMaster(nullptr),
391 mbIsDraw(bIsDraw)
396 // XExporter
397 void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent >& xDoc )
399 SvXMLExport::setSourceDocument( xDoc );
401 // prepare factory parts
402 mpSdPropHdlFactory = new XMLSdPropHdlFactory( GetModel(), *this );
404 // construct PropertySetMapper
405 rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( mpSdPropHdlFactory, true);
407 // get or create text paragraph export
408 GetTextParagraphExport();
409 mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, *this );
411 // chain text attributes
412 mpPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
414 // construct PresPagePropsMapper
415 xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, mpSdPropHdlFactory, true);
417 mpPresPagePropsMapper = new XMLPageExportPropertyMapper( xMapper, *this );
419 // add family name
420 GetAutoStylePool()->AddFamily(
421 XmlStyleFamily::SD_GRAPHICS_ID,
422 XML_STYLE_FAMILY_SD_GRAPHICS_NAME,
423 GetPropertySetMapper(),
424 XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX);
425 GetAutoStylePool()->AddFamily(
426 XmlStyleFamily::SD_PRESENTATION_ID,
427 XML_STYLE_FAMILY_SD_PRESENTATION_NAME,
428 GetPropertySetMapper(),
429 XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX);
430 GetAutoStylePool()->AddFamily(
431 XmlStyleFamily::SD_DRAWINGPAGE_ID,
432 XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME,
433 GetPresPagePropsMapper(),
434 XML_STYLE_FAMILY_SD_DRAWINGPAGE_PREFIX);
435 // prepare access to styles
436 Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), UNO_QUERY );
437 if(xFamSup.is())
439 mxDocStyleFamilies = xFamSup->getStyleFamilies();
442 // prepare access to master pages
443 Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), UNO_QUERY);
444 if(xMasterPagesSupplier.is())
446 mxDocMasterPages = xMasterPagesSupplier->getMasterPages();
447 if(mxDocMasterPages.is())
449 mnDocMasterPageCount = mxDocMasterPages->getCount();
450 maMasterPagesStyleNames.insert( maMasterPagesStyleNames.begin(), mnDocMasterPageCount, "" );
454 // prepare access to draw pages
455 Reference <XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), UNO_QUERY);
456 if(xDrawPagesSupplier.is())
458 mxDocDrawPages = xDrawPagesSupplier->getDrawPages();
459 if(mxDocDrawPages.is())
461 mnDocDrawPageCount = mxDocDrawPages->getCount();
462 maDrawPagesStyleNames.insert( maDrawPagesStyleNames.begin(), mnDocDrawPageCount, "" );
463 maDrawNotesPagesStyleNames.insert( maDrawNotesPagesStyleNames.begin(), mnDocDrawPageCount, "" );
464 if( !mbIsDraw )
465 maDrawPagesAutoLayoutNames.realloc( mnDocDrawPageCount + 1 );
467 HeaderFooterPageSettingsImpl aEmptySettings;
468 maDrawPagesHeaderFooterSettings.insert( maDrawPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
469 maDrawNotesPagesHeaderFooterSettings.insert( maDrawNotesPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
473 // #82003# count all draw objects for use with progress bar.
474 // #88245# init mnObjectCount once, use counter itself as flag. It
475 // is initialized to 0.
476 if(!mnObjectCount)
478 if( IsImpress() )
480 // #91587# add handout master count
481 Reference<presentation::XHandoutMasterSupplier> xHandoutSupp(GetModel(), UNO_QUERY);
482 if(xHandoutSupp.is())
484 Reference<XDrawPage> xHandoutPage(xHandoutSupp->getHandoutMasterPage());
485 if(xHandoutPage.is() && xHandoutPage->getCount())
486 mnObjectCount += ImpRecursiveObjectCount(xHandoutPage);
490 if(mxDocMasterPages.is())
492 for(sal_Int32 a(0); a < mnDocMasterPageCount; a++)
494 Any aAny(mxDocMasterPages->getByIndex(a));
495 Reference< drawing::XShapes > xMasterPage;
497 if((aAny >>= xMasterPage) && xMasterPage.is())
499 mnObjectCount += ImpRecursiveObjectCount(xMasterPage);
502 if( IsImpress() )
504 // #91587# take notes pages from master pages into account
505 Reference<presentation::XPresentationPage> xPresPage;
506 if((aAny >>= xPresPage) && xPresPage.is())
508 Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
509 if(xNotesPage.is() && xNotesPage->getCount())
510 mnObjectCount += ImpRecursiveObjectCount(xNotesPage);
516 if(mxDocDrawPages.is())
518 for(sal_Int32 a(0); a < mnDocDrawPageCount; a++)
520 Any aAny(mxDocDrawPages->getByIndex(a));
521 Reference< drawing::XShapes > xPage;
523 if((aAny >>= xPage) && xPage.is())
525 mnObjectCount += ImpRecursiveObjectCount(xPage);
528 if( IsImpress() )
530 // #91587# take notes pages from draw pages into account
531 Reference<presentation::XPresentationPage> xPresPage;
532 if((aAny >>= xPresPage) && xPresPage.is())
534 Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
535 if(xNotesPage.is() && xNotesPage->getCount())
536 mnObjectCount += ImpRecursiveObjectCount(xNotesPage);
542 // #82003# init progress bar
543 GetProgressBarHelper()->SetReference(mnObjectCount);
546 // add namespaces
547 GetNamespaceMap_().Add(
548 GetXMLToken(XML_NP_PRESENTATION),
549 GetXMLToken(XML_N_PRESENTATION),
550 XML_NAMESPACE_PRESENTATION);
552 GetNamespaceMap_().Add(
553 GetXMLToken(XML_NP_SMIL),
554 GetXMLToken(XML_N_SMIL_COMPAT),
555 XML_NAMESPACE_SMIL);
557 GetNamespaceMap_().Add(
558 GetXMLToken(XML_NP_ANIMATION),
559 GetXMLToken(XML_N_ANIMATION),
560 XML_NAMESPACE_ANIMATION);
562 if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
564 GetNamespaceMap_().Add(
565 GetXMLToken(XML_NP_OFFICE_EXT),
566 GetXMLToken(XML_N_OFFICE_EXT),
567 XML_NAMESPACE_OFFICE_EXT);
570 GetShapeExport()->enableLayerExport();
572 // #88546# enable progress bar increments
573 GetShapeExport()->enableHandleProgressBar();
576 // #82003# helper function for recursive object count
577 sal_uInt32 SdXMLExport::ImpRecursiveObjectCount(const Reference< drawing::XShapes >& xShapes)
579 sal_uInt32 nRetval(0);
581 if(xShapes.is())
583 sal_Int32 nCount = xShapes->getCount();
585 for(sal_Int32 a(0); a < nCount; a++)
587 Any aAny(xShapes->getByIndex(a));
588 Reference< drawing::XShapes > xGroup;
590 if((aAny >>= xGroup) && xGroup.is())
592 // #93180# count group objects, too.
593 nRetval += 1 + ImpRecursiveObjectCount(xGroup);
595 else
597 nRetval++;
602 return nRetval;
605 SdXMLExport::~SdXMLExport()
607 // cleanup factory, decrease refcount. Should lead to destruction.
608 mpSdPropHdlFactory.clear();
610 // cleanup mapper, decrease refcount. Should lead to destruction.
611 mpPropertySetMapper.clear();
613 // cleanup presPage mapper, decrease refcount. Should lead to destruction.
614 mpPresPagePropsMapper.clear();
616 mvPageMasterInfoList.clear();
618 // clear auto-layout infos
619 mvAutoLayoutInfoList.clear();
622 void SdXMLExport::ImpPrepAutoLayoutInfos()
624 if(!IsImpress())
625 return;
627 OUString aStr;
628 auto DrawPagesAutoLayoutNamesRange = asNonConstRange(maDrawPagesAutoLayoutNames);
629 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
630 if( xHandoutSupp.is() )
632 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
633 if( xHandoutPage.is() )
635 if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr))
636 DrawPagesAutoLayoutNamesRange[0] = aStr;
640 // prepare name creation
641 for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
643 Any aAny(mxDocDrawPages->getByIndex(nCnt));
644 Reference<XDrawPage> xDrawPage;
646 if((aAny >>= xDrawPage) && xDrawPage.is())
648 if(ImpPrepAutoLayoutInfo(xDrawPage, aStr))
649 DrawPagesAutoLayoutNamesRange[nCnt+1] = aStr;
654 bool SdXMLExport::ImpPrepAutoLayoutInfo(const Reference<XDrawPage>& xPage, OUString& rName)
656 rName.clear();
657 bool bRetval(false);
659 Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
660 if(xPropSet.is())
662 sal_uInt16 nType = sal_uInt16();
663 Any aAny = xPropSet->getPropertyValue("Layout");
664 if(aAny >>= nType)
666 if(ImpXMLAutoLayoutInfo::IsCreateNecessary(nType))
668 ImpXMLEXPPageMasterInfo* pInfo = nullptr;
670 // get master-page info
671 Reference < drawing::XMasterPageTarget > xMasterPageInt(xPage, UNO_QUERY);
672 if(xMasterPageInt.is())
674 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
675 if(xUsedMasterPage.is())
677 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
678 if(xMasterNamed.is())
680 OUString sMasterPageName = xMasterNamed->getName();
681 pInfo = ImpGetPageMasterInfoByName(sMasterPageName);
686 // create entry and look for existence
687 ImpXMLAutoLayoutInfo* pNew;
688 auto it = std::find_if(mvAutoLayoutInfoList.begin(), mvAutoLayoutInfoList.end(),
689 [=](std::unique_ptr<ImpXMLAutoLayoutInfo> const & rInfo) { return nType == rInfo->GetLayoutType() && pInfo == rInfo->GetPageMasterInfo(); });
690 if (it != mvAutoLayoutInfoList.end())
692 pNew = it->get();
694 else
696 pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
697 mvAutoLayoutInfoList.emplace_back( pNew );
698 OUString sNewName =
699 "AL" + OUString::number(mvAutoLayoutInfoList.size() - 1) +
700 "T" + OUString::number(nType);
701 pNew->SetLayoutName(sNewName);
704 rName = pNew->GetLayoutName();
705 bRetval = true;
710 return bRetval;
713 void SdXMLExport::ImpWriteAutoLayoutInfos()
715 for(const auto & pInfo : mvAutoLayoutInfoList)
717 if(pInfo)
719 // prepare presentation-page layout attributes, style-name
720 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, pInfo->GetLayoutName());
722 // write draw-style attributes
723 SvXMLElementExport aDSE(*this, XML_NAMESPACE_STYLE, XML_PRESENTATION_PAGE_LAYOUT, true, true);
725 // write presentation placeholders
726 switch(pInfo->GetLayoutType())
728 case AUTOLAYOUT_TITLE :
730 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
731 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
732 break;
734 case AUTOLAYOUT_TITLE_CONTENT :
736 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
737 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, pInfo->GetPresRectangle());
738 break;
740 case AUTOLAYOUT_CHART :
742 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
743 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, pInfo->GetPresRectangle());
744 break;
746 case AUTOLAYOUT_TITLE_2CONTENT :
748 tools::Rectangle aLeft(pInfo->GetPresRectangle());
749 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
750 tools::Rectangle aRight(aLeft);
751 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
753 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
754 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
755 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
756 break;
758 case AUTOLAYOUT_TEXTCHART :
760 tools::Rectangle aLeft(pInfo->GetPresRectangle());
761 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
762 tools::Rectangle aRight(aLeft);
763 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
765 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
766 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
767 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aRight);
768 break;
770 case AUTOLAYOUT_TEXTCLIP :
772 tools::Rectangle aLeft(pInfo->GetPresRectangle());
773 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
774 tools::Rectangle aRight(aLeft);
775 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
777 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
778 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
779 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aRight);
780 break;
782 case AUTOLAYOUT_CHARTTEXT :
784 tools::Rectangle aLeft(pInfo->GetPresRectangle());
785 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
786 tools::Rectangle aRight(aLeft);
787 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
789 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
790 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aLeft);
791 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
792 break;
794 case AUTOLAYOUT_TAB :
796 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
797 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTable, pInfo->GetPresRectangle());
798 break;
800 case AUTOLAYOUT_CLIPTEXT :
802 tools::Rectangle aLeft(pInfo->GetPresRectangle());
803 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
804 tools::Rectangle aRight(aLeft);
805 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
807 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
808 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
809 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
810 break;
812 case AUTOLAYOUT_TEXTOBJ :
814 tools::Rectangle aLeft(pInfo->GetPresRectangle());
815 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
816 tools::Rectangle aRight(aLeft);
817 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
819 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
820 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
821 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRight);
822 break;
824 case AUTOLAYOUT_OBJ :
826 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
827 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, pInfo->GetPresRectangle());
828 break;
830 case AUTOLAYOUT_TITLE_CONTENT_2CONTENT :
832 tools::Rectangle aLeft(pInfo->GetPresRectangle());
833 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
834 tools::Rectangle aRightTop(aLeft);
835 aRightTop.AdjustLeft(aRightTop.GetWidth() * 1.05);
836 aRightTop.setHeight(tools::Long(aRightTop.GetHeight() * 0.477));
837 tools::Rectangle aRightBottom(aRightTop);
838 aRightBottom.AdjustTop(aRightBottom.GetHeight() * 1.095);
840 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
841 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
842 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightTop);
843 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightBottom);
844 break;
846 case AUTOLAYOUT_OBJTEXT :
848 tools::Rectangle aLeft(pInfo->GetPresRectangle());
849 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
850 tools::Rectangle aRight(aLeft);
851 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
853 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
854 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeft);
855 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
856 break;
858 case AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT :
860 tools::Rectangle aTop(pInfo->GetPresRectangle());
861 aTop.setHeight(tools::Long(aTop.GetHeight() * 0.477));
862 tools::Rectangle aBottom(aTop);
863 aBottom.AdjustTop(aBottom.GetHeight() * 1.095);
865 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
866 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTop);
867 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
868 break;
870 case AUTOLAYOUT_TITLE_2CONTENT_CONTENT :
872 tools::Rectangle aLeftTop(pInfo->GetPresRectangle());
873 aLeftTop.setWidth(tools::Long(aLeftTop.GetWidth() * 0.488));
874 tools::Rectangle aRight(aLeftTop);
875 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
876 aLeftTop.setHeight(tools::Long(aLeftTop.GetHeight() * 0.477));
877 tools::Rectangle aLeftBottom(aLeftTop);
878 aLeftBottom.AdjustTop(aLeftBottom.GetHeight() * 1.095);
880 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
881 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftTop);
882 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftBottom);
883 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
884 break;
886 case AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT :
888 tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
889 aTopLeft.setHeight(tools::Long(aTopLeft.GetHeight() * 0.477));
890 tools::Rectangle aBottom(aTopLeft);
891 aBottom.AdjustTop(aBottom.GetHeight() * 1.095);
892 aTopLeft.setWidth(tools::Long(aTopLeft.GetWidth() * 0.488));
893 tools::Rectangle aTopRight(aTopLeft);
894 aTopRight.AdjustLeft(aTopRight.GetWidth() * 1.05);
896 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
897 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
898 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
899 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
900 break;
902 case AUTOLAYOUT_TEXTOVEROBJ :
904 tools::Rectangle aTop(pInfo->GetPresRectangle());
905 aTop.setHeight(tools::Long(aTop.GetHeight() * 0.477));
906 tools::Rectangle aBottom(aTop);
907 aBottom.AdjustTop(aBottom.GetHeight() * 1.095);
909 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
910 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aTop);
911 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottom);
912 break;
914 case AUTOLAYOUT_TITLE_4CONTENT :
916 tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
917 aTopLeft.setHeight(tools::Long(aTopLeft.GetHeight() * 0.477));
918 aTopLeft.setWidth(tools::Long(aTopLeft.GetWidth() * 0.488));
919 tools::Rectangle aBottomLeft(aTopLeft);
920 aBottomLeft.AdjustTop(aBottomLeft.GetHeight() * 1.095);
921 tools::Rectangle aTopRight(aTopLeft);
922 aTopRight.AdjustLeft(aTopRight.GetWidth() * 1.05);
923 tools::Rectangle aBottomRight(aTopRight);
924 aBottomRight.AdjustTop(aBottomRight.GetHeight() * 1.095);
926 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
927 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
928 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
929 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomLeft);
930 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomRight);
931 break;
933 case AUTOLAYOUT_TITLE_ONLY :
935 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
936 break;
938 case AUTOLAYOUT_NOTES :
940 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderPage, pInfo->GetTitleRectangle());
941 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderNotes, pInfo->GetPresRectangle());
942 break;
944 case AUTOLAYOUT_HANDOUT1 :
945 case AUTOLAYOUT_HANDOUT2 :
946 case AUTOLAYOUT_HANDOUT3 :
947 case AUTOLAYOUT_HANDOUT4 :
948 case AUTOLAYOUT_HANDOUT6 :
949 case AUTOLAYOUT_HANDOUT9 :
951 sal_Int32 nColCnt, nRowCnt;
952 sal_Int32 nGapX = pInfo->GetGapX();
953 sal_Int32 nGapY = pInfo->GetGapY();
955 switch(pInfo->GetLayoutType())
957 case 22 : nColCnt = 1; nRowCnt = 1; break;
958 case 23 : nColCnt = 1; nRowCnt = 2; break;
959 case 24 : nColCnt = 1; nRowCnt = 3; break;
960 case 25 : nColCnt = 2; nRowCnt = 2; break;
961 case 26 : nColCnt = 3; nRowCnt = 2; break;
962 case 31 : nColCnt = 3; nRowCnt = 3; break;
963 default: nColCnt = 0; nRowCnt = 0; break; // FIXME - What is correct values?
966 Size aPartSize(pInfo->GetTitleRectangle().GetSize());
967 Point aPartPos(pInfo->GetTitleRectangle().TopLeft());
969 if(aPartSize.Width() > aPartSize.Height())
971 sal_Int32 nZwi(nColCnt);
972 nColCnt = nRowCnt;
973 nRowCnt = nZwi;
976 if (nColCnt == 0 || nRowCnt == 0)
977 break;
979 aPartSize.setWidth( (aPartSize.Width() - ((nColCnt - 1) * nGapX)) / nColCnt );
980 aPartSize.setHeight( (aPartSize.Height() - ((nRowCnt - 1) * nGapY)) / nRowCnt );
982 Point aTmpPos(aPartPos);
984 for (sal_Int32 a = 0; a < nRowCnt; a++)
986 aTmpPos.setX(aPartPos.X());
988 for (sal_Int32 b = 0; b < nColCnt; b++)
990 tools::Rectangle aTmpRect(aTmpPos, aPartSize);
992 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderHandout, aTmpRect);
993 aTmpPos.AdjustX( aPartSize.Width() + nGapX );
996 aTmpPos.AdjustY( aPartSize.Height() + nGapY );
998 break;
1000 case AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT :
1002 tools::Rectangle aTop(pInfo->GetPresRectangle());
1003 aTop.setHeight(tools::Long(aTop.GetHeight() * 0.488));
1004 tools::Rectangle aBottom(aTop);
1005 aBottom.AdjustTop(aBottom.GetHeight() * 1.05);
1007 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1008 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aTop);
1009 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aBottom);
1010 break;
1012 case AUTOLAYOUT_VTITLE_VCONTENT :
1014 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
1015 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1016 break;
1018 case AUTOLAYOUT_TITLE_VCONTENT :
1020 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1021 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
1022 break;
1024 case AUTOLAYOUT_TITLE_2VTEXT :
1026 tools::Rectangle aLeft(pInfo->GetPresRectangle());
1027 aLeft.setWidth(tools::Long(aLeft.GetWidth() * 0.488));
1028 tools::Rectangle aRight(aLeft);
1029 aRight.AdjustLeft(aRight.GetWidth() * 1.05);
1031 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1032 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
1033 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aRight);
1034 break;
1036 case AUTOLAYOUT_ONLY_TEXT :
1038 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
1039 break;
1042 case AUTOLAYOUT_4CLIPART :
1044 tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
1045 aTopLeft.setHeight(tools::Long(aTopLeft.GetHeight() * 0.477));
1046 aTopLeft.setWidth(tools::Long(aTopLeft.GetWidth() * 0.488));
1047 tools::Rectangle aBottomLeft(aTopLeft);
1048 aBottomLeft.AdjustTop(aBottomLeft.GetHeight() * 1.095);
1049 tools::Rectangle aTopRight(aTopLeft);
1050 aTopRight.AdjustLeft(aTopRight.GetWidth() * 1.05);
1051 tools::Rectangle aBottomRight(aTopRight);
1052 aBottomRight.AdjustTop(aBottomRight.GetHeight() * 1.095);
1054 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1055 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1056 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1057 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1058 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1059 break;
1062 case AUTOLAYOUT_TITLE_6CONTENT :
1064 tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
1065 aTopLeft.setHeight(tools::Long(aTopLeft.GetHeight() * 0.477));
1066 aTopLeft.setWidth(tools::Long(aTopLeft.GetWidth() * 0.322));
1067 tools::Rectangle aTopCenter(aTopLeft);
1068 aTopCenter.AdjustLeft(aTopCenter.GetWidth() * 1.05);
1069 tools::Rectangle aTopRight(aTopLeft);
1070 aTopRight.AdjustLeft(aTopRight.GetWidth() * 2 * 1.05);
1072 tools::Rectangle aBottomLeft(aTopLeft);
1073 aBottomLeft.AdjustTop(aBottomLeft.GetHeight() * 1.095);
1074 tools::Rectangle aBottomCenter(aTopCenter);
1075 aBottomCenter.AdjustTop(aBottomCenter.GetHeight() * 1.095);
1076 tools::Rectangle aBottomRight(aTopRight);
1077 aBottomRight.AdjustTop(aBottomRight.GetHeight() * 1.095);
1079 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
1080 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
1081 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopCenter);
1082 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
1083 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
1084 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomCenter);
1085 ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
1086 break;
1088 default:
1090 OSL_FAIL("XMLEXP: unknown autolayout export");
1091 break;
1098 void SdXMLExport::ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl, const tools::Rectangle& rRect)
1100 OUString aStr;
1101 OUStringBuffer sStringBuffer;
1103 // prepare presentation-placeholder attributes, presentation:object
1104 switch(ePl)
1106 case XmlPlaceholderTitle: aStr = "title"; break;
1107 case XmlPlaceholderOutline: aStr = "outline"; break;
1108 case XmlPlaceholderSubtitle: aStr = "subtitle"; break;
1109 case XmlPlaceholderGraphic: aStr = "graphic"; break;
1110 case XmlPlaceholderObject: aStr = "object"; break;
1111 case XmlPlaceholderChart: aStr = "chart"; break;
1112 case XmlPlaceholderTable: aStr = "table"; break;
1113 case XmlPlaceholderPage: aStr = "page"; break;
1114 case XmlPlaceholderNotes: aStr = "notes"; break;
1115 case XmlPlaceholderHandout: aStr = "handout"; break;
1116 case XmlPlaceholderVerticalTitle: aStr = "vertical_title"; break;
1117 case XmlPlaceholderVerticalOutline: aStr = "vertical_outline"; break;
1120 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_OBJECT, aStr);
1122 // svg:x,y,width,height
1123 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, rRect.Left());
1124 aStr = sStringBuffer.makeStringAndClear();
1125 AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
1127 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, rRect.Top());
1128 aStr = sStringBuffer.makeStringAndClear();
1129 AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
1131 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1132 rRect.GetWidth());
1133 aStr = sStringBuffer.makeStringAndClear();
1134 AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
1136 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1137 rRect.GetHeight());
1138 aStr = sStringBuffer.makeStringAndClear();
1139 AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
1141 // write presentation-placeholder
1142 SvXMLElementExport aPPL(*this, XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, true, true);
1145 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetOrCreatePageMasterInfo( const Reference< XDrawPage >& xMasterPage )
1147 bool bDoesExist = false;
1149 ImpXMLEXPPageMasterInfo* pNewInfo = new ImpXMLEXPPageMasterInfo(*this, xMasterPage);
1151 // compare with prev page-master infos
1152 for( size_t a = 0; !bDoesExist && a < mvPageMasterInfoList.size(); a++)
1154 if ( mvPageMasterInfoList.at(a)
1155 && *mvPageMasterInfoList.at(a) == *pNewInfo
1158 delete pNewInfo;
1159 pNewInfo = mvPageMasterInfoList.at(a).get();
1160 bDoesExist = true;
1163 // add entry when not found same page-master infos
1164 if(!bDoesExist)
1165 mvPageMasterInfoList.emplace_back( pNewInfo );
1167 return pNewInfo;
1170 void SdXMLExport::ImpPrepPageMasterInfos()
1172 if( IsImpress() )
1174 // create page master info for handout master page
1176 Reference< XHandoutMasterSupplier > xHMS( GetModel(), UNO_QUERY );
1177 if( xHMS.is() )
1179 Reference< XDrawPage > xMasterPage( xHMS->getHandoutMasterPage() );
1180 if( xMasterPage.is() )
1181 mpHandoutPageMaster = ImpGetOrCreatePageMasterInfo(xMasterPage);
1185 // create page master infos for master pages
1186 if(!mnDocMasterPageCount)
1187 return;
1189 // look for needed page-masters, create these
1190 for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
1192 Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
1193 ImpXMLEXPPageMasterInfo* pNewInfo = nullptr;
1195 if(xMasterPage.is())
1196 pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage);
1198 mvPageMasterUsageList.push_back( pNewInfo );
1200 // look for page master of handout page
1201 if(IsImpress())
1203 pNewInfo = nullptr;
1204 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
1205 if(xPresPage.is())
1207 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
1208 if(xNotesPage.is())
1210 pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage);
1213 mvNotesPageMasterUsageList.push_back( pNewInfo );
1218 void SdXMLExport::ImpWritePageMasterInfos()
1220 // write created page-masters, create names for these
1221 for( size_t nCnt = 0; nCnt < mvPageMasterInfoList.size(); nCnt++)
1223 ImpXMLEXPPageMasterInfo* pInfo = mvPageMasterInfoList.at(nCnt).get();
1224 if(pInfo)
1226 // create name
1227 OUString sNewName = "PM" + OUString::number(nCnt);
1228 pInfo->SetName(sNewName);
1230 // prepare page-master attributes
1231 OUString sString;
1232 OUStringBuffer sStringBuffer;
1234 sString = sNewName;
1235 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sString);
1237 // write page-layout
1238 SvXMLElementExport aPME(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT, true, true);
1240 // prepare style:properties inside page-master
1241 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1242 pInfo->GetBorderTop());
1243 sString = sStringBuffer.makeStringAndClear();
1244 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_TOP, sString);
1246 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1247 pInfo->GetBorderBottom());
1248 sString = sStringBuffer.makeStringAndClear();
1249 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, sString);
1251 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1252 pInfo->GetBorderLeft());
1253 sString = sStringBuffer.makeStringAndClear();
1254 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_LEFT, sString);
1256 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1257 pInfo->GetBorderRight());
1258 sString = sStringBuffer.makeStringAndClear();
1259 AddAttribute(XML_NAMESPACE_FO, XML_MARGIN_RIGHT, sString);
1261 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1262 pInfo->GetWidth());
1263 sString = sStringBuffer.makeStringAndClear();
1264 AddAttribute(XML_NAMESPACE_FO, XML_PAGE_WIDTH, sString);
1266 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1267 pInfo->GetHeight());
1268 sString = sStringBuffer.makeStringAndClear();
1269 AddAttribute(XML_NAMESPACE_FO, XML_PAGE_HEIGHT, sString);
1271 if(pInfo->GetOrientation() == view::PaperOrientation_PORTRAIT)
1272 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_PORTRAIT);
1273 else
1274 AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_LANDSCAPE);
1276 // write style:properties
1277 SvXMLElementExport aPMF(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_PROPERTIES, true, true);
1282 ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(std::u16string_view rName)
1284 if(!rName.empty())
1286 for(const auto & pInfo : mvPageMasterInfoList)
1288 if(pInfo)
1290 if(!pInfo->GetMasterPageName().isEmpty() && rName == pInfo->GetMasterPageName())
1292 return pInfo.get();
1297 return nullptr;
1300 void SdXMLExport::ImpPrepDrawPageInfos()
1302 // create draw:style-name entries for page export
1303 // containing presentation page attributes AND background attributes
1304 // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1306 sal_Int32 nCnt;
1307 for(nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
1309 Reference<XDrawPage> xDrawPage;
1310 mxDocDrawPages->getByIndex(nCnt) >>= xDrawPage;
1311 maDrawPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1313 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
1314 if(xPresPage.is())
1316 maDrawNotesPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xPresPage->getNotesPage(), false );
1318 maDrawPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xDrawPage );
1319 maDrawNotesPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xPresPage->getNotesPage() );
1324 static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, std::u16string_view pPrefix )
1326 // search rVector if there is already a string that equals rText
1327 auto aIter = std::find(rVector.begin(), rVector.end(), rText);
1328 sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;
1330 // if nothing is found, append the string at the end of rVector
1331 if( aIter == rVector.end() )
1332 rVector.push_back( rText );
1334 // create a reference string with pPrefix and the index of the
1335 // found or created rText
1336 return pPrefix + OUString::number( nIndex );
1339 static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, bool bFixed, sal_Int32 nFormat, std::u16string_view pPrefix )
1341 // search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
1342 auto aIter = std::find_if(rVector.begin(), rVector.end(),
1343 [bFixed, &rText, nFormat](const DateTimeDeclImpl& rDecl) {
1344 return (rDecl.mbFixed == bFixed) &&
1345 (!bFixed || (rDecl.maStrText == rText)) &&
1346 (bFixed || (rDecl.mnFormat == nFormat));
1348 sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;
1350 // if nothing is found, append a new DateTimeDeclImpl
1351 if( aIter == rVector.end() )
1353 DateTimeDeclImpl aDecl;
1354 aDecl.maStrText = rText;
1355 aDecl.mbFixed = bFixed;
1356 aDecl.mnFormat = nFormat;
1357 rVector.push_back( aDecl );
1360 // create a reference string with pPrefix and the index of the
1361 // found or created DateTimeDeclImpl
1362 return pPrefix + OUString::number( nIndex );
1365 constexpr OUString gpStrHeaderTextPrefix = u"hdr"_ustr;
1366 constexpr OUString gpStrFooterTextPrefix = u"ftr"_ustr;
1367 constexpr OUString gpStrDateTimeTextPrefix = u"dtd"_ustr;
1369 HeaderFooterPageSettingsImpl SdXMLExport::ImpPrepDrawPageHeaderFooterDecls( const Reference<XDrawPage>& xDrawPage )
1371 HeaderFooterPageSettingsImpl aSettings;
1373 if( xDrawPage.is() ) try
1375 Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
1376 Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
1378 OUString aStrText;
1380 static constexpr OUString aStrHeaderTextProp( u"HeaderText"_ustr );
1381 if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
1383 xSet->getPropertyValue( aStrHeaderTextProp ) >>= aStrText;
1384 if( !aStrText.isEmpty() )
1385 aSettings.maStrHeaderDeclName = findOrAppendImpl( maHeaderDeclsVector, aStrText, gpStrHeaderTextPrefix );
1388 static constexpr OUString aStrFooterTextProp( u"FooterText"_ustr );
1389 if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
1391 xSet->getPropertyValue( aStrFooterTextProp ) >>= aStrText;
1392 if( !aStrText.isEmpty() )
1393 aSettings.maStrFooterDeclName = findOrAppendImpl( maFooterDeclsVector, aStrText, gpStrFooterTextPrefix );
1396 static constexpr OUString aStrDateTimeTextProp( u"DateTimeText"_ustr );
1397 if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
1399 bool bFixed = false;
1400 sal_Int32 nFormat = 0;
1401 xSet->getPropertyValue( aStrDateTimeTextProp ) >>= aStrText;
1402 xSet->getPropertyValue("IsDateTimeFixed") >>= bFixed;
1403 xSet->getPropertyValue("DateTimeFormat") >>= nFormat;
1405 if( !bFixed || !aStrText.isEmpty() )
1407 aSettings.maStrDateTimeDeclName = findOrAppendImpl( maDateTimeDeclsVector, aStrText, bFixed, nFormat, gpStrDateTimeTextPrefix );
1408 if( !bFixed )
1409 addDataStyle( nFormat );
1413 catch(const Exception&)
1415 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1418 return aSettings;
1421 void SdXMLExport::ImpWriteHeaderFooterDecls()
1423 OUStringBuffer sBuffer;
1425 if( !maHeaderDeclsVector.empty() )
1427 // export header decls
1428 const OUString aPrefix( gpStrHeaderTextPrefix );
1429 sal_Int32 nIndex = 1;
1430 for( const auto& rDecl : maHeaderDeclsVector )
1432 sBuffer.append( aPrefix + OUString::number( nIndex ) );
1433 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1435 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, true, true);
1436 Characters(rDecl);
1437 ++nIndex;
1441 if( !maFooterDeclsVector.empty() )
1443 // export footer decls
1444 const OUString aPrefix( gpStrFooterTextPrefix );
1445 sal_Int32 nIndex = 1;
1446 for( const auto& rDecl : maFooterDeclsVector )
1448 sBuffer.append( aPrefix + OUString::number( nIndex ) );
1449 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1451 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, false, false);
1452 Characters(rDecl);
1453 ++nIndex;
1457 if( maDateTimeDeclsVector.empty() )
1458 return;
1460 // export footer decls
1461 const OUString aPrefix( gpStrDateTimeTextPrefix );
1462 sal_Int32 nIndex = 1;
1463 for( const auto& rDecl : maDateTimeDeclsVector )
1465 sBuffer.append( aPrefix + OUString::number( nIndex ) );
1466 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
1468 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE );
1470 if( !rDecl.mbFixed )
1471 AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) );
1473 SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, false, false);
1474 if( rDecl.mbFixed )
1475 Characters(rDecl.maStrText);
1477 ++nIndex;
1481 void SdXMLExport::ImplExportHeaderFooterDeclAttributes( const HeaderFooterPageSettingsImpl& aSettings )
1483 if( !aSettings.maStrHeaderDeclName.isEmpty() )
1484 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, aSettings.maStrHeaderDeclName );
1486 if( !aSettings.maStrFooterDeclName.isEmpty() )
1487 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, aSettings.maStrFooterDeclName );
1489 if( !aSettings.maStrDateTimeDeclName.isEmpty() )
1490 AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, aSettings.maStrDateTimeDeclName );
1493 OUString SdXMLExport::ImpCreatePresPageStyleName( const Reference<XDrawPage>& xDrawPage, bool bExportBackground /* = true */ )
1495 // create name
1496 OUString sStyleName;
1498 // create style for this page and add to auto style pool
1500 Reference< beans::XPropertySet > xPropSet1(xDrawPage, UNO_QUERY);
1501 if(xPropSet1.is())
1503 Reference< beans::XPropertySet > xPropSet;
1505 if( bExportBackground )
1507 // since the background items are in a different propertyset
1508 // which itself is a property of the pages property set
1509 // we now merge these two propertysets if possible to simulate
1510 // a single propertyset with all draw page properties
1511 static constexpr OUString aBackground(u"Background"_ustr);
1512 Reference< beans::XPropertySet > xPropSet2;
1513 Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
1514 if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
1516 Any aAny( xPropSet1->getPropertyValue( aBackground ) );
1517 aAny >>= xPropSet2;
1520 if( xPropSet2.is() )
1521 xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xPropSet2 );
1522 else
1523 xPropSet = xPropSet1;
1525 else
1527 xPropSet = xPropSet1;
1530 const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );
1532 std::vector<XMLPropertyState> aPropStates(aMapperRef->Filter(*this, xPropSet));
1534 if( !aPropStates.empty() )
1536 // there are filtered properties -> hard attributes
1537 // try to find this style in AutoStylePool
1538 sStyleName = GetAutoStylePool()->Find(XmlStyleFamily::SD_DRAWINGPAGE_ID, sStyleName, aPropStates);
1540 if(sStyleName.isEmpty())
1542 // Style did not exist, add it to AutoStalePool
1543 sStyleName = GetAutoStylePool()->Add(XmlStyleFamily::SD_DRAWINGPAGE_ID, sStyleName, std::move(aPropStates));
1548 return sStyleName;
1551 void SdXMLExport::ImpPrepMasterPageInfos()
1553 // create draw:style-name entries for master page export
1554 // containing only background attributes
1555 // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
1557 sal_Int32 nCnt;
1558 for( nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
1560 Reference<XDrawPage> xDrawPage;
1561 mxDocMasterPages->getByIndex(nCnt) >>= xDrawPage;
1562 maMasterPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
1565 if( !IsImpress() )
1566 return;
1568 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
1569 if( xHandoutSupp.is() )
1571 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
1572 if( xHandoutPage.is() )
1574 maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage );
1575 maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false );
1580 void SdXMLExport::ImpWritePresentationStyles()
1582 if(!IsImpress())
1583 return;
1585 for (sal_Int32 nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
1587 Any aAny(mxDocMasterPages->getByIndex(nCnt));
1588 Reference<container::XNamed> xNamed;
1590 if(aAny >>= xNamed)
1592 // write presentation styles (ONLY if presentation)
1593 if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
1595 rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(*this, GetAutoStylePool().get()));
1596 const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
1598 OUString aPrefix( xNamed->getName() + "-" );
1600 aStEx->exportStyleFamily(xNamed->getName(),
1601 XML_STYLE_FAMILY_SD_PRESENTATION_NAME,
1602 aMapperRef, false,
1603 XmlStyleFamily::SD_PRESENTATION_ID, &aPrefix);
1609 void SdXMLExport::ExportMeta_()
1611 uno::Sequence<beans::NamedValue> stats { { "ObjectCount", uno::Any(mnObjectCount) } };
1613 // update document statistics at the model
1614 uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(GetModel(),
1615 uno::UNO_QUERY_THROW);
1616 uno::Reference<document::XDocumentProperties> xDocProps(
1617 xPropSup->getDocumentProperties());
1618 if (xDocProps.is()) {
1619 xDocProps->setDocumentStatistics(stats);
1622 // call parent
1623 SvXMLExport::ExportMeta_();
1626 void SdXMLExport::ExportFontDecls_()
1628 GetFontAutoStylePool(); // make sure the pool is created
1629 SvXMLExport::ExportFontDecls_();
1632 void SdXMLExport::ExportContent_()
1634 // export <pres:header-decl>, <pres:footer-decl> and <pres:date-time-decl> elements
1635 ImpWriteHeaderFooterDecls();
1637 // page export
1638 for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
1640 uno::Reference<drawing::XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), uno::UNO_QUERY );
1642 // set progress view
1643 if(GetStatusIndicator().is())
1644 GetStatusIndicator()->setValue(((nPageInd + 1) * 100) / mnDocDrawPageCount);
1646 if(xDrawPage.is())
1648 // prepare page attributes, name of page
1649 Reference < container::XNamed > xNamed(xDrawPage, UNO_QUERY);
1650 if(xNamed.is())
1651 AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, xNamed->getName());
1653 // draw:style-name (presentation page attributes AND background attributes)
1654 if( !maDrawPagesStyleNames[nPageInd].isEmpty() )
1655 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
1656 maDrawPagesStyleNames[nPageInd]);
1658 // draw:master-page-name
1659 Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
1660 if(xMasterPageInt.is())
1662 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
1663 if(xUsedMasterPage.is())
1665 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
1666 if(xMasterNamed.is())
1668 AddAttribute(XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME,
1669 EncodeStyleName( xMasterNamed->getName()) );
1674 // presentation:page-layout-name
1675 if( IsImpress() && !maDrawPagesAutoLayoutNames[nPageInd+1].isEmpty())
1677 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, maDrawPagesAutoLayoutNames[nPageInd+1] );
1680 Reference< beans::XPropertySet > xProps( xDrawPage, UNO_QUERY );
1681 if( xProps.is() )
1685 OUString aBookmarkURL;
1686 xProps->getPropertyValue("BookmarkURL") >>= aBookmarkURL;
1688 if( !aBookmarkURL.isEmpty() )
1690 sal_Int32 nIndex = aBookmarkURL.lastIndexOf( '#' );
1691 if( nIndex != -1 )
1693 OUString aFileName( aBookmarkURL.copy( 0, nIndex ) );
1694 std::u16string_view aBookmarkName( aBookmarkURL.subView( nIndex+1 ) );
1696 aBookmarkURL = GetRelativeReference( aFileName ) + "#" + aBookmarkName;
1699 AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, aBookmarkURL);
1700 AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1701 AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_REPLACE );
1702 AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
1705 catch(const Exception&)
1707 OSL_FAIL(" no \"BookmarkURL\" property at page?" );
1711 if( IsImpress() )
1712 ImplExportHeaderFooterDeclAttributes( maDrawPagesHeaderFooterSettings[nPageInd] );
1714 OUString sNavigationOrder( getNavigationOrder( xDrawPage ) );
1715 if( !sNavigationOrder.isEmpty() )
1716 AddAttribute ( XML_NAMESPACE_DRAW, XML_NAV_ORDER, sNavigationOrder );
1718 rtl::Reference< xmloff::AnimationsExporter > xAnimationsExporter;
1719 uno::Reference< css::animations::XAnimationNodeSupplier > xAnimNodeSupplier;
1721 // prepare animation export
1722 if(IsImpress())
1724 if( getExportFlags() & SvXMLExportFlags::OASIS )
1726 // export new animations for oasis format
1727 xAnimNodeSupplier.set( xDrawPage, UNO_QUERY );
1729 // prepare animations exporter if impress
1730 if(xAnimNodeSupplier.is())
1732 xAnimationsExporter = new xmloff::AnimationsExporter( *this, xProps );
1733 xAnimationsExporter->prepare( xAnimNodeSupplier->getAnimationNode() );
1736 else
1738 // export old animations for ooo format
1739 rtl::Reference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter();
1740 GetShapeExport()->setAnimationsExporter( xAnimExport );
1744 // write draw:id
1745 const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage );
1746 if( !aPageId.isEmpty() )
1748 AddAttributeIdLegacy(XML_NAMESPACE_DRAW, aPageId);
1751 // write page
1752 SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, true, true);
1754 // write optional office:forms
1755 exportFormsElement( xDrawPage );
1757 // write graphic objects on this page (if any)
1758 if(xDrawPage.is() && xDrawPage->getCount())
1759 GetShapeExport()->exportShapes( xDrawPage );
1761 // write animations and presentation notes (ONLY if presentation)
1762 if(IsImpress())
1764 if(xAnimNodeSupplier.is())
1766 xAnimationsExporter->exportAnimations( xAnimNodeSupplier->getAnimationNode() );
1768 else
1770 // animations
1771 rtl::Reference< XMLAnimationsExporter > xAnimExport( GetShapeExport()->getAnimationsExporter() );
1772 if( xAnimExport.is() )
1773 xAnimExport->exportAnimations( *this );
1775 xAnimExport = nullptr;
1776 GetShapeExport()->setAnimationsExporter( xAnimExport );
1779 // presentations
1780 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
1781 if(xPresPage.is())
1783 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
1784 if(xNotesPage.is())
1786 if( !maDrawNotesPagesStyleNames[nPageInd].isEmpty() )
1787 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maDrawNotesPagesStyleNames[nPageInd]);
1789 ImplExportHeaderFooterDeclAttributes( maDrawNotesPagesHeaderFooterSettings[nPageInd] );
1791 // write presentation notes
1792 SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, true, true);
1794 // write optional office:forms
1795 exportFormsElement( xNotesPage );
1797 // write shapes per se
1798 GetShapeExport()->exportShapes( xNotesPage );
1803 exportAnnotations( xDrawPage );
1807 if( IsImpress() )
1808 exportPresentationSettings();
1811 void SdXMLExport::exportPresentationSettings()
1815 Reference< XPresentationSupplier > xPresSupplier( GetModel(), UNO_QUERY );
1816 if( !xPresSupplier.is() )
1817 return;
1819 Reference< XPropertySet > xPresProps( xPresSupplier->getPresentation(), UNO_QUERY );
1820 if( !xPresProps.is() )
1821 return;
1823 bool bHasAttr = false;
1825 bool bTemp = false;
1827 // export range
1828 xPresProps->getPropertyValue("IsShowAll") >>= bTemp;
1829 if( !bTemp )
1831 OUString aFirstPage;
1832 xPresProps->getPropertyValue("FirstPage") >>= aFirstPage;
1833 if( !aFirstPage.isEmpty() )
1835 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_PAGE, aFirstPage );
1836 bHasAttr = true;
1838 else
1840 OUString aCustomShow;
1841 xPresProps->getPropertyValue("CustomShow") >>= aCustomShow;
1842 if( !aCustomShow.isEmpty() )
1844 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW, aCustomShow );
1845 bHasAttr = true;
1850 xPresProps->getPropertyValue("IsEndless") >>= bTemp;
1851 if( bTemp )
1853 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ENDLESS, XML_TRUE );
1854 bHasAttr = true;
1856 sal_Int32 nPause = 0;
1857 xPresProps->getPropertyValue("Pause") >>= nPause;
1859 util::Duration aDuration;
1860 aDuration.Seconds = static_cast<sal_uInt16>(nPause);
1862 OUStringBuffer aOut;
1863 ::sax::Converter::convertDuration(aOut, aDuration);
1864 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAUSE, aOut.makeStringAndClear() );
1867 xPresProps->getPropertyValue("AllowAnimations") >>= bTemp;
1868 if( !bTemp )
1870 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, XML_DISABLED );
1871 bHasAttr = true;
1874 xPresProps->getPropertyValue("IsAlwaysOnTop") >>= bTemp;
1875 if( bTemp )
1877 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STAY_ON_TOP, XML_TRUE );
1878 bHasAttr = true;
1881 xPresProps->getPropertyValue("IsAutomatic") >>= bTemp;
1882 if( bTemp )
1884 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FORCE_MANUAL, XML_TRUE );
1885 bHasAttr = true;
1888 xPresProps->getPropertyValue("IsFullScreen") >>= bTemp;
1889 if( !bTemp )
1891 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FULL_SCREEN, XML_FALSE );
1892 bHasAttr = true;
1895 // We need to always export this attribute, because the import had the wrong default (tdf#108824)
1896 xPresProps->getPropertyValue("IsMouseVisible") >>= bTemp;
1897 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_VISIBLE, bTemp ? XML_TRUE : XML_FALSE);
1898 bHasAttr = true;
1900 xPresProps->getPropertyValue("StartWithNavigator") >>= bTemp;
1901 if( bTemp )
1903 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_WITH_NAVIGATOR, XML_TRUE );
1904 bHasAttr = true;
1907 xPresProps->getPropertyValue("UsePen") >>= bTemp;
1908 if( bTemp )
1910 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_AS_PEN, XML_TRUE );
1911 bHasAttr = true;
1914 xPresProps->getPropertyValue("IsTransitionOnClick") >>= bTemp;
1915 if( !bTemp )
1917 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_TRANSITION_ON_CLICK, XML_DISABLED );
1918 bHasAttr = true;
1921 xPresProps->getPropertyValue("IsShowLogo") >>= bTemp;
1922 if( bTemp )
1924 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW_LOGO, XML_TRUE );
1925 bHasAttr = true;
1928 Reference< container::XNameContainer > xShows;
1929 Sequence< OUString > aShowNames;
1930 bool bHasNames = false;
1932 Reference< XCustomPresentationSupplier > xSup( GetModel(), UNO_QUERY );
1933 if( xSup.is() )
1935 xShows = xSup->getCustomPresentations();
1936 if( xShows.is() )
1938 aShowNames = xShows->getElementNames();
1939 bHasNames = aShowNames.hasElements();
1943 if( bHasAttr || bHasNames )
1945 SvXMLElementExport aSettings(*this, XML_NAMESPACE_PRESENTATION, XML_SETTINGS, true, true);
1947 if( !bHasNames )
1948 return;
1950 Reference< XIndexContainer > xShow;
1951 Reference< XNamed > xPageName;
1953 OUStringBuffer sTmp;
1955 for( const auto& rShowName : std::as_const(aShowNames) )
1957 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, rShowName );
1959 xShows->getByName( rShowName ) >>= xShow;
1960 SAL_WARN_IF( !xShow.is(), "xmloff", "invalid custom show!" );
1961 if( !xShow.is() )
1962 continue;
1964 const sal_Int32 nPageCount = xShow->getCount();
1965 for( sal_Int32 nPage = 0; nPage < nPageCount; nPage++ )
1967 xShow->getByIndex( nPage ) >>= xPageName;
1969 if( !xPageName.is() )
1970 continue;
1972 if( !sTmp.isEmpty() )
1973 sTmp.append( ',' );
1974 sTmp.append( xPageName->getName() );
1978 if( !sTmp.isEmpty() )
1979 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAGES, sTmp.makeStringAndClear() );
1981 SvXMLElementExport aShows(*this, XML_NAMESPACE_PRESENTATION, XML_SHOW, true, true);
1985 catch(const uno::Exception&)
1987 TOOLS_WARN_EXCEPTION("xmloff.draw", "while exporting <presentation:settings>");
1991 void SdXMLExport::ExportStyles_(bool bUsed)
1993 GetPropertySetMapper()->SetAutoStyles( false );
1995 // export fill styles
1996 SvXMLExport::ExportStyles_( bUsed );
1998 // write draw:style-name for object graphic-styles
1999 GetShapeExport()->ExportGraphicDefaults();
2001 // do not export in ODF 1.1 or older
2002 if (getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
2003 GetShapeExport()->GetShapeTableExport()->exportTableStyles();
2005 // write presentation styles
2006 ImpWritePresentationStyles();
2008 // prepare draw:auto-layout-name for page export
2009 ImpPrepAutoLayoutInfos();
2011 // write draw:auto-layout-name for page export
2012 ImpWriteAutoLayoutInfos();
2014 Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2015 if( xInfoSet.is() )
2017 Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2019 if( xInfoSetInfo->hasPropertyByName( gsPageLayoutNames ) )
2021 xInfoSet->setPropertyValue( gsPageLayoutNames, Any(maDrawPagesAutoLayoutNames) );
2026 void SdXMLExport::collectAutoStyles()
2028 SvXMLExport::collectAutoStyles();
2029 if (mbAutoStylesCollected)
2030 return;
2032 Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
2033 if( xInfoSet.is() )
2035 Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
2037 if( xInfoSetInfo->hasPropertyByName( gsPageLayoutNames ) )
2039 xInfoSet->getPropertyValue( gsPageLayoutNames ) >>= maDrawPagesAutoLayoutNames;
2043 GetPropertySetMapper()->SetAutoStyles( true );
2045 if( getExportFlags() & SvXMLExportFlags::STYLES )
2047 // #80012# PageMaster export moved from _ExportStyles
2048 // prepare page-master infos
2049 ImpPrepPageMasterInfos();
2051 // prepare draw:style-name for master page export
2052 ImpPrepMasterPageInfos();
2055 if( getExportFlags() & SvXMLExportFlags::CONTENT )
2057 // prepare draw:style-name for page export
2058 ImpPrepDrawPageInfos();
2061 if( getExportFlags() & SvXMLExportFlags::STYLES )
2063 // create auto style infos for shapes on master handout page
2064 if( IsImpress() )
2066 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2067 if( xHandoutSupp.is() )
2069 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2070 if( xHandoutPage.is() && xHandoutPage->getCount())
2071 GetShapeExport()->collectShapesAutoStyles( xHandoutPage );
2075 // create auto style infos for objects on master pages
2076 for(sal_Int32 nMPageId(0); nMPageId < mnDocMasterPageCount; nMPageId++)
2078 Reference< XDrawPage > xMasterPage(mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2080 if( xMasterPage.is() )
2082 // collect layer information
2083 GetFormExport()->examineForms( xMasterPage );
2085 // get MasterPage Name
2086 OUString aMasterPageNamePrefix;
2087 Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2088 if(xNamed.is())
2090 aMasterPageNamePrefix = xNamed->getName();
2092 if(!aMasterPageNamePrefix.isEmpty())
2094 aMasterPageNamePrefix += "-";
2096 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2098 if(xMasterPage.is() && xMasterPage->getCount())
2099 GetShapeExport()->collectShapesAutoStyles( xMasterPage );
2101 if(IsImpress())
2103 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2104 if(xPresPage.is())
2106 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2107 if(xNotesPage.is())
2109 // collect layer information
2110 GetFormExport()->examineForms( xNotesPage );
2112 if(xNotesPage->getCount())
2113 GetShapeExport()->collectShapesAutoStyles( xNotesPage );
2117 collectAnnotationAutoStyles(xMasterPage);
2122 if( getExportFlags() & SvXMLExportFlags::CONTENT )
2124 // prepare animations exporter if impress
2125 if(IsImpress() && (!(getExportFlags() & SvXMLExportFlags::OASIS)) )
2127 rtl::Reference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter();
2128 GetShapeExport()->setAnimationsExporter( xAnimExport );
2131 // create auto style infos for objects on pages
2132 for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
2134 Reference<XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), UNO_QUERY );
2135 if( xDrawPage.is() )
2137 // collect layer information
2138 GetFormExport()->examineForms( xDrawPage );
2140 // get MasterPage Name
2141 OUString aMasterPageNamePrefix;
2142 Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, UNO_QUERY);
2143 if(xMasterPageInt.is())
2145 Reference<XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
2146 if(xUsedMasterPage.is())
2148 Reference < container::XNamed > xMasterNamed(xUsedMasterPage, UNO_QUERY);
2149 if(xMasterNamed.is())
2151 aMasterPageNamePrefix = xMasterNamed->getName();
2155 if(!aMasterPageNamePrefix.isEmpty())
2157 aMasterPageNamePrefix += "-";
2160 GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
2162 // prepare object infos
2163 if(xDrawPage.is() && xDrawPage->getCount())
2164 GetShapeExport()->collectShapesAutoStyles( xDrawPage );
2166 // prepare presentation notes page object infos (ONLY if presentation)
2167 if(IsImpress())
2169 Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
2170 if(xPresPage.is())
2172 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2173 if(xNotesPage.is())
2175 // collect layer information
2176 GetFormExport()->examineForms( xNotesPage );
2178 if(xNotesPage->getCount())
2179 GetShapeExport()->collectShapesAutoStyles( xNotesPage );
2184 collectAnnotationAutoStyles( xDrawPage );
2187 if (IsImpress())
2189 rtl::Reference< XMLAnimationsExporter > xAnimExport;
2190 GetShapeExport()->setAnimationsExporter( xAnimExport );
2194 mbAutoStylesCollected = true;
2197 void SdXMLExport::ExportAutoStyles_()
2199 collectAutoStyles();
2201 if( getExportFlags() & SvXMLExportFlags::STYLES )
2203 // write page-master infos
2204 ImpWritePageMasterInfos();
2207 // export draw-page styles
2208 GetAutoStylePool()->exportXML( XmlStyleFamily::SD_DRAWINGPAGE_ID );
2210 exportAutoDataStyles();
2212 GetShapeExport()->exportAutoStyles();
2214 SvXMLExportFlags nContentAutostyles = SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES;
2215 if ( ( getExportFlags() & nContentAutostyles ) == nContentAutostyles )
2216 GetFormExport()->exportAutoStyles( );
2218 // ...for text
2219 GetTextParagraphExport()->exportTextAutoStyles();
2222 void SdXMLExport::ExportMasterStyles_()
2224 // export layer
2225 SdXMLayerExporter::exportLayer( *this );
2227 // export handout master page if impress
2228 if( IsImpress() )
2230 Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
2231 if( xHandoutSupp.is() )
2233 Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
2234 if( xHandoutPage.is() )
2236 // presentation:page-layout-name
2237 if( IsImpress() && !maDrawPagesAutoLayoutNames[0].isEmpty())
2239 AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, EncodeStyleName( maDrawPagesAutoLayoutNames[0] ));
2242 ImpXMLEXPPageMasterInfo* pInfo = mpHandoutPageMaster;
2243 if(pInfo)
2245 const OUString& sString = pInfo->GetName();
2246 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2249 // draw:style-name
2250 if( !maHandoutMasterStyleName.isEmpty() )
2251 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maHandoutMasterStyleName);
2253 ImplExportHeaderFooterDeclAttributes( maHandoutPageHeaderFooterSettings );
2255 // write masterpage
2256 SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_HANDOUT_MASTER, true, true);
2258 // write graphic objects on this master page (if any)
2259 if(xHandoutPage.is() && xHandoutPage->getCount())
2260 GetShapeExport()->exportShapes( xHandoutPage );
2265 // export MasterPages in master-styles section
2266 for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
2268 Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
2269 if(xMasterPage.is())
2271 // prepare masterpage attributes
2272 Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
2273 if(xNamed.is())
2275 bool bEncoded = false;
2276 OUString sMasterPageName = xNamed->getName();
2277 AddAttribute(XML_NAMESPACE_STYLE, XML_NAME,
2278 EncodeStyleName( sMasterPageName, &bEncoded ));
2279 if( bEncoded )
2280 AddAttribute(
2281 XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
2282 sMasterPageName );
2285 ImpXMLEXPPageMasterInfo* pInfo = mvPageMasterUsageList.at( nMPageId );
2286 if(pInfo)
2288 const OUString& sString = pInfo->GetName();
2289 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
2292 // draw:style-name (background attributes)
2293 if( !maMasterPagesStyleNames[nMPageId].isEmpty() )
2294 AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2295 maMasterPagesStyleNames[nMPageId]);
2297 // write masterpage
2298 SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_MASTER_PAGE, true, true);
2300 // write optional office:forms
2301 exportFormsElement( xMasterPage );
2303 // write optional loext:theme
2304 exportTheme(xMasterPage);
2306 // write graphic objects on this master page (if any)
2307 if(xMasterPage.is() && xMasterPage->getCount())
2308 GetShapeExport()->exportShapes( xMasterPage );
2310 // write presentation notes (ONLY if presentation)
2311 if(IsImpress())
2313 Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
2314 if(xPresPage.is())
2316 Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
2317 if(xNotesPage.is())
2319 ImpXMLEXPPageMasterInfo* pMasterInfo = mvNotesPageMasterUsageList.at( nMPageId );
2320 if(pMasterInfo)
2322 const OUString& sString = pMasterInfo->GetName();
2323 AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString);
2326 // write presentation notes
2327 SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, true, true);
2329 // write optional office:forms
2330 exportFormsElement( xNotesPage );
2332 // write shapes per se
2333 GetShapeExport()->exportShapes( xNotesPage );
2337 exportAnnotations( xMasterPage );
2342 void SdXMLExport::exportFormsElement( const Reference< XDrawPage >& xDrawPage )
2344 if( !xDrawPage.is() )
2345 return;
2347 Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY );
2348 if ( xFormsSupplier.is() && xFormsSupplier->hasForms() )
2350 // write masterpage
2351 ::xmloff::OOfficeFormsExport aForms(*this);
2352 GetFormExport()->exportForms( xDrawPage );
2355 if(! GetFormExport()->seekPage( xDrawPage ) )
2357 OSL_FAIL( "OFormLayerXMLExport::seekPage failed!" );
2361 void SdXMLExport::exportTheme(const uno::Reference<drawing::XDrawPage>& xDrawPage)
2363 if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
2365 // Do not export in standard ODF 1.3 or older.
2366 return;
2369 uno::Reference<beans::XPropertySet> xPropertySet(xDrawPage, uno::UNO_QUERY);
2370 if (!xPropertySet.is())
2371 return;
2373 uno::Reference<util::XTheme> xTheme;
2374 xPropertySet->getPropertyValue("Theme") >>= xTheme;
2375 if (!xTheme.is())
2376 return;
2378 auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
2379 if (!pUnoTheme)
2380 return;
2382 auto pTheme = pUnoTheme->getTheme();
2383 if (!pTheme)
2384 return;
2386 ExportThemeElement(pTheme);
2389 void SdXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
2391 Reference< beans::XPropertySet > xPropSet( GetModel(), UNO_QUERY );
2392 if( !xPropSet.is() )
2393 return;
2395 awt::Rectangle aVisArea;
2396 xPropSet->getPropertyValue("VisibleArea") >>= aVisArea;
2398 rProps.realloc(4);
2399 beans::PropertyValue* pProps = rProps.getArray();
2401 pProps[0].Name = "VisibleAreaTop";
2402 pProps[0].Value <<= aVisArea.Y;
2403 pProps[1].Name = "VisibleAreaLeft";
2404 pProps[1].Value <<= aVisArea.X;
2405 pProps[2].Name = "VisibleAreaWidth";
2406 pProps[2].Value <<= aVisArea.Width;
2407 pProps[3].Name = "VisibleAreaHeight";
2408 pProps[3].Value <<= aVisArea.Height;
2412 void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
2414 Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
2415 if( !xFac.is() )
2416 return;
2418 Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
2419 if( xProps.is() )
2420 SvXMLUnitConverter::convertPropertySet( rProps, xProps );
2421 DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get()));
2422 if (!pFilter)
2423 return;
2424 const uno::Reference< embed::XStorage > xStorage(GetTargetStorage());
2425 if (!xStorage.is())
2426 return;
2427 rProps = pFilter->filterStreamsToStorage(xStorage, rProps);
2430 void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat )
2432 sal_Int32 nFormat = nNumberFormat;
2433 if( (nNumberFormat > 1) && (nNumberFormat <= 0x0f) )
2434 nFormat -= 2;
2436 if( bTimeFormat )
2438 maUsedTimeStyles.insert( nFormat );
2440 else
2442 maUsedDateStyles.insert( nFormat );
2446 void SdXMLExport::exportDataStyles()
2448 // there are no data styles to export in draw/impress yet
2451 void SdXMLExport::exportAutoDataStyles()
2453 for( const auto& rUsedDateStyle : maUsedDateStyles )
2454 SdXMLNumberStylesExporter::exportDateStyle( *this, rUsedDateStyle );
2456 for( const auto& rUsedTimeStyle : maUsedTimeStyles )
2457 SdXMLNumberStylesExporter::exportTimeStyle( *this, rUsedTimeStyle );
2459 if(HasFormExport())
2460 GetFormExport()->exportAutoControlNumberStyles();
2463 OUString SdXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat ) const
2465 if( bTimeFormat )
2467 return SdXMLNumberStylesExporter::getTimeStyleName( nNumberFormat );
2469 else
2471 return SdXMLNumberStylesExporter::getDateStyleName( nNumberFormat );
2475 OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPage )
2477 OUStringBuffer sNavOrder;
2480 Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
2481 Reference< XIndexAccess > xNavOrder( xSet->getPropertyValue("NavigationOrder"), UNO_QUERY_THROW );
2483 Reference< XIndexAccess > xZOrderAccess = xDrawPage;
2485 // only export navigation order if it is different from the z-order
2486 if( (xNavOrder.get() != xZOrderAccess.get()) && (xNavOrder->getCount() == xDrawPage->getCount()) )
2488 sal_Int32 nIndex;
2489 const sal_Int32 nCount = xNavOrder->getCount();
2490 for( nIndex = 0; nIndex < nCount; ++nIndex )
2492 OUString sId( getInterfaceToIdentifierMapper().registerReference( Reference< XInterface >( xNavOrder->getByIndex( nIndex ), UNO_QUERY ) ) );
2493 if( !sId.isEmpty() )
2495 if( !sNavOrder.isEmpty() )
2496 sNavOrder.append( ' ' );
2497 sNavOrder.append( sId );
2502 catch(const Exception&)
2505 return sNavOrder.makeStringAndClear();
2508 void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage )
2510 Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2511 if( !xAnnotationAccess.is() ) return;
2515 Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2516 if( xAnnotationEnumeration.is() )
2518 while( xAnnotationEnumeration->hasMoreElements() )
2520 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_SET_THROW );
2521 Reference< XText > xText( xAnnotation->getTextRange() );
2522 if(xText.is() && !xText->getString().isEmpty())
2523 GetTextParagraphExport()->collectTextAutoStyles( xText );
2527 catch(const Exception&)
2529 TOOLS_WARN_EXCEPTION("xmloff.draw",
2530 "exception caught during export of annotation auto styles");
2534 void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
2536 // do not export in standard ODF 1.3 or older
2537 if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
2539 return;
2542 Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
2543 if( !xAnnotationAccess.is() )
2544 return;
2548 Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
2549 if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() )
2551 bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
2552 SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
2553 SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo);
2555 OUStringBuffer sStringBuffer;
2558 Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_SET_THROW );
2560 RealPoint2D aPosition( xAnnotation->getPosition() );
2562 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2563 static_cast<sal_Int32>( aPosition.X * 100 ) );
2564 AddAttribute(XML_NAMESPACE_SVG, XML_X, sStringBuffer.makeStringAndClear());
2566 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2567 static_cast<sal_Int32>( aPosition.Y * 100 ) );
2568 AddAttribute(XML_NAMESPACE_SVG, XML_Y, sStringBuffer.makeStringAndClear());
2570 RealSize2D aSize( xAnnotation->getSize() );
2572 if( aSize.Width || aSize.Height )
2574 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2575 static_cast<sal_Int32>( aSize.Width * 100 ) );
2576 AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, sStringBuffer.makeStringAndClear());
2577 GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2578 static_cast<sal_Int32>( aSize.Height * 100 ) );
2579 AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, sStringBuffer.makeStringAndClear());
2582 // annotation element + content
2583 SvXMLElementExport aElem(*this, XML_NAMESPACE_OFFICE_EXT, XML_ANNOTATION, false, true);
2585 // author
2586 OUString aAuthor( xAnnotation->getAuthor() );
2587 if( !aAuthor.isEmpty() )
2589 SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, true, false );
2590 Characters( bRemovePersonalInfo
2591 ? "Author" + OUString::number( SvXMLExport::GetInfoID(aAuthor) )
2592 : aAuthor );
2595 // initials
2596 OUString aInitials( xAnnotation->getInitials() );
2597 if( !aInitials.isEmpty() )
2599 // OFFICE-3776 export meta:creator-initials for ODF 1.3
2600 SvXMLElementExport aInitialsElem( *this,
2601 (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
2602 ? XML_NAMESPACE_META
2603 : XML_NAMESPACE_LO_EXT,
2604 (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
2605 ? XML_CREATOR_INITIALS
2606 : XML_SENDER_INITIALS,
2607 true, false );
2608 Characters( bRemovePersonalInfo
2609 ? OUString::number( SvXMLExport::GetInfoID(aInitials) )
2610 : aInitials );
2614 // date time
2615 css::util::DateTime aDate( bRemovePersonalInfo
2616 ? css::util::DateTime(0, 0, 0, 0, 1, 1, 1970, true) // Epoch time
2617 : xAnnotation->getDateTime() );
2618 ::sax::Converter::convertDateTime(sStringBuffer, aDate, nullptr, true);
2619 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, true, false );
2620 Characters( sStringBuffer.makeStringAndClear() );
2623 css::uno::Reference < css::text::XText > xText( xAnnotation->getTextRange() );
2624 if( xText.is() )
2625 GetTextParagraphExport()->exportText( xText );
2627 while( xAnnotationEnumeration->hasMoreElements() );
2630 catch(const Exception&)
2632 TOOLS_WARN_EXCEPTION("xmloff.draw", "exception caught during export of annotations");
2636 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2637 com_sun_star_comp_Impress_XMLOasisExporter_get_implementation(
2638 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2640 return cppu::acquire(new SdXMLExport(
2641 pCtx, "XMLImpressExportOasis", false,
2642 SvXMLExportFlags::OASIS | SvXMLExportFlags::META | SvXMLExportFlags::STYLES
2643 | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES
2644 | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS | SvXMLExportFlags::SETTINGS
2645 | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
2648 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2649 com_sun_star_comp_Impress_XMLOasisStylesExporter_get_implementation(
2650 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2652 return cppu::acquire(new SdXMLExport(
2653 pCtx, "XMLImpressStylesExportOasis", false,
2654 SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
2655 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS));
2658 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2659 com_sun_star_comp_Impress_XMLOasisContentExporter_get_implementation(
2660 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2662 return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressContentExportOasis", false,
2663 SvXMLExportFlags::OASIS | SvXMLExportFlags::AUTOSTYLES
2664 | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
2665 | SvXMLExportFlags::FONTDECLS));
2668 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2669 com_sun_star_comp_Impress_XMLOasisMetaExporter_get_implementation(
2670 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2672 return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressMetaExportOasis", false,
2673 SvXMLExportFlags::OASIS | SvXMLExportFlags::META));
2676 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2677 com_sun_star_comp_Impress_XMLOasisSettingsExporter_get_implementation(
2678 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2680 return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressSettingsExportOasis", false,
2681 SvXMLExportFlags::OASIS | SvXMLExportFlags::SETTINGS));
2684 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2685 com_sun_star_comp_Impress_XMLExporter_get_implementation(uno::XComponentContext* pCtx,
2686 uno::Sequence<uno::Any> const& /*rSeq*/)
2688 return cppu::acquire(new SdXMLExport(
2689 pCtx, "XMLImpressExportOOO", false,
2690 SvXMLExportFlags::META | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
2691 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
2692 | SvXMLExportFlags::SETTINGS | SvXMLExportFlags::FONTDECLS
2693 | SvXMLExportFlags::EMBEDDED));
2696 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2697 com_sun_star_comp_Draw_XMLExporter_get_implementation(uno::XComponentContext* pCtx,
2698 uno::Sequence<uno::Any> const& /*rSeq*/)
2700 return cppu::acquire(new SdXMLExport(
2701 pCtx, "XMLDrawExportOOO", true,
2702 SvXMLExportFlags::META | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
2703 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
2704 | SvXMLExportFlags::SETTINGS | SvXMLExportFlags::FONTDECLS
2705 | SvXMLExportFlags::EMBEDDED));
2708 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2709 com_sun_star_comp_Draw_XMLOasisSettingsExporter_get_implementation(
2710 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2712 return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawSettingsExportOasis", true,
2713 SvXMLExportFlags::OASIS | SvXMLExportFlags::SETTINGS));
2716 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2717 com_sun_star_comp_Draw_XMLOasisMetaExporter_get_implementation(
2718 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2720 return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawMetaExportOasis", true,
2721 SvXMLExportFlags::OASIS | SvXMLExportFlags::META));
2724 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2725 com_sun_star_comp_Draw_XMLOasisContentExporter_get_implementation(
2726 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2728 return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawContentExportOasis", true,
2729 SvXMLExportFlags::OASIS | SvXMLExportFlags::AUTOSTYLES
2730 | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
2731 | SvXMLExportFlags::FONTDECLS));
2734 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2735 com_sun_star_comp_Draw_XMLOasisStylesExporter_get_implementation(
2736 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2738 return cppu::acquire(new SdXMLExport(
2739 pCtx, "XMLDrawStylesExportOasis", true,
2740 SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
2741 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS));
2744 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2745 com_sun_star_comp_Draw_XMLOasisExporter_get_implementation(uno::XComponentContext* pCtx,
2746 uno::Sequence<uno::Any> const& /*rSeq*/)
2748 return cppu::acquire(new SdXMLExport(
2749 pCtx, "XMLDrawExportOasis", true,
2750 SvXMLExportFlags::OASIS | SvXMLExportFlags::META | SvXMLExportFlags::STYLES
2751 | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES
2752 | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS | SvXMLExportFlags::SETTINGS
2753 | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
2756 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2757 com_sun_star_comp_DrawingLayer_XMLExporter_get_implementation(
2758 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2760 return cppu::acquire(
2761 new SdXMLExport(pCtx, "XMLDrawingLayerExport", true,
2762 SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES
2763 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
2764 | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
2767 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
2768 com_sun_star_comp_Impress_XMLClipboardExporter_get_implementation(
2769 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
2771 return cppu::acquire(
2772 new SdXMLExport(pCtx, "XMLImpressClipboardExport", /*bIsDraw=*/false,
2773 SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES
2774 | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
2775 | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
2778 XMLFontAutoStylePool* SdXMLExport::CreateFontAutoStylePool()
2780 bool bEmbedFonts = false;
2781 bool bEmbedUsedOnly = false;
2782 bool bEmbedLatinScript = true;
2783 bool bEmbedAsianScript = true;
2784 bool bEmbedComplexScript = true;
2786 if (getExportFlags() & SvXMLExportFlags::CONTENT)
2790 Reference<lang::XMultiServiceFactory> xFactory(GetModel(), UNO_QUERY);
2791 Reference<beans::XPropertySet> xProps;
2792 Reference<beans::XPropertySetInfo> xInfo;
2794 if (xFactory.is())
2795 xProps.set(xFactory->createInstance("com.sun.star.document.Settings"), UNO_QUERY);
2796 if (xProps.is())
2797 xInfo = xProps->getPropertySetInfo();
2798 if (xInfo.is() && xProps.is())
2800 if (xInfo->hasPropertyByName("EmbedFonts"))
2801 xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
2802 if (xInfo->hasPropertyByName("EmbedOnlyUsedFonts"))
2803 xProps->getPropertyValue("EmbedOnlyUsedFonts") >>= bEmbedUsedOnly;
2804 if (xInfo->hasPropertyByName("EmbedLatinScriptFonts"))
2805 xProps->getPropertyValue("EmbedLatinScriptFonts") >>= bEmbedLatinScript;
2806 if (xInfo->hasPropertyByName("EmbedAsianScriptFonts"))
2807 xProps->getPropertyValue("EmbedAsianScriptFonts") >>= bEmbedAsianScript;
2808 if (xInfo->hasPropertyByName("EmbedComplexScriptFonts"))
2809 xProps->getPropertyValue("EmbedComplexScriptFonts") >>= bEmbedComplexScript;
2811 } catch(...)
2813 // clipboard document doesn't have shell so throws from getPropertyValue
2814 // gallery elements may not support com.sun.star.document.Settings so throws from createInstance
2818 XMLFontAutoStylePool *pPool = new XMLFontAutoStylePool( *this, bEmbedFonts );
2819 pPool->setEmbedOnlyUsedFonts(bEmbedUsedOnly);
2820 pPool->setEmbedFontScripts(bEmbedLatinScript, bEmbedAsianScript, bEmbedComplexScript);
2822 Reference< beans::XPropertySet > xProps( GetModel(), UNO_QUERY );
2823 if ( xProps.is() ) {
2824 Sequence<Any> aAnySeq;
2825 if( xProps->getPropertyValue("Fonts") >>= aAnySeq )
2827 if( aAnySeq.getLength() % 5 == 0 )
2829 int nLen = aAnySeq.getLength() / 5;
2830 int nSeqIndex = 0;
2831 for( int i = 0; i < nLen; i++ )
2833 OUString sFamilyName, sStyleName;
2834 sal_Int16 eFamily(FAMILY_DONTKNOW),
2835 ePitch(PITCH_DONTKNOW),
2836 eCharSet(RTL_TEXTENCODING_DONTKNOW);
2838 aAnySeq[nSeqIndex++] >>= sFamilyName;
2839 aAnySeq[nSeqIndex++] >>= sStyleName;
2840 aAnySeq[nSeqIndex++] >>= eFamily;
2841 aAnySeq[nSeqIndex++] >>= ePitch;
2842 aAnySeq[nSeqIndex++] >>= eCharSet;
2844 pPool->Add( sFamilyName, sStyleName, FontFamily( eFamily ), FontPitch( ePitch ), rtl_TextEncoding( eCharSet ) );
2850 return pPool;
2853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */