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