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