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