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 <stdio.h>
21 : #include <oox/drawingml/chart/chartconverter.hxx>
22 : #include <oox/token/tokens.hxx>
23 : #include <oox/ole/vbaproject.hxx>
24 : #include <epptooxml.hxx>
25 : #include <epptdef.hxx>
26 : #include <oox/export/shapes.hxx>
27 :
28 : #include <cppuhelper/implementationentry.hxx>
29 : #include <cppuhelper/factory.hxx>
30 : #include <sax/fshelper.hxx>
31 : #include <rtl/ustrbuf.hxx>
32 : #include <filter/msfilter/escherex.hxx>
33 : #include <tools/poly.hxx>
34 :
35 : #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
36 : #include <com/sun/star/animations/AnimationCalcMode.hpp>
37 : #include <com/sun/star/animations/AnimationFill.hpp>
38 : #include <com/sun/star/animations/AnimationNodeType.hpp>
39 : #include <com/sun/star/animations/AnimationRestart.hpp>
40 : #include <com/sun/star/animations/AnimationValueType.hpp>
41 : #include <com/sun/star/animations/Event.hpp>
42 : #include <com/sun/star/animations/EventTrigger.hpp>
43 : #include <com/sun/star/animations/Timing.hpp>
44 : #include <com/sun/star/animations/ValuePair.hpp>
45 : #include <com/sun/star/animations/XAnimateSet.hpp>
46 : #include <com/sun/star/animations/XAnimationNode.hpp>
47 : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
48 : #include <com/sun/star/animations/XTransitionFilter.hpp>
49 : #include <com/sun/star/beans/Property.hpp>
50 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
51 : #include <com/sun/star/container/XEnumerationAccess.hpp>
52 : #include <com/sun/star/drawing/FillStyle.hpp>
53 : #include <com/sun/star/drawing/RectanglePoint.hpp>
54 : #include <com/sun/star/geometry/RealPoint2D.hpp>
55 : #include <com/sun/star/office/XAnnotationEnumeration.hpp>
56 : #include <com/sun/star/office/XAnnotationAccess.hpp>
57 : #include <com/sun/star/presentation/AnimationSpeed.hpp>
58 : #include <com/sun/star/presentation/EffectNodeType.hpp>
59 : #include <com/sun/star/util/DateTime.hpp>
60 :
61 : #include <oox/export/utils.hxx>
62 :
63 : #include "pptexanimations.hxx"
64 :
65 : #include <com/sun/star/document/XDocumentProperties.hpp>
66 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
67 :
68 : // presentation namespaces
69 : #define PNMSS FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", \
70 : FSNS( XML_xmlns, XML_p ), "http://schemas.openxmlformats.org/presentationml/2006/main", \
71 : FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
72 :
73 : using namespace ::com::sun::star;
74 : using namespace ::com::sun::star::animations;
75 : using namespace ::com::sun::star::beans;
76 : using namespace ::com::sun::star::container;
77 : using namespace ::com::sun::star::drawing;
78 : using namespace ::com::sun::star::geometry;
79 : using namespace ::com::sun::star::presentation;
80 : using namespace ::com::sun::star::office;
81 : using namespace ::com::sun::star::text;
82 : using namespace ::com::sun::star::uno;
83 : using namespace ::com::sun::star::util;
84 : using namespace ::ppt;
85 : using ::com::sun::star::beans::XPropertySet;
86 : using ::com::sun::star::beans::XPropertySetInfo;
87 : using ::com::sun::star::container::XIndexAccess;
88 : using ::sax_fastparser::FSHelperPtr;
89 :
90 : DBG(void dump_pset(Reference< XPropertySet > rXPropSet);)
91 :
92 : #define IDS(x) OString(OStringLiteral(#x " ") + OString::number( mnShapeIdMax++ )).getStr()
93 :
94 : namespace oox {
95 : using namespace drawingml;
96 : namespace core {
97 :
98 386 : class PowerPointShapeExport : public ShapeExport
99 : {
100 : PowerPointExport& mrExport;
101 : PageType mePageType;
102 : bool mbMaster;
103 : public:
104 : PowerPointShapeExport( FSHelperPtr pFS, ShapeHashMap* pShapeMap, PowerPointExport* pFB );
105 : void SetMaster( bool bMaster );
106 : void SetPageType( PageType ePageType );
107 : ShapeExport& WriteNonVisualProperties( Reference< XShape > xShape ) SAL_OVERRIDE;
108 : ShapeExport& WriteTextShape( Reference< XShape > xShape ) SAL_OVERRIDE;
109 : ShapeExport& WriteUnknownShape( Reference< XShape > xShape ) SAL_OVERRIDE;
110 : ShapeExport& WritePlaceholderShape( Reference< XShape > xShape, PlaceholderType ePlaceholder );
111 : ShapeExport& WritePageShape( Reference< XShape > xShape, PageType ePageType, bool bPresObj );
112 :
113 : // helper parts
114 : bool WritePlaceholder( Reference< XShape > xShape, PlaceholderType ePlaceholder, bool bMaster );
115 : };
116 :
117 : enum PPTXLayout {
118 : LAYOUT_BLANK,
119 : LAYOUT_TITLE_SLIDE,
120 : LAYOUT_TITLE_CONTENT,
121 : LAYOUT_TITLE_2CONTENT,
122 : LAYOUT_TITLE,
123 : LAYOUT_CENTERED_TEXT,
124 : LAYOUT_TITLE_2CONTENT_CONTENT,
125 : LAYOUT_TITLE_CONTENT_2CONTENT,
126 : LAYOUT_TITLE_2CONTENT_OVER_CONTENT,
127 : LAYOUT_TITLE_CONTENT_OVER_CONTENT,
128 : LAYOUT_TITLE_4CONTENT,
129 : LAYOUT_TITLE_6CONTENT,
130 : LAYOUT_SIZE
131 : };
132 :
133 : struct PPTXLayoutInfo {
134 : int nType;
135 : const char* sName;
136 : const char* sType;
137 : };
138 :
139 : static const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE] = {
140 : { 20, "Blank Slide", "blank" },
141 : { 0, "Title Slide", "tx" },
142 : { 1, "Title, Content", "obj" },
143 : { 3, "Title, 2 Content", "twoObj" },
144 : { 19, "Title Only", "titleOnly" },
145 : { 32, "Centered Text", "objOnly" }, // not exactly, but close
146 : { 15, "Title, 2 Content and Content", "twoObjAndObj" },
147 : { 12, "Title Content and 2 Content", "objAndTwoObj" },
148 : { 16, "Title, 2 Content over Content", "twoObjOverTx" }, // not exactly, but close
149 : { 14, "Title, Content over Content", "objOverTx" }, // not exactly, but close
150 : { 18, "Title, 4 Content", "fourObj" },
151 : { 33, "Title, 6 Content", "blank" } // not defined => blank
152 : };
153 :
154 28 : int PowerPointExport::GetPPTXLayoutId( int nOffset )
155 : {
156 28 : int nId = LAYOUT_BLANK;
157 :
158 : DBG(printf("GetPPTXLayoutId %d\n", nOffset));
159 :
160 28 : switch( nOffset ) {
161 : case 0:
162 20 : nId = LAYOUT_TITLE_SLIDE;
163 20 : break;
164 : case 1:
165 4 : nId = LAYOUT_TITLE_CONTENT;
166 4 : break;
167 : case 3:
168 1 : nId = LAYOUT_TITLE_2CONTENT;
169 1 : break;
170 : case 19:
171 1 : nId = LAYOUT_TITLE;
172 1 : break;
173 : case 15:
174 0 : nId = LAYOUT_TITLE_2CONTENT_CONTENT;
175 0 : break;
176 : case 12:
177 0 : nId = LAYOUT_TITLE_CONTENT_2CONTENT;
178 0 : break;
179 : case 16:
180 0 : nId = LAYOUT_TITLE_2CONTENT_OVER_CONTENT;
181 0 : break;
182 : case 14:
183 0 : nId = LAYOUT_TITLE_CONTENT_OVER_CONTENT;
184 0 : break;
185 : case 18:
186 0 : nId = LAYOUT_TITLE_4CONTENT;
187 0 : break;
188 : case 32:
189 0 : nId = LAYOUT_CENTERED_TEXT;
190 0 : break;
191 : case 33:
192 0 : nId = LAYOUT_TITLE_6CONTENT;
193 0 : break;
194 : case 20:
195 : default:
196 2 : nId = LAYOUT_BLANK;
197 2 : break;
198 : }
199 :
200 28 : return nId;
201 : }
202 :
203 386 : PowerPointShapeExport::PowerPointShapeExport( FSHelperPtr pFS, ShapeHashMap* pShapeMap,
204 : PowerPointExport* pFB )
205 : : ShapeExport( XML_p, pFS, pShapeMap, pFB )
206 : , mrExport( *pFB )
207 : , mePageType(UNDEFINED)
208 386 : , mbMaster(false)
209 : {
210 386 : }
211 :
212 370 : void PowerPointShapeExport::SetMaster( bool bMaster )
213 : {
214 370 : mbMaster = bMaster;
215 370 : }
216 :
217 370 : void PowerPointShapeExport::SetPageType( PageType ePageType )
218 : {
219 370 : mePageType = ePageType;
220 370 : }
221 :
222 97 : ShapeExport& PowerPointShapeExport::WriteNonVisualProperties( Reference< XShape > )
223 : {
224 97 : GetFS()->singleElementNS( XML_p, XML_nvPr, FSEND );
225 :
226 97 : return *this;
227 : }
228 :
229 898 : ShapeExport& PowerPointShapeExport::WriteTextShape( Reference< XShape > xShape )
230 : {
231 898 : OUString sShapeType = xShape->getShapeType();
232 :
233 : DBG(printf( "shape(text): %s\n", USS(sShapeType) ));
234 :
235 898 : if ( sShapeType == "com.sun.star.drawing.TextShape" )
236 : {
237 2 : ShapeExport::WriteTextShape( xShape );
238 : }
239 896 : else if ( sShapeType == "com.sun.star.presentation.DateTimeShape" )
240 : {
241 22 : if( !WritePlaceholder( xShape, DateAndTime, mbMaster ) )
242 0 : ShapeExport::WriteTextShape( xShape );
243 : }
244 874 : else if ( sShapeType == "com.sun.star.presentation.FooterShape" )
245 : {
246 22 : if( !WritePlaceholder( xShape, Footer, mbMaster ) )
247 0 : ShapeExport::WriteTextShape( xShape );
248 : }
249 852 : else if ( sShapeType == "com.sun.star.presentation.HeaderShape" )
250 : {
251 2 : if( !WritePlaceholder( xShape, Header, mbMaster ) )
252 0 : ShapeExport::WriteTextShape( xShape );
253 : }
254 850 : else if ( sShapeType == "com.sun.star.presentation.NotesShape" )
255 : {
256 3 : if( mePageType == NOTICE && mrExport.GetPresObj() )
257 3 : WritePlaceholderShape( xShape, Notes );
258 : else
259 0 : ShapeExport::WriteTextShape( xShape );
260 : }
261 847 : else if ( sShapeType == "com.sun.star.presentation.OutlinerShape" )
262 : {
263 536 : if( !WritePlaceholder( xShape, Outliner, mbMaster ) )
264 2 : ShapeExport::WriteTextShape( xShape );
265 : }
266 311 : else if ( sShapeType == "com.sun.star.presentation.SlideNumberShape" )
267 : {
268 22 : if( !WritePlaceholder( xShape, SlideNumber, mbMaster ) )
269 0 : ShapeExport::WriteTextShape( xShape );
270 : }
271 289 : else if ( sShapeType == "com.sun.star.presentation.TitleTextShape" )
272 : {
273 289 : if( !WritePlaceholder( xShape, Title, mbMaster ) )
274 6 : ShapeExport::WriteTextShape( xShape );
275 : }
276 :
277 898 : return *this;
278 : }
279 :
280 84 : ShapeExport& PowerPointShapeExport::WriteUnknownShape( Reference< XShape > xShape )
281 : {
282 84 : OUString sShapeType = xShape->getShapeType();
283 :
284 : DBG(printf( "shape(unknown): %s\n", USS(sShapeType) ));
285 :
286 84 : if ( sShapeType == "com.sun.star.drawing.GroupShape" )
287 : {
288 10 : Reference< XIndexAccess > rXIndexAccess( xShape, UNO_QUERY );
289 :
290 10 : mrExport.EnterGroup( rXIndexAccess );
291 10 : DBG(printf( "enter group\n" ));
292 : }
293 74 : else if ( sShapeType == "com.sun.star.drawing.PageShape" )
294 : {
295 0 : WritePageShape( xShape, mePageType, mrExport.GetPresObj() );
296 : }
297 74 : else if ( sShapeType == "com.sun.star.presentation.SubtitleShape" )
298 : {
299 70 : if( !WritePlaceholder( xShape, Subtitle, mbMaster ) )
300 4 : ShapeExport::WriteTextShape( xShape );
301 : }
302 :
303 84 : return *this;
304 : }
305 :
306 26 : PowerPointExport::PowerPointExport( const Reference< XComponentContext > & rxCtxt )
307 : : XmlFilterBase(rxCtxt)
308 : , PPTWriterBase()
309 : , mnLayoutFileIdMax(1)
310 : , mnSlideIdMax(1 << 8)
311 : , mnSlideMasterIdMax(1U << 31)
312 : , mnAnimationNodeIdMax(1)
313 26 : , mbCreateNotes(false)
314 : {
315 26 : memset( mLayoutInfo, 0, sizeof(mLayoutInfo) );
316 26 : }
317 :
318 52 : PowerPointExport::~PowerPointExport()
319 : {
320 52 : }
321 :
322 26 : void PowerPointExport::writeDocumentProperties()
323 : {
324 26 : uno::Reference<document::XDocumentPropertiesSupplier> xDPS( mXModel, uno::UNO_QUERY );
325 52 : uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
326 :
327 26 : if (xDocProps.is())
328 : {
329 26 : PowerPointExport& mrExport(*this);
330 26 : mrExport.exportDocumentProperties( xDocProps );
331 26 : }
332 26 : }
333 :
334 0 : bool PowerPointExport::importDocument() throw()
335 : {
336 0 : return false;
337 : }
338 :
339 26 : bool PowerPointExport::exportDocument() throw (css::uno::RuntimeException, std::exception)
340 : {
341 26 : DrawingML::ResetCounters();
342 26 : maShapeMap.clear ();
343 :
344 26 : mXModel.set( getModel(), UNO_QUERY );
345 :
346 : //write document properties
347 26 : writeDocumentProperties();
348 :
349 26 : addRelation( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "ppt/presentation.xml" );
350 :
351 52 : mPresentationFS = openFragmentStreamWithSerializer( "ppt/presentation.xml",
352 26 : "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" );
353 :
354 : addRelation( mPresentationFS->getOutputStream(),
355 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
356 26 : "theme/theme1.xml" );
357 :
358 26 : mPresentationFS->startElementNS( XML_p, XML_presentation, PNMSS, FSEND );
359 :
360 26 : mXStatusIndicator.set( getStatusIndicator(), UNO_QUERY );
361 :
362 26 : OUString sBaseURI( "BaseURI");
363 52 : std::vector< PropertyValue > aProperties;
364 52 : PropertyValue aProperty;
365 26 : aProperty.Name = sBaseURI;
366 26 : aProperty.Value = makeAny( getFileUrl() );
367 26 : aProperties.push_back( aProperty );
368 :
369 26 : exportPPT(aProperties);
370 :
371 : mPresentationFS->singleElementNS( XML_p, XML_sldSz,
372 : XML_cx, IS( PPTtoEMU( maDestPageSize.Width ) ),
373 : XML_cy, IS( PPTtoEMU( maDestPageSize.Height ) ),
374 26 : FSEND );
375 : // for some reason if added before slides list it will not load the slides (alas with error reports) in mso
376 : mPresentationFS->singleElementNS( XML_p, XML_notesSz,
377 : XML_cx, IS( PPTtoEMU( maNotesPageSize.Width ) ),
378 : XML_cy, IS( PPTtoEMU( maNotesPageSize.Height ) ),
379 26 : FSEND );
380 :
381 26 : WriteAuthors();
382 :
383 26 : mPresentationFS->endElementNS( XML_p, XML_presentation );
384 26 : mPresentationFS.reset();
385 : // Free all FSHelperPtr, to flush data before committing storage
386 26 : mpSlidesFSArray.clear();
387 :
388 26 : commitStorage();
389 :
390 26 : maShapeMap.clear();
391 26 : maAuthors.clear();
392 :
393 52 : return true;
394 : }
395 :
396 0 : ::oox::ole::VbaProject* PowerPointExport::implCreateVbaProject() const
397 : {
398 0 : return new ::oox::ole::VbaProject( getComponentContext(), getModel(), "Impress" );
399 : }
400 :
401 27 : void PowerPointExport::ImplWriteBackground( FSHelperPtr pFS, Reference< XPropertySet > rXPropSet )
402 : {
403 27 : FillStyle aFillStyle( FillStyle_NONE );
404 27 : if ( ImplGetPropertyValue( rXPropSet, "FillStyle" ) )
405 27 : mAny >>= aFillStyle;
406 :
407 43 : if( aFillStyle == FillStyle_NONE ||
408 32 : aFillStyle == FillStyle_GRADIENT ||
409 16 : aFillStyle == FillStyle_HATCH )
410 38 : return;
411 :
412 16 : pFS->startElementNS( XML_p, XML_bg, FSEND );
413 16 : pFS->startElementNS( XML_p, XML_bgPr, FSEND );
414 :
415 16 : PowerPointShapeExport( pFS, &maShapeMap, this ).WriteFill( rXPropSet );
416 :
417 16 : pFS->endElementNS( XML_p, XML_bgPr );
418 16 : pFS->endElementNS( XML_p, XML_bg );
419 : }
420 :
421 : #define MAIN_GROUP \
422 : "<p:nvGrpSpPr>\
423 : <p:cNvPr id=\"1\" name=\"\"/>\
424 : <p:cNvGrpSpPr/>\
425 : <p:nvPr/>\
426 : </p:nvGrpSpPr>\
427 : <p:grpSpPr>\
428 : <a:xfrm>\
429 : <a:off x=\"0\" y=\"0\"/>\
430 : <a:ext cx=\"0\" cy=\"0\"/>\
431 : <a:chOff x=\"0\" y=\"0\"/>\
432 : <a:chExt cx=\"0\" cy=\"0\"/>\
433 : </a:xfrm>\
434 : </p:grpSpPr>"
435 :
436 : #define GETA(propName) \
437 : ImplGetPropertyValue( mXPagePropSet, OUString( #propName ) )
438 :
439 : #define GET(variable, propName) \
440 : if ( GETA(propName) ) \
441 : mAny >>= variable;
442 :
443 0 : const char* PowerPointExport::GetSideDirection( sal_uInt8 nDirection )
444 : {
445 0 : const char* pDirection = NULL;
446 :
447 0 : switch( nDirection ) {
448 : case 0:
449 0 : pDirection = "r";
450 0 : break;
451 : case 1:
452 0 : pDirection = "d";
453 0 : break;
454 : case 2:
455 0 : pDirection = "l";
456 0 : break;
457 : case 3:
458 0 : pDirection = "u";
459 0 : break;
460 : }
461 :
462 0 : return pDirection;
463 : }
464 :
465 0 : const char* PowerPointExport::GetCornerDirection( sal_uInt8 nDirection )
466 : {
467 0 : const char* pDirection = NULL;
468 :
469 0 : switch( nDirection ) {
470 : case 4:
471 0 : pDirection = "rd";
472 0 : break;
473 : case 5:
474 0 : pDirection = "ld";
475 0 : break;
476 : case 6:
477 0 : pDirection = "ru";
478 0 : break;
479 : case 7:
480 0 : pDirection = "lu";
481 0 : break;
482 : }
483 :
484 0 : return pDirection;
485 : }
486 :
487 0 : const char* PowerPointExport::Get8Direction( sal_uInt8 nDirection )
488 : {
489 0 : const char* pDirection = GetSideDirection( nDirection );
490 :
491 0 : if( !pDirection )
492 0 : pDirection = GetCornerDirection( nDirection );
493 :
494 0 : return pDirection;
495 : }
496 :
497 28 : void PowerPointExport::WriteTransition( FSHelperPtr pFS )
498 : {
499 28 : FadeEffect eFadeEffect = FadeEffect_NONE;
500 28 : GET( eFadeEffect, Effect );
501 :
502 : OSL_TRACE("fade effect %d", eFadeEffect);
503 :
504 28 : sal_Int16 nTransitionType = 0, nTransitionSubtype = 0;
505 28 : sal_Int8 nPPTTransitionType = 0;
506 28 : sal_uInt8 nDirection = 0;
507 :
508 196 : if( GETA( TransitionType ) && ( mAny >>= nTransitionType ) &&
509 196 : GETA( TransitionSubtype ) && ( mAny >>= nTransitionSubtype ) )
510 28 : nPPTTransitionType = GetTransition( nTransitionType, nTransitionSubtype, eFadeEffect, nDirection );
511 :
512 28 : if( !nPPTTransitionType && eFadeEffect != FadeEffect_NONE )
513 0 : nPPTTransitionType = GetTransition( eFadeEffect, nDirection );
514 :
515 28 : if( nPPTTransitionType ) {
516 0 : AnimationSpeed animationSpeed = AnimationSpeed_MEDIUM;
517 0 : const char* speed = NULL;
518 0 : sal_Int32 advanceTiming = -1;
519 0 : sal_Int32 changeType = 0;
520 :
521 0 : if( GETA( Speed ) ) {
522 0 : mAny >>= animationSpeed;
523 :
524 0 : switch( animationSpeed ) {
525 : default:
526 : case AnimationSpeed_MEDIUM:
527 0 : speed = "med";
528 0 : break;
529 : case AnimationSpeed_SLOW:
530 0 : speed = "slow";
531 0 : break;
532 : case AnimationSpeed_FAST:
533 0 : break;
534 : }
535 : }
536 :
537 0 : if( GETA( Change ) )
538 0 : mAny >>= changeType;
539 :
540 : // 1 means automatic, 2 half automatic - not sure what it means - at least I don't see it in UI
541 0 : if( changeType == 1 && GETA( Duration ) )
542 0 : mAny >>= advanceTiming;
543 :
544 : pFS->startElementNS( XML_p, XML_transition,
545 : XML_spd, speed,
546 0 : XML_advTm, advanceTiming != -1 ? I32S( advanceTiming*1000 ) : NULL,
547 0 : FSEND );
548 :
549 0 : sal_Int32 nTransition = 0;
550 0 : const char* pDirection = NULL;
551 0 : const char* pOrientation = NULL;
552 0 : const char* pThruBlk = NULL;
553 0 : const char* pSpokes = NULL;
554 0 : char pSpokesTmp[2] = "0";
555 :
556 0 : switch( nPPTTransitionType ) {
557 : case PPT_TRANSITION_TYPE_BLINDS:
558 0 : nTransition = XML_blinds;
559 0 : pDirection = ( nDirection == 0) ? "vert" : "horz";
560 0 : break;
561 : case PPT_TRANSITION_TYPE_CHECKER:
562 0 : nTransition = XML_checker;
563 0 : pDirection = ( nDirection == 1) ? "vert" : "horz";
564 0 : break;
565 : case PPT_TRANSITION_TYPE_CIRCLE:
566 0 : nTransition = XML_circle;
567 0 : break;
568 : case PPT_TRANSITION_TYPE_COMB:
569 0 : nTransition = XML_comb;
570 0 : pDirection = ( nDirection == 1) ? "vert" : "horz";
571 0 : break;
572 : case PPT_TRANSITION_TYPE_COVER:
573 0 : nTransition = XML_cover;
574 0 : pDirection = Get8Direction( nDirection );
575 0 : break;
576 : case PPT_TRANSITION_TYPE_DIAMOND:
577 0 : nTransition = XML_diamond;
578 0 : break;
579 : case PPT_TRANSITION_TYPE_DISSOLVE:
580 0 : nTransition = XML_dissolve;
581 0 : break;
582 : case PPT_TRANSITION_TYPE_FADE:
583 0 : nTransition = XML_fade;
584 0 : pThruBlk = "true";
585 0 : break;
586 : case PPT_TRANSITION_TYPE_SMOOTHFADE:
587 0 : nTransition = XML_fade;
588 0 : break;
589 : case PPT_TRANSITION_TYPE_NEWSFLASH:
590 0 : nTransition = XML_newsflash;
591 0 : break;
592 : case PPT_TRANSITION_TYPE_PLUS:
593 0 : nTransition = XML_plus;
594 0 : break;
595 : case PPT_TRANSITION_TYPE_PULL:
596 0 : nTransition = XML_pull;
597 0 : pDirection = Get8Direction( nDirection );
598 0 : break;
599 : case PPT_TRANSITION_TYPE_PUSH:
600 0 : nTransition = XML_push;
601 0 : pDirection = GetSideDirection( nDirection );
602 0 : break;
603 : case PPT_TRANSITION_TYPE_RANDOM:
604 0 : nTransition = XML_random;
605 0 : break;
606 : case PPT_TRANSITION_TYPE_RANDOM_BARS:
607 0 : nTransition = XML_randomBar;
608 0 : pDirection = ( nDirection == 1) ? "vert" : "horz";
609 0 : break;
610 : case PPT_TRANSITION_TYPE_SPLIT:
611 0 : nTransition = XML_split;
612 0 : pDirection = ( nDirection & 1) ? "in" : "out";
613 0 : pOrientation = ( nDirection < 2) ? "horz" : "vert";
614 0 : break;
615 : case PPT_TRANSITION_TYPE_STRIPS:
616 0 : nTransition = XML_strips;
617 0 : pDirection = GetCornerDirection( nDirection );
618 0 : break;
619 : case PPT_TRANSITION_TYPE_WEDGE:
620 0 : nTransition = XML_wedge;
621 0 : break;
622 : case PPT_TRANSITION_TYPE_WHEEL:
623 0 : nTransition = XML_wheel;
624 0 : if( nDirection != 4 && nDirection <= 9 ) {
625 0 : pSpokesTmp[0] = '0' + nDirection;
626 0 : pSpokes = pSpokesTmp;
627 : }
628 0 : break;
629 : case PPT_TRANSITION_TYPE_WIPE:
630 0 : nTransition = XML_wipe;
631 0 : pDirection = GetSideDirection( nDirection );
632 0 : break;
633 : case PPT_TRANSITION_TYPE_ZOOM:
634 0 : nTransition = XML_zoom;
635 0 : pDirection = ( nDirection == 1) ? "in" : "out";
636 0 : break;
637 : // coverity[dead_error_line] - following conditions exist to avoid compiler warning
638 : case PPT_TRANSITION_TYPE_NONE:
639 : default:
640 0 : nTransition = 0;
641 : }
642 :
643 0 : if( nTransition )
644 : pFS->singleElementNS( XML_p, nTransition,
645 : XML_dir, pDirection,
646 : XML_orient, pOrientation,
647 : XML_spokes, pSpokes,
648 : XML_thruBlk, pThruBlk,
649 0 : FSEND );
650 :
651 0 : pFS->endElementNS( XML_p, XML_transition );
652 : }
653 28 : }
654 :
655 0 : void PowerPointExport::WriteAnimationProperty( FSHelperPtr pFS, const Any& rAny )
656 : {
657 0 : if( !rAny.hasValue() )
658 0 : return;
659 :
660 0 : switch( rAny.getValueType().getTypeClass() ) {
661 : case TypeClass_STRING:
662 : pFS->singleElementNS( XML_p, XML_strVal,
663 0 : XML_val, USS( *static_cast< const OUString* >( rAny.getValue() ) ),
664 0 : FSEND );
665 0 : break;
666 : default:
667 0 : break;
668 : }
669 : }
670 :
671 0 : void PowerPointExport::WriteAnimateValues( FSHelperPtr pFS, const Reference< XAnimate >& rXAnimate )
672 : {
673 0 : const Sequence< double > aKeyTimes = rXAnimate->getKeyTimes();
674 0 : if( aKeyTimes.getLength() <= 0 )
675 0 : return;
676 0 : const Sequence< Any > aValues = rXAnimate->getValues();
677 0 : const OUString& sFormula = rXAnimate->getFormula();
678 0 : const OUString& rAttributeName = rXAnimate->getAttributeName();
679 :
680 : DBG(printf("animate values, formula: %s\n", USS( sFormula )));
681 :
682 0 : pFS->startElementNS( XML_p, XML_tavLst, FSEND );
683 :
684 0 : for( int i = 0; i < aKeyTimes.getLength(); i++ ) {
685 : DBG(printf("animate value %d: %f\n", i, aKeyTimes[ i ]));
686 0 : if( aValues[ i ].hasValue() ) {
687 : pFS->startElementNS( XML_p, XML_tav,
688 0 : XML_fmla, sFormula.isEmpty() ? NULL : USS( sFormula ),
689 0 : XML_tm, I32S( ( sal_Int32 )( aKeyTimes[ i ]*100000.0 ) ),
690 0 : FSEND );
691 0 : pFS->startElementNS( XML_p, XML_val, FSEND );
692 0 : ValuePair aPair;
693 0 : if( aValues[ i ] >>= aPair ) {
694 0 : WriteAnimationProperty( pFS, AnimationExporter::convertAnimateValue( aPair.First, rAttributeName ) );
695 0 : WriteAnimationProperty( pFS, AnimationExporter::convertAnimateValue( aPair.Second, rAttributeName ) );
696 : } else
697 0 : WriteAnimationProperty( pFS, AnimationExporter::convertAnimateValue( aValues[ i ], rAttributeName ) );
698 :
699 0 : pFS->endElementNS( XML_p, XML_val );
700 0 : pFS->endElementNS( XML_p, XML_tav );
701 : }
702 : }
703 :
704 0 : pFS->endElementNS( XML_p, XML_tavLst );
705 : }
706 :
707 0 : void PowerPointExport::WriteAnimateTo( FSHelperPtr pFS, const Any& rValue, const OUString& rAttributeName )
708 : {
709 0 : if( !rValue.hasValue() )
710 0 : return;
711 :
712 : DBG(printf("to attribute name: %s\n", USS( rAttributeName )));
713 :
714 0 : pFS->startElementNS( XML_p, XML_to, FSEND );
715 :
716 0 : WriteAnimationProperty(pFS, AnimationExporter::convertAnimateValue(rValue, rAttributeName));
717 :
718 0 : pFS->endElementNS( XML_p, XML_to );
719 : }
720 :
721 0 : void PowerPointExport::WriteAnimationAttributeName( FSHelperPtr pFS, const OUString& rAttributeName )
722 : {
723 0 : if( rAttributeName.isEmpty() )
724 0 : return;
725 :
726 0 : pFS->startElementNS( XML_p, XML_attrNameLst, FSEND );
727 :
728 : DBG(printf("write attribute name: %s\n", USS( rAttributeName )));
729 :
730 0 : const char* sAttributeName = NULL;
731 0 : if ( rAttributeName == "Visibility" ) {
732 0 : sAttributeName = "style.visibility";
733 0 : } else if ( rAttributeName == "X" ) {
734 0 : sAttributeName = "ppt_x";
735 0 : } else if ( rAttributeName == "Y" ) {
736 0 : sAttributeName = "ppt_y";
737 : }
738 :
739 0 : pFS->startElementNS( XML_p, XML_attrName, FSEND );
740 0 : pFS->writeEscaped( sAttributeName );
741 0 : pFS->endElementNS( XML_p, XML_attrName );
742 :
743 0 : pFS->endElementNS( XML_p, XML_attrNameLst );
744 : }
745 :
746 0 : void PowerPointExport::WriteAnimationTarget( FSHelperPtr pFS, const Any& rTarget )
747 : {
748 0 : sal_Int32 nBegin = -1, nEnd = -1;
749 : bool bParagraphTarget;
750 0 : Reference< XShape > rXShape = AnimationExporter::getTargetElementShape( rTarget, nBegin, nEnd, bParagraphTarget );
751 :
752 0 : if( rXShape.is() ) {
753 0 : pFS->startElementNS( XML_p, XML_tgtEl, FSEND );
754 : pFS->startElementNS( XML_p, XML_spTgt,
755 : XML_spid, I32S( ShapeExport::GetShapeID( rXShape, &maShapeMap ) ),
756 0 : FSEND );
757 0 : if( bParagraphTarget ) {
758 0 : pFS->startElementNS( XML_p, XML_txEl, FSEND );
759 : pFS->singleElementNS( XML_p, XML_pRg,
760 : XML_st, I32S( nBegin ),
761 : XML_end, I32S( nEnd ),
762 0 : FSEND );
763 0 : pFS->endElementNS( XML_p, XML_txEl );
764 : }
765 0 : pFS->endElementNS( XML_p, XML_spTgt );
766 0 : pFS->endElementNS( XML_p, XML_tgtEl );
767 0 : }
768 0 : }
769 :
770 0 : void PowerPointExport::WriteAnimationNodeAnimate( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild )
771 : {
772 0 : Reference< XAnimate > rXAnimate( rXNode, UNO_QUERY );
773 0 : if( !rXAnimate.is() )
774 0 : return;
775 :
776 0 : const char* pCalcMode = NULL;
777 0 : const char* pValueType = NULL;
778 0 : bool bSimple = ( nXmlNodeType != XML_anim );
779 :
780 0 : if( !bSimple ) {
781 0 : switch( rXAnimate->getCalcMode() ) {
782 : case AnimationCalcMode::DISCRETE:
783 0 : pCalcMode = "discrete";
784 0 : break;
785 : case AnimationCalcMode::LINEAR:
786 0 : pCalcMode = "lin";
787 0 : break;
788 : }
789 :
790 0 : switch( AnimationExporter::GetValueTypeForAttributeName( rXAnimate->getAttributeName() ) ) {
791 : case AnimationValueType::STRING:
792 0 : pValueType = "str";
793 0 : break;
794 : case AnimationValueType::NUMBER:
795 0 : pValueType = "num";
796 0 : break;
797 : case AnimationValueType::COLOR:
798 0 : pValueType = "clr";
799 0 : break;
800 : }
801 : }
802 :
803 : pFS->startElementNS( XML_p, nXmlNodeType,
804 : XML_calcmode, pCalcMode,
805 : XML_valueType, pValueType,
806 0 : FSEND );
807 0 : WriteAnimationNodeAnimateInside( pFS, rXNode, bMainSeqChild, bSimple );
808 0 : pFS->endElementNS( XML_p, nXmlNodeType );
809 : }
810 :
811 0 : void PowerPointExport::WriteAnimationNodeAnimateInside( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, bool bMainSeqChild, bool bSimple )
812 : {
813 0 : Reference< XAnimate > rXAnimate( rXNode, UNO_QUERY );
814 0 : if( !rXAnimate.is() )
815 0 : return;
816 :
817 0 : const char* pAdditive = NULL;
818 :
819 0 : if( !bSimple ) {
820 0 : switch( rXAnimate->getAdditive() ) {
821 : case AnimationAdditiveMode::BASE:
822 0 : pAdditive = "base";
823 0 : break;
824 : case AnimationAdditiveMode::SUM:
825 0 : pAdditive = "sum";
826 0 : break;
827 : case AnimationAdditiveMode::REPLACE:
828 0 : pAdditive = "repl";
829 0 : break;
830 : case AnimationAdditiveMode::MULTIPLY:
831 0 : pAdditive = "mult";
832 0 : break;
833 : case AnimationAdditiveMode::NONE:
834 0 : pAdditive = "none";
835 0 : break;
836 : }
837 : }
838 :
839 : pFS->startElementNS( XML_p, XML_cBhvr,
840 : XML_additive, pAdditive,
841 0 : FSEND );
842 0 : WriteAnimationNodeCommonPropsStart( pFS, rXNode, true, bMainSeqChild );
843 0 : WriteAnimationTarget( pFS, rXAnimate->getTarget() );
844 0 : WriteAnimationAttributeName( pFS, rXAnimate->getAttributeName() );
845 0 : pFS->endElementNS( XML_p, XML_cBhvr );
846 0 : WriteAnimateValues( pFS, rXAnimate );
847 0 : WriteAnimateTo( pFS, rXAnimate->getTo(), rXAnimate->getAttributeName() );
848 : }
849 :
850 2 : void PowerPointExport::WriteAnimationCondition( FSHelperPtr pFS, const char* pDelay, const char* pEvent, double fDelay, bool bHasFDelay )
851 : {
852 2 : if( bHasFDelay || pDelay || pEvent ) {
853 2 : if( !pEvent )
854 : pFS->singleElementNS( XML_p, XML_cond,
855 0 : XML_delay, bHasFDelay ? I64S( (sal_uInt32) (fDelay*1000.0) ) : pDelay,
856 0 : FSEND );
857 : else {
858 : pFS->startElementNS( XML_p, XML_cond,
859 6 : XML_delay, bHasFDelay ? I64S( (sal_uInt32) (fDelay*1000.0) ) : pDelay,
860 : XML_evt, pEvent,
861 4 : FSEND );
862 :
863 2 : pFS->startElementNS( XML_p, XML_tgtEl, FSEND );
864 2 : pFS->singleElementNS( XML_p, XML_sldTgt, FSEND );
865 2 : pFS->endElementNS( XML_p, XML_tgtEl );
866 :
867 2 : pFS->endElementNS( XML_p, XML_cond );
868 : }
869 : }
870 2 : }
871 :
872 0 : void PowerPointExport::WriteAnimationCondition( FSHelperPtr pFS, Any& rAny, bool bWriteEvent, bool bMainSeqChild )
873 : {
874 0 : bool bHasFDelay = false;
875 0 : double fDelay = 0;
876 : Timing eTiming;
877 0 : Event aEvent;
878 0 : const char* pDelay = NULL;
879 0 : const char* pEvent = NULL;
880 :
881 0 : if( rAny >>= fDelay )
882 0 : bHasFDelay = true;
883 0 : else if( rAny >>= eTiming )
884 : {
885 0 : if( eTiming == Timing_INDEFINITE )
886 0 : pDelay = "indefinite";
887 : }
888 0 : else if( rAny >>= aEvent )
889 : {
890 : // TODO
891 : DBG(printf ("animation condition event: TODO\n"));
892 : DBG(printf ("event offset has value: %d trigger: %d source has value: %d\n", aEvent.Offset.hasValue(), aEvent.Trigger, aEvent.Source.hasValue()));
893 :
894 0 : if( !bWriteEvent && aEvent.Trigger == EventTrigger::ON_NEXT && bMainSeqChild )
895 0 : pDelay = "indefinite";
896 0 : else if( bWriteEvent ) {
897 0 : switch( aEvent.Trigger ) {
898 : case EventTrigger::ON_NEXT:
899 0 : pEvent = "onNext";
900 0 : break;
901 : case EventTrigger::ON_PREV:
902 0 : pEvent = "onPrev";
903 0 : break;
904 : case EventTrigger::BEGIN_EVENT:
905 0 : pEvent = "begin";
906 0 : break;
907 : case EventTrigger::END_EVENT:
908 0 : pEvent = "end";
909 0 : break;
910 : case EventTrigger::ON_BEGIN:
911 0 : pEvent = "onBegin";
912 0 : break;
913 : case EventTrigger::ON_END:
914 0 : pEvent = "onEnd";
915 0 : break;
916 : case EventTrigger::ON_CLICK:
917 0 : pEvent = "onClick";
918 0 : break;
919 : case EventTrigger::ON_DBL_CLICK:
920 0 : pEvent = "onDblClick";
921 0 : break;
922 : case EventTrigger::ON_STOP_AUDIO:
923 0 : pEvent = "onStopAudio";
924 0 : break;
925 : case EventTrigger::ON_MOUSE_ENTER:
926 0 : pEvent = "onMouseOver"; // not exact?
927 0 : break;
928 : case EventTrigger::ON_MOUSE_LEAVE:
929 0 : pEvent = "onMouseOut";
930 0 : break;
931 : }
932 : }
933 :
934 0 : if( aEvent.Offset >>= fDelay ) {
935 0 : bHasFDelay = true;
936 : DBG(printf ("event offset: %f\n", fDelay));
937 0 : } else if( aEvent.Offset >>= eTiming ) {
938 0 : if( eTiming == Timing_INDEFINITE )
939 0 : pDelay = "indefinite";
940 : DBG(printf ("event offset timing: %d\n", eTiming));
941 : }
942 : }
943 :
944 0 : WriteAnimationCondition( pFS, pDelay, pEvent, fDelay, bHasFDelay );
945 0 : }
946 :
947 2 : void PowerPointExport::WriteAnimationNodeCommonPropsStart( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, bool bSingle, bool bMainSeqChild )
948 : {
949 2 : const char* pDuration = NULL;
950 2 : const char* pRestart = NULL;
951 2 : const char* pNodeType = NULL;
952 2 : const char* pPresetClass = NULL;
953 2 : const char* pFill = NULL;
954 2 : double fDuration = 0;
955 2 : Any aAny;
956 :
957 2 : aAny = rXNode->getDuration();
958 2 : if( aAny.hasValue() ) {
959 : Timing eTiming;
960 :
961 1 : if( aAny >>= eTiming ) {
962 1 : if( eTiming == Timing_INDEFINITE )
963 1 : pDuration = "indefinite";
964 : } else
965 0 : aAny >>= fDuration;
966 : }
967 :
968 2 : switch( rXNode->getRestart() ) {
969 : case AnimationRestart::ALWAYS:
970 0 : pRestart = "always";
971 0 : break;
972 : case AnimationRestart::WHEN_NOT_ACTIVE:
973 0 : pRestart = "whenNotActive";
974 0 : break;
975 : case AnimationRestart::NEVER:
976 1 : pRestart = "never";
977 1 : break;
978 : }
979 :
980 2 : const Sequence< NamedValue > aUserData = rXNode->getUserData();
981 : const Any* pAny[ DFF_ANIM_PROPERTY_ID_COUNT ];
982 2 : AnimationExporter::GetUserData( aUserData, pAny, sizeof( pAny ) );
983 :
984 2 : sal_Int16 nType = 0;
985 2 : if( pAny[ DFF_ANIM_NODE_TYPE ] && ( *pAny[ DFF_ANIM_NODE_TYPE ] >>= nType ) ) {
986 2 : switch( nType ) {
987 : case EffectNodeType::TIMING_ROOT:
988 1 : pNodeType = "tmRoot";
989 1 : if( !pDuration )
990 0 : pDuration = "indefinite";
991 1 : if( !pRestart )
992 0 : pRestart = "never";
993 1 : break;
994 : case EffectNodeType::MAIN_SEQUENCE:
995 1 : pNodeType = "mainSeq";
996 1 : break;
997 : case EffectNodeType::ON_CLICK:
998 0 : pNodeType = "clickEffect";
999 0 : break;
1000 : case EffectNodeType::AFTER_PREVIOUS:
1001 0 : pNodeType = "afterEffect";
1002 0 : break;
1003 : case EffectNodeType::WITH_PREVIOUS:
1004 0 : pNodeType = "withEffect";
1005 0 : break;
1006 : case EffectNodeType::INTERACTIVE_SEQUENCE:
1007 0 : pNodeType = "interactiveSeq";
1008 0 : break;
1009 : }
1010 : }
1011 :
1012 2 : sal_uInt32 nPresetClass = DFF_ANIM_PRESS_CLASS_USER_DEFINED;
1013 2 : if ( pAny[ DFF_ANIM_PRESET_CLASS ] ) {
1014 0 : if ( *pAny[ DFF_ANIM_PRESET_CLASS ] >>= nPresetClass ) {
1015 0 : switch( nPresetClass ) {
1016 : case EffectPresetClass::ENTRANCE:
1017 0 : pPresetClass = "entr";
1018 0 : break;
1019 : case EffectPresetClass::EXIT:
1020 0 : pPresetClass = "exit";
1021 0 : break;
1022 : case EffectPresetClass::EMPHASIS:
1023 0 : pPresetClass = "emph";
1024 0 : break;
1025 : case EffectPresetClass::MOTIONPATH:
1026 0 : pPresetClass = "path";
1027 0 : break;
1028 : case EffectPresetClass::OLEACTION:
1029 0 : pPresetClass = "verb"; // ?
1030 0 : break;
1031 : case EffectPresetClass::MEDIACALL:
1032 0 : pPresetClass = "mediacall";
1033 0 : break;
1034 : }
1035 : }
1036 : }
1037 :
1038 2 : sal_uInt32 nPresetId = 0;
1039 2 : bool bPresetId = false;
1040 2 : if ( pAny[ DFF_ANIM_PRESET_ID ] ) {
1041 0 : OUString sPreset;
1042 0 : if ( *pAny[ DFF_ANIM_PRESET_ID ] >>= sPreset )
1043 0 : nPresetId = AnimationExporter::GetPresetID( sPreset, nPresetClass, bPresetId );
1044 : }
1045 :
1046 2 : sal_uInt32 nPresetSubType = 0;
1047 2 : bool bPresetSubType = false;
1048 2 : if ( pAny[ DFF_ANIM_PRESET_SUB_TYPE ] ) {
1049 0 : OUString sPresetSubType;
1050 0 : if ( *pAny[ DFF_ANIM_PRESET_SUB_TYPE ] >>= sPresetSubType ) {
1051 0 : nPresetSubType = AnimationExporter::TranslatePresetSubType( nPresetClass, nPresetId, sPresetSubType );
1052 0 : bPresetSubType = true;
1053 0 : }
1054 : }
1055 :
1056 2 : if( nType != EffectNodeType::TIMING_ROOT && nType != EffectNodeType::MAIN_SEQUENCE ) {
1057 : // it doesn't seem to work right on root and mainseq nodes
1058 0 : sal_Int16 nFill = AnimationExporter::GetFillMode( rXNode, AnimationFill::AUTO );
1059 0 : switch( nFill ) {
1060 : case AnimationFill::FREEZE:
1061 0 : pFill = "freeze";
1062 0 : break;
1063 : case AnimationFill::HOLD:
1064 0 : pFill = "hold";
1065 0 : break;
1066 : case AnimationFill::REMOVE:
1067 0 : pFill = "remove";
1068 0 : break;
1069 : case AnimationFill::TRANSITION:
1070 0 : pFill = "transition";
1071 0 : break;
1072 : }
1073 : }
1074 :
1075 : pFS->startElementNS( XML_p, XML_cTn,
1076 : XML_id, I64S( mnAnimationNodeIdMax ++ ),
1077 4 : XML_dur, fDuration != 0 ? I32S( (sal_Int32) ( fDuration * 1000.0 ) ) : pDuration,
1078 : XML_restart, pRestart,
1079 : XML_nodeType, pNodeType,
1080 : XML_fill, pFill,
1081 : XML_presetClass, pPresetClass,
1082 2 : XML_presetID, bPresetId ? I64S( nPresetId ) : NULL,
1083 2 : XML_presetSubtype, bPresetSubType ? I64S( nPresetSubType ) : NULL,
1084 6 : FSEND );
1085 :
1086 2 : aAny = rXNode->getBegin();
1087 2 : if( aAny.hasValue() ) {
1088 0 : Sequence< Any > aCondSeq;
1089 :
1090 0 : pFS->startElementNS( XML_p, XML_stCondLst, FSEND );
1091 0 : if( aAny >>= aCondSeq ) {
1092 0 : for( int i = 0; i < aCondSeq.getLength(); i ++ )
1093 0 : WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild );
1094 : } else
1095 0 : WriteAnimationCondition( pFS, aAny, false, bMainSeqChild );
1096 0 : pFS->endElementNS( XML_p, XML_stCondLst );
1097 : }
1098 :
1099 2 : aAny = rXNode->getEnd();
1100 2 : if( aAny.hasValue() ) {
1101 0 : Sequence< Any > aCondSeq;
1102 :
1103 0 : pFS->startElementNS( XML_p, XML_endCondLst, FSEND );
1104 0 : if( aAny >>= aCondSeq ) {
1105 0 : for( int i = 0; i < aCondSeq.getLength(); i ++ )
1106 0 : WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild );
1107 : } else
1108 0 : WriteAnimationCondition( pFS, aAny, false, bMainSeqChild );
1109 0 : pFS->endElementNS( XML_p, XML_endCondLst );
1110 : }
1111 :
1112 2 : Reference< XEnumerationAccess > xEnumerationAccess( rXNode, UNO_QUERY );
1113 2 : if( xEnumerationAccess.is() ) {
1114 2 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY );
1115 2 : if( xEnumeration.is() ) {
1116 : DBG(printf ("-----\n"));
1117 :
1118 2 : if( xEnumeration->hasMoreElements() ) {
1119 1 : pFS->startElementNS( XML_p, XML_childTnLst, FSEND );
1120 :
1121 1 : do {
1122 1 : Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY );
1123 1 : if( xChildNode.is() )
1124 1 : WriteAnimationNode( pFS, xChildNode, nType == EffectNodeType::MAIN_SEQUENCE );
1125 1 : } while( xEnumeration->hasMoreElements() );
1126 :
1127 1 : pFS->endElementNS( XML_p, XML_childTnLst );
1128 : }
1129 : DBG(printf ("-----\n"));
1130 2 : }
1131 : }
1132 :
1133 2 : if( bSingle )
1134 2 : pFS->endElementNS( XML_p, XML_cTn );
1135 2 : }
1136 :
1137 1 : void PowerPointExport::WriteAnimationNodeSeq( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, sal_Int32, bool bMainSeqChild )
1138 : {
1139 : DBG(printf ("write animation node SEQ\n"));
1140 :
1141 1 : pFS->startElementNS( XML_p, XML_seq, FSEND );
1142 :
1143 1 : WriteAnimationNodeCommonPropsStart( pFS, rXNode, true, bMainSeqChild );
1144 :
1145 1 : pFS->startElementNS( XML_p, XML_prevCondLst, FSEND );
1146 1 : WriteAnimationCondition( pFS, NULL, "onPrev", 0, true );
1147 1 : pFS->endElementNS( XML_p, XML_prevCondLst );
1148 :
1149 1 : pFS->startElementNS( XML_p, XML_nextCondLst, FSEND );
1150 1 : WriteAnimationCondition( pFS, NULL, "onNext", 0, true );
1151 1 : pFS->endElementNS( XML_p, XML_nextCondLst );
1152 :
1153 1 : pFS->endElementNS( XML_p, XML_seq );
1154 1 : }
1155 :
1156 0 : void PowerPointExport::WriteAnimationNodeEffect( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, sal_Int32, bool bMainSeqChild )
1157 : {
1158 : DBG(printf ("write animation node FILTER\n"));
1159 :
1160 0 : Reference< XTransitionFilter > xFilter( rXNode, UNO_QUERY );
1161 0 : if ( xFilter.is() ) {
1162 0 : const char* pFilter = ppt::AnimationExporter::FindTransitionName( xFilter->getTransition(), xFilter->getSubtype(), xFilter->getDirection() );
1163 0 : const char* pDirection = xFilter->getDirection() ? "in" : "out";
1164 : pFS->startElementNS( XML_p, XML_animEffect,
1165 : XML_filter, pFilter,
1166 : XML_transition, pDirection,
1167 0 : FSEND );
1168 :
1169 0 : WriteAnimationNodeAnimateInside( pFS, rXNode, bMainSeqChild, false );
1170 :
1171 0 : pFS->endElementNS( XML_p, XML_animEffect );
1172 0 : }
1173 0 : }
1174 :
1175 2 : void PowerPointExport::WriteAnimationNode( FSHelperPtr pFS, const Reference< XAnimationNode >& rXNode, bool bMainSeqChild )
1176 : {
1177 : DBG(printf ("export node type: %d\n", rXNode->getType()));
1178 2 : sal_Int32 xmlNodeType = -1;
1179 : typedef void (PowerPointExport::*AnimationNodeWriteMethod)( FSHelperPtr, const Reference< XAnimationNode >&, sal_Int32, bool );
1180 2 : AnimationNodeWriteMethod pMethod = NULL;
1181 :
1182 2 : switch( rXNode->getType() ) {
1183 : case AnimationNodeType::PAR:
1184 1 : xmlNodeType = XML_par;
1185 1 : break;
1186 : case AnimationNodeType::SEQ:
1187 1 : pMethod = &PowerPointExport::WriteAnimationNodeSeq;
1188 1 : break;
1189 : case AnimationNodeType::ANIMATE:
1190 0 : xmlNodeType = XML_anim;
1191 0 : pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
1192 0 : break;
1193 : case AnimationNodeType::SET:
1194 0 : xmlNodeType = XML_set;
1195 0 : pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
1196 0 : break;
1197 : case AnimationNodeType::TRANSITIONFILTER:
1198 0 : xmlNodeType = XML_animEffect;
1199 0 : pMethod = &PowerPointExport::WriteAnimationNodeEffect;
1200 0 : break;
1201 : }
1202 :
1203 2 : if( pMethod ) {
1204 1 : (this->*(pMethod))( pFS, rXNode, xmlNodeType, bMainSeqChild );
1205 2 : return;
1206 : }
1207 :
1208 1 : if( xmlNodeType == -1 )
1209 0 : return;
1210 :
1211 1 : pFS->startElementNS( XML_p, xmlNodeType, FSEND );
1212 :
1213 1 : WriteAnimationNodeCommonPropsStart( pFS, rXNode, true, bMainSeqChild );
1214 :
1215 1 : pFS->endElementNS( XML_p, xmlNodeType );
1216 : }
1217 :
1218 28 : void PowerPointExport::WriteAnimations( FSHelperPtr pFS )
1219 : {
1220 28 : Reference< XAnimationNodeSupplier > xNodeSupplier( mXDrawPage, UNO_QUERY );
1221 28 : if( xNodeSupplier.is() ) {
1222 28 : const Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() );
1223 28 : if( xNode.is() ) {
1224 28 : Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY );
1225 28 : if( xEnumerationAccess.is() ) {
1226 28 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY );
1227 28 : if( xEnumeration.is() && xEnumeration->hasMoreElements() ) {
1228 :
1229 1 : pFS->startElementNS( XML_p, XML_timing, FSEND );
1230 1 : pFS->startElementNS( XML_p, XML_tnLst, FSEND );
1231 :
1232 1 : WriteAnimationNode( pFS, xNode, false );
1233 :
1234 1 : pFS->endElementNS( XML_p, XML_tnLst );
1235 1 : pFS->endElementNS( XML_p, XML_timing );
1236 28 : }
1237 28 : }
1238 28 : }
1239 28 : }
1240 28 : }
1241 :
1242 0 : static OUString lcl_GetInitials( const OUString& sName )
1243 : {
1244 0 : OUStringBuffer sRet;
1245 :
1246 0 : if ( !sName.isEmpty() ) {
1247 0 : sRet.append ( sName[0] );
1248 0 : sal_Int32 nStart = 0, nOffset;
1249 :
1250 0 : while ( ( nOffset = sName.indexOf ( ' ', nStart ) ) != -1 ) {
1251 0 : if ( nOffset + 1 < sName.getLength() )
1252 0 : sRet.append ( sName[ nOffset + 1 ] );
1253 0 : nStart = nOffset + 1;
1254 : }
1255 : }
1256 :
1257 0 : return sRet.makeStringAndClear();
1258 : }
1259 :
1260 26 : void PowerPointExport::WriteAuthors()
1261 : {
1262 26 : if ( maAuthors.size() <= 0 )
1263 52 : return;
1264 :
1265 : FSHelperPtr pFS = openFragmentStreamWithSerializer( "ppt/commentAuthors.xml",
1266 0 : "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml" );
1267 : addRelation( mPresentationFS->getOutputStream(),
1268 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
1269 0 : "commentAuthors.xml" );
1270 :
1271 : pFS->startElementNS( XML_p, XML_cmAuthorLst,
1272 : FSNS( XML_xmlns, XML_p ), "http://schemas.openxmlformats.org/presentationml/2006/main",
1273 0 : FSEND );
1274 :
1275 0 : for( AuthorsMap::value_type i : maAuthors ) {
1276 : pFS->singleElementNS( XML_p, XML_cmAuthor,
1277 : XML_id, I32S( i.second.nId ),
1278 : XML_name, USS( i.first ),
1279 : XML_initials, USS( lcl_GetInitials( i.first ) ),
1280 : XML_lastIdx, I32S( i.second.nLastIndex ),
1281 : XML_clrIdx, I32S( i.second.nId ),
1282 0 : FSEND );
1283 0 : }
1284 :
1285 0 : pFS->endElementNS( XML_p, XML_cmAuthorLst );
1286 : }
1287 :
1288 0 : sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex( const OUString& sAuthor, sal_Int32& nLastIndex )
1289 : {
1290 0 : if ( maAuthors.count( sAuthor ) <= 0 ) {
1291 : struct AuthorComments aAuthorComments;
1292 :
1293 0 : aAuthorComments.nId = maAuthors.size();
1294 0 : aAuthorComments.nLastIndex = 0;
1295 :
1296 0 : maAuthors[ sAuthor ] = aAuthorComments;
1297 : }
1298 :
1299 0 : nLastIndex = ++maAuthors[ sAuthor ].nLastIndex;
1300 :
1301 0 : return maAuthors[ sAuthor ].nId;
1302 : }
1303 :
1304 28 : bool PowerPointExport::WriteComments( sal_uInt32 nPageNum )
1305 : {
1306 28 : Reference< XAnnotationAccess > xAnnotationAccess( mXDrawPage, uno::UNO_QUERY );
1307 28 : if ( xAnnotationAccess.is() )
1308 : {
1309 28 : Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
1310 :
1311 28 : if ( xAnnotationEnumeration->hasMoreElements() )
1312 : {
1313 : FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer()
1314 0 : .appendAscii( "ppt/comments/comment" )
1315 0 : .append( (sal_Int32) nPageNum + 1 )
1316 0 : .appendAscii( ".xml" )
1317 : .makeStringAndClear(),
1318 0 : "application/vnd.openxmlformats-officedocument.presentationml.comments+xml" );
1319 :
1320 : pFS->startElementNS( XML_p, XML_cmLst,
1321 : FSNS( XML_xmlns, XML_p ), "http://schemas.openxmlformats.org/presentationml/2006/main",
1322 0 : FSEND );
1323 :
1324 0 : do {
1325 0 : Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
1326 0 : DateTime aDateTime( xAnnotation->getDateTime() );
1327 0 : RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
1328 0 : Reference< XText > xText( xAnnotation->getTextRange() );
1329 : sal_Int32 nLastIndex;
1330 0 : sal_Int32 nId = GetAuthorIdAndLastIndex ( xAnnotation->getAuthor(), nLastIndex );
1331 : char cDateTime[32];
1332 :
1333 0 : snprintf(cDateTime, 31, "%02d-%02d-%02dT%02d:%02d:%02d.%09" SAL_PRIuUINT32, aDateTime.Year, aDateTime.Month, aDateTime.Day, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
1334 :
1335 : pFS->startElementNS( XML_p, XML_cm,
1336 : XML_authorId, I32S( nId ),
1337 : XML_dt, cDateTime,
1338 : XML_idx, I32S( nLastIndex ),
1339 0 : FSEND );
1340 :
1341 : pFS->singleElementNS( XML_p, XML_pos,
1342 0 : XML_x, I64S( ( (sal_Int64) ( 57600*aRealPoint2D.X + 1270 )/2540.0 ) ),
1343 0 : XML_y, I64S( ( (sal_Int64) ( 57600*aRealPoint2D.Y + 1270 )/2540.0 ) ),
1344 0 : FSEND );
1345 :
1346 : pFS->startElementNS( XML_p, XML_text,
1347 0 : FSEND );
1348 0 : pFS->write( xText->getString() );
1349 0 : pFS->endElementNS( XML_p, XML_text );
1350 :
1351 0 : pFS->endElementNS( XML_p, XML_cm );
1352 :
1353 0 : } while ( xAnnotationEnumeration->hasMoreElements() );
1354 :
1355 0 : pFS->endElementNS( XML_p, XML_cmLst );
1356 :
1357 0 : return true;
1358 28 : }
1359 : }
1360 :
1361 28 : return false;
1362 : }
1363 :
1364 28 : void PowerPointExport::ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNum, sal_uInt16 /* nMode */,
1365 : bool bHasBackground, Reference< XPropertySet > aXBackgroundPropSet )
1366 : {
1367 : DBG(printf("write slide: %" SAL_PRIuUINT32 "\n----------------\n", nPageNum));
1368 :
1369 : // slides list
1370 28 : if( nPageNum == 0 )
1371 26 : mPresentationFS->startElementNS( XML_p, XML_sldIdLst, FSEND );
1372 :
1373 : // add explicit relation of presentation to this slide
1374 : OUString sRelId = addRelation( mPresentationFS->getOutputStream(),
1375 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
1376 : OUStringBuffer()
1377 56 : .appendAscii( "slides/slide" )
1378 56 : .append( (sal_Int32) nPageNum + 1 )
1379 28 : .appendAscii( ".xml" )
1380 28 : .makeStringAndClear() );
1381 :
1382 : mPresentationFS->singleElementNS( XML_p, XML_sldId,
1383 28 : XML_id, I32S( GetNewSlideId() ),
1384 : FSNS( XML_r, XML_id ), USS( sRelId ),
1385 56 : FSEND );
1386 :
1387 28 : if( nPageNum == mnPages - 1 )
1388 26 : mPresentationFS->endElementNS( XML_p, XML_sldIdLst );
1389 :
1390 : FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer()
1391 56 : .appendAscii( "ppt/slides/slide" )
1392 56 : .append( (sal_Int32) nPageNum + 1 )
1393 28 : .appendAscii( ".xml" )
1394 : .makeStringAndClear(),
1395 112 : "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" );
1396 :
1397 28 : if( mpSlidesFSArray.size() < mnPages )
1398 26 : mpSlidesFSArray.resize( mnPages );
1399 28 : mpSlidesFSArray[ nPageNum ] = pFS;
1400 :
1401 28 : const char* pShow = NULL;
1402 :
1403 28 : if( GETA( Visible ) ) {
1404 28 : bool bShow(false);
1405 28 : if( ( mAny >>= bShow ) && !bShow )
1406 0 : pShow = "0";
1407 : }
1408 :
1409 : pFS->startElementNS( XML_p, XML_sld, PNMSS,
1410 : XML_show, pShow,
1411 28 : FSEND );
1412 :
1413 28 : pFS->startElementNS( XML_p, XML_cSld, FSEND );
1414 :
1415 : // background
1416 28 : if( bHasBackground ) {
1417 1 : ImplWriteBackground( pFS, aXBackgroundPropSet );
1418 : }
1419 :
1420 28 : WriteShapeTree( pFS, NORMAL, false );
1421 :
1422 28 : pFS->endElementNS( XML_p, XML_cSld );
1423 :
1424 28 : WriteTransition( pFS );
1425 28 : WriteAnimations( pFS );
1426 :
1427 28 : pFS->endElementNS( XML_p, XML_sld );
1428 :
1429 : // add implicit relation to slide layout
1430 : addRelation( pFS->getOutputStream(),
1431 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
1432 : OUStringBuffer()
1433 56 : .appendAscii( "../slideLayouts/slideLayout" )
1434 56 : .append( GetLayoutFileId( GetPPTXLayoutId( GetLayoutOffset( mXPagePropSet ) ), nMasterNum ) )
1435 28 : .appendAscii( ".xml" )
1436 28 : .makeStringAndClear() );
1437 :
1438 28 : if ( WriteComments( nPageNum ) )
1439 : // add implicit relation to slide comments
1440 : addRelation( pFS->getOutputStream(),
1441 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
1442 : OUStringBuffer()
1443 0 : .appendAscii( "../comments/comment" )
1444 0 : .append( (sal_Int32) nPageNum + 1 )
1445 0 : .appendAscii( ".xml" )
1446 0 : .makeStringAndClear() );
1447 :
1448 28 : DBG(printf("----------------\n"));
1449 28 : }
1450 :
1451 28 : void PowerPointExport::ImplWriteNotes( sal_uInt32 nPageNum )
1452 : {
1453 28 : if( !mbCreateNotes || !ContainsOtherShapeThanPlaceholders( true ) )
1454 54 : return;
1455 :
1456 : DBG(printf("write Notes %" SAL_PRIuUINT32 "\n----------------\n", nPageNum));
1457 :
1458 : FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer()
1459 4 : .appendAscii( "ppt/notesSlides/notesSlide" )
1460 4 : .append( (sal_Int32) nPageNum + 1 )
1461 2 : .appendAscii( ".xml" )
1462 : .makeStringAndClear(),
1463 6 : "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml" );
1464 :
1465 2 : pFS->startElementNS( XML_p, XML_notes, PNMSS, FSEND );
1466 :
1467 2 : pFS->startElementNS( XML_p, XML_cSld, FSEND );
1468 :
1469 2 : WriteShapeTree( pFS, NOTICE, false );
1470 :
1471 2 : pFS->endElementNS( XML_p, XML_cSld );
1472 :
1473 2 : pFS->endElementNS( XML_p, XML_notes );
1474 :
1475 : // add implicit relation to slide
1476 : addRelation( pFS->getOutputStream(),
1477 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
1478 : OUStringBuffer()
1479 4 : .appendAscii( "../slides/slide" )
1480 4 : .append( (sal_Int32) nPageNum + 1 )
1481 2 : .appendAscii( ".xml" )
1482 2 : .makeStringAndClear() );
1483 :
1484 : // add slide implicit relation to notes
1485 2 : if( mpSlidesFSArray.size() >= nPageNum )
1486 2 : addRelation( mpSlidesFSArray[ nPageNum ]->getOutputStream(),
1487 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
1488 : OUStringBuffer()
1489 4 : .appendAscii( "../notesSlides/notesSlide" )
1490 4 : .append( (sal_Int32) nPageNum + 1 )
1491 2 : .appendAscii( ".xml" )
1492 4 : .makeStringAndClear() );
1493 :
1494 : // add implicit relation to notes master
1495 : addRelation( pFS->getOutputStream(),
1496 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
1497 2 : "../notesMasters/notesMaster1.xml" );
1498 :
1499 2 : DBG(printf("----------------\n"));
1500 : }
1501 :
1502 312 : void PowerPointExport::AddLayoutIdAndRelation( FSHelperPtr pFS, sal_Int32 nLayoutFileId )
1503 : {
1504 : // add implicit relation of slide master to slide layout
1505 : OUString sRelId = addRelation( pFS->getOutputStream(),
1506 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
1507 : OUStringBuffer()
1508 624 : .appendAscii( "../slideLayouts/slideLayout" )
1509 312 : .append( nLayoutFileId )
1510 312 : .appendAscii( ".xml" )
1511 312 : .makeStringAndClear() );
1512 :
1513 : pFS->singleElementNS( XML_p, XML_sldLayoutId,
1514 312 : XML_id, I64S( GetNewSlideMasterId() ),
1515 : FSNS( XML_r, XML_id ), USS( sRelId ),
1516 624 : FSEND );
1517 312 : }
1518 :
1519 : sal_Int32 PowerPointExport::nStyleLevelToken[5] =
1520 : {
1521 : XML_lvl1pPr,
1522 : XML_lvl2pPr,
1523 : XML_lvl3pPr,
1524 : XML_lvl4pPr,
1525 : XML_lvl5pPr
1526 : };
1527 :
1528 26 : void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPropertySet > aXBackgroundPropSet )
1529 : {
1530 : DBG(printf("write slide master: %" SAL_PRIuUINT32 "\n----------------\n", nPageNum));
1531 :
1532 : // slides list
1533 26 : if( nPageNum == 0 )
1534 26 : mPresentationFS->startElementNS( XML_p, XML_sldMasterIdLst, FSEND );
1535 :
1536 : OUString sRelId = addRelation( mPresentationFS->getOutputStream(),
1537 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
1538 : OUStringBuffer()
1539 52 : .appendAscii( "slideMasters/slideMaster" )
1540 52 : .append( (sal_Int32) nPageNum + 1 )
1541 26 : .appendAscii( ".xml" )
1542 26 : .makeStringAndClear() );
1543 :
1544 : mPresentationFS->singleElementNS( XML_p, XML_sldMasterId,
1545 : XML_id, OString::number( GetNewSlideMasterId() ).getStr(),
1546 : FSNS( XML_r, XML_id ), USS( sRelId ),
1547 26 : FSEND );
1548 :
1549 26 : if( nPageNum == mnMasterPages - 1 )
1550 26 : mPresentationFS->endElementNS( XML_p, XML_sldMasterIdLst );
1551 :
1552 : FSHelperPtr pFS =
1553 : openFragmentStreamWithSerializer( OUStringBuffer()
1554 52 : .appendAscii( "ppt/slideMasters/slideMaster" )
1555 52 : .append( (sal_Int32) nPageNum + 1 )
1556 26 : .appendAscii( ".xml" )
1557 : .makeStringAndClear(),
1558 104 : "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" );
1559 :
1560 : // write theme per master
1561 26 : WriteTheme( nPageNum );
1562 :
1563 : // add implicit relation to the presentation theme
1564 : addRelation( pFS->getOutputStream(),
1565 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
1566 : OUStringBuffer()
1567 52 : .appendAscii( "../theme/theme" )
1568 52 : .append( (sal_Int32) nPageNum + 1 )
1569 26 : .appendAscii( ".xml" )
1570 26 : .makeStringAndClear() );
1571 :
1572 26 : pFS->startElementNS( XML_p, XML_sldMaster, PNMSS, FSEND );
1573 :
1574 26 : pFS->startElementNS( XML_p, XML_cSld, FSEND );
1575 :
1576 26 : ImplWriteBackground( pFS, aXBackgroundPropSet );
1577 26 : WriteShapeTree( pFS, LAYOUT, true );
1578 :
1579 26 : pFS->endElementNS( XML_p, XML_cSld );
1580 :
1581 : // color map - now it uses colors from hardcoded theme, once we eventually generate theme, this might need update
1582 : pFS->singleElementNS( XML_p, XML_clrMap,
1583 : XML_bg1, "lt1",
1584 : XML_bg2, "lt2",
1585 : XML_tx1, "dk1",
1586 : XML_tx2, "dk2",
1587 : XML_accent1, "accent1",
1588 : XML_accent2, "accent2",
1589 : XML_accent3, "accent3",
1590 : XML_accent4, "accent4",
1591 : XML_accent5, "accent5",
1592 : XML_accent6, "accent6",
1593 : XML_hlink, "hlink",
1594 : XML_folHlink, "folHlink",
1595 26 : FSEND );
1596 :
1597 : // use master's id type as they have same range, mso does that as well
1598 26 : pFS->startElementNS( XML_p, XML_sldLayoutIdLst, FSEND );
1599 :
1600 26 : int nCount = 0;
1601 338 : for( int i = 0; i < LAYOUT_SIZE; i++) {
1602 312 : sal_Int32 nLayoutFileId = GetLayoutFileId( i, nPageNum );
1603 312 : if( nLayoutFileId > 0 ) {
1604 0 : AddLayoutIdAndRelation( pFS, nLayoutFileId );
1605 0 : nCount++;
1606 : } else {
1607 312 : ImplWritePPTXLayout( i, nPageNum );
1608 312 : AddLayoutIdAndRelation( pFS, GetLayoutFileId( i, nPageNum ) );
1609 : }
1610 : }
1611 :
1612 26 : pFS->endElementNS( XML_p, XML_sldLayoutIdLst );
1613 :
1614 26 : pFS->endElementNS( XML_p, XML_sldMaster );
1615 :
1616 26 : DBG(printf("----------------\n"));
1617 26 : }
1618 :
1619 652 : sal_Int32 PowerPointExport::GetLayoutFileId( sal_Int32 nOffset, sal_uInt32 nMasterNum )
1620 : {
1621 : DBG(printf("GetLayoutFileId offset: %" SAL_PRIdINT32 " master: %" SAL_PRIuUINT32 "", nOffset, nMasterNum));
1622 652 : if( mLayoutInfo[ nOffset ].mnFileIdArray.size() <= nMasterNum )
1623 312 : return 0;
1624 :
1625 340 : return mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ];
1626 : }
1627 :
1628 28 : void PowerPointExport::ImplWriteLayout( sal_Int32 /*nOffset*/, sal_uInt32 /*nMasterNum*/ )
1629 : {
1630 : // we write all the layouts together with master(s)
1631 : // ImplWritePPTXLayout( GetPPTXLayoutId( nOffset ), nMasterNum );
1632 28 : }
1633 :
1634 312 : void PowerPointExport::ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum )
1635 : {
1636 : DBG(printf("write layout: %" SAL_PRIdINT32 "\n", nOffset));
1637 :
1638 312 : Reference< drawing::XDrawPagesSupplier > xDPS( getModel(), uno::UNO_QUERY );
1639 624 : Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY );
1640 624 : Reference< drawing::XDrawPage > xSlide;
1641 624 : Reference< container::XIndexAccess > xIndexAccess( xDrawPages, uno::UNO_QUERY );
1642 :
1643 312 : xSlide = xDrawPages->insertNewByIndex( xIndexAccess->getCount() );
1644 :
1645 : #ifdef DEBUG
1646 : if( xSlide.is() )
1647 : printf("new page created\n");
1648 : #endif
1649 :
1650 624 : Reference< beans::XPropertySet > xPropSet( xSlide, uno::UNO_QUERY );
1651 312 : xPropSet->setPropertyValue( "Layout", makeAny( short( aLayoutInfo[ nOffset ].nType ) ) );
1652 : DBG(dump_pset( xPropSet ));
1653 :
1654 312 : mXPagePropSet = Reference< XPropertySet >( xSlide, UNO_QUERY );
1655 312 : mXShapes = Reference< XShapes >( xSlide, UNO_QUERY );
1656 :
1657 312 : if( mLayoutInfo[ nOffset ].mnFileIdArray.size() < mnMasterPages ) {
1658 312 : mLayoutInfo[ nOffset ].mnFileIdArray.resize( mnMasterPages );
1659 : }
1660 :
1661 312 : if( mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ] != 0 )
1662 312 : return;
1663 :
1664 : FSHelperPtr pFS
1665 : = openFragmentStreamWithSerializer( OUStringBuffer()
1666 624 : .appendAscii( "ppt/slideLayouts/slideLayout" )
1667 624 : .append( (sal_Int32) mnLayoutFileIdMax )
1668 312 : .appendAscii( ".xml" )
1669 : .makeStringAndClear(),
1670 1248 : "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" );
1671 :
1672 : // add implicit relation of slide layout to slide master
1673 : addRelation( pFS->getOutputStream(),
1674 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
1675 : OUStringBuffer()
1676 624 : .appendAscii( "../slideMasters/slideMaster" )
1677 624 : .append( (sal_Int32) nMasterNum + 1 )
1678 312 : .appendAscii( ".xml" )
1679 312 : .makeStringAndClear() );
1680 :
1681 : pFS->startElementNS( XML_p, XML_sldLayout,
1682 : PNMSS,
1683 : XML_type, aLayoutInfo[ nOffset ].sType,
1684 : XML_preserve, "1",
1685 312 : FSEND );
1686 :
1687 : pFS->startElementNS( XML_p, XML_cSld,
1688 : XML_name, aLayoutInfo[ nOffset ].sName,
1689 312 : FSEND );
1690 : //pFS->write( MINIMAL_SPTREE ); // TODO: write actual shape tree
1691 312 : WriteShapeTree( pFS, LAYOUT, true );
1692 :
1693 312 : pFS->endElementNS( XML_p, XML_cSld );
1694 :
1695 312 : pFS->endElementNS( XML_p, XML_sldLayout );
1696 :
1697 312 : mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ] = mnLayoutFileIdMax;
1698 :
1699 312 : mnLayoutFileIdMax ++;
1700 :
1701 624 : xDrawPages->remove( xSlide );
1702 : }
1703 :
1704 370 : void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, bool bMaster )
1705 : {
1706 370 : PowerPointShapeExport aDML( pFS, &maShapeMap, this );
1707 370 : aDML.SetMaster( bMaster );
1708 370 : aDML.SetPageType( ePageType );
1709 : sal_uInt32 nShapes;
1710 :
1711 370 : pFS->startElementNS( XML_p, XML_spTree, FSEND );
1712 370 : pFS->write( MAIN_GROUP );
1713 :
1714 370 : ResetGroupTable( nShapes = mXShapes->getCount() );
1715 :
1716 1811 : while( GetNextGroupEntry() ) {
1717 :
1718 1071 : sal_uInt32 nGroups = GetGroupsClosed();
1719 1071 : for ( sal_uInt32 i = 0; i < nGroups; i++ ) {
1720 : DBG(printf( "leave group\n" ));
1721 : }
1722 :
1723 1071 : if ( GetShapeByIndex( GetCurrentGroupIndex(), true ) ) {
1724 : DBG(printf( "mType: \"%s\"\n", mType.getStr() ));
1725 1071 : aDML.WriteShape( mXShape );
1726 : }
1727 : }
1728 :
1729 370 : pFS->endElementNS( XML_p, XML_spTree );
1730 370 : }
1731 :
1732 : #define BEGIN_SHAPE mpFS->startElementNS( XML_p, XML_sp, FSEND )
1733 : #define END_SHAPE mpFS->endElementNS( XML_p, XML_sp )
1734 :
1735 0 : ShapeExport& PowerPointShapeExport::WritePageShape( Reference< XShape > xShape, PageType ePageType, bool bPresObj )
1736 : {
1737 0 : if( ( ePageType == NOTICE && bPresObj ) || ePageType == LAYOUT )
1738 0 : return WritePlaceholderShape( xShape, SlideImage );
1739 :
1740 0 : return WriteTextShape( xShape );
1741 : }
1742 :
1743 963 : bool PowerPointShapeExport::WritePlaceholder( Reference< XShape > xShape, PlaceholderType ePlaceholder, bool bMaster )
1744 : {
1745 : DBG(printf("WritePlaceholder %d %d\n", bMaster, ShapeExport::NonEmptyText( xShape )));
1746 963 : if( bMaster && ShapeExport::NonEmptyText( xShape ) ) {
1747 951 : WritePlaceholderShape( xShape, ePlaceholder );
1748 :
1749 951 : return true;
1750 : }
1751 :
1752 12 : return false;
1753 : }
1754 :
1755 954 : ShapeExport& PowerPointShapeExport::WritePlaceholderShape( Reference< XShape > xShape, PlaceholderType ePlaceholder )
1756 : {
1757 954 : BEGIN_SHAPE;
1758 :
1759 : // non visual shape properties
1760 954 : mpFS->startElementNS( XML_p, XML_nvSpPr, FSEND );
1761 954 : WriteNonVisualDrawingProperties( xShape, IDS( PlaceHolder ) );
1762 954 : mpFS->startElementNS( XML_p, XML_cNvSpPr, FSEND );
1763 954 : mpFS->singleElementNS( XML_a, XML_spLocks, XML_noGrp, "1", FSEND );
1764 954 : mpFS->endElementNS( XML_p, XML_cNvSpPr );
1765 954 : mpFS->startElementNS( XML_p, XML_nvPr, FSEND );
1766 :
1767 954 : const char* pType = NULL;
1768 954 : switch( ePlaceholder ) {
1769 : case SlideImage:
1770 0 : pType = "sldImg";
1771 0 : break;
1772 : case Notes:
1773 3 : pType = "body";
1774 3 : break;
1775 : case Header:
1776 2 : pType = "hdr";
1777 2 : break;
1778 : case Footer:
1779 22 : pType = "ftr";
1780 22 : break;
1781 : case SlideNumber:
1782 22 : pType = "sldNum";
1783 22 : break;
1784 : case DateAndTime:
1785 22 : pType = "dt";
1786 22 : break;
1787 : case Outliner:
1788 534 : pType = "body";
1789 534 : break;
1790 : case Title:
1791 283 : pType = "title";
1792 283 : break;
1793 : case Subtitle:
1794 66 : pType = "subTitle";
1795 66 : break;
1796 : default:
1797 : DBG(printf("warning: unhandled placeholder type: %d\n", ePlaceholder));
1798 : }
1799 : DBG(printf("write placeholder %s\n", pType));
1800 954 : mpFS->singleElementNS( XML_p, XML_ph, XML_type, pType, FSEND );
1801 954 : mpFS->endElementNS( XML_p, XML_nvPr );
1802 954 : mpFS->endElementNS( XML_p, XML_nvSpPr );
1803 :
1804 : // visual shape properties
1805 954 : mpFS->startElementNS( XML_p, XML_spPr, FSEND );
1806 954 : WriteShapeTransformation( xShape, XML_a );
1807 954 : WritePresetShape( "rect" );
1808 954 : Reference< XPropertySet > xProps( xShape, UNO_QUERY );
1809 954 : if( xProps.is() )
1810 954 : WriteBlipFill( xProps, "GraphicURL" );
1811 954 : mpFS->endElementNS( XML_p, XML_spPr );
1812 :
1813 954 : WriteTextBox( xShape, XML_p );
1814 :
1815 954 : END_SHAPE;
1816 :
1817 954 : return *this;
1818 : }
1819 :
1820 : #define MINIMAL_THEME " <a:themeElements>\
1821 : <a:clrScheme name=\"Office\">\
1822 : <a:dk1>\
1823 : <a:sysClr val=\"windowText\" lastClr=\"000000\"/>\
1824 : </a:dk1>\
1825 : <a:lt1>\
1826 : <a:sysClr val=\"window\" lastClr=\"FFFFFF\"/>\
1827 : </a:lt1>\
1828 : <a:dk2>\
1829 : <a:srgbClr val=\"1F497D\"/>\
1830 : </a:dk2>\
1831 : <a:lt2>\
1832 : <a:srgbClr val=\"EEECE1\"/>\
1833 : </a:lt2>\
1834 : <a:accent1>\
1835 : <a:srgbClr val=\"4F81BD\"/>\
1836 : </a:accent1>\
1837 : <a:accent2>\
1838 : <a:srgbClr val=\"C0504D\"/>\
1839 : </a:accent2>\
1840 : <a:accent3>\
1841 : <a:srgbClr val=\"9BBB59\"/>\
1842 : </a:accent3>\
1843 : <a:accent4>\
1844 : <a:srgbClr val=\"8064A2\"/>\
1845 : </a:accent4>\
1846 : <a:accent5>\
1847 : <a:srgbClr val=\"4BACC6\"/>\
1848 : </a:accent5>\
1849 : <a:accent6>\
1850 : <a:srgbClr val=\"F79646\"/>\
1851 : </a:accent6>\
1852 : <a:hlink>\
1853 : <a:srgbClr val=\"0000FF\"/>\
1854 : </a:hlink>\
1855 : <a:folHlink>\
1856 : <a:srgbClr val=\"800080\"/>\
1857 : </a:folHlink>\
1858 : </a:clrScheme>\
1859 : <a:fontScheme name=\"Office\">\
1860 : <a:majorFont>\
1861 : <a:latin typeface=\"Arial\"/>\
1862 : <a:ea typeface=\"DejaVu Sans\"/>\
1863 : <a:cs typeface=\"DejaVu Sans\"/>\
1864 : </a:majorFont>\
1865 : <a:minorFont>\
1866 : <a:latin typeface=\"Arial\"/>\
1867 : <a:ea typeface=\"DejaVu Sans\"/>\
1868 : <a:cs typeface=\"DejaVu Sans\"/>\
1869 : </a:minorFont>\
1870 : </a:fontScheme>\
1871 : <a:fmtScheme name=\"Office\">\
1872 : <a:fillStyleLst>\
1873 : <a:solidFill>\
1874 : <a:schemeClr val=\"phClr\"/>\
1875 : </a:solidFill>\
1876 : <a:gradFill rotWithShape=\"1\">\
1877 : <a:gsLst>\
1878 : <a:gs pos=\"0\">\
1879 : <a:schemeClr val=\"phClr\">\
1880 : <a:tint val=\"50000\"/>\
1881 : <a:satMod val=\"300000\"/>\
1882 : </a:schemeClr>\
1883 : </a:gs>\
1884 : <a:gs pos=\"35000\">\
1885 : <a:schemeClr val=\"phClr\">\
1886 : <a:tint val=\"37000\"/>\
1887 : <a:satMod val=\"300000\"/>\
1888 : </a:schemeClr>\
1889 : </a:gs>\
1890 : <a:gs pos=\"100000\">\
1891 : <a:schemeClr val=\"phClr\">\
1892 : <a:tint val=\"15000\"/>\
1893 : <a:satMod val=\"350000\"/>\
1894 : </a:schemeClr>\
1895 : </a:gs>\
1896 : </a:gsLst>\
1897 : <a:lin ang=\"16200000\" scaled=\"1\"/>\
1898 : </a:gradFill>\
1899 : <a:gradFill rotWithShape=\"1\">\
1900 : <a:gsLst>\
1901 : <a:gs pos=\"0\">\
1902 : <a:schemeClr val=\"phClr\">\
1903 : <a:shade val=\"51000\"/>\
1904 : <a:satMod val=\"130000\"/>\
1905 : </a:schemeClr>\
1906 : </a:gs>\
1907 : <a:gs pos=\"80000\">\
1908 : <a:schemeClr val=\"phClr\">\
1909 : <a:shade val=\"93000\"/>\
1910 : <a:satMod val=\"130000\"/>\
1911 : </a:schemeClr>\
1912 : </a:gs>\
1913 : <a:gs pos=\"100000\">\
1914 : <a:schemeClr val=\"phClr\">\
1915 : <a:shade val=\"94000\"/>\
1916 : <a:satMod val=\"135000\"/>\
1917 : </a:schemeClr>\
1918 : </a:gs>\
1919 : </a:gsLst>\
1920 : <a:lin ang=\"16200000\" scaled=\"0\"/>\
1921 : </a:gradFill>\
1922 : </a:fillStyleLst>\
1923 : <a:lnStyleLst>\
1924 : <a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
1925 : <a:solidFill>\
1926 : <a:schemeClr val=\"phClr\">\
1927 : <a:shade val=\"95000\"/>\
1928 : <a:satMod val=\"105000\"/>\
1929 : </a:schemeClr>\
1930 : </a:solidFill>\
1931 : <a:prstDash val=\"solid\"/>\
1932 : </a:ln>\
1933 : <a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
1934 : <a:solidFill>\
1935 : <a:schemeClr val=\"phClr\"/>\
1936 : </a:solidFill>\
1937 : <a:prstDash val=\"solid\"/>\
1938 : </a:ln>\
1939 : <a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
1940 : <a:solidFill>\
1941 : <a:schemeClr val=\"phClr\"/>\
1942 : </a:solidFill>\
1943 : <a:prstDash val=\"solid\"/>\
1944 : </a:ln>\
1945 : </a:lnStyleLst>\
1946 : <a:effectStyleLst>\
1947 : <a:effectStyle>\
1948 : <a:effectLst>\
1949 : <a:outerShdw blurRad=\"40000\" dist=\"20000\" dir=\"5400000\" rotWithShape=\"0\">\
1950 : <a:srgbClr val=\"000000\">\
1951 : <a:alpha val=\"38000\"/>\
1952 : </a:srgbClr>\
1953 : </a:outerShdw>\
1954 : </a:effectLst>\
1955 : </a:effectStyle>\
1956 : <a:effectStyle>\
1957 : <a:effectLst>\
1958 : <a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">\
1959 : <a:srgbClr val=\"000000\">\
1960 : <a:alpha val=\"35000\"/>\
1961 : </a:srgbClr>\
1962 : </a:outerShdw>\
1963 : </a:effectLst>\
1964 : </a:effectStyle>\
1965 : <a:effectStyle>\
1966 : <a:effectLst>\
1967 : <a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">\
1968 : <a:srgbClr val=\"000000\">\
1969 : <a:alpha val=\"35000\"/>\
1970 : </a:srgbClr>\
1971 : </a:outerShdw>\
1972 : </a:effectLst>\
1973 : <a:scene3d>\
1974 : <a:camera prst=\"orthographicFront\">\
1975 : <a:rot lat=\"0\" lon=\"0\" rev=\"0\"/>\
1976 : </a:camera>\
1977 : <a:lightRig rig=\"threePt\" dir=\"t\">\
1978 : <a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/>\
1979 : </a:lightRig>\
1980 : </a:scene3d>\
1981 : <a:sp3d>\
1982 : <a:bevelT w=\"63500\" h=\"25400\"/>\
1983 : </a:sp3d>\
1984 : </a:effectStyle>\
1985 : </a:effectStyleLst>\
1986 : <a:bgFillStyleLst>\
1987 : <a:solidFill>\
1988 : <a:schemeClr val=\"phClr\"/>\
1989 : </a:solidFill>\
1990 : <a:gradFill rotWithShape=\"1\">\
1991 : <a:gsLst>\
1992 : <a:gs pos=\"0\">\
1993 : <a:schemeClr val=\"phClr\">\
1994 : <a:tint val=\"40000\"/>\
1995 : <a:satMod val=\"350000\"/>\
1996 : </a:schemeClr>\
1997 : </a:gs>\
1998 : <a:gs pos=\"40000\">\
1999 : <a:schemeClr val=\"phClr\">\
2000 : <a:tint val=\"45000\"/>\
2001 : <a:shade val=\"99000\"/>\
2002 : <a:satMod val=\"350000\"/>\
2003 : </a:schemeClr>\
2004 : </a:gs>\
2005 : <a:gs pos=\"100000\">\
2006 : <a:schemeClr val=\"phClr\">\
2007 : <a:shade val=\"20000\"/>\
2008 : <a:satMod val=\"255000\"/>\
2009 : </a:schemeClr>\
2010 : </a:gs>\
2011 : </a:gsLst>\
2012 : <a:path path=\"circle\">\
2013 : <a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/>\
2014 : </a:path>\
2015 : </a:gradFill>\
2016 : <a:gradFill rotWithShape=\"1\">\
2017 : <a:gsLst>\
2018 : <a:gs pos=\"0\">\
2019 : <a:schemeClr val=\"phClr\">\
2020 : <a:tint val=\"80000\"/>\
2021 : <a:satMod val=\"300000\"/>\
2022 : </a:schemeClr>\
2023 : </a:gs>\
2024 : <a:gs pos=\"100000\">\
2025 : <a:schemeClr val=\"phClr\">\
2026 : <a:shade val=\"30000\"/>\
2027 : <a:satMod val=\"200000\"/>\
2028 : </a:schemeClr>\
2029 : </a:gs>\
2030 : </a:gsLst>\
2031 : <a:path path=\"circle\">\
2032 : <a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>\
2033 : </a:path>\
2034 : </a:gradFill>\
2035 : </a:bgFillStyleLst>\
2036 : </a:fmtScheme>\
2037 : </a:themeElements>"
2038 :
2039 28 : void PowerPointExport::WriteTheme( sal_Int32 nThemeNum )
2040 : {
2041 : FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer()
2042 56 : .appendAscii( "ppt/theme/theme" )
2043 56 : .append( (sal_Int32) nThemeNum + 1 )
2044 28 : .appendAscii( ".xml" )
2045 : .makeStringAndClear(),
2046 84 : "application/vnd.openxmlformats-officedocument.theme+xml" );
2047 :
2048 : pFS->startElementNS( XML_a, XML_theme,
2049 : FSNS( XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
2050 : XML_name, "Office Theme",
2051 28 : FSEND );
2052 :
2053 28 : pFS->write( MINIMAL_THEME );
2054 28 : pFS->endElementNS( XML_a, XML_theme );
2055 28 : }
2056 :
2057 26 : bool PowerPointExport::ImplCreateDocument()
2058 : {
2059 26 : mbCreateNotes = false;
2060 :
2061 52 : for( sal_uInt32 i = 0; i < mnPages; i++ )
2062 : {
2063 28 : if ( !GetPageByIndex( i, NOTICE ) )
2064 0 : return false;
2065 :
2066 28 : if( ContainsOtherShapeThanPlaceholders( true ) ) {
2067 2 : mbCreateNotes = true;
2068 2 : break;
2069 : }
2070 : }
2071 :
2072 26 : return true;
2073 : }
2074 :
2075 2 : bool PowerPointExport::WriteNotesMaster()
2076 : {
2077 : DBG(printf("write Notes master\n----------------\n"));
2078 :
2079 2 : mPresentationFS->startElementNS( XML_p, XML_notesMasterIdLst, FSEND );
2080 :
2081 : OUString sRelId = addRelation( mPresentationFS->getOutputStream(),
2082 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
2083 2 : "notesMasters/notesMaster1.xml" );
2084 :
2085 : mPresentationFS->singleElementNS( XML_p, XML_notesMasterId,
2086 : FSNS( XML_r, XML_id ), USS( sRelId ),
2087 2 : FSEND );
2088 :
2089 2 : mPresentationFS->endElementNS( XML_p, XML_notesMasterIdLst );
2090 :
2091 : FSHelperPtr pFS =
2092 : openFragmentStreamWithSerializer( "ppt/notesMasters/notesMaster1.xml",
2093 4 : "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml" );
2094 : // write theme per master
2095 2 : WriteTheme( mnMasterPages );
2096 :
2097 : // add implicit relation to the presentation theme
2098 : addRelation( pFS->getOutputStream(),
2099 : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
2100 : OUStringBuffer()
2101 4 : .appendAscii( "../theme/theme" )
2102 4 : .append( (sal_Int32) mnMasterPages + 1 )
2103 2 : .appendAscii( ".xml" )
2104 2 : .makeStringAndClear() );
2105 :
2106 2 : pFS->startElementNS( XML_p, XML_notesMaster, PNMSS, FSEND );
2107 :
2108 2 : pFS->startElementNS( XML_p, XML_cSld, FSEND );
2109 :
2110 4 : Reference< XPropertySet > aXBackgroundPropSet;
2111 2 : if( ImplGetPropertyValue( mXPagePropSet, OUString( "Background" ) ) &&
2112 0 : ( mAny >>= aXBackgroundPropSet ) )
2113 0 : ImplWriteBackground( pFS, aXBackgroundPropSet );
2114 :
2115 2 : WriteShapeTree( pFS, NOTICE, true );
2116 :
2117 2 : pFS->endElementNS( XML_p, XML_cSld );
2118 :
2119 : // color map - now it uses colors from hardcoded theme, once we eventually generate theme, this might need update
2120 : pFS->singleElementNS( XML_p, XML_clrMap,
2121 : XML_bg1, "lt1",
2122 : XML_bg2, "lt2",
2123 : XML_tx1, "dk1",
2124 : XML_tx2, "dk2",
2125 : XML_accent1, "accent1",
2126 : XML_accent2, "accent2",
2127 : XML_accent3, "accent3",
2128 : XML_accent4, "accent4",
2129 : XML_accent5, "accent5",
2130 : XML_accent6, "accent6",
2131 : XML_hlink, "hlink",
2132 : XML_folHlink, "folHlink",
2133 2 : FSEND );
2134 :
2135 2 : pFS->endElementNS( XML_p, XML_notesMaster );
2136 :
2137 : DBG(printf("----------------\n"));
2138 :
2139 4 : return true;
2140 : }
2141 :
2142 26 : bool PowerPointExport::ImplCreateMainNotes()
2143 : {
2144 26 : if( mbCreateNotes )
2145 2 : return WriteNotesMaster();
2146 :
2147 24 : return true;
2148 : }
2149 :
2150 2 : OUString SAL_CALL PowerPointExport_getImplementationName() throw()
2151 : {
2152 2 : return OUString( "com.sun.star.comp.Impress.oox.PowerPointExport" );
2153 : }
2154 :
2155 2 : uno::Sequence< OUString > SAL_CALL PowerPointExport_getSupportedServiceNames() throw()
2156 : {
2157 2 : return Sequence< OUString >();
2158 : }
2159 :
2160 26 : uno::Reference< uno::XInterface > SAL_CALL PowerPointExport_createInstance(const uno::Reference< XComponentContext > & rxCtxt ) throw( uno::Exception )
2161 : {
2162 26 : return static_cast<cppu::OWeakObject*>(new PowerPointExport( rxCtxt ));
2163 : }
2164 :
2165 0 : OUString PowerPointExport::getImplementationName() throw (css::uno::RuntimeException, std::exception)
2166 : {
2167 0 : return PowerPointExport_getImplementationName();
2168 : }
2169 : }
2170 : }
2171 :
2172 : // UNO component
2173 :
2174 : static const struct cppu::ImplementationEntry g_entries[] =
2175 : {
2176 : {
2177 : oox::core::PowerPointExport_createInstance,
2178 : oox::core::PowerPointExport_getImplementationName,
2179 : oox::core::PowerPointExport_getSupportedServiceNames,
2180 : cppu::createSingleComponentFactory,
2181 : 0 , 0
2182 : },
2183 : { 0, 0, 0, 0, 0, 0 }
2184 : };
2185 :
2186 : #ifdef __cplusplus
2187 : extern "C"
2188 : {
2189 : #endif
2190 :
2191 2 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL sdfilt_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
2192 : {
2193 2 : return cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
2194 : }
2195 :
2196 : #ifdef __cplusplus
2197 : }
2198 : #endif
2199 :
2200 : DBG(
2201 : void dump_pset(Reference< XPropertySet > rXPropSet)
2202 : {
2203 : Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo ();
2204 : Sequence< beans::Property > props = info->getProperties ();
2205 :
2206 : for (int i=0; i < props.getLength (); i++) {
2207 : OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8);
2208 : printf ("%30s = ", name.getStr() );
2209 :
2210 : Any value = rXPropSet->getPropertyValue( props [i].Name );
2211 :
2212 : OUString strValue;
2213 : sal_Int32 intValue;
2214 : bool boolValue;
2215 : RectanglePoint pointValue;
2216 :
2217 : if( value >>= strValue )
2218 : printf ("\"%s\"\n", USS( strValue ) );
2219 : else if( value >>= intValue )
2220 : printf ("%" SAL_PRIdINT32 " (hex: %" SAL_PRIxUINT32 ")\n", intValue, intValue);
2221 : else if( value >>= boolValue )
2222 : printf ("%d (bool)\n", boolValue);
2223 : else if( value >>= pointValue )
2224 : printf ("%d (RectanglePoint)\n", pointValue);
2225 : else
2226 : printf ("??? <unhandled type>\n");
2227 : }
2228 : }
2229 12 : );
2230 :
2231 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|