LCOV - code coverage report
Current view: top level - sd/source/filter/eppt - pptx-epptooxml.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 941 0.0 %
Date: 2014-04-14 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10