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