LCOV - code coverage report
Current view: top level - sd/source/filter/eppt - epptbase.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 19 22 86.4 %
Date: 2015-06-13 12:38:46 Functions: 13 16 81.2 %
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             : #ifndef INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
      21             : #define INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
      22             : 
      23             : #include <vector>
      24             : #include <boost/ptr_container/ptr_vector.hpp>
      25             : 
      26             : #include <vcl/mapmod.hxx>
      27             : #include <tools/stream.hxx>
      28             : #include <tools/fract.hxx>
      29             : #include <tools/gen.hxx>
      30             : #include <com/sun/star/beans/XPropertySet.hpp>
      31             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      32             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      33             : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      34             : #include <com/sun/star/frame/XModel.hpp>
      35             : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      36             : #include <com/sun/star/presentation/FadeEffect.hpp>
      37             : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
      38             : #include <vcl/vclptr.hxx>
      39             : #include <vcl/outdev.hxx>
      40             : 
      41             : #include "grouptable.hxx"
      42             : 
      43             : // PLACEMENT_ID
      44             : enum class EppLayout
      45             : {
      46             :     TITLESLIDE            =  0, /* The slide is a title slide                                                             */
      47             :     TITLEANDBODYSLIDE     =  1, /* Title and body slide                                                                   */
      48             :     TITLEMASTERSLIDE      =  2, /* Title master slide                                                                     */
      49             :     MASTERSLIDE           =  3, /* Master slide layout                                                                    */
      50             :     MASTERNOTES           =  4, /* Master notes layout                                                                    */
      51             :     NOTESTITLEBODY        =  5, /* Notes title/body layout                                                                */
      52             :     HANDOUTLAYOUT         =  6, /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
      53             :     ONLYTITLE             =  7, /* Only title placeholder                                                                 */
      54             :     TWOCOLUMNSANDTITLE    =  8, /* Body of the slide has 2 columns and a title                                            */
      55             :     TWOROWSANDTITLE       =  9, /* Slide's body has 2 rows and a title                                                    */
      56             :     RIGHTCOLUMN2ROWS      = 10, /* Body contains 2 columns, right column has 2 rows                                       */
      57             :     LEFTCOLUMN2ROWS       = 11, /* Body contains 2 columns, left column has 2 rows                                        */
      58             :     BOTTOMROW2COLUMNS     = 12, /* Body contains 2 rows, bottom row has 2 columns                                         */
      59             :     TOPROW2COLUMN         = 13, /* Body contains 2 rows, top row has 2 columns                                            */
      60             :     FOUROBJECTS           = 14, /* 4 objects                                                                              */
      61             :     BIGOBJECT             = 15, /* Big object                                                                             */
      62             :     BLANCSLIDE            = 16, /* Blank slide                                                                            */
      63             :     TITLERIGHTBODYLEFT    = 17, /* Vertical title on the right, body on the left                                          */
      64             :     TITLERIGHT2BODIESLEFT = 18  /* Vertical title on the right, body on the left split into 2 rows                        */
      65             : };
      66             : 
      67             : #define EPP_LAYOUT_SIZE 25
      68             : 
      69             : class PptEscherEx;
      70             : 
      71             : struct PHLayout
      72             : {
      73             :     EppLayout   nLayout;
      74             :     sal_uInt8   nPlaceHolder[ 8 ];
      75             : 
      76             :     sal_uInt8   nUsedObjectPlaceHolder;
      77             :     sal_uInt8   nTypeOfTitle;
      78             :     sal_uInt8   nTypeOfOutliner;
      79             : 
      80             :     bool    bTitlePossible;
      81             :     bool    bOutlinerPossible;
      82             :     bool    bSecOutlinerPossible;
      83             : };
      84             : 
      85             : enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
      86             : 
      87        1585 : class PropValue
      88             : {
      89             :     protected :
      90             : 
      91             :         ::com::sun::star::uno::Any                              mAny;
      92             : 
      93             :         ::com::sun::star::uno::Reference
      94             :             < ::com::sun::star::beans::XPropertySet >           mXPropSet;
      95             : 
      96             :         bool    ImplGetPropertyValue( const OUString& rString );
      97             :         bool    ImplGetPropertyValue( const ::com::sun::star::uno::Reference
      98             :                         < ::com::sun::star::beans::XPropertySet > &, const OUString& );
      99             : 
     100             :     public :
     101             : 
     102        1585 :         PropValue() {}
     103             : 
     104             :         PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet )
     105             :             : mXPropSet( rXPropSet )
     106             :         {}
     107             : 
     108             :         ::com::sun::star::uno::Any GetAny() { return mAny; }
     109             : 
     110             :         static bool GetPropertyValue(
     111             :             ::com::sun::star::uno::Any& rAny,
     112             :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
     113             :             const OUString& rPropertyName,
     114             :             bool bTestPropertyAvailability = false );
     115             : 
     116             :         static ::com::sun::star::beans::PropertyState GetPropertyState(
     117             :             const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &,
     118             :             const OUString& rPropertyName );
     119             : };
     120             : 
     121             : class EscherGraphicProvider;
     122             : class PPTExBulletProvider
     123             : {
     124             :     friend struct PPTExParaSheet;
     125             : 
     126             :     protected :
     127             : 
     128             :         SvMemoryStream          aBuExPictureStream;
     129             :         SvMemoryStream          aBuExOutlineStream;
     130             :         SvMemoryStream          aBuExMasterStream;
     131             : 
     132             :         EscherGraphicProvider*  pGraphicProv;
     133             : 
     134             :     public :
     135             : 
     136             :         sal_uInt16              GetId( const OString& rUniqueId, Size& rGraphicSize );
     137             : 
     138             :                                 PPTExBulletProvider();
     139             :                                 ~PPTExBulletProvider();
     140             : };
     141             : 
     142         104 : struct FontCollectionEntry
     143             : {
     144             :         OUString                Name;
     145             :         double                  Scaling;
     146             :         sal_Int16               Family;
     147             :         sal_Int16               Pitch;
     148             :         sal_Int16               CharSet;
     149             : 
     150             :         OUString                Original;
     151             :         bool                bIsConverted;
     152             : 
     153          50 :         FontCollectionEntry( const OUString& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) :
     154             :                             Scaling ( 1.0 ),
     155             :                             Family  ( nFamily ),
     156             :                             Pitch   ( nPitch ),
     157             :                             CharSet ( nCharSet ),
     158          50 :                             Original( rName )
     159             :                             {
     160          50 :                                 ImplInit( rName );
     161          50 :                             };
     162             : 
     163        1556 :         FontCollectionEntry( const OUString& rName ) :
     164             :                             Scaling ( 1.0 ),
     165             :                             Family  ( 0 ),
     166             :                             Pitch   ( 0 ),
     167             :                             CharSet ( 0 ),
     168        1556 :                             Original( rName )
     169             :                             {
     170        1556 :                                 ImplInit( rName );
     171        1556 :                             };
     172             :         ~FontCollectionEntry();
     173             : 
     174             :     private :
     175             : 
     176             :         FontCollectionEntry() {}
     177             : 
     178             :         void ImplInit( const OUString& rName );
     179             : };
     180             : 
     181             : class FontCollection
     182             : {
     183             : public :
     184             : 
     185             :     FontCollection();
     186             : 
     187             :     ~FontCollection();
     188             : 
     189             :     static short GetScriptDirection( const OUString& rText );
     190             : 
     191             :     sal_uInt32  GetId( FontCollectionEntry& rFontDescriptor );
     192             : 
     193        1576 :     inline sal_uInt32  GetCount() const { return maFonts.size(); };
     194             : 
     195             :     const FontCollectionEntry* GetById( sal_uInt32 nId );
     196             : 
     197          75 :     FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
     198             : 
     199             : private:
     200             : 
     201             :     VclPtr<VirtualDevice> pVDev;
     202             :     boost::ptr_vector<FontCollectionEntry> maFonts;
     203             : };
     204             : 
     205             : #define PPTEX_STYLESHEETENTRYS  9
     206             : 
     207             : enum PPTExTextAttr
     208             : {
     209             :     ParaAttr_BulletOn,
     210             :     ParaAttr_BuHardFont,
     211             :     ParaAttr_BuHardColor,
     212             :     ParaAttr_BuHardHeight,
     213             :     ParaAttr_BulletChar,
     214             :     ParaAttr_BulletFont,
     215             :     ParaAttr_BulletHeight,
     216             :     ParaAttr_BulletColor,
     217             :     ParaAttr_Adjust,
     218             :     ParaAttr_LineFeed,
     219             :     ParaAttr_UpperDist,
     220             :     ParaAttr_LowerDist,
     221             :     ParaAttr_TextOfs,
     222             :     ParaAttr_BulletOfs,
     223             :     ParaAttr_DefaultTab,
     224             :     ParaAttr_AsianLB_1,
     225             :     ParaAttr_AsianLB_2,
     226             :     ParaAttr_AsianLB_3,
     227             :     ParaAttr_BiDi,
     228             :     CharAttr_Bold,
     229             :     CharAttr_Italic,
     230             :     CharAttr_Underline,
     231             :     CharAttr_Shadow,
     232             :     CharAttr_Strikeout,
     233             :     CharAttr_Embossed,
     234             :     CharAttr_Font,
     235             :     CharAttr_AsianOrComplexFont,
     236             :     CharAttr_Symbol,
     237             :     CharAttr_FontHeight,
     238             :     CharAttr_FontColor,
     239             :     CharAttr_Escapement
     240             : };
     241             : 
     242             : struct PPTExCharLevel
     243             : {
     244             :     sal_uInt16      mnFlags;
     245             :     sal_uInt16      mnFont;
     246             :     sal_uInt16      mnAsianOrComplexFont;
     247             :     sal_uInt16      mnFontHeight;
     248             :     sal_uInt16      mnEscapement;
     249             :     sal_uInt32      mnFontColor;
     250             : };
     251             : 
     252             : struct PPTExCharSheet
     253             : {
     254             :                 PPTExCharLevel  maCharLevel[ 5 ];
     255             : 
     256             :                 PPTExCharSheet( int nInstance );
     257             : 
     258             :                 void    SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
     259             :                                         FontCollection& rFontCollection, int nLevel );
     260             :                 void    Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
     261             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
     262             : 
     263             : };
     264             : 
     265             : struct PPTExParaLevel
     266             : {
     267             :     bool        mbIsBullet;
     268             :     sal_uInt16      mnBulletChar;
     269             :     sal_uInt16      mnBulletFont;
     270             :     sal_uInt16      mnBulletHeight;
     271             :     sal_uInt32      mnBulletColor;
     272             : 
     273             :     sal_uInt16      mnAdjust;
     274             :     sal_Int16       mnOOAdjust;
     275             :     sal_uInt16      mnLineFeed;
     276             :     sal_uInt16      mnUpperDist;
     277             :     sal_uInt16      mnLowerDist;
     278             :     sal_uInt16      mnTextOfs;
     279             :     sal_uInt16      mnBulletOfs;
     280             :     sal_uInt16      mnDefaultTab;
     281             : 
     282             :     bool        mbExtendedBulletsUsed;
     283             :     sal_uInt16      mnBulletId;
     284             :     sal_uInt16      mnBulletStart;
     285             :     sal_uInt32      mnMappedNumType;
     286             :     sal_uInt32      mnNumberingType;
     287             :     sal_uInt16      mnAsianSettings;
     288             :     sal_uInt16      mnBiDi;
     289             : };
     290             : 
     291             : struct PPTExParaSheet
     292             : {
     293             :                 PPTExBulletProvider* pBuProv;
     294             : 
     295             :                 sal_uInt32  mnInstance;
     296             : 
     297             :                 PPTExParaLevel  maParaLevel[ 5 ];
     298             :                 PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider* pProv );
     299             : 
     300             :                 void    SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
     301             :                                         FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel );
     302             :                 void    Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
     303             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
     304             : };
     305             : 
     306             : class PPTExStyleSheet
     307             : {
     308             : 
     309             :     public :
     310             : 
     311             :                 PPTExCharSheet*     mpCharSheet[ PPTEX_STYLESHEETENTRYS ];
     312             :                 PPTExParaSheet*     mpParaSheet[ PPTEX_STYLESHEETENTRYS ];
     313             : 
     314             :                 PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider* pBuProv );
     315             :                 ~PPTExStyleSheet();
     316             : 
     317          32 :                 PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; };
     318             :                 PPTExCharSheet& GetCharSheet( int nInstance ) { return *mpCharSheet[ nInstance ]; };
     319             : 
     320             :                 void            SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
     321             :                                                 FontCollection& rFontCollection, int nInstance, int nLevel );
     322             :                 bool        IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue );
     323             : 
     324           6 :                 static sal_uInt32 SizeOfTxCFStyleAtom() { return 24; }
     325             :                 void            WriteTxCFStyleAtom( SvStream& rSt );
     326             : };
     327             : 
     328             : class PPTWriterBase : public PropValue, public GroupTable
     329             : {
     330             : protected:
     331             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                 mXModel;
     332             :     ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >        mXStatusIndicator;
     333             : 
     334             :     bool            mbStatusIndicator;
     335             : 
     336             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier >   mXDrawPagesSupplier;
     337             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
     338             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages >           mXDrawPages;
     339             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >            mXDrawPage;
     340             :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >           mXPagePropSet;
     341             :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >           mXBackgroundPropSet;
     342             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >              mXShapes;
     343             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >               mXShape;
     344             :     ::com::sun::star::awt::Size         maSize;
     345             :     ::com::sun::star::awt::Point        maPosition;
     346             :     Rectangle           maRect;
     347             :     OString        mType;
     348             :     bool            mbPresObj;
     349             :     bool            mbEmptyPresObj;
     350             :     sal_Int32           mnAngle;
     351             : 
     352             :     sal_uInt32          mnPages;            ///< number of Slides ( w/o master pages & notes & handout )
     353             :     sal_uInt32          mnMasterPages;
     354             : 
     355             :     Fraction                        maFraction;
     356             :     MapMode                         maMapModeSrc;
     357             :     MapMode                         maMapModeDest;
     358             :     ::com::sun::star::awt::Size     maDestPageSize;
     359             :     ::com::sun::star::awt::Size     maPageSize; // #i121183# Keep size in logic coordinates (100th mm)
     360             :     ::com::sun::star::awt::Size     maNotesPageSize;
     361             : 
     362             :     PageType                        meLatestPageType;
     363             :     std::vector< PPTExStyleSheet* > maStyleSheetList;
     364             :     PPTExStyleSheet*                mpStyleSheet;
     365             : 
     366             :     FontCollection      maFontCollection;
     367             : 
     368           0 :     virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
     369           0 :                                  bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
     370             :     virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
     371           0 :     virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
     372           5 :     virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {}
     373             : 
     374          26 :     virtual void exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& ) {}
     375          26 :     virtual void exportPPTPost() {}
     376             : 
     377             :     virtual bool ImplCreateDocument()=0;
     378             :     virtual bool ImplCreateMainNotes()=0;
     379             : 
     380             :     bool GetStyleSheets();
     381             :     bool GetShapeByIndex( sal_uInt32 nIndex, bool bGroup = false );
     382             : 
     383             :     bool CreateMainNotes();
     384             : 
     385             :     ::com::sun::star::awt::Size   MapSize( const ::com::sun::star::awt::Size& );
     386             :     ::com::sun::star::awt::Point  MapPoint( const ::com::sun::star::awt::Point& );
     387             :     Rectangle                     MapRectangle( const ::com::sun::star::awt::Rectangle& );
     388             : 
     389             :     bool ContainsOtherShapeThanPlaceholders( bool bForOOMLX );
     390             : 
     391             : public:
     392             :     PPTWriterBase();
     393             :     PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
     394             :                    const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd );
     395             : 
     396             :     virtual ~PPTWriterBase();
     397             : 
     398             :     void exportPPT(const std::vector< com::sun::star::beans::PropertyValue >&);
     399             : 
     400             :     bool InitSOIface();
     401             :     bool GetPageByIndex( sal_uInt32 nIndex, PageType );
     402             :     sal_uInt32 GetMasterIndex( PageType ePageType );
     403             :     bool SetCurrentStyleSheet( sal_uInt32 nPageNum );
     404             : 
     405           3 :     bool GetPresObj() { return mbPresObj; }
     406             : 
     407             :     static PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
     408             :     static PHLayout& GetLayout( sal_Int32 nOffset );
     409             :     static sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
     410             :     static sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
     411             : 
     412             :     bool CreateSlide( sal_uInt32 nPageNum );
     413             :     bool CreateSlideMaster( sal_uInt32 nPageNum );
     414             :     bool CreateNotes( sal_uInt32 nPageNum );
     415             : 
     416             :     static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
     417             :     static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
     418             : };
     419             : 
     420             : #endif
     421             : 
     422             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11