LCOV - code coverage report
Current view: top level - libreoffice/sd/source/filter/eppt - eppt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 884 0.1 %
Date: 2012-12-27 Functions: 2 26 7.7 %
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 <eppt.hxx>
      21             : #include "epptdef.hxx"
      22             : #include <tools/globname.hxx>
      23             : #include <tools/poly.hxx>
      24             : #include <vcl/graph.hxx>
      25             : #include <vcl/bmpacc.hxx>
      26             : #include <vcl/gradient.hxx>
      27             : #include <rtl/ustring.hxx>
      28             : #include <tools/stream.hxx>
      29             : #include <svtools/fltcall.hxx>
      30             : #include <sfx2/docfile.hxx>
      31             : #include <svx/unoapi.hxx>
      32             : #include <svx/svdobj.hxx>
      33             : #include <svx/svdoole2.hxx>
      34             : #include <svx/svdmodel.hxx>
      35             : #include <svx/svdpage.hxx>
      36             : #include <com/sun/star/view/PaperOrientation.hpp>
      37             : #include <com/sun/star/view/PaperFormat.hpp>
      38             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      39             : #include <com/sun/star/office/XAnnotation.hpp>
      40             : #include <com/sun/star/office/XAnnotationAccess.hpp>
      41             : #include <com/sun/star/office/XAnnotationEnumeration.hpp>
      42             : #include <com/sun/star/geometry/RealPoint2D.hpp>
      43             : #include <com/sun/star/util/DateTime.hpp>
      44             : #include <tools/zcodec.hxx>
      45             : #include <editeng/svxenum.hxx>
      46             : #include <sot/storinfo.hxx>
      47             : #include <filter/msfilter/msoleexp.hxx>
      48             : #include <vcl/virdev.hxx>
      49             : #include <svtools/wmf.hxx>
      50             : #include <filter/msfilter/msdffimp.hxx>
      51             : #include <filter/msfilter/svxmsbas.hxx>
      52             : #include <editeng/flditem.hxx>
      53             : #include <sfx2/docinf.hxx>
      54             : #include <oox/export/utils.hxx>
      55             : #include <oox/ole/olehelper.hxx>
      56             : 
      57             : using namespace com::sun::star;
      58             : using namespace ::com::sun::star::uno;
      59             : using namespace ::com::sun::star::presentation;
      60             : 
      61             : using ::com::sun::star::beans::XPropertySet;
      62             : 
      63             : //============================ PPTWriter ==================================
      64             : 
      65           0 : PPTWriter::PPTWriter( SvStorageRef& rSvStorage,
      66             :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rXModel,
      67             :             ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rXStatInd,
      68             :             SvMemoryStream* pVBA, sal_uInt32 nCnvrtFlags ) :
      69             :     PPTWriterBase           ( rXModel, rXStatInd ),
      70             :     mnCnvrtFlags            ( nCnvrtFlags ),
      71             :     mbStatus                ( sal_False ),
      72             :     mbUseNewAnimations      ( sal_True ),
      73             :     mnLatestStatValue       ( 0 ),
      74             :     mrStg                   ( rSvStorage ),
      75             :     mpCurUserStrm           ( NULL ),
      76             :     mpStrm                  ( NULL ),
      77             :     mpPicStrm               ( NULL ),
      78             :     mpPptEscherEx           ( NULL ),
      79             :     mnVBAOleOfs             ( 0 ),
      80             :     mpVBA                   ( pVBA ),
      81             :     mnExEmbed               ( 0 ),
      82           0 :     mpExEmbed               ( new SvMemoryStream ),
      83             :     mnPagesWritten          ( 0 ),
      84           0 :     mnTxId                  ( 0x7a2f64 )
      85             : {
      86           0 : }
      87             : 
      88           0 : void PPTWriter::exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& rMediaData )
      89             : {
      90           0 :     if ( !mrStg.Is() )
      91             :         return;
      92             : 
      93             :     // MasterPages + Slides und Notizen + NotesMasterPage
      94           0 :     mnDrawings = mnMasterPages + ( mnPages << 1 ) + 1;
      95             : 
      96           0 :     if ( mXStatusIndicator.is() )
      97             :     {
      98           0 :         mbStatusIndicator = sal_True;
      99           0 :         mnStatMaxValue = ( mnPages + mnMasterPages ) * 5;
     100           0 :         mXStatusIndicator->start( rtl::OUString( "PowerPoint Export" ), mnStatMaxValue + ( mnStatMaxValue >> 3 ) );
     101             :     }
     102             : 
     103           0 :     SvGlobalName aGName( 0x64818d10L, 0x4f9b, 0x11cf, 0x86, 0xea, 0x00, 0xaa, 0x00, 0xb9, 0x29, 0xe8 );
     104           0 :     mrStg->SetClass( aGName, 0,  rtl::OUString("MS PowerPoint 97") );
     105             : 
     106           0 :     if ( !ImplCreateCurrentUserStream() )
     107             :         return;
     108             : 
     109           0 :     mpStrm = mrStg->OpenSotStream( rtl::OUString( "PowerPoint Document" ) );
     110           0 :     if ( !mpStrm )
     111             :         return;
     112             : 
     113           0 :     if ( !mpPicStrm )
     114           0 :         mpPicStrm = mrStg->OpenSotStream( rtl::OUString( "Pictures" ) );
     115             : 
     116           0 :     std::vector< com::sun::star::beans::PropertyValue >::const_iterator aIter( rMediaData.begin() );
     117           0 :     while( aIter != rMediaData.end() )
     118             :     {
     119           0 :         if ( (*aIter).Name == "BaseURI" )
     120             :         {
     121           0 :             (*aIter).Value >>= maBaseURI;
     122           0 :             break;
     123             :         }
     124           0 :         aIter++;
     125             :     }
     126           0 :     mpPptEscherEx = new PptEscherEx( *mpStrm, maBaseURI );
     127             : }
     128             : 
     129           0 : void PPTWriter::exportPPTPost( )
     130             : {
     131           0 :     if ( !ImplCloseDocument() )
     132           0 :         return;
     133             : 
     134           0 :     if ( mbStatusIndicator )
     135             :     {
     136           0 :         mXStatusIndicator->setText( rtl::OUString( "PowerPoint Export" ) );
     137           0 :         sal_uInt32 nValue = mnStatMaxValue + ( mnStatMaxValue >> 3 );
     138           0 :         if ( nValue > mnLatestStatValue )
     139             :         {
     140           0 :             mXStatusIndicator->setValue( nValue );
     141           0 :             mnLatestStatValue = nValue;
     142             :         }
     143             :     }
     144             : 
     145           0 :     ImplWriteOLE();
     146             : 
     147           0 :     ImplWriteVBA();
     148             : 
     149           0 :     if ( !ImplWriteAtomEnding() )
     150           0 :         return;
     151             : 
     152           0 :     if ( !ImplCreateDocumentSummaryInformation() )
     153           0 :         return;
     154             : 
     155           0 :     mbStatus = sal_True;
     156             : };
     157             : 
     158             : // ---------------------------------------------------------------------------------------------
     159             : 
     160             : void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStream& rBinaryTagData10Atom );
     161             : 
     162           0 : void PPTWriter::ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNum, sal_uInt16 nMode,
     163             :                                 sal_Bool bHasBackground, Reference< XPropertySet > aXBackgroundPropSet )
     164             : {
     165           0 :     Any aAny;
     166             : 
     167           0 :     const PHLayout& rLayout = GetLayout( mXPagePropSet );
     168           0 :     mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_Slide | nPageNum, mpStrm->Tell() );
     169           0 :     mpPptEscherEx->OpenContainer( EPP_Slide );
     170           0 :     mpPptEscherEx->AddAtom( 24, EPP_SlideAtom, 2 );
     171           0 :     *mpStrm << rLayout.nLayout;
     172           0 :     mpStrm->Write( rLayout.nPlaceHolder, 8 );       // placeholderIDs ( 8Stueck )
     173           0 :     *mpStrm << (sal_uInt32)(nMasterNum | 0x80000000)// master ID ( ist gleich 0x80000000 bei einer masterpage   )
     174           0 :             << (sal_uInt32)nPageNum + 0x100         // notes ID ( ist gleich null wenn keine notizen vorhanden )
     175           0 :             << nMode
     176           0 :             << (sal_uInt16)0;                       // padword
     177             : 
     178           0 :     mnDiaMode = 0;
     179           0 :     sal_Bool bVisible = sal_True;
     180           0 :     ::com::sun::star::presentation::FadeEffect eFe = ::com::sun::star::presentation::FadeEffect_NONE;
     181             : 
     182           0 :     if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Visible" ) ) )
     183           0 :         aAny >>= bVisible;
     184           0 :     if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Change" ) ) )
     185             :     {
     186           0 :         switch ( *(sal_Int32*)aAny.getValue() )
     187             :         {
     188             :             case 1 :        // automatisch
     189           0 :                 mnDiaMode++;
     190             :             case 2 :        // halbautomatisch
     191           0 :                 mnDiaMode++;
     192             :             default :
     193             :             case 0 :        // manuell
     194           0 :             break;
     195             :         }
     196             :     }
     197           0 :     if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Effect" ) ) )
     198           0 :         aAny >>= eFe;
     199             : 
     200           0 :     sal_uInt32  nSoundRef = 0;
     201           0 :     sal_Bool    bIsSound = sal_False;
     202           0 :     sal_Bool    bStopSound = sal_False;
     203           0 :     sal_Bool    bLoopSound = sal_False;
     204             : 
     205           0 :     if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Sound" ) ) )
     206             :     {
     207           0 :         rtl::OUString aSoundURL;
     208           0 :         if ( aAny >>= aSoundURL )
     209             :         {
     210           0 :             nSoundRef = maSoundCollection.GetId( aSoundURL );
     211           0 :             bIsSound = sal_True;
     212             :         }
     213             :         else
     214           0 :             aAny >>= bStopSound;
     215             :     }
     216           0 :     if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "LoopSound" ) ) )
     217           0 :         aAny >>= bLoopSound;
     218             : 
     219             :     sal_Bool bNeedsSSSlideInfoAtom = ( bVisible == sal_False )
     220             :                                     || ( mnDiaMode == 2 )
     221             :                                     || ( bIsSound )
     222             :                                     || ( bStopSound )
     223           0 :                                     || ( eFe != ::com::sun::star::presentation::FadeEffect_NONE );
     224           0 :     if ( bNeedsSSSlideInfoAtom )
     225             :     {
     226           0 :         sal_uInt8   nDirection = 0;
     227           0 :         sal_uInt8   nTransitionType = 0;
     228           0 :         sal_uInt16  nBuildFlags = 1;        // advange by mouseclick
     229           0 :         sal_Int32       nSlideTime = 0;         // muss noch !!!
     230           0 :         sal_uInt8   nSpeed = 1;
     231             : 
     232           0 :         if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Speed" ) ) )
     233             :         {
     234             :             ::com::sun::star::presentation::AnimationSpeed aAs;
     235           0 :             aAny >>= aAs;
     236           0 :             nSpeed = (sal_uInt8)aAs;
     237             :         }
     238           0 :         sal_Int16 nTT = 0;
     239           0 :         if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "TransitionType" ) )
     240           0 :             && ( aAny >>= nTT ) )
     241             :         {
     242           0 :             sal_Int16 nTST = 0;
     243           0 :             if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "TransitionSubtype" ) )
     244           0 :                 && ( aAny >>= nTST ) )
     245           0 :                 nTransitionType = GetTransition( nTT, nTST, eFe, nDirection );
     246             : 
     247             :         }
     248           0 :         if ( !nTransitionType )
     249           0 :             nTransitionType = GetTransition( eFe, nDirection );
     250           0 :         if ( mnDiaMode == 2 )                                   // automatic ?
     251           0 :             nBuildFlags |= 0x400;
     252           0 :         if ( bVisible == sal_False )
     253           0 :             nBuildFlags |= 4;
     254           0 :         if ( bIsSound )
     255           0 :             nBuildFlags |= 16;
     256           0 :         if ( bLoopSound )
     257           0 :             nBuildFlags |= 64;
     258           0 :         if ( bStopSound )
     259           0 :             nBuildFlags |= 256;
     260             : 
     261           0 :         if ( GetPropertyValue( aAny, mXPagePropSet, rtl::OUString( "Duration" ) ) )// duration of this slide
     262           0 :             nSlideTime = *(sal_Int32*)aAny.getValue() << 10;        // in ticks
     263             : 
     264           0 :         mpPptEscherEx->AddAtom( 16, EPP_SSSlideInfoAtom );
     265           0 :         *mpStrm << nSlideTime       // standtime in ticks
     266           0 :                 << nSoundRef
     267           0 :                 << nDirection
     268           0 :                 << nTransitionType
     269           0 :                 << nBuildFlags
     270           0 :                 << nSpeed
     271           0 :                 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0;
     272             :     }
     273             : 
     274           0 :     ImplCreateHeaderFooters( mXPagePropSet );
     275             : 
     276           0 :     EscherSolverContainer aSolverContainer;
     277           0 :     mpPptEscherEx->OpenContainer( EPP_PPDrawing );
     278           0 :     mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
     279           0 :     mpPptEscherEx->EnterGroup(0,0);
     280           0 :     ImplWritePage( rLayout, aSolverContainer, NORMAL, sal_False, nPageNum );    // Die Shapes der Seite werden im PPT Dok. erzeugt
     281           0 :     mpPptEscherEx->LeaveGroup();
     282             : 
     283           0 :     if ( bHasBackground )
     284           0 :         ImplWriteBackground( aXBackgroundPropSet );
     285             :     else
     286             :     {
     287           0 :         mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
     288           0 :         mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 );             // Flags: Connector | Background | HasSpt
     289           0 :         EscherPropertyContainer aPropOpt;
     290           0 :         aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, PPTtoEMU( maDestPageSize.Width ) );
     291           0 :         aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, PPTtoEMU( maDestPageSize.Width ) );
     292           0 :         aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
     293           0 :         aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
     294           0 :         aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
     295           0 :         aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );                // if true, this is the background shape
     296           0 :         aPropOpt.Commit( *mpStrm );
     297           0 :         mpPptEscherEx->CloseContainer();    // ESCHER_SpContainer
     298             :     }
     299             : 
     300           0 :     aSolverContainer.WriteSolver( *mpStrm );
     301             : 
     302           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_DgContainer
     303           0 :     mpPptEscherEx->CloseContainer();    // EPP_Drawing
     304           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
     305           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
     306             : 
     307           0 :     SvMemoryStream aBinaryTagData10Atom;
     308           0 :     ImplExportComments( mXDrawPage, aBinaryTagData10Atom );
     309           0 :     if ( mbUseNewAnimations )
     310             :     {
     311           0 :         SvMemoryStream amsofbtAnimGroup;
     312           0 :         ppt::AnimationExporter aExporter( aSolverContainer, maSoundCollection );
     313           0 :         aExporter.doexport( mXDrawPage, amsofbtAnimGroup );
     314           0 :         sal_uInt32 nmsofbtAnimGroupSize = amsofbtAnimGroup.Tell();
     315           0 :         if ( nmsofbtAnimGroupSize )
     316             :         {
     317             :             {
     318           0 :                 EscherExAtom aMagic2( aBinaryTagData10Atom, 0x2eeb );
     319           0 :                 aBinaryTagData10Atom << (sal_uInt32)0x01c45df9
     320           0 :                                      << (sal_uInt32)0xe1471b30;
     321             :             }
     322             :             {
     323           0 :                 EscherExAtom aMagic( aBinaryTagData10Atom, 0x2b00 );
     324           0 :                 aBinaryTagData10Atom << (sal_uInt32)0;
     325             :             }
     326           0 :             aBinaryTagData10Atom.Write( amsofbtAnimGroup.GetData(), amsofbtAnimGroup.Tell() );
     327             :             {
     328           0 :                 EscherExContainer aMagic2( aBinaryTagData10Atom, 0x2b02 );
     329             :             }
     330           0 :         }
     331             :     }
     332           0 :     if ( aBinaryTagData10Atom.Tell() )
     333             :     {
     334           0 :         EscherExContainer aProgTags     ( *mpStrm, EPP_ProgTags );
     335           0 :         EscherExContainer aProgBinaryTag( *mpStrm, EPP_ProgBinaryTag );
     336             :         {
     337           0 :             EscherExAtom aCString( *mpStrm, EPP_CString );
     338           0 :             *mpStrm << (sal_uInt32)0x5f005f
     339           0 :                     << (sal_uInt32)0x50005f
     340           0 :                     << (sal_uInt32)0x540050
     341           0 :                     << (sal_uInt16)0x31
     342           0 :                     << (sal_uInt16)0x30;
     343             :         }
     344             :         {
     345           0 :             EscherExAtom aBinaryTagData( *mpStrm, EPP_BinaryTagData );
     346           0 :             mpStrm->Write( aBinaryTagData10Atom.GetData(), aBinaryTagData10Atom.Tell() );
     347           0 :         }
     348             :     }
     349           0 :     mpPptEscherEx->CloseContainer();    // EPP_Slide
     350           0 : }
     351             : 
     352             : // ---------------------------------------------------------------------------------------------
     353             : 
     354           0 : void PPTWriter::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPropertySet > aXBackgroundPropSet )
     355             : {
     356           0 :     mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_MainMaster | nPageNum, mpStrm->Tell() );
     357           0 :     mpPptEscherEx->OpenContainer( EPP_MainMaster );
     358           0 :     mpPptEscherEx->AddAtom( 24, EPP_SlideAtom, 2 );
     359           0 :     *mpStrm << (sal_Int32)EPP_LAYOUT_TITLEANDBODYSLIDE  // slide layout -> title and body slide
     360           0 :             << (sal_uInt8)1 << (sal_uInt8)2 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0     // placeholderID
     361           0 :             << (sal_uInt32)0        // master ID ( ist gleich null bei einer masterpage )
     362           0 :             << (sal_uInt32)0        // notes ID ( ist gleich null wenn keine notizen vorhanden )
     363           0 :             << (sal_uInt16)0        // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
     364           0 :             << (sal_uInt16)0;       // padword
     365             : 
     366           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     367           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
     368           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     369           0 :     *mpStrm << (sal_uInt32)0xff0000 << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x00ffff << (sal_uInt32)0x0099ff << (sal_uInt32)0xffff00 << (sal_uInt32)0x0000ff << (sal_uInt32)0x969696;
     370           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     371           0 :     *mpStrm << (sal_uInt32)0xccffff << (sal_uInt32)0x000000 << (sal_uInt32)0x336666 << (sal_uInt32)0x008080 << (sal_uInt32)0x339933 << (sal_uInt32)0x000080 << (sal_uInt32)0xcc3300 << (sal_uInt32)0x66ccff;
     372           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     373           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x333333 << (sal_uInt32)0x000000 << (sal_uInt32)0xdddddd << (sal_uInt32)0x808080 << (sal_uInt32)0x4d4d4d << (sal_uInt32)0xeaeaea;
     374           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     375           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x66ccff << (sal_uInt32)0xff0000 << (sal_uInt32)0xcc00cc << (sal_uInt32)0xc0c0c0;
     376           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     377           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0xc0c0c0 << (sal_uInt32)0xff6600 << (sal_uInt32)0x0000ff << (sal_uInt32)0x009900;
     378           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
     379           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0xff9933 << (sal_uInt32)0xccff99 << (sal_uInt32)0xcc00cc << (sal_uInt32)0xb2b2b2;
     380             : 
     381           0 :     for ( int nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
     382             :     {
     383           0 :         if ( nInstance == EPP_TEXTTYPE_notUsed )
     384           0 :             continue;
     385             : 
     386             :         // the auto color is dependent to the page background,so we have to set a page that is in the right context
     387           0 :         if ( nInstance == EPP_TEXTTYPE_Notes )
     388           0 :             GetPageByIndex( 0, NOTICE );
     389             :         else
     390           0 :             GetPageByIndex( 0, MASTER );
     391             : 
     392           0 :         mpPptEscherEx->BeginAtom();
     393             : 
     394           0 :         sal_Bool bFirst = sal_True;
     395           0 :         sal_Bool bSimpleText = sal_False;
     396             : 
     397           0 :         *mpStrm << (sal_uInt16)5;                           // paragraph count
     398             : 
     399           0 :         for ( sal_uInt16 nLev = 0; nLev < 5; nLev++ )
     400             :         {
     401           0 :             if ( nInstance >= EPP_TEXTTYPE_CenterBody )
     402             :             {
     403           0 :                 bFirst = sal_False;
     404           0 :                 bSimpleText = sal_True;
     405           0 :                 *mpStrm << nLev;
     406             :             }
     407           0 :             mpStyleSheet->mpParaSheet[ nInstance ]->Write( *mpStrm, mpPptEscherEx, nLev, bFirst, bSimpleText, mXPagePropSet );
     408           0 :             mpStyleSheet->mpCharSheet[ nInstance ]->Write( *mpStrm, mpPptEscherEx, nLev, bFirst, bSimpleText, mXPagePropSet );
     409           0 :             bFirst = sal_False;
     410             :         }
     411           0 :         mpPptEscherEx->EndAtom( EPP_TxMasterStyleAtom, 0, nInstance );
     412             :     }
     413           0 :     GetPageByIndex( nPageNum, MASTER );
     414             : 
     415           0 :     EscherSolverContainer aSolverContainer;
     416             : 
     417           0 :     mpPptEscherEx->OpenContainer( EPP_PPDrawing );
     418           0 :     mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
     419             : 
     420           0 :     mpPptEscherEx->EnterGroup(0,0);
     421           0 :     ImplWritePage( GetLayout( 0 ), aSolverContainer, MASTER, sal_True );    // Die Shapes der Seite werden im PPT Dok. erzeugt
     422           0 :     mpPptEscherEx->LeaveGroup();
     423             : 
     424           0 :     ImplWriteBackground( aXBackgroundPropSet );
     425             : 
     426           0 :     aSolverContainer.WriteSolver( *mpStrm );
     427             : 
     428           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_DgContainer
     429           0 :     mpPptEscherEx->CloseContainer();    // EPP_Drawing
     430           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
     431           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
     432             : 
     433           0 :     if ( aBuExMasterStream.Tell() )
     434             :     {
     435           0 :         ImplProgTagContainer( mpStrm, &aBuExMasterStream );
     436             :     }
     437           0 :     mpPptEscherEx->CloseContainer();    // EPP_MainMaster
     438           0 : };
     439             : 
     440             : // ---------------------------------------------------------------------------------------------
     441             : 
     442           0 : PPTWriter::~PPTWriter()
     443             : {
     444           0 :     delete mpExEmbed;
     445           0 :     delete mpPptEscherEx;
     446           0 :     delete mpCurUserStrm;
     447           0 :     delete mpPicStrm;
     448           0 :     delete mpStrm;
     449             : 
     450           0 :     std::vector< PPTExStyleSheet* >::iterator aStyleSheetIter( maStyleSheetList.begin() );
     451           0 :     while( aStyleSheetIter < maStyleSheetList.end() )
     452           0 :         delete *aStyleSheetIter++;
     453             : 
     454           0 :     for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
     455           0 :         delete *it;
     456             : 
     457           0 :     if ( mbStatusIndicator )
     458           0 :         mXStatusIndicator->end();
     459           0 : }
     460             : 
     461             : // ---------------------------------------------------------------------------------------------
     462             : 
     463           0 : sal_Bool PPTWriter::ImplCreateCurrentUserStream()
     464             : {
     465           0 :     mpCurUserStrm = mrStg->OpenSotStream( rtl::OUString( "Current User" ) );
     466           0 :     if ( !mpCurUserStrm )
     467           0 :         return sal_False;
     468           0 :     char pUserName[] = "Current User";
     469           0 :     sal_uInt32 nLenOfUserName = strlen( pUserName );
     470           0 :     sal_uInt32 nSizeOfRecord = 0x14 + ( ( nLenOfUserName + 4 ) & ~ 3 );
     471             : 
     472           0 :     *mpCurUserStrm << (sal_uInt16)0 << (sal_uInt16)EPP_CurrentUserAtom << nSizeOfRecord;
     473           0 :     *mpCurUserStrm << (sal_uInt32)0x14                  // Len
     474           0 :                    << (sal_uInt32)0xe391c05f;           // Magic
     475             : 
     476           0 :     sal_uInt32 nEditPos = mpCurUserStrm->Tell();
     477           0 :     *mpCurUserStrm << (sal_uInt32)0x0                   // OffsetToCurrentEdit;
     478           0 :                    << (sal_uInt16)nLenOfUserName        //
     479           0 :                    << (sal_uInt16)0x3f4                 // DocFileVersion
     480           0 :                    << (sal_uInt8)3                      // MajorVersion
     481           0 :                    << (sal_uInt8)0                      // MinorVersion
     482           0 :                    << (sal_uInt16)0;                    // Pad Word
     483           0 :     pUserName[ nLenOfUserName ] = 8;
     484           0 :     mpCurUserStrm->Write( pUserName, nLenOfUserName + 1 );
     485           0 :     for ( sal_uInt32 i = 0x15 + nLenOfUserName; i < nSizeOfRecord; i++ )
     486             :     {
     487           0 :         *mpCurUserStrm << (sal_uInt8)0;                 // pad bytes
     488             :     };
     489           0 :     mpCurUserStrm->Seek( nEditPos );
     490           0 :     return sal_True;
     491             : };
     492             : 
     493             : // ---------------------------------------------------------------------------------------------
     494             : 
     495           0 : sal_Bool PPTWriter::ImplCreateDocumentSummaryInformation()
     496             : {
     497             :     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     498           0 :         mXModel, uno::UNO_QUERY_THROW);
     499             :     uno::Reference<document::XDocumentProperties> xDocProps(
     500           0 :         xDPS->getDocumentProperties());
     501             : 
     502           0 :     if (xDocProps.is()) {
     503             : 
     504             :         // no idea what this is...
     505             :         static sal_uInt8 aGuid[ 0x52 ] =
     506             :         {
     507             :             0x4e, 0x00, 0x00, 0x00,
     508             :             '{',0,'D',0,'B',0,'1',0,'A',0,'C',0,'9',0,'6',0,'4',0,'-',0,
     509             :             'E',0,'3',0,'9',0,'C',0,'-',0,'1',0,'1',0,'D',0,'2',0,'-',0,
     510             :             'A',0,'1',0,'E',0,'F',0,'-',0,'0',0,'0',0,'6',0,'0',0,'9',0,
     511             :             '7',0,'D',0,'A',0,'5',0,'6',0,'8',0,'9',0,'}',0
     512             :         };
     513           0 :         uno::Sequence<sal_uInt8> aGuidSeq(aGuid, 0x52);
     514             : 
     515           0 :         SvMemoryStream  aHyperBlob;
     516           0 :         ImplCreateHyperBlob( aHyperBlob );
     517             : 
     518           0 :         uno::Sequence<sal_uInt8> aHyperSeq(aHyperBlob.Tell());
     519             :         const sal_uInt8* pBlob(
     520           0 :             static_cast<const sal_uInt8*>(aHyperBlob.GetData()));
     521           0 :         for (sal_Int32 j = 0; j < aHyperSeq.getLength(); ++j) {
     522           0 :             aHyperSeq[j] = pBlob[j];
     523             :         }
     524             : 
     525           0 :         if ( mnCnvrtFlags & 0x8000 )
     526             :         {
     527           0 :             uno::Sequence<sal_uInt8> aThumbSeq;
     528           0 :             if ( GetPageByIndex( 0, NORMAL ) && ImplGetPropertyValue( mXPagePropSet, rtl::OUString( "PreviewBitmap" ) ) )
     529             :             {
     530             :                 aThumbSeq =
     531           0 :                     *static_cast<const uno::Sequence<sal_uInt8>*>(mAny.getValue());
     532             :             }
     533             :             sfx2::SaveOlePropertySet( xDocProps, mrStg,
     534           0 :                     &aThumbSeq, &aGuidSeq, &aHyperSeq);
     535             :         }
     536             :         else
     537             :         {
     538             :             sfx2::SaveOlePropertySet( xDocProps, mrStg,
     539           0 :                     NULL, &aGuidSeq, &aHyperSeq );
     540           0 :         }
     541             :     }
     542             : 
     543           0 :     return sal_True;
     544             : }
     545             : 
     546             : // ---------------------------------------------------------------------------------------------
     547             : 
     548           0 : void PPTWriter::ImplWriteExtParaHeader( SvMemoryStream& rSt, sal_uInt32 nRef, sal_uInt32 nInstance, sal_uInt32 nSlideId )
     549             : {
     550           0 :     if ( rSt.Tell() )
     551             :     {
     552             :         aBuExOutlineStream << (sal_uInt32)( ( EPP_PST_ExtendedParagraphHeaderAtom << 16 )
     553           0 :                                 | ( nRef << 4 ) )
     554           0 :                             << (sal_uInt32)8
     555           0 :                             << (sal_uInt32)nSlideId
     556           0 :                             << (sal_uInt32)nInstance;
     557           0 :         aBuExOutlineStream.Write( rSt.GetData(), rSt.Tell() );
     558             :     }
     559           0 : }
     560             : 
     561             : // ---------------------------------------------------------------------------------------------
     562             : 
     563           0 : void PPTWriter::ImplCreateHeaderFooterStrings( SvStream& rStrm, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPagePropSet )
     564             : {
     565           0 :     if ( rXPagePropSet.is() )
     566             :     {
     567           0 :         rtl::OUString aString;
     568           0 :         ::com::sun::star::uno::Any aAny;
     569           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "HeaderText" ), sal_True ) )
     570             :         {
     571           0 :             if ( aAny >>= aString )
     572           0 :                 PPTWriter::WriteCString( rStrm, aString, 1 );
     573             :         }
     574           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "FooterText" ), sal_True ) )
     575             :         {
     576           0 :             if ( aAny >>= aString )
     577           0 :                 PPTWriter::WriteCString( rStrm, aString, 2 );
     578             :         }
     579           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "DateTimeText" ), sal_True ) )
     580             :         {
     581           0 :             if ( aAny >>= aString )
     582           0 :                 PPTWriter::WriteCString( rStrm, aString, 0 );
     583           0 :         }
     584             :     }
     585           0 : }
     586             : 
     587             : // ---------------------------------------------------------------------------------------------
     588             : 
     589           0 : void PPTWriter::ImplCreateHeaderFooters( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPagePropSet )
     590             : {
     591           0 :     if ( rXPagePropSet.is() )
     592             :     {
     593           0 :         sal_Bool bVal = sal_False;
     594           0 :         sal_uInt32 nVal = 0;
     595           0 :         ::com::sun::star::uno::Any aAny;
     596           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "IsHeaderVisible" ), sal_True ) )
     597             :         {
     598           0 :             if ( ( aAny >>= bVal ) && bVal )
     599           0 :                 nVal |= 0x100000;
     600             :         }
     601           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "IsFooterVisible" ), sal_True ) )
     602             :         {
     603           0 :             if ( ( aAny >>= bVal ) && bVal )
     604           0 :                 nVal |= 0x200000;
     605             :         }
     606           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "IsDateTimeVisible" ), sal_True ) )
     607             :         {
     608           0 :             if ( ( aAny >>= bVal ) && bVal )
     609           0 :                 nVal |= 0x010000;
     610             :         }
     611           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "IsPageNumberVisible" ), sal_True ) )
     612             :         {
     613           0 :             if ( ( aAny >>= bVal ) && bVal )
     614           0 :                 nVal |= 0x080000;
     615             :         }
     616           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "IsDateTimeFixed" ), sal_True ) )
     617             :         {
     618           0 :             if ( ( aAny >>= bVal ) && !bVal )
     619           0 :                 nVal |= 0x20000;
     620             :             else
     621           0 :                 nVal |= 0x40000;
     622             :         }
     623           0 :         if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, rtl::OUString( "DateTimeFormat" ), sal_True ) )
     624             :         {
     625           0 :             sal_Int32 nFormat = *(sal_Int32*)aAny.getValue();
     626           0 :             SvxDateFormat eDateFormat = (SvxDateFormat)( nFormat & 0xf );
     627           0 :             SvxTimeFormat eTimeFormat = (SvxTimeFormat)( ( nFormat >> 4 ) & 0xf );
     628           0 :             switch( eDateFormat )
     629             :             {
     630             :                 case SVXDATEFORMAT_F :
     631           0 :                     nFormat = 1;
     632           0 :                 break;
     633             :                 case SVXDATEFORMAT_D :
     634           0 :                     nFormat = 2;
     635           0 :                 break;
     636             :                 case SVXDATEFORMAT_C :
     637           0 :                     nFormat = 4;
     638           0 :                 break;
     639             :                 default:
     640             :                 case SVXDATEFORMAT_A :
     641           0 :                     nFormat = 0;
     642             :             }
     643           0 :             switch( eTimeFormat )
     644             :             {
     645             :                 case SVXTIMEFORMAT_24_HM :
     646           0 :                     nFormat = 9;
     647           0 :                 break;
     648             :                 case SVXTIMEFORMAT_12_HM :
     649           0 :                     nFormat = 11;
     650           0 :                 break;
     651             :                 case SVXTIMEFORMAT_24_HMS :
     652           0 :                     nFormat = 10;
     653           0 :                 break;
     654             :                 case SVXTIMEFORMAT_12_HMS :
     655           0 :                     nFormat = 12;
     656           0 :                 break;
     657             :                 default:
     658           0 :                     break;
     659             :             }
     660           0 :             nVal |= nFormat;
     661             :         }
     662             : 
     663           0 :         mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 0 );
     664           0 :         mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
     665           0 :         *mpStrm << nVal;
     666           0 :         ImplCreateHeaderFooterStrings( *mpStrm, rXPagePropSet );
     667           0 :         mpPptEscherEx->CloseContainer();
     668             :     }
     669           0 : }
     670             : 
     671             : // ---------------------------------------------------------------------------------------------
     672             : 
     673           0 : sal_Bool PPTWriter::ImplCreateDocument()
     674             : {
     675             :     sal_uInt32 i;
     676           0 :     sal_uInt16 nSlideType = EPP_SLIDESIZE_TYPECUSTOM;
     677             : 
     678           0 :     sal_uInt32 nWidth = maDestPageSize.Width;
     679           0 :     sal_uInt32 nHeight = maDestPageSize.Height;
     680             : 
     681           0 :     if ( ( nWidth == 0x1680 ) && ( nHeight == 0x10e0 ) )
     682           0 :         nSlideType = EPP_SLIDESIZE_TYPEONSCREEN;
     683           0 :     else if ( ( nWidth == 0x1200 ) && ( nHeight == 0x240 ) )
     684           0 :         nSlideType = EPP_SLIDESIZE_TYPEBANNER;
     685           0 :     else if ( ( nWidth == 0x1950 ) && ( nHeight == 0x10e0 ) )
     686           0 :         nSlideType = EPP_SLIDESIZE_TYPE35MM;
     687           0 :     else if ( ( nWidth == 0x1860 ) && ( nHeight == 0x10e0 ) )
     688           0 :         nSlideType = EPP_SLIDESIZE_TYPEA4PAPER;
     689             : 
     690           0 :     mpPptEscherEx->OpenContainer( EPP_Document );
     691             :     // CREATE DOCUMENT ATOM
     692           0 :     mpPptEscherEx->AddAtom( 40, EPP_DocumentAtom, 1 );
     693           0 :     *mpStrm << nWidth                           // Slide Size in Master coordinates X
     694           0 :             << nHeight                          //   "     "   "    "        "      Y
     695           0 :             << (sal_Int32)maNotesPageSize.Width     // Notes Page Size                  X
     696           0 :             << (sal_Int32)maNotesPageSize.Height    //   "     "   "                    Y
     697           0 :             << (sal_Int32)1 << (sal_Int32)2;            // the scale used when the Powerpoint document is embedded. the default is 1:2
     698           0 :     mpPptEscherEx->InsertPersistOffset( EPP_MAINNOTESMASTER_PERSIST_KEY, mpStrm->Tell() );
     699           0 :     *mpStrm << (sal_uInt32)0                        // Reference to NotesMaster ( 0 if none );
     700           0 :             << (sal_uInt32)0                        // Reference to HandoutMaster ( 0 if none );
     701           0 :             << (sal_Int16)1                         // Number of the first slide;
     702           0 :             << nSlideType                           // Size of the document slides ( default: EPP_SLIDESIZETYPEONSCREEN )
     703           0 :             << (sal_uInt8)0                         // bool1 indicates if document was saved with embedded true type fonts
     704           0 :             << (sal_uInt8)0                         // bool1 indicates if the placeholders on the title slide are omitted
     705           0 :             << (sal_uInt8)0                         // bool1 right to left ( flag for Bidi version )
     706           0 :             << (sal_uInt8)1;                            // bool1 visibility of comments shapes
     707             : 
     708           0 :     mpPptEscherEx->PtInsert( EPP_Persist_Document, mpStrm->Tell() );
     709             : 
     710           0 :     mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 3 );  //Master footer (default)
     711           0 :     mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
     712           0 :     *mpStrm << (sal_uInt32)0x25000d;
     713           0 :     if ( GetPageByIndex( 0, MASTER ) )
     714           0 :         ImplCreateHeaderFooterStrings( *mpStrm, mXPagePropSet );
     715           0 :     mpPptEscherEx->CloseContainer();
     716           0 :     mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 4 );  //NotesMaster footer (default)
     717           0 :     mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
     718           0 :     *mpStrm << (sal_uInt32)0x3d000d;
     719           0 :     if ( GetPageByIndex( 0, NOTICE ) )
     720           0 :         ImplCreateHeaderFooterStrings( *mpStrm, mXPagePropSet );
     721           0 :     mpPptEscherEx->CloseContainer();
     722             : 
     723           0 :     mpPptEscherEx->OpenContainer( EPP_SlideListWithText );      // Animation info fuer die Slides
     724             : 
     725           0 :     for ( i = 0; i < mnPages; i++ )
     726             :     {
     727           0 :         mpPptEscherEx->AddAtom( 20, EPP_SlidePersistAtom );
     728           0 :         mpPptEscherEx->InsertPersistOffset( EPP_MAINSLIDE_PERSIST_KEY | i, mpStrm->Tell() );
     729           0 :         *mpStrm << (sal_uInt32)0                                // psrReference - logical reference to the slide persist object ( EPP_MAINSLIDE_PERSIST_KEY )
     730           0 :                 << (sal_uInt32)4                                // flags - only bit 3 used, if set then slide contains shapes other than placeholders
     731           0 :                 << (sal_Int32)0                                     // numberTexts - number of placeholder texts stored with the persist object.  Allows to display outline view without loading the slide persist objects
     732           0 :                 << (sal_Int32)i + 0x100                             // slideId - Unique slide identifier, used for OLE link monikers for example
     733           0 :                 << (sal_uInt32)0;                               // reserved, usualy 0
     734             : 
     735           0 :         if ( !GetPageByIndex( i, NORMAL ) )                     // sehr aufregend: noch einmal ueber alle seiten
     736           0 :             return sal_False;
     737           0 :         SetCurrentStyleSheet( GetMasterIndex( NORMAL ) );
     738             : 
     739             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >
     740           0 :             aXName( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
     741             : 
     742           0 :         if ( aXName.is() )
     743           0 :             maSlideNameList.push_back( aXName->getName() );
     744             :         else
     745           0 :             maSlideNameList.push_back( ::rtl::OUString() );
     746           0 :     }
     747           0 :     mpPptEscherEx->CloseContainer();    // EPP_SlideListWithText
     748             : 
     749           0 :     mpPptEscherEx->OpenContainer( EPP_SlideListWithText, 2 );   // Animation info fuer die notes
     750           0 :     for( i = 0; i < mnPages; i++ )
     751             :     {
     752           0 :         mpPptEscherEx->AddAtom( 20, EPP_SlidePersistAtom );
     753           0 :         mpPptEscherEx->InsertPersistOffset( EPP_MAINNOTES_PERSIST_KEY | i, mpStrm->Tell() );
     754           0 :         *mpStrm << (sal_uInt32)0
     755           0 :                 << (sal_uInt32)4
     756           0 :                 << (sal_Int32)0
     757           0 :                 << (sal_Int32)i + 0x100
     758           0 :                 << (sal_uInt32)0;
     759             :     }
     760           0 :     mpPptEscherEx->CloseContainer();        // EPP_SlideListWithText
     761             : 
     762             :     ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XPresentationSupplier >
     763           0 :         aXPresSupplier( mXModel, ::com::sun::star::uno::UNO_QUERY );            ;
     764           0 :     if ( aXPresSupplier.is() )
     765             :     {
     766             :         ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XPresentation >
     767           0 :             aXPresentation( aXPresSupplier->getPresentation() );
     768           0 :         if ( aXPresentation.is() )
     769             :         {
     770             :             mXPropSet = ::com::sun::star::uno::Reference<
     771             :                 ::com::sun::star::beans::XPropertySet >
     772           0 :                     ( aXPresentation, ::com::sun::star::uno::UNO_QUERY );
     773           0 :             if ( mXPropSet.is() )
     774             :             {
     775           0 :                 ::rtl::OUString aCustomShow;
     776           0 :                 sal_uInt32  nPenColor = 0x1000000;
     777           0 :                 sal_Int32   nRestartTime = 0x7fffffff;
     778           0 :                 sal_Int16   nStartSlide = 0;
     779           0 :                 sal_Int16   nEndSlide = 0;
     780           0 :                 sal_uInt32  nFlags = 0;             // Bit 0:   Auto advance
     781             :                                                     // Bit 1    Skip builds ( do not allow slide effects )
     782             :                                                     // Bit 2    Use slide range
     783             :                                                     // Bit 3    Use named show
     784             :                                                     // Bit 4    Browse mode on
     785             :                                                     // Bit 5    Kiosk mode on
     786             :                                                     // Bit 7    loop continously
     787             :                                                     // Bit ?    show scrollbar
     788             : 
     789           0 :                 if ( ImplGetPropertyValue( rtl::OUString( "CustomShow" ) ) )
     790             :                 {
     791           0 :                     aCustomShow = ( *(::rtl::OUString*)mAny.getValue() );
     792           0 :                     if ( !aCustomShow.isEmpty() )
     793             :                     {
     794           0 :                         nFlags |= 8;
     795             :                     }
     796             :                 }
     797           0 :                 if ( ( nFlags & 8 ) == 0 )
     798             :                 {
     799           0 :                     if ( ImplGetPropertyValue( rtl::OUString( "FirstPage" ) ) )
     800             :                     {
     801           0 :                         ::rtl::OUString aSlideName( *(::rtl::OUString*)mAny.getValue() );
     802             : 
     803             :                         std::vector<rtl::OUString>::const_iterator pIter = std::find(
     804           0 :                                     maSlideNameList.begin(),maSlideNameList.end(),aSlideName);
     805             : 
     806           0 :                         if (pIter != maSlideNameList.end())
     807             :                         {
     808           0 :                             nStartSlide = pIter - maSlideNameList.begin() + 1;
     809           0 :                             nFlags |= 4;
     810           0 :                             nEndSlide = (sal_uInt16)mnPages;
     811           0 :                         }
     812             :                     }
     813             :                 }
     814             : 
     815           0 :                 if ( ImplGetPropertyValue( rtl::OUString("IsAutomatic" ) ) )
     816             :                 {
     817           0 :                     sal_Bool bBool = sal_False;
     818           0 :                     mAny >>= bBool;
     819           0 :                     if ( !bBool )
     820           0 :                         nFlags |= 1;
     821             :                 }
     822             : 
     823           0 :                 if ( ImplGetPropertyValue( rtl::OUString( "IsEndless" ) ) ) // muesste eigendlich heissen IsNotEndless !=)"�()&
     824             :                 {
     825           0 :                     sal_Bool bBool = sal_False;
     826           0 :                     mAny >>= bBool;
     827           0 :                     if ( bBool )
     828           0 :                         nFlags |= 0x80;
     829             :                 }
     830           0 :                 if ( ImplGetPropertyValue( rtl::OUString( "IsFullScreen" ) ) )
     831             :                 {
     832           0 :                     sal_Bool bBool = sal_False;
     833           0 :                     mAny >>= bBool;
     834           0 :                     if ( !bBool )
     835           0 :                         nFlags |= 0x11;
     836             :                 }
     837             : 
     838           0 :                 mpPptEscherEx->AddAtom( 80, EPP_SSDocInfoAtom, 1 );
     839           0 :                 *mpStrm << nPenColor << nRestartTime << nStartSlide << nEndSlide;
     840             : 
     841           0 :                 sal_uInt32 nCustomShowNameLen = aCustomShow.getLength();
     842           0 :                 if ( nCustomShowNameLen > 31 )
     843           0 :                     nCustomShowNameLen = 31;
     844           0 :                 if ( nCustomShowNameLen )       // named show identifier
     845             :                 {
     846           0 :                     const sal_Unicode* pCustomShow = aCustomShow.getStr();
     847           0 :                     for ( i = 0; i < nCustomShowNameLen; i++ )
     848             :                     {
     849           0 :                         *mpStrm << (sal_uInt16)( pCustomShow[ i ] );
     850             :                     }
     851             :                 }
     852           0 :                 for ( i = nCustomShowNameLen; i < 32; i++, *mpStrm << (sal_uInt16)0 ) ;
     853             : 
     854           0 :                 *mpStrm << nFlags;
     855             :                 ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XCustomPresentationSupplier >
     856           0 :                     aXCPSup( mXModel, ::com::sun::star::uno::UNO_QUERY );
     857           0 :                 if ( aXCPSup.is() )
     858             :                 {
     859             :                     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     860           0 :                         aXCont( aXCPSup->getCustomPresentations() );
     861           0 :                     if ( aXCont.is() )
     862             :                     {
     863           0 :                         ::com::sun::star::uno::Sequence< ::rtl::OUString> aNameSeq( aXCont->getElementNames() );
     864           0 :                         const ::rtl::OUString* pUString = aNameSeq.getArray();
     865           0 :                         sal_uInt32 nCount = aNameSeq.getLength();
     866           0 :                         if ( nCount )
     867             :                         {
     868           0 :                             mpPptEscherEx->OpenContainer( EPP_NamedShows );
     869           0 :                             sal_uInt32 nCustomShowIndex = 0;
     870           0 :                             for( i = 0; i < nCount; i++ )        // Anzahl der Custom Shows
     871             :                             {
     872           0 :                                 if ( !pUString[ i ].isEmpty() )
     873             :                                 {
     874           0 :                                     mpPptEscherEx->OpenContainer( EPP_NamedShow, nCustomShowIndex++ );
     875             : 
     876           0 :                                     sal_uInt32 nNamedShowLen = pUString[ i ].getLength();
     877           0 :                                     if ( nNamedShowLen > 31 )
     878           0 :                                         nNamedShowLen = 31;
     879           0 :                                     mpPptEscherEx->AddAtom( nNamedShowLen << 1, EPP_CString );
     880           0 :                                     const sal_Unicode* pCustomShowName = pUString[ i ].getStr();
     881           0 :                                     for ( sal_uInt32 k = 0; k < nNamedShowLen; *mpStrm << (sal_uInt16)( pCustomShowName[ k++ ] ) ) ;
     882           0 :                                     mAny = aXCont->getByName( pUString[ i ] );
     883           0 :                                     if ( mAny.getValue() )
     884             :                                     {
     885             : 
     886           0 :                                         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > aXIC;
     887           0 :                                         if ( mAny >>= aXIC )
     888             :                                         {
     889           0 :                                             mpPptEscherEx->BeginAtom();
     890             : 
     891           0 :                                             sal_Int32 nSlideCount = aXIC->getCount();
     892           0 :                                             for ( sal_Int32 j = 0; j < nSlideCount; j++ )   // Anzahl der Slides
     893             :                                             {
     894           0 :                                                 mAny = aXIC->getByIndex( j );
     895           0 :                                                 if ( mAny.getValue() )
     896             :                                                 {
     897             :                                                     ::com::sun::star::uno::Reference<
     898           0 :                                                         ::com::sun::star::drawing::XDrawPage > aXDrawPage;
     899           0 :                                                     if ( mAny >>= aXDrawPage )
     900             :                                                     {
     901             :                                                         ::com::sun::star::uno::Reference<
     902             :                                                             ::com::sun::star::container::XNamed >
     903           0 :                                                             aXName( aXDrawPage, ::com::sun::star::uno::UNO_QUERY );
     904           0 :                                                         if ( aXName.is() )
     905             :                                                         {
     906           0 :                                                             ::rtl::OUString aSlideName( aXName->getName() );
     907             :                                                             std::vector<rtl::OUString>::const_iterator pIter = std::find(
     908           0 :                                                                         maSlideNameList.begin(),maSlideNameList.end(),aSlideName);
     909             : 
     910           0 :                                                             if (pIter != maSlideNameList.end())
     911             :                                                             {
     912           0 :                                                                 sal_uInt32 nPageNumber = pIter - maSlideNameList.begin();
     913           0 :                                                                 *mpStrm << (sal_uInt32)( nPageNumber + 0x100 ); // unique slide id
     914           0 :                                                             }
     915           0 :                                                         }
     916           0 :                                                     }
     917             :                                                 }
     918             :                                             }
     919           0 :                                             mpPptEscherEx->EndAtom( EPP_NamedShowSlides );
     920           0 :                                         }
     921             :                                     }
     922           0 :                                     mpPptEscherEx->CloseContainer();            // EPP_NamedShow
     923             :                                 }
     924             :                             }
     925           0 :                             mpPptEscherEx->CloseContainer();                // EPP_NamedShows
     926           0 :                         }
     927           0 :                     }
     928           0 :                 }
     929             :             }
     930           0 :         }
     931             :     }
     932           0 :     mpPptEscherEx->AddAtom( 0, EPP_EndDocument );
     933           0 :     mpPptEscherEx->CloseContainer();    // EPP_Document
     934           0 :     return sal_True;
     935             : };
     936             : 
     937             : // ---------------------------------------------------------------------------------------------
     938             : 
     939           0 : sal_Bool PPTWriter::ImplCreateHyperBlob( SvMemoryStream& rStrm )
     940             : {
     941           0 :     sal_uInt32 nCurrentOfs, nParaOfs, nParaCount = 0;
     942             : 
     943           0 :     nParaOfs = rStrm.Tell();
     944           0 :     rStrm << (sal_uInt32)0;         // property size
     945           0 :     rStrm << (sal_uInt32)0;         // property count
     946             : 
     947           0 :     for ( std::vector<EPPTHyperlink>::const_iterator pIter = maHyperlink.begin(); pIter != maHyperlink.end(); ++pIter )
     948             :     {
     949           0 :         nParaCount += 6;
     950           0 :         rStrm   << (sal_uInt32)3    // Type VT_I4
     951           0 :                 << (sal_uInt32)7    // (VTI4 - Private1)
     952           0 :                 << (sal_uInt32)3    // Type VT_I4
     953           0 :                 << (sal_uInt32)6    // (VTI4 - Private2)
     954           0 :                 << (sal_uInt32)3    // Type VT_I4
     955           0 :                 << (sal_uInt32)0;   // (VTI4 - Private3)
     956             : 
     957             :         // INFO
     958             :         // HIWORD:  = 0 : do not change anything
     959             :         //          = 1 : replace the hyperlink with the target and subadress in the following two VTLPWSTR
     960             :         //          = 2 : delete the hyperlink
     961             :         // LOWORD:  = 0 : graphic shown as background (link)
     962             :         //          = 1 : graphic shown as shape (link)
     963             :         //          = 2 : graphic is used to fill a shape
     964             :         //          = 3 : graphic used to fill a shape outline (future use)
     965             :         //          = 4 : hyperlink attached to a shape
     966             :         //          = 5 :    "         "      " " (Word) field
     967             :         //          = 6 :    "         "      " " (Excel) range
     968             :         //          = 7 :    "         "      " " (PPT) text range
     969             :         //          = 8 :    "         "      " " (Project) task
     970             : 
     971           0 :         sal_uInt32 nUrlLen = pIter->aURL.Len();
     972           0 :         const sal_Unicode* pUrl = pIter->aURL.GetBuffer();
     973             : 
     974           0 :         sal_uInt32 nInfo = 7;
     975             : 
     976           0 :         rStrm   << (sal_uInt32)3    // Type VT_I4
     977           0 :                 << nInfo;       // Info
     978             : 
     979           0 :         switch( pIter->nType & 0xff )
     980             :         {
     981             :             case 1 :        // click action to slidenumber
     982             :             {
     983           0 :                 rStrm << (sal_uInt32)0x1f << (sal_uInt32)1 << (sal_uInt32)0;    // path
     984           0 :                 rStrm << (sal_uInt32)0x1f << (sal_uInt32)( nUrlLen + 1 );
     985           0 :                 for ( sal_uInt32 i = 0; i < nUrlLen; i++ )
     986             :                 {
     987           0 :                     rStrm << pUrl[ i ];
     988             :                 }
     989           0 :                 rStrm << (sal_uInt16)0;
     990             :             }
     991           0 :             break;
     992             :             case 2 :
     993             :             {
     994             :                 sal_uInt32 i;
     995             : 
     996           0 :                 rStrm   << (sal_uInt32)0x1f
     997           0 :                         << (sal_uInt32)( nUrlLen + 1 );
     998           0 :                 for ( i = 0; i < nUrlLen; i++ )
     999             :                 {
    1000           0 :                     rStrm << pUrl[ i ];
    1001             :                 }
    1002           0 :                 if ( ! ( i & 1 ) )
    1003           0 :                     rStrm << (sal_uInt16)0;
    1004           0 :                 rStrm   << (sal_uInt16)0
    1005           0 :                         << (sal_uInt32)0x1f
    1006           0 :                         << (sal_uInt32)1
    1007           0 :                         << (sal_uInt32)0;
    1008             :             }
    1009           0 :             break;
    1010             :         }
    1011             :     }
    1012           0 :     nCurrentOfs = rStrm.Tell();
    1013           0 :     rStrm.Seek( nParaOfs );
    1014           0 :     rStrm << (sal_uInt32)( nCurrentOfs - ( nParaOfs + 4 ) );
    1015           0 :     rStrm << nParaCount;
    1016           0 :     rStrm.Seek( nCurrentOfs );
    1017           0 :     return sal_True;
    1018             : }
    1019             : 
    1020             : // ---------------------------------------------------------------------------------------------
    1021             : 
    1022           0 : sal_Bool PPTWriter::ImplCreateMainNotes()
    1023             : {
    1024           0 :     EscherSolverContainer aSolverContainer;
    1025             : 
    1026           0 :     mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_MainNotes, mpStrm->Tell() );
    1027           0 :     mpPptEscherEx->OpenContainer( EPP_Notes );
    1028           0 :     mpPptEscherEx->AddAtom( 8, EPP_NotesAtom, 1 );
    1029           0 :     *mpStrm << (sal_uInt32)0x80000001                                               // Number that identifies this slide
    1030           0 :             << (sal_uInt32)0;                                                       // follow nothing
    1031           0 :     mpPptEscherEx->OpenContainer( EPP_PPDrawing );
    1032           0 :     mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
    1033           0 :     mpPptEscherEx->EnterGroup(0,0);
    1034             : 
    1035           0 :     ImplWritePage( GetLayout( 20 ), aSolverContainer, NOTICE, sal_True );
    1036             : 
    1037           0 :     mpPptEscherEx->LeaveGroup();
    1038           0 :     mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
    1039           0 :     mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 );
    1040           0 :     EscherPropertyContainer aPropOpt;
    1041           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0xffffff );                             // stock valued fill color
    1042           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
    1043           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, 0x68bdde );
    1044           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, 0x8b9f8e );
    1045           0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
    1046           0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0 );
    1047           0 :     aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
    1048           0 :     aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );                            // if true, this is the background shape
    1049           0 :     aPropOpt.Commit( *mpStrm );
    1050           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_SpContainer
    1051             : 
    1052           0 :     aSolverContainer.WriteSolver( *mpStrm );
    1053             : 
    1054           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_DgContainer
    1055           0 :     mpPptEscherEx->CloseContainer();    // EPP_Drawing
    1056           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
    1057           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
    1058           0 :     mpPptEscherEx->CloseContainer();    // EPP_Notes
    1059           0 :     return sal_True;
    1060             : }
    1061             : 
    1062             : // ---------------------------------------------------------------------------------------------
    1063             : 
    1064           0 : static rtl::OUString getInitials( const rtl::OUString& rName )
    1065             : {
    1066           0 :     rtl::OUString sInitials;
    1067             : 
    1068           0 :     const sal_Unicode * pStr = rName.getStr();
    1069           0 :     sal_Int32 nLength = rName.getLength();
    1070             : 
    1071           0 :     while( nLength )
    1072             :     {
    1073             :         // skip whitespace
    1074           0 :         while( nLength && (*pStr <= ' ') )
    1075             :         {
    1076           0 :             nLength--; pStr++;
    1077             :         }
    1078             : 
    1079             :         // take letter
    1080           0 :         if( nLength )
    1081             :         {
    1082           0 :             sInitials += rtl::OUString( *pStr );
    1083           0 :             nLength--; pStr++;
    1084             :         }
    1085             : 
    1086             :         // skip letters until whitespace
    1087           0 :         while( nLength && (*pStr > ' ') )
    1088             :         {
    1089           0 :             nLength--; pStr++;
    1090             :         }
    1091             :     }
    1092             : 
    1093           0 :     return sInitials;
    1094             : }
    1095             : 
    1096           0 : void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStream& rBinaryTagData10Atom )
    1097             : {
    1098             :     try
    1099             :     {
    1100           0 :         uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
    1101           0 :         uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
    1102             : 
    1103           0 :         sal_Int32 nIndex = 1;
    1104             : 
    1105           0 :         while( xAnnotationEnumeration->hasMoreElements() )
    1106             :         {
    1107           0 :             EscherExContainer aComment10( rBinaryTagData10Atom, EPP_Comment10 );
    1108             :             {
    1109           0 :                 uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
    1110             : 
    1111           0 :                 geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
    1112           0 :                 MapMode aMapDest( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) );
    1113             :                 Point aPoint( OutputDevice::LogicToLogic( Point( static_cast< sal_Int32 >( aRealPoint2D.X * 100.0 ),
    1114           0 :                     static_cast< sal_Int32 >( aRealPoint2D.Y * 100.0 ) ), MAP_100TH_MM, aMapDest ) );
    1115             : 
    1116           0 :                 rtl::OUString sAuthor( xAnnotation->getAuthor() );
    1117           0 :                 uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
    1118           0 :                 rtl::OUString sText( xText->getString() );
    1119           0 :                 rtl::OUString sInitials( getInitials( sAuthor ) );
    1120           0 :                 util::DateTime aDateTime( xAnnotation->getDateTime() );
    1121           0 :                 if ( !sAuthor.isEmpty() )
    1122           0 :                     PPTWriter::WriteCString( rBinaryTagData10Atom, sAuthor, 0 );
    1123           0 :                 if ( !sText.isEmpty() )
    1124           0 :                     PPTWriter::WriteCString( rBinaryTagData10Atom, sText, 1 );
    1125           0 :                 if ( !sInitials.isEmpty() )
    1126           0 :                     PPTWriter::WriteCString( rBinaryTagData10Atom, sInitials, 2 );
    1127             : 
    1128           0 :                 sal_Int16 nMilliSeconds = aDateTime.HundredthSeconds * 10;
    1129           0 :                 EscherExAtom aCommentAtom10( rBinaryTagData10Atom, EPP_CommentAtom10 );
    1130           0 :                 rBinaryTagData10Atom << nIndex++
    1131           0 :                                      << aDateTime.Year
    1132           0 :                                      << aDateTime.Month
    1133           0 :                                      << aDateTime.Day   // todo: day of week
    1134           0 :                                      << aDateTime.Day
    1135           0 :                                      << aDateTime.Hours
    1136           0 :                                      << aDateTime.Minutes
    1137           0 :                                      << aDateTime.Seconds
    1138           0 :                                      << nMilliSeconds
    1139           0 :                                      << static_cast< sal_Int32 >( aPoint.X() )
    1140           0 :                                      << static_cast< sal_Int32 >( aPoint.Y() );
    1141             :             }
    1142           0 :         }
    1143             :     }
    1144           0 :     catch ( uno::Exception& )
    1145             :     {
    1146             :     }
    1147           0 : }
    1148             : 
    1149             : // ---------------------------------------------------------------------------------------------
    1150             : 
    1151           0 : void PPTWriter::ImplWriteNotes( sal_uInt32 nPageNum )
    1152             : {
    1153           0 :     mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_Notes | nPageNum, mpStrm->Tell() );
    1154           0 :     mpPptEscherEx->OpenContainer( EPP_Notes );
    1155           0 :     mpPptEscherEx->AddAtom( 8, EPP_NotesAtom, 1 );
    1156           0 :     *mpStrm << (sal_uInt32)nPageNum + 0x100
    1157           0 :             << (sal_uInt16)3                                        // follow master ....
    1158           0 :             << (sal_uInt16)0;
    1159             : 
    1160           0 :     ImplCreateHeaderFooters( mXPagePropSet );
    1161             : 
    1162           0 :     EscherSolverContainer aSolverContainer;
    1163             : 
    1164           0 :     mpPptEscherEx->OpenContainer( EPP_PPDrawing );
    1165           0 :     mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
    1166           0 :     mpPptEscherEx->EnterGroup(0,0);
    1167             : 
    1168           0 :     ImplWritePage( GetLayout( 20 ), aSolverContainer, NOTICE, sal_False );  // Die Shapes der Seite werden im PPT Dok. erzeugt
    1169             : 
    1170           0 :     mpPptEscherEx->LeaveGroup();
    1171           0 :     mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
    1172           0 :     mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 ); // Flags: Connector | Background | HasSpt
    1173           0 :     EscherPropertyContainer aPropOpt;
    1174           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0xffffff );     // stock valued fill color
    1175           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
    1176           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, 0x8b9f8e );
    1177           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, 0x68bdde );
    1178           0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
    1179           0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
    1180           0 :     aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
    1181           0 :     aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
    1182           0 :     aPropOpt.Commit( *mpStrm );
    1183           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_SpContainer
    1184             : 
    1185           0 :     aSolverContainer.WriteSolver( *mpStrm );
    1186             : 
    1187           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_DgContainer
    1188           0 :     mpPptEscherEx->CloseContainer();    // EPP_Drawing
    1189           0 :     mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
    1190           0 :     *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
    1191           0 :     mpPptEscherEx->CloseContainer();    // EPP_Notes
    1192           0 : };
    1193             : 
    1194           0 : void PPTWriter::ImplWriteBackground( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet )
    1195             : {
    1196             :     //************************ ******
    1197             :     //** DEFAULT BACKGROUND SHAPE **
    1198             :     //******************************
    1199             : 
    1200           0 :     sal_uInt32 nFillColor = 0xffffff;
    1201           0 :     sal_uInt32 nFillBackColor = 0;
    1202             : 
    1203           0 :     mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
    1204           0 :     mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 );                     // Flags: Connector | Background | HasSpt
    1205           0 :     Point aEmptyPoint = Point();
    1206           0 :     Rectangle aRect( aEmptyPoint, Size( 28000, 21000 ) );
    1207           0 :     EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm, aRect );
    1208           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
    1209           0 :     ::com::sun::star::drawing::FillStyle aFS( ::com::sun::star::drawing::FillStyle_NONE );
    1210           0 :     if ( ImplGetPropertyValue( rXPropSet, rtl::OUString( "FillStyle" ) ) )
    1211           0 :         mAny >>= aFS;
    1212             : 
    1213           0 :     switch( aFS )
    1214             :     {
    1215             :         case ::com::sun::star::drawing::FillStyle_GRADIENT :
    1216             :         {
    1217           0 :             aPropOpt.CreateGradientProperties( rXPropSet );
    1218           0 :             aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x1f001e );
    1219           0 :             aPropOpt.GetOpt( ESCHER_Prop_fillColor, nFillColor );
    1220           0 :             aPropOpt.GetOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
    1221             :         }
    1222           0 :         break;
    1223             : 
    1224             :         case ::com::sun::star::drawing::FillStyle_BITMAP :
    1225           0 :             aPropOpt.CreateGraphicProperties( rXPropSet, rtl::OUString( "FillBitmapURL" ), sal_True );
    1226           0 :         break;
    1227             : 
    1228             :         case ::com::sun::star::drawing::FillStyle_HATCH :
    1229           0 :             aPropOpt.CreateGraphicProperties( rXPropSet, rtl::OUString( "FillHatch" ), sal_True );
    1230           0 :         break;
    1231             : 
    1232             :         case ::com::sun::star::drawing::FillStyle_SOLID :
    1233             :         {
    1234           0 :             if ( ImplGetPropertyValue( rXPropSet, rtl::OUString( "FillColor" ) ) )
    1235             :             {
    1236           0 :                 nFillColor = mpPptEscherEx->GetColor( *((sal_uInt32*)mAny.getValue()) );
    1237           0 :                 nFillBackColor = nFillColor ^ 0xffffff;
    1238             :             }
    1239             :         }   // PASSTHROUGH INTENDED
    1240             :         case ::com::sun::star::drawing::FillStyle_NONE :
    1241             :         default:
    1242           0 :             aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
    1243           0 :         break;
    1244             :     }
    1245           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillColor, nFillColor );
    1246           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
    1247           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, PPTtoEMU( maDestPageSize.Width ) );
    1248           0 :     aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, PPTtoEMU( maDestPageSize.Height ) );
    1249           0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
    1250           0 :     aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_bwWhite );
    1251           0 :     aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
    1252           0 :     aPropOpt.Commit( *mpStrm );
    1253           0 :     mpPptEscherEx->CloseContainer();    // ESCHER_SpContainer
    1254           0 : }
    1255             : 
    1256           0 : void PPTWriter::ImplWriteVBA()
    1257             : {
    1258           0 :     if ( mpVBA )
    1259             :     {
    1260           0 :         mpVBA->Seek( STREAM_SEEK_TO_END );
    1261           0 :         sal_uInt32 nLen = mpVBA->Tell();
    1262           0 :         if ( nLen > 8 )
    1263             :         {
    1264           0 :             nLen -= 8;
    1265           0 :             mnVBAOleOfs = mpStrm->Tell();
    1266           0 :             mpPptEscherEx->BeginAtom();
    1267           0 :             mpStrm->Write( (sal_Int8*)mpVBA->GetData() + 8, nLen );
    1268           0 :             mpPptEscherEx->EndAtom( EPP_ExOleObjStg, 0, 1 );
    1269             :         }
    1270             :     }
    1271           0 : }
    1272             : 
    1273             : // ---------------------------------------------------------------------------------------------
    1274             : 
    1275           0 : void PPTWriter::ImplWriteOLE( )
    1276             : {
    1277             : 
    1278           0 :     SvxMSExportOLEObjects aOleExport( mnCnvrtFlags );
    1279             : 
    1280           0 :     for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
    1281             :     {
    1282           0 :         PPTExOleObjEntry* pPtr = *it;
    1283           0 :         SvMemoryStream* pStrm = NULL;
    1284           0 :         pPtr->nOfsB = mpStrm->Tell();
    1285           0 :         switch ( pPtr->eType )
    1286             :         {
    1287             :             case NORMAL_OLE_OBJECT :
    1288             :             {
    1289           0 :                 SdrObject* pSdrObj = GetSdrObjectFromXShape( pPtr->xShape );
    1290           0 :                 if ( pSdrObj && pSdrObj->ISA( SdrOle2Obj ) )
    1291             :                 {
    1292           0 :                     ::uno::Reference < embed::XEmbeddedObject > xObj( ( (SdrOle2Obj*) pSdrObj )->GetObjRef() );
    1293           0 :                     if( xObj.is() )
    1294             :                     {
    1295           0 :                         SvStorageRef xTempStorage( new SvStorage( new SvMemoryStream(), sal_True ) );
    1296           0 :                         aOleExport.ExportOLEObject( xObj, *xTempStorage );
    1297             : 
    1298             :                         //TODO/MBA: testing
    1299           0 :                         rtl::OUString aPersistStream( SVEXT_PERSIST_STREAM );
    1300           0 :                         SvMemoryStream aStream;
    1301           0 :                         SvStorageRef xCleanStorage( new SvStorage( sal_False, aStream ) );
    1302           0 :                         xTempStorage->CopyTo( xCleanStorage );
    1303             :                         // create a dummy content stream, the dummy content is necessary for ppt, but not for
    1304             :                         // doc files, so we can't share code.
    1305           0 :                         SotStorageStreamRef xStm = xCleanStorage->OpenSotStream( aPersistStream, STREAM_STD_READWRITE );
    1306           0 :                         *xStm   << (sal_uInt32)0        // no ClipboardId
    1307           0 :                                 << (sal_uInt32)4        // no target device
    1308           0 :                                 << (sal_uInt32)1        // aspect ratio
    1309           0 :                                 << (sal_Int32)-1        // L-Index
    1310           0 :                                 << (sal_uInt32)0        // Advanced Flags
    1311           0 :                                 << (sal_uInt32)0        // compression
    1312           0 :                                 << (sal_uInt32)0        // Size
    1313           0 :                                 << (sal_uInt32)0        //  "
    1314           0 :                                 << (sal_uInt32)0;
    1315           0 :                         pStrm = xCleanStorage->CreateMemoryStream();
    1316           0 :                     }
    1317             :                 }
    1318             :             }
    1319           0 :             break;
    1320             : 
    1321             :             case OCX_CONTROL :
    1322             :             {
    1323           0 :                 if ( pPtr->xControlModel.is() )
    1324             :                 {
    1325           0 :                     rtl::OUString aName;
    1326           0 :                     ::com::sun::star::awt::Size aSize;
    1327           0 :                     SvStorageRef xDest( new SvStorage( new SvMemoryStream(), sal_True ) );
    1328           0 :                     sal_Bool bOk = oox::ole::MSConvertOCXControls::WriteOCXStream( mXModel, xDest, pPtr->xControlModel, aSize, aName );
    1329           0 :                     if ( bOk )
    1330           0 :                         pStrm = xDest->CreateMemoryStream();
    1331             :                 }
    1332             :             }
    1333             :         }
    1334           0 :         if ( pStrm )
    1335             :         {
    1336           0 :             mpPptEscherEx->BeginAtom();
    1337           0 :             pStrm->Seek( STREAM_SEEK_TO_END );
    1338           0 :             sal_uInt32 npStrmSize = pStrm->Tell();
    1339           0 :             *mpStrm << npStrmSize;                  // uncompressed size
    1340             : 
    1341           0 :             pStrm->Seek( 0 );
    1342           0 :             ZCodec aZCodec( 0x8000, 0x8000 );
    1343           0 :             aZCodec.BeginCompression();
    1344           0 :             aZCodec.Compress( *pStrm, *mpStrm );
    1345           0 :             aZCodec.EndCompression();
    1346           0 :             delete pStrm;
    1347           0 :             mpPptEscherEx->EndAtom( EPP_ExOleObjStg, 0, 1 );
    1348             :         }
    1349             :     }
    1350           0 : }
    1351             : 
    1352             : // ---------------------------------------------------------------------------------------------
    1353             : // PersistantTable und UserEditAtom schreiben
    1354             : 
    1355           0 : sal_Bool PPTWriter::ImplWriteAtomEnding()
    1356             : {
    1357             : 
    1358             : #define EPP_LastViewTypeNone        0
    1359             : #define EPP_LastViewTypeSlideView   1
    1360             : #define EPP_LastViewTypeOutlineView 2
    1361             : #define EPP_LastViewTypeNotes       3
    1362             : 
    1363           0 :     sal_uInt32  i, nPos, nOfs, nPersistOfs = mpStrm->Tell();
    1364           0 :     sal_uInt32  nPersistEntrys = 0;
    1365           0 :     *mpStrm << (sal_uInt32)0 << (sal_uInt32)0 << (sal_uInt32)0;         // Record Header und ersten Eintrag ueberspringen
    1366             : 
    1367             :     // Document pesist schreiben
    1368           0 :         nPersistEntrys++;
    1369           0 :         *mpStrm << (sal_uInt32)0;
    1370             :     // MasterPages persists schreiben
    1371           0 :     for ( i = 0; i < mnMasterPages; i++ )
    1372             :     {
    1373           0 :         nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_MainMaster | i );
    1374           0 :         if ( nOfs )
    1375             :         {
    1376           0 :             *mpStrm << nOfs;
    1377           0 :             mpPptEscherEx->InsertAtPersistOffset( EPP_MAINMASTER_PERSIST_KEY | i, ++nPersistEntrys );
    1378             :         }
    1379             :     }
    1380             :     // MainNotesMaster persist schreiben
    1381           0 :     nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_MainNotes );
    1382           0 :     if ( nOfs )
    1383             :     {
    1384           0 :         *mpStrm << nOfs;
    1385           0 :         mpPptEscherEx->InsertAtPersistOffset( EPP_MAINNOTESMASTER_PERSIST_KEY, ++nPersistEntrys );
    1386             :     }
    1387             :     // Slide persists schreiben -> es gilt hier auch den EPP_SlidePersistAtome mit einem gueltigen wert zu beschreiben
    1388           0 :     for ( i = 0; i < mnPages; i++ )
    1389             :     {
    1390           0 :         nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_Slide | i );
    1391           0 :         if ( nOfs )
    1392             :         {
    1393           0 :             *mpStrm << nOfs;
    1394           0 :             mpPptEscherEx->InsertAtPersistOffset( EPP_MAINSLIDE_PERSIST_KEY | i, ++nPersistEntrys );
    1395             :         }
    1396             :     }
    1397             :     // Notes persists schreiben
    1398           0 :     for ( i = 0; i < mnPages; i++ )
    1399             :     {
    1400           0 :         nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_Notes | i );
    1401           0 :         if ( nOfs )
    1402             :         {
    1403           0 :             *mpStrm << nOfs;
    1404           0 :             mpPptEscherEx->InsertAtPersistOffset( EPP_MAINNOTES_PERSIST_KEY | i, ++nPersistEntrys );
    1405             :         }
    1406             :     }
    1407             :     // Ole persists
    1408           0 :     for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
    1409             :     {
    1410           0 :         PPTExOleObjEntry* pPtr = *it;
    1411           0 :         nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_ExObj );
    1412           0 :         if ( nOfs )
    1413             :         {
    1414           0 :             nPersistEntrys++;
    1415           0 :             *mpStrm << pPtr->nOfsB;
    1416           0 :             sal_uInt32 nOldPos, nPersOfs = nOfs + pPtr->nOfsA + 16 + 8;     // 8 bytes atom header, +16 to the persist entry
    1417           0 :             nOldPos = mpStrm->Tell();
    1418           0 :             mpStrm->Seek( nPersOfs );
    1419           0 :             *mpStrm << nPersistEntrys;
    1420           0 :             mpStrm->Seek( nOldPos );
    1421             :         }
    1422             :     }
    1423             :     // VB persist
    1424           0 :     if ( mnVBAOleOfs && mpVBA )
    1425             :     {
    1426           0 :         nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_VBAInfoAtom );
    1427           0 :         if ( nOfs )
    1428             :         {
    1429           0 :             nPersistEntrys++;
    1430             :             sal_uInt32 n1, n2;
    1431             : 
    1432           0 :             mpVBA->Seek( 0 );
    1433           0 :             *mpVBA >> n1
    1434           0 :                    >> n2;
    1435             : 
    1436           0 :             *mpStrm << mnVBAOleOfs;
    1437           0 :             sal_uInt32 nOldPos = mpStrm->Tell();
    1438           0 :             mpStrm->Seek( nOfs );               // Fill the VBAInfoAtom with the correct index to the persisttable
    1439           0 :             *mpStrm << nPersistEntrys
    1440           0 :                     << n1
    1441           0 :                     << sal_Int32(2);
    1442           0 :             mpStrm->Seek( nOldPos );
    1443             : 
    1444             :         }
    1445             :     }
    1446           0 :     nPos = mpStrm->Tell();
    1447           0 :     mpStrm->Seek( nPersistOfs );
    1448           0 :     mpPptEscherEx->AddAtom( ( nPersistEntrys + 1 ) << 2, EPP_PersistPtrIncrementalBlock );      // Record Header eintragen
    1449           0 :     *mpStrm << (sal_uInt32)( ( nPersistEntrys << 20 ) | 1 );
    1450           0 :     mpStrm->Seek( nPos );
    1451             : 
    1452           0 :     *mpCurUserStrm << (sal_uInt32)nPos;             // offset to current edit setzen
    1453           0 :     mpPptEscherEx->AddAtom( 28, EPP_UserEditAtom );
    1454           0 :     *mpStrm << (sal_Int32)0x100                     // last slide ID
    1455           0 :             << (sal_uInt32)0x03000dbc               // minor and major app version that did the save
    1456           0 :             << (sal_uInt32)0                        // offset last save, 0 after a full save
    1457           0 :             << nPersistOfs                      // File offset to persist pointers for this save operation
    1458           0 :             << (sal_uInt32)1                        // Persist reference to the document persist object
    1459           0 :             << (sal_uInt32)nPersistEntrys           // max persists written, Seed value for persist object id management
    1460           0 :             << (sal_Int16)EPP_LastViewTypeSlideView // last view type
    1461           0 :             << (sal_Int16)0x12;                     // padword
    1462             : 
    1463           0 :     return sal_True;
    1464             : }
    1465             : 
    1466             : // ---------------------
    1467             : // - exported function -
    1468             : // ---------------------
    1469             : 
    1470           0 : extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL ExportPPT( const std::vector< com::sun::star::beans::PropertyValue >& rMediaData, SvStorageRef& rSvStorage,
    1471             :                     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rXModel,
    1472             :                         ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rXStatInd,
    1473             :                             SvMemoryStream* pVBA, sal_uInt32 nCnvrtFlags )
    1474             : {
    1475             :     PPTWriter*  pPPTWriter;
    1476           0 :     sal_Bool bStatus = sal_False;
    1477             : 
    1478           0 :     pPPTWriter = new PPTWriter( rSvStorage, rXModel, rXStatInd, pVBA, nCnvrtFlags );
    1479           0 :     if ( pPPTWriter )
    1480             :     {
    1481           0 :         pPPTWriter->exportPPT(rMediaData);
    1482           0 :         bStatus = ( pPPTWriter->IsValid() == sal_True );
    1483           0 :         delete pPPTWriter;
    1484             :     }
    1485             : 
    1486           0 :     return bStatus;
    1487             : }
    1488             : 
    1489           0 : extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL SaveVBA( SfxObjectShell& rDocShell, SvMemoryStream*& pBas )
    1490             : {
    1491           0 :     SvStorageRef xDest( new SvStorage( new SvMemoryStream(), sal_True ) );
    1492           0 :     SvxImportMSVBasic aMSVBas( rDocShell, *xDest );
    1493           0 :     aMSVBas.SaveOrDelMSVBAStorage( sal_True, rtl::OUString( "_MS_VBA_Overhead" ) );
    1494             : 
    1495           0 :     SvStorageRef xOverhead = xDest->OpenSotStorage( rtl::OUString( "_MS_VBA_Overhead") );
    1496           0 :     if ( xOverhead.Is() && ( xOverhead->GetError() == SVSTREAM_OK ) )
    1497             :     {
    1498           0 :         SvStorageRef xOverhead2 = xOverhead->OpenSotStorage( rtl::OUString( "_MS_VBA_Overhead") );
    1499           0 :         if ( xOverhead2.Is() && ( xOverhead2->GetError() == SVSTREAM_OK ) )
    1500             :         {
    1501           0 :             SvStorageStreamRef xTemp = xOverhead2->OpenSotStream( rtl::OUString( "_MS_VBA_Overhead2") );
    1502           0 :             if ( xTemp.Is() && ( xTemp->GetError() == SVSTREAM_OK ) )
    1503             :             {
    1504           0 :                 sal_uInt32 nLen = xTemp->GetSize();
    1505           0 :                 if ( nLen )
    1506             :                 {
    1507           0 :                     char* pTemp = new char[ nLen ];
    1508           0 :                     if ( pTemp )
    1509             :                     {
    1510           0 :                         xTemp->Seek( STREAM_SEEK_TO_BEGIN );
    1511           0 :                         xTemp->Read( pTemp, nLen );
    1512           0 :                         pBas = new SvMemoryStream( pTemp, nLen, STREAM_READ );
    1513           0 :                         pBas->ObjectOwnsMemory( sal_True );
    1514           0 :                         return sal_True;
    1515             :                     }
    1516             :                 }
    1517           0 :             }
    1518           0 :         }
    1519             :     }
    1520             : 
    1521           0 :     return sal_False;
    1522           3 : }
    1523             : 
    1524             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10