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