diff options
author | Tor Lillqvist <tlillqvist@novell.com> | 2010-11-01 14:47:36 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@hemulen.(none)> | 2010-11-05 23:52:14 +0200 |
commit | ba5b9d706f16ca781f2783959e06abb819880cd8 (patch) | |
tree | 1e3db08ecd286c4bdf2488f55fddcc6a5689c1c7 | |
parent | 80e43cec401734db2df250b1d09159bc30a7d2f9 (diff) |
From hg changeset 0d3461509c7b601f0084eb3560fde9b6941c42ab in ooxml11
ooxml11: add added files
-rw-r--r-- | sd/source/filter/eppt/epptbase.hxx | 443 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptooxml.hxx | 148 | ||||
-rw-r--r-- | sd/source/filter/eppt/grouptable.hxx | 86 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptbase.cxx | 1010 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptooxml.cxx | 1451 |
5 files changed, 3138 insertions, 0 deletions
diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx new file mode 100644 index 000000000..b0576eeee --- /dev/null +++ b/sd/source/filter/eppt/epptbase.hxx @@ -0,0 +1,443 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EPPT_EPPTBASE_HXX +#define EPPT_EPPTBASE_HXX + +#include "grouptable.hxx" +#include <vector> +#include <vcl/mapmod.hxx> +#include <tools/list.hxx> +#include <tools/string.hxx> +#include <tools/stream.hxx> +#include <tools/gen.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#include <com/sun/star/drawing/XMasterPageTarget.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/presentation/XPresentationSupplier.hpp> +#include <com/sun/star/presentation/FadeEffect.hpp> +#include <com/sun/star/task/XStatusIndicatorSupplier.hpp> + +// PLACEMENT_ID +#define EPP_LAYOUT_TITLESLIDE 0 /* The slide is a title slide */ +#define EPP_LAYOUT_TITLEANDBODYSLIDE 1 /* Title and body slide */ +#define EPP_LAYOUT_TITLEMASTERSLIDE 2 /* Title master slide */ +#define EPP_LAYOUT_MASTERSLIDE 3 /* Master slide layout */ +#define EPP_LAYOUT_MASTERNOTES 4 /* Master notes layout */ +#define EPP_LAYOUT_NOTESTITLEBODY 5 /* Notes title/body layout */ +#define EPP_LAYOUT_HANDOUTLAYOUT 6 /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */ +#define EPP_LAYOUT_ONLYTITLE 7 /* Only title placeholder */ +#define EPP_LAYOUT_2COLUMNSANDTITLE 8 /* Body of the slide has 2 columns and a title */ +#define EPP_LAYOUT_2ROWSANDTITLE 9 /* Slide's body has 2 rows and a title */ +#define EPP_LAYOUT_RIGHTCOLUMN2ROWS 10 /* Body contains 2 columns, right column has 2 rows */ +#define EPP_LAYOUT_LEFTCOLUMN2ROWS 11 /* Body contains 2 columns, left column has 2 rows */ +#define EPP_LAYOUT_BOTTOMROW2COLUMNS 12 /* Body contains 2 rows, bottom row has 2 columns */ +#define EPP_LAYOUT_TOPROW2COLUMN 13 /* Body contains 2 rows, top row has 2 columns */ +#define EPP_LAYOUT_4OBJECTS 14 /* 4 objects */ +#define EPP_LAYOUT_BIGOBJECT 15 /* Big object */ +#define EPP_LAYOUT_BLANCSLIDE 16 /* Blank slide */ +#define EPP_LAYOUT_TITLERIGHTBODYLEFT 17 /* Vertical title on the right, body on the left */ +#define EPP_LAYOUT_TITLERIGHT2BODIESLEFT 18 /* Vertical title on the right, body on the left split into 2 rows */ + +#define EPP_LAYOUT_SIZE 25 + +class Polygon; +class PptEscherEx; +class XStatusIndicatorRef; + +struct PHLayout +{ + sal_Int32 nLayout; + sal_uInt8 nPlaceHolder[ 8 ]; + + sal_uInt8 nUsedObjectPlaceHolder; + sal_uInt8 nTypeOfTitle; + sal_uInt8 nTypeOfOutliner; + + BOOL bTitlePossible; + BOOL bOutlinerPossible; + BOOL bSecOutlinerPossible; +}; + +enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3 }; + +class PropValue +{ + protected : + + ::com::sun::star::uno::Any mAny; + + ::com::sun::star::uno::Reference + < ::com::sun::star::beans::XPropertySet > mXPropSet; + + sal_Bool ImplGetPropertyValue( const String& rString ); + sal_Bool ImplGetPropertyValue( const ::com::sun::star::uno::Reference + < ::com::sun::star::beans::XPropertySet > &, const String& ); + + public : + + PropValue() {} + + PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ) + : mXPropSet( rXPropSet ) + {} + + ::com::sun::star::uno::Any GetAny() { return mAny; } + + static sal_Bool GetPropertyValue( + ::com::sun::star::uno::Any& rAny, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &, + const String& rPropertyName, + sal_Bool bTestPropertyAvailability = sal_False ); + + static ::com::sun::star::beans::PropertyState GetPropertyState( + const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &, + const String& rPropertyName ); +}; + +class EscherGraphicProvider; +class PPTExBulletProvider +{ + friend struct PPTExParaSheet; + + protected : + + SvMemoryStream aBuExPictureStream; + SvMemoryStream aBuExOutlineStream; + SvMemoryStream aBuExMasterStream; + + EscherGraphicProvider* pGraphicProv; + + public : + + sal_uInt16 GetId( const ByteString& rUniqueId, Size& rGraphicSize ); + + PPTExBulletProvider(); + ~PPTExBulletProvider(); +}; + +struct FontCollectionEntry +{ + String Name; + double Scaling; + sal_Int16 Family; + sal_Int16 Pitch; + sal_Int16 CharSet; + + String Original; + sal_Bool bIsConverted; + + FontCollectionEntry( const String& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) : + Scaling ( 1.0 ), + Family ( nFamily ), + Pitch ( nPitch ), + CharSet ( nCharSet ), + Original( rName ) + { + ImplInit( rName ); + }; + + FontCollectionEntry( const String& rName ) : + Scaling ( 1.0 ), + Original( rName ) + { + ImplInit( rName ); + }; + ~FontCollectionEntry(); + + private : + + FontCollectionEntry() {}; + + void ImplInit( const String& rName ); +}; + +class VirtualDevice; +class FontCollection : private List +{ + VirtualDevice* pVDev; + public : + FontCollection(); + ~FontCollection(); + + short GetScriptDirection( const String& rText ) const; + sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor ); + sal_uInt32 GetCount() const { return List::Count(); }; + const FontCollectionEntry* GetById( sal_uInt32 nId ); + FontCollectionEntry& GetLast() { return *(FontCollectionEntry*)List::Last(); }; +}; + +// ------------------------------------------------------------------------ + +#define PPTEX_STYLESHEETENTRYS 9 + +enum PPTExTextAttr +{ + ParaAttr_BulletOn, + ParaAttr_BuHardFont, + ParaAttr_BuHardColor, + ParaAttr_BuHardHeight, + ParaAttr_BulletChar, + ParaAttr_BulletFont, + ParaAttr_BulletHeight, + ParaAttr_BulletColor, + ParaAttr_Adjust, + ParaAttr_LineFeed, + ParaAttr_UpperDist, + ParaAttr_LowerDist, + ParaAttr_TextOfs, + ParaAttr_BulletOfs, + ParaAttr_DefaultTab, + ParaAttr_AsianLB_1, + ParaAttr_AsianLB_2, + ParaAttr_AsianLB_3, + ParaAttr_BiDi, + CharAttr_Bold, + CharAttr_Italic, + CharAttr_Underline, + CharAttr_Shadow, + CharAttr_Strikeout, + CharAttr_Embossed, + CharAttr_Font, + CharAttr_AsianOrComplexFont, + CharAttr_Symbol, + CharAttr_FontHeight, + CharAttr_FontColor, + CharAttr_Escapement +}; + +struct PPTExCharLevel +{ + sal_uInt16 mnFlags; + sal_uInt16 mnFont; + sal_uInt16 mnAsianOrComplexFont; + sal_uInt16 mnFontHeight; + sal_uInt16 mnEscapement; + sal_uInt32 mnFontColor; +}; + +struct PPTExCharSheet +{ + PPTExCharLevel maCharLevel[ 5 ]; + + PPTExCharSheet( int nInstance ); + + void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &, + FontCollection& rFontCollection, int nLevel ); + void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, sal_Bool bFirst, sal_Bool bSimpleText, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet ); + +}; + +struct PPTExParaLevel +{ + sal_Bool mbIsBullet; + sal_uInt16 mnBulletChar; + sal_uInt16 mnBulletFont; + sal_uInt16 mnBulletHeight; + sal_uInt32 mnBulletColor; + + sal_uInt16 mnAdjust; + sal_Int16 mnOOAdjust; + sal_uInt16 mnLineFeed; + sal_uInt16 mnUpperDist; + sal_uInt16 mnLowerDist; + sal_uInt16 mnTextOfs; + sal_uInt16 mnBulletOfs; + sal_uInt16 mnDefaultTab; + + sal_Bool mbExtendedBulletsUsed; + sal_uInt16 mnBulletId; + sal_uInt16 mnBulletStart; + sal_uInt32 mnMappedNumType; + sal_uInt32 mnNumberingType; + sal_uInt16 mnAsianSettings; + sal_uInt16 mnBiDi; +}; + +struct PPTExParaSheet +{ + PPTExBulletProvider& rBuProv; + + sal_uInt32 mnInstance; + + PPTExParaLevel maParaLevel[ 5 ]; + PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider& rProv ); + + void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &, + FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel ); + void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, sal_Bool bFirst, sal_Bool bSimpleText, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet ); +}; + +class PPTExStyleSheet +{ + + public : + + PPTExCharSheet* mpCharSheet[ PPTEX_STYLESHEETENTRYS ]; + PPTExParaSheet* mpParaSheet[ PPTEX_STYLESHEETENTRYS ]; + + PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider& rBuProv ); + ~PPTExStyleSheet(); + + PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; }; + PPTExCharSheet& GetCharSheet( int nInstance ) { return *mpCharSheet[ nInstance ]; }; + + void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &, + FontCollection& rFontCollection, int nInstance, int nLevel ); + sal_Bool IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue ); + + sal_uInt32 SizeOfTxCFStyleAtom() const; + void WriteTxCFStyleAtom( SvStream& rSt ); +}; + +// ------------------------------------------------------------------------ + +class PPTWriterBase : public PropValue, public GroupTable +{ +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mXModel; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mXStatusIndicator; + + sal_Bool mbStatusIndicator; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > mXDrawPagesSupplier; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > mXDrawPages; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mXDrawPage; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPagePropSet; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXBackgroundPropSet; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mXShapes; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mXShape; + ::com::sun::star::awt::Size maSize; + ::com::sun::star::awt::Point maPosition; + Rectangle maRect; + ByteString mType; + sal_Bool mbPresObj; + sal_Bool mbEmptyPresObj; + sal_Int32 mnAngle; + + sal_uInt32 mnPages; // number of Slides ( w/o master pages & notes & handout ) + sal_uInt32 mnMasterPages; + + Fraction maFraction; + MapMode maMapModeSrc; + MapMode maMapModeDest; + ::com::sun::star::awt::Size maDestPageSize; + ::com::sun::star::awt::Size maNotesPageSize; + + PageType meLatestPageType; + std::vector< PPTExStyleSheet* > maStyleSheetList; + PPTExStyleSheet* mpStyleSheet; + + FontCollection maFontCollection; + + List maTextRuleList; // TextRuleEntry's + + virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */, + sal_Bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {} + virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0; + virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {} + virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {} + + virtual void exportPPTPre() {} + virtual void exportPPTPost() {} + + virtual sal_Bool ImplCreateDocument()=0; + virtual sal_Bool ImplCreateMainNotes()=0; + + sal_Bool GetStyleSheets(); + sal_Bool GetShapeByIndex( sal_uInt32 nIndex, sal_Bool bGroup = FALSE ); + + sal_Bool CreateMainNotes(); + + ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ); + ::com::sun::star::awt::Point MapPoint( const ::com::sun::star::awt::Point& ); + Rectangle MapRectangle( const ::com::sun::star::awt::Rectangle& ); + + sal_Bool ContainsOtherShapeThanPlaceholders( sal_Bool bForOOMLX ); + +public: + PPTWriterBase(); + PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd ); + + ~PPTWriterBase(); + + void exportPPT(); + + sal_Bool InitSOIface(); + sal_Bool GetPageByIndex( sal_uInt32 nIndex, PageType ); + sal_uInt32 GetMasterIndex( PageType ePageType ); + sal_Bool SetCurrentStyleSheet( sal_uInt32 nPageNum ); + + sal_Bool GetPresObj() { return mbPresObj; } + + PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const; + PHLayout& GetLayout( sal_Int32 nOffset ) const; + sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const; + + sal_Bool CreateSlide( sal_uInt32 nPageNum ); + sal_Bool CreateSlideMaster( sal_uInt32 nPageNum ); + sal_Bool CreateNotes( sal_uInt32 nPageNum ); + + static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection ); + static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection ); +}; + +#define PPT_TRANSITION_TYPE_NONE 0 +#define PPT_TRANSITION_TYPE_RANDOM 1 +#define PPT_TRANSITION_TYPE_BLINDS 2 +#define PPT_TRANSITION_TYPE_CHECKER 3 +#define PPT_TRANSITION_TYPE_COVER 4 +#define PPT_TRANSITION_TYPE_DISSOLVE 5 +#define PPT_TRANSITION_TYPE_FADE 6 +#define PPT_TRANSITION_TYPE_PULL 7 +#define PPT_TRANSITION_TYPE_RANDOM_BARS 8 +#define PPT_TRANSITION_TYPE_STRIPS 9 +#define PPT_TRANSITION_TYPE_WIPE 10 +#define PPT_TRANSITION_TYPE_ZOOM 11 +#define PPT_TRANSITION_TYPE_SPLIT 13 + +// effects, new in xp +#define PPT_TRANSITION_TYPE_DIAMOND 17 +#define PPT_TRANSITION_TYPE_PLUS 18 +#define PPT_TRANSITION_TYPE_WEDGE 19 +#define PPT_TRANSITION_TYPE_PUSH 20 +#define PPT_TRANSITION_TYPE_COMB 21 +#define PPT_TRANSITION_TYPE_NEWSFLASH 22 +#define PPT_TRANSITION_TYPE_SMOOTHFADE 23 +#define PPT_TRANSITION_TYPE_WHEEL 26 +#define PPT_TRANSITION_TYPE_CIRCLE 27 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx new file mode 100644 index 000000000..2a91782af --- /dev/null +++ b/sd/source/filter/eppt/epptooxml.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EPPT_POWERPOINT_EXPORT_HXX +#define EPPT_POWERPOINT_EXPORT_HXX + +#include <oox/core/xmlfilterbase.hxx> +#include <oox/helper/zipstorage.hxx> +#include <oox/vml/vmldrawing.hxx> + +#include "epptbase.hxx" + +namespace oox { + namespace drawingml { + class ShapeExport; + } +namespace core { + +class PowerPointShapeExport; + +struct LayoutInfo +{ + std::vector< sal_Int32 > mnFileIdArray; +}; + +enum PlaceholderType +{ + None, + SlideImage, + Notes, + Header, + Footer, + SlideNumber, + DateAndTime, + Outliner, + Title, + Subtitle +}; + +class PowerPointExport : public XmlFilterBase, public PPTWriterBase +{ + friend class PowerPointShapeExport; +public: + + PowerPointExport( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr ); + ~PowerPointExport(); + + // from FilterBase + virtual bool importDocument() throw(); + virtual bool exportDocument() throw(); + + // only needed for import, leave them empty, refactor later XmlFilterBase to export and import base? + virtual sal_Int32 getSchemeClr( sal_Int32 /* nColorSchemeToken */ ) const { return 0; } + virtual oox::vml::Drawing* getVmlDrawing() { return NULL; } + virtual const oox::drawingml::Theme* getCurrentTheme() const { return NULL; } + virtual const oox::drawingml::table::TableStyleListPtr getTableStyles() { return oox::drawingml::table::TableStyleListPtr(); } + virtual oox::drawingml::chart::ChartConverter& getChartConverter(); + + static const char* GetSideDirection( sal_uInt8 nDirection ); + static const char* GetCornerDirection( sal_uInt8 nDirection ); + static const char* Get8Direction( sal_uInt8 nDirection ); + +protected: + + virtual void ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNum, sal_uInt16 nMode, + sal_Bool bHasBackground, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet ); + virtual void ImplWriteNotes( sal_uInt32 nPageNum ); + virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet ); + virtual void ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum ); + void WriteTheme( sal_Int32 nThemeNum ); + + virtual sal_Bool ImplCreateDocument(); + virtual sal_Bool ImplCreateMainNotes(); + + sal_Bool WriteNotesMaster(); + + void WriteTextStyles( ::sax_fastparser::FSHelperPtr pFS ); + void WriteTextStyle( ::sax_fastparser::FSHelperPtr pFS, int nInstance, sal_Int32 xmlToken ); + void WriteTextStyleLevel( ::sax_fastparser::FSHelperPtr pFS, int nInstance, int nLevel ); + void ImplWriteBackground( ::sax_fastparser::FSHelperPtr pFS, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet ); + + sal_Int32 GetLayoutFileId( sal_Int32 nOffset, sal_uInt32 nMasterNum ); + + // shapes + void WriteShapeTree( ::sax_fastparser::FSHelperPtr pFS, PageType ePageType, sal_Bool bMaster ); + + void WritePlaceholderShape( ::sax_fastparser::FSHelperPtr pFS, drawingml::ShapeExport& rDML, PlaceholderType ePlaceholder ); + void WritePageShape( ::sax_fastparser::FSHelperPtr pFS, drawingml::ShapeExport& rDML, PageType ePageType ); + + // helper parts + sal_Bool WritePlaceholder( ::sax_fastparser::FSHelperPtr pFS, drawingml::ShapeExport& rDML, PlaceholderType ePlaceholder, sal_Bool bMaster ); + + sal_uInt32 GetNewSlideId() { return mnSlideIdMax ++; } + sal_uInt32 GetNewSlideMasterId() { return mnSlideMasterIdMax ++; } + +private: + void AddLayoutIdAndRelation( ::sax_fastparser::FSHelperPtr pFS, sal_Int32 nLayoutFileId ); + + virtual ::rtl::OUString implGetImplementationName() const; + + ::boost::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv; + + ::sax_fastparser::FSHelperPtr mPresentationFS; + + LayoutInfo mLayoutInfo[EPP_LAYOUT_SIZE]; + std::vector< ::sax_fastparser::FSHelperPtr > mpSlidesFSArray; + std::vector< ::sax_fastparser::FSHelperPtr > mpMasterFSArray; + sal_Int32 mnLayoutFileIdMax; + + sal_uInt32 mnSlideIdMax; + sal_uInt32 mnSlideMasterIdMax; + + sal_Int32 mnShapeIdMax; + sal_Int32 mnPictureIdMax; + + sal_Bool mbCreateNotes; + + static sal_Int32 nStyleLevelToken[5]; +}; + +} +} + +#endif diff --git a/sd/source/filter/eppt/grouptable.hxx b/sd/source/filter/eppt/grouptable.hxx new file mode 100644 index 000000000..d9e11661a --- /dev/null +++ b/sd/source/filter/eppt/grouptable.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EPPT_GROUP_TABLE +#define EPPT_GROUP_TABLE + +#include <com/sun/star/container/XIndexAccess.hpp> + +struct GroupEntry +{ + sal_uInt32 mnCurrentPos; + sal_uInt32 mnCount; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > mXIndexAccess; + + GroupEntry( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & rIndex ) + { + mXIndexAccess = rIndex; + mnCount =mXIndexAccess->getCount(); + mnCurrentPos = 0; + }; + + GroupEntry( sal_uInt32 nCount ) + { + mnCount = nCount; + mnCurrentPos = 0; + }; + + ~GroupEntry(){}; +}; + +class GroupTable +{ + protected: + + sal_uInt32 mnIndex; + sal_uInt32 mnCurrentGroupEntry; + sal_uInt32 mnMaxGroupEntry; + sal_uInt32 mnGroupsClosed; + GroupEntry** mpGroupEntry; + + void ImplResizeGroupTable( sal_uInt32 nEntrys ); + + public: + + sal_uInt32 GetCurrentGroupIndex() const { return mnIndex; }; + sal_Int32 GetCurrentGroupLevel() const { return mnCurrentGroupEntry - 1; }; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & + GetCurrentGroupAccess() const { return mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mXIndexAccess; }; + sal_uInt32 GetGroupsClosed(); + void SkipCurrentGroup(); + void ResetGroupTable( sal_uInt32 nCount ); + void ClearGroupTable(); + sal_Bool EnterGroup( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & rIndex ); + sal_Bool GetNextGroupEntry(); + GroupTable(); + ~GroupTable(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx new file mode 100644 index 000000000..47084b9e2 --- /dev/null +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -0,0 +1,1010 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "eppt.hxx" +#include "epptdef.hxx" + +#include <cppuhelper/extract.hxx> +#include <tools/globname.hxx> +#include <tools/datetime.hxx> +#include <tools/poly.hxx> +#include <tools/stream.hxx> +#include <tools/zcodec.hxx> +#include <vcl/graph.hxx> +#include <vcl/bmpacc.hxx> +#include <vcl/gradient.hxx> +#include <vcl/virdev.hxx> +#include <rtl/ustring.hxx> +#include <svtools/fltcall.hxx> +#include <svtools/wmf.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/docinf.hxx> +#include <svx/unoapi.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdpage.hxx> +#include <com/sun/star/view/PaperOrientation.hpp> +#include <com/sun/star/view/PaperFormat.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/office/XAnnotation.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> +#include <com/sun/star/office/XAnnotationEnumeration.hpp> +#include <com/sun/star/geometry/RealPoint2D.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/animations/TransitionType.hpp> +#include <com/sun/star/animations/TransitionSubType.hpp> +#include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/awt/FontFamily.hpp> +#include <com/sun/star/awt/FontPitch.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/presentation/XPresentationPage.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <editeng/svxenum.hxx> +#include <editeng/flditem.hxx> +#include <sot/storinfo.hxx> +#include <filter/msfilter/msoleexp.hxx> +#include <filter/msfilter/msdffimp.hxx> +#include <filter/msfilter/svxmsbas.hxx> + +#ifdef DEBUG +#define DBG(x) x +#include <stdio.h> +#else +#define DBG(x) +#endif + +using namespace com::sun::star; + +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::awt::FontFamily; +using namespace ::com::sun::star::awt::FontPitch; +using namespace ::com::sun::star::presentation; + +using ::com::sun::star::awt::FontDescriptor; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNamed; +using ::com::sun::star::drawing::XDrawPagesSupplier; +using ::com::sun::star::drawing::XMasterPagesSupplier; +using ::com::sun::star::drawing::XShapes; +using ::com::sun::star::drawing::XMasterPageTarget; +using ::com::sun::star::drawing::XDrawPage; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::style::XStyleFamiliesSupplier; +using ::com::sun::star::style::XStyle; +using ::com::sun::star::task::XStatusIndicator; +using ::com::sun::star::text::XSimpleText; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; + +static PHLayout pPHLayout[] = +{ + { EPP_LAYOUT_TITLESLIDE, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, TRUE, TRUE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, FALSE, FALSE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, TRUE, FALSE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, FALSE, FALSE }, + { EPP_LAYOUT_RIGHTCOLUMN2ROWS, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2ROWSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_LEFTCOLUMN2ROWS, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TOPROW2COLUMN, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2ROWSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_4OBJECTS, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, FALSE, FALSE }, + { EPP_LAYOUT_ONLYTITLE, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, FALSE, FALSE }, + { EPP_LAYOUT_BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, FALSE, FALSE, FALSE }, + { EPP_LAYOUT_TITLERIGHT2BODIESLEFT, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLERIGHTBODYLEFT, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, TRUE, TRUE, FALSE }, + { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, TRUE, TRUE, FALSE } +}; + +#define PPT_WRITER_BASE_INIT_VALUES \ + maFraction ( 1, 576 ), \ + maMapModeSrc ( MAP_100TH_MM ), \ + maMapModeDest ( MAP_INCH, Point(), maFraction, maFraction ), \ + meLatestPageType ( NORMAL ) + +PPTWriterBase::PPTWriterBase() : + PPT_WRITER_BASE_INIT_VALUES +{ + DBG(printf ("PPTWriterBase::PPTWriterBase()\n")); +} + +PPTWriterBase::PPTWriterBase( const Reference< XModel > & rXModel, + const Reference< XStatusIndicator > & rXStatInd ) : + mXModel ( rXModel ), + mXStatusIndicator ( rXStatInd ), + mbStatusIndicator ( false ), + PPT_WRITER_BASE_INIT_VALUES +{ +} + +// --------------------------------------------------------------------------------------------- + +PPTWriterBase::~PPTWriterBase() +{ + if ( mbStatusIndicator ) + mXStatusIndicator->end(); +} + +// --------------------------------------------------------------------------------------------- + +void PPTWriterBase::exportPPT() +{ + if ( !InitSOIface() ) + return; + + FontCollectionEntry aDefaultFontDesc( String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ), + ROMAN, + awt::FontPitch::VARIABLE, + RTL_TEXTENCODING_MS_1252 ); + maFontCollection.GetId( aDefaultFontDesc ); // default is always times new roman + + if ( !GetPageByIndex( 0, NOTICE ) ) + return; + + INT32 nWidth = 21000; + if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) ) + mAny >>= nWidth; + INT32 nHeight = 29700; + if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) ) + mAny >>= nHeight; + + maNotesPageSize = MapSize( awt::Size( nWidth, nHeight ) ); + + if ( !GetPageByIndex( 0, MASTER ) ) + return; + + nWidth = 28000; + if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) ) + mAny >>= nWidth; + nHeight = 21000; + if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) ) + mAny >>= nHeight; + maDestPageSize = MapSize( awt::Size( nWidth, nHeight ) ); + + DBG(printf( "call exportDocumentPre()\n")); + exportPPTPre(); + + if ( !GetStyleSheets() ) + return; + + if ( !ImplCreateDocument() ) + return; + + sal_uInt32 i; + + for ( i = 0; i < mnPages; i++ ) + { + if ( GetPageByIndex( i, NORMAL ) ) { + sal_uInt32 nMasterNum = GetMasterIndex( NORMAL ); + ImplWriteLayout( GetLayoutOffset( mXPagePropSet ), nMasterNum ); + } + } + + for ( i = 0; i < mnMasterPages; i++ ) + { + if ( !CreateSlideMaster( i ) ) + return; + } + if ( !CreateMainNotes() ) + return; + maTextRuleList.First(); // rewind list, so we can get the current or next entry without + // searching, all entrys are sorted# + for ( i = 0; i < mnPages; i++ ) + { + DBG(printf( "call ImplCreateSlide( %d )\n", i)); + if ( !CreateSlide( i ) ) + return; + } + + for ( i = 0; i < mnPages; i++ ) + { + if ( !CreateNotes( i ) ) + return; + } + + DBG(printf( "call exportDocumentPost()\n")); + exportPPTPost(); +} + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::InitSOIface() +{ + while( TRUE ) + { + mXDrawPagesSupplier = Reference< XDrawPagesSupplier >( mXModel, UNO_QUERY ); + if ( !mXDrawPagesSupplier.is() ) + break; + + mXMasterPagesSupplier = Reference< XMasterPagesSupplier >( mXModel, UNO_QUERY ); + if ( !mXMasterPagesSupplier.is() ) + break; + mXDrawPages = mXMasterPagesSupplier->getMasterPages(); + if ( !mXDrawPages.is() ) + break; + mnMasterPages = mXDrawPages->getCount(); + mXDrawPages = mXDrawPagesSupplier->getDrawPages(); + if( !mXDrawPages.is() ) + break; + mnPages = mXDrawPages->getCount(); + if ( !GetPageByIndex( 0, NORMAL ) ) + break; + + return TRUE; + } + return FALSE; +} + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType ) +{ + while( TRUE ) + { + if ( ePageType != meLatestPageType ) + { + switch( ePageType ) + { + case NORMAL : + case NOTICE : + { + mXDrawPages = mXDrawPagesSupplier->getDrawPages(); + if( !mXDrawPages.is() ) + return FALSE; + } + break; + + case MASTER : + { + mXDrawPages = mXMasterPagesSupplier->getMasterPages(); + if( !mXDrawPages.is() ) + return FALSE; + } + break; + default: + break; + } + meLatestPageType = ePageType; + } + Any aAny( mXDrawPages->getByIndex( nIndex ) ); + aAny >>= mXDrawPage; + if ( !mXDrawPage.is() ) + break; + if ( ePageType == NOTICE ) + { + Reference< XPresentationPage > aXPresentationPage( mXDrawPage, UNO_QUERY ); + if ( !aXPresentationPage.is() ) + break; + mXDrawPage = aXPresentationPage->getNotesPage(); + if ( !mXDrawPage.is() ) + break; + } + mXPagePropSet = Reference< XPropertySet >( mXDrawPage, UNO_QUERY ); + if ( !mXPagePropSet.is() ) + break; + + mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY ); + if ( !mXShapes.is() ) + break; + + /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is + taken the property from the master */ + sal_Bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ), sal_True ); + if ( bHasBackground ) + bHasBackground = ( aAny >>= mXBackgroundPropSet ); + if ( !bHasBackground ) + { + Reference< XMasterPageTarget > aXMasterPageTarget( mXDrawPage, UNO_QUERY ); + if ( aXMasterPageTarget.is() ) + { + Reference< XDrawPage > aXMasterDrawPage; + aXMasterDrawPage = aXMasterPageTarget->getMasterPage(); + if ( aXMasterDrawPage.is() ) + { + Reference< XPropertySet > aXMasterPagePropSet; + aXMasterPagePropSet = Reference< XPropertySet > + ( aXMasterDrawPage, UNO_QUERY ); + if ( aXMasterPagePropSet.is() ) + { + sal_Bool bBackground = GetPropertyValue( aAny, aXMasterPagePropSet, + String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) ); + if ( bBackground ) + { + aAny >>= mXBackgroundPropSet; + } + } + } + } + } + return TRUE; + } + return FALSE; +} + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum ) +{ + Any aAny; + + if ( !GetPageByIndex( nPageNum, NORMAL ) ) + return FALSE; + + sal_uInt32 nMasterNum = GetMasterIndex( NORMAL ); + SetCurrentStyleSheet( nMasterNum ); + + Reference< XPropertySet > aXBackgroundPropSet; + sal_Bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) ); + if ( bHasBackground ) + bHasBackground = ( aAny >>= aXBackgroundPropSet ); + + sal_uInt16 nMode = 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background + if ( bHasBackground ) + nMode &=~4; + +/* sj: Don't know what's IsBackgroundVisible for, have to ask cl + if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundVisible" ) ) ) ) + { + sal_Bool bBackgroundVisible; + if ( aAny >>= bBackgroundVisible ) + { + if ( bBackgroundVisible ) + nMode &= ~4; + } + } +*/ + if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundObjectsVisible" ) ) ) ) + { + sal_Bool bBackgroundObjectsVisible = sal_False; + if ( aAny >>= bBackgroundObjectsVisible ) + { + if ( !bBackgroundObjectsVisible ) + nMode &= ~1; + } + } + + ImplWriteSlide( nPageNum, nMasterNum, nMode, bHasBackground, aXBackgroundPropSet ); + + return TRUE; +}; + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum ) +{ + if ( !GetPageByIndex( nPageNum, NOTICE ) ) + return FALSE; + SetCurrentStyleSheet( GetMasterIndex( NORMAL ) ); + + ImplWriteNotes( nPageNum ); + + return TRUE; +}; + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum ) +{ + if ( !GetPageByIndex( nPageNum, MASTER ) ) + return FALSE; + SetCurrentStyleSheet( nPageNum ); + + if ( !ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) ) ) // Backgroundshape laden + return FALSE; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet; + if ( !( mAny >>= aXBackgroundPropSet ) ) + return FALSE; + + ImplWriteSlideMaster( nPageNum, aXBackgroundPropSet ); + + return TRUE; +}; + +// --------------------------------------------------------------------------------------------- + +sal_Int32 PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const +{ + ::com::sun::star::uno::Any aAny; + sal_Int32 nLayout = 20; + if ( GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Layout" ) ) ), sal_True ) + aAny >>= nLayout; + + if ( ( nLayout >= 21 ) && ( nLayout <= 26 ) ) // NOTES _> HANDOUT6 + nLayout = 20; + if ( ( nLayout >= 27 ) && ( nLayout <= 30 ) ) // VERTICAL LAYOUT + nLayout -= 6; + else if ( nLayout > 30 ) + nLayout = 20; + + return nLayout; +} + +PHLayout& PPTWriterBase::GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const +{ + return pPHLayout[ GetLayoutOffset( rXPropSet ) ]; +} + +// --------------------------------------------------------------------------------------------- + +PHLayout& PPTWriterBase::GetLayout( sal_Int32 nOffset ) const +{ + if( nOffset >= 0 && nOffset < EPP_LAYOUT_SIZE ) + return pPHLayout[ nOffset ]; + + DBG(printf("asked %d for layout outside of 0,%d array scope\n", nOffset, EPP_LAYOUT_SIZE )); + + return pPHLayout[ 0 ]; +} + +// --------------------------------------------------------------------------------------------- + +sal_uInt32 PPTWriterBase::GetMasterIndex( PageType ePageType ) +{ + sal_uInt32 nRetValue = 0; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget > + aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY ); + + if ( aXMasterPageTarget.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > + aXDrawPage = aXMasterPageTarget->getMasterPage(); + if ( aXDrawPage.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + aXPropertySet( aXDrawPage, ::com::sun::star::uno::UNO_QUERY ); + + if ( aXPropertySet.is() ) + { + if ( ImplGetPropertyValue( aXPropertySet, String( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) ) + nRetValue |= *(sal_Int16*)mAny.getValue(); + if ( nRetValue & 0xffff ) // ueberlauf vermeiden + nRetValue--; + } + } + } + if ( ePageType == NOTICE ) + nRetValue += mnMasterPages; + return nRetValue; +} + +// ----------------------------------------------------------------------- + +sal_Bool PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum ) +{ + sal_Bool bRet = sal_False; + if ( nPageNum >= maStyleSheetList.size() ) + nPageNum = 0; + else + bRet = sal_True; + mpStyleSheet = maStyleSheetList[ nPageNum ]; + return bRet; +} + +// --------------------------------------------------------------------------------------------- + +sal_Bool PPTWriterBase::GetStyleSheets() +{ + int nInstance, nLevel; + sal_Bool bRetValue = sal_False; + sal_uInt32 nPageNum; + + for ( nPageNum = 0; nPageNum < mnMasterPages; nPageNum++ ) + { + Reference< XNamed > + aXNamed; + + Reference< XNameAccess > + aXNameAccess; + + Reference< XStyleFamiliesSupplier > + aXStyleFamiliesSupplier( mXModel, UNO_QUERY ); + + Reference< XPropertySet > + aXPropSet( mXModel, UNO_QUERY ); + + sal_uInt16 nDefaultTab = ( aXPropSet.is() && ImplGetPropertyValue( aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TabStop" ) ) ) ) + ? (sal_uInt16)( *(sal_Int32*)mAny.getValue() / 4.40972 ) + : 1250; + + maStyleSheetList.push_back( new PPTExStyleSheet( nDefaultTab, (PPTExBulletProvider&)*this ) ); + SetCurrentStyleSheet( nPageNum ); + if ( GetPageByIndex( nPageNum, MASTER ) ) + aXNamed = Reference< XNamed > + ( mXDrawPage, UNO_QUERY ); + + if ( aXStyleFamiliesSupplier.is() ) + aXNameAccess = aXStyleFamiliesSupplier->getStyleFamilies(); + + bRetValue = aXNamed.is() && aXNameAccess.is() && aXStyleFamiliesSupplier.is(); + if ( bRetValue ) + { + for ( nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_CenterTitle; nInstance++ ) + { + String aStyle; + String aFamily; + switch ( nInstance ) + { + case EPP_TEXTTYPE_CenterTitle : + case EPP_TEXTTYPE_Title : + { + aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "title" ) ); + aFamily = aXNamed->getName(); + } + break; + case EPP_TEXTTYPE_Body : + { + aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "outline1" ) ); // SD_LT_SEPARATOR + aFamily = aXNamed->getName(); + } + break; + case EPP_TEXTTYPE_Other : + { + aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "standard" ) ); + aFamily = String( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ); + } + break; + case EPP_TEXTTYPE_CenterBody : + { + aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "subtitle" ) ); + aFamily = aXNamed->getName(); + } + break; + } + if ( aStyle.Len() && aFamily.Len() ) + { + try + { + Reference< XNameAccess >xNameAccess; + if ( aXNameAccess->hasByName( aFamily ) ) + { + Any aAny( aXNameAccess->getByName( aFamily ) ); + if( aAny.getValue() && ::cppu::extractInterface( xNameAccess, aAny ) ) + { + Reference< XNameAccess > aXFamily; + if ( aAny >>= aXFamily ) + { + if ( aXFamily->hasByName( aStyle ) ) + { + Reference< XStyle > xStyle; + aAny = aXFamily->getByName( aStyle ); + if( aAny.getValue() && ::cppu::extractInterface( xStyle, aAny ) ) + { + Reference< XStyle > aXStyle; + aAny >>= aXStyle; + Reference< XPropertySet > + xPropSet( aXStyle, UNO_QUERY ); + if( xPropSet.is() ) + mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, 0 ); + for ( nLevel = 1; nLevel < 5; nLevel++ ) + { + if ( nInstance == EPP_TEXTTYPE_Body ) + { + sal_Unicode cTemp = aStyle.GetChar( aStyle.Len() - 1 ); + aStyle.SetChar( aStyle.Len() - 1, ++cTemp ); + if ( aXFamily->hasByName( aStyle ) ) + { + aXFamily->getByName( aStyle ) >>= xStyle; + if( xStyle.is() ) + { + Reference< XPropertySet > + xPropertySet( xStyle, UNO_QUERY ); + if ( xPropertySet.is() ) + mpStyleSheet->SetStyleSheet( xPropertySet, maFontCollection, nInstance, nLevel ); + } + } + } + else + mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, nLevel ); + } + } + } + } + } + } + } + catch( Exception& ) + { + // + } + } + } + for ( ; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ ) + { + + } + } + } + return bRetValue; +} + +// ----------------------------------------------------------------------- + +sal_Bool PPTWriterBase::CreateMainNotes() +{ + if ( !GetPageByIndex( 0, NOTICE ) ) + return FALSE; + SetCurrentStyleSheet( 0 ); + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget > + aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY ); + + if ( !aXMasterPageTarget.is() ) + return FALSE; + + mXDrawPage = aXMasterPageTarget->getMasterPage(); + if ( !mXDrawPage.is() ) + return FALSE; + + mXPropSet = ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY ); + if ( !mXPropSet.is() ) + return FALSE; + + mXShapes = ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > + ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY ); + if ( !mXShapes.is() ) + return FALSE; + + return ImplCreateMainNotes(); +} + +// ----------------------------------------------------------------------- + +awt::Size PPTWriterBase::MapSize( const awt::Size& rSize ) +{ + Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) ); + + if ( !aRetSize.Width() ) + aRetSize.Width()++; + if ( !aRetSize.Height() ) + aRetSize.Height()++; + return awt::Size( aRetSize.Width(), aRetSize.Height() ); +} + +// ----------------------------------------------------------------------- + +awt::Point PPTWriterBase::MapPoint( const awt::Point& rPoint ) +{ + Point aRet( OutputDevice::LogicToLogic( Point( rPoint.X, rPoint.Y ), maMapModeSrc, maMapModeDest ) ); + return awt::Point( aRet.X(), aRet.Y() ); +} + +// ----------------------------------------------------------------------- + +Rectangle PPTWriterBase::MapRectangle( const awt::Rectangle& rRect ) +{ + ::com::sun::star::awt::Point aPoint( rRect.X, rRect.Y ); + ::com::sun::star::awt::Size aSize( rRect.Width, rRect.Height ); + ::com::sun::star::awt::Point aP( MapPoint( aPoint ) ); + ::com::sun::star::awt::Size aS( MapSize( aSize ) ); + return Rectangle( Point( aP.X, aP.Y ), Size( aS.Width, aS.Height ) ); +} + +// ----------------------------------------------------------------------- + +sal_Bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex, sal_Bool bGroup ) +{ + while(TRUE) + { + if ( ( bGroup == FALSE ) || ( GetCurrentGroupLevel() == 0 ) ) + { + Any aAny( mXShapes->getByIndex( nIndex ) ); + aAny >>= mXShape; + } + else + { + Any aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) ); + aAny >>= mXShape; + } + if ( !mXShape.is() ) + break; + + Any aAny( mXShape->queryInterface( ::getCppuType( (const Reference< XPropertySet >*) 0 ) )); + aAny >>= mXPropSet; + + if ( !mXPropSet.is() ) + break; + maPosition = MapPoint( mXShape->getPosition() ); + maSize = MapSize( mXShape->getSize() ); + maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) ); + mType = ByteString( String( mXShape->getShapeType() ), RTL_TEXTENCODING_UTF8 ); + mType.Erase( 0, 13 ); // "com.sun.star." entfernen + sal_uInt16 nPos = mType.Search( (const char*)"Shape" ); + mType.Erase( nPos, 5 ); + + mbPresObj = mbEmptyPresObj = FALSE; + if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsPresentationObject" ) ) ) ) + mAny >>= mbPresObj; + + if ( mbPresObj && ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsEmptyPresentationObject" ) ) ) ) + mAny >>= mbEmptyPresObj; + + mnAngle = ( PropValue::GetPropertyValue( aAny, + mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ), sal_True ) ) + ? *((sal_Int32*)aAny.getValue() ) + : 0; + + return TRUE; + } + return FALSE; +} + +// ----------------------------------------------------------------------- + +sal_Int8 PPTWriterBase::GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, FadeEffect eEffect, sal_uInt8& nDirection ) +{ + sal_Int8 nPPTTransitionType = 0; + nDirection = 0; + + switch( nTransitionType ) + { + case TransitionType::FADE : + { + if ( nTransitionSubtype == TransitionSubType::CROSSFADE ) + nPPTTransitionType = PPT_TRANSITION_TYPE_SMOOTHFADE; + else if ( nTransitionSubtype == TransitionSubType::FADEOVERCOLOR ) + nPPTTransitionType = PPT_TRANSITION_TYPE_FADE; + } + break; + case PPT_TRANSITION_TYPE_COMB : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_COMB; + if ( nTransitionSubtype == TransitionSubType::COMBVERTICAL ) + nDirection++; + } + break; + case TransitionType::PUSHWIPE : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_PUSH; + switch( nTransitionSubtype ) + { + case TransitionSubType::FROMRIGHT: nDirection = 0; break; + case TransitionSubType::FROMBOTTOM: nDirection = 1; break; + case TransitionSubType::FROMLEFT: nDirection = 2; break; + case TransitionSubType::FROMTOP: nDirection = 3; break; + } + } + break; + case TransitionType::PINWHEELWIPE : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_WHEEL; + switch( nTransitionSubtype ) + { + case TransitionSubType::ONEBLADE: nDirection = 1; break; + case TransitionSubType::TWOBLADEVERTICAL : nDirection = 2; break; + case TransitionSubType::THREEBLADE : nDirection = 3; break; + case TransitionSubType::FOURBLADE: nDirection = 4; break; + case TransitionSubType::EIGHTBLADE: nDirection = 8; break; + } + } + break; + case TransitionType::FANWIPE : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_WEDGE; + } + break; + case TransitionType::ELLIPSEWIPE : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_CIRCLE; + } + break; + case TransitionType::FOURBOXWIPE : + { + nPPTTransitionType = PPT_TRANSITION_TYPE_PLUS; + } + break; + case TransitionType::IRISWIPE : + { + switch( nTransitionSubtype ) { + case TransitionSubType::RECTANGLE: + nPPTTransitionType = PPT_TRANSITION_TYPE_ZOOM; + nDirection = (eEffect == FadeEffect_FADE_FROM_CENTER) ? 0 : 1; + break; + default: + nPPTTransitionType = PPT_TRANSITION_TYPE_DIAMOND; + break; + } + } + break; + } + + return nPPTTransitionType; +} + +sal_Int8 PPTWriterBase::GetTransition( FadeEffect eEffect, sal_uInt8& nDirection ) +{ + sal_Int8 nPPTTransitionType = 0; + + switch ( eEffect ) + { + default : + case FadeEffect_RANDOM : + nPPTTransitionType = PPT_TRANSITION_TYPE_RANDOM; + break; + + case FadeEffect_HORIZONTAL_STRIPES : + nDirection++; + case FadeEffect_VERTICAL_STRIPES : + nPPTTransitionType = PPT_TRANSITION_TYPE_BLINDS; + break; + + case FadeEffect_VERTICAL_CHECKERBOARD : + nDirection++; + case FadeEffect_HORIZONTAL_CHECKERBOARD : + nPPTTransitionType = PPT_TRANSITION_TYPE_CHECKER; + break; + + case FadeEffect_MOVE_FROM_UPPERLEFT : + nDirection++; + case FadeEffect_MOVE_FROM_UPPERRIGHT : + nDirection++; + case FadeEffect_MOVE_FROM_LOWERLEFT : + nDirection++; + case FadeEffect_MOVE_FROM_LOWERRIGHT : + nDirection++; + case FadeEffect_MOVE_FROM_TOP : + nDirection++; + case FadeEffect_MOVE_FROM_LEFT : + nDirection++; + case FadeEffect_MOVE_FROM_BOTTOM : + nDirection++; + case FadeEffect_MOVE_FROM_RIGHT : + nPPTTransitionType = PPT_TRANSITION_TYPE_COVER; + break; + + case FadeEffect_DISSOLVE : + nPPTTransitionType = PPT_TRANSITION_TYPE_DISSOLVE; + break; + + case FadeEffect_VERTICAL_LINES : + nDirection++; + case FadeEffect_HORIZONTAL_LINES : + nPPTTransitionType = PPT_TRANSITION_TYPE_RANDOM_BARS; + break; + + case FadeEffect_CLOSE_HORIZONTAL : + nDirection++; + case FadeEffect_OPEN_HORIZONTAL : + nDirection++; + case FadeEffect_CLOSE_VERTICAL : + nDirection++; + case FadeEffect_OPEN_VERTICAL : + nPPTTransitionType = PPT_TRANSITION_TYPE_SPLIT; + break; + + case FadeEffect_FADE_FROM_UPPERLEFT : + nDirection++; + case FadeEffect_FADE_FROM_UPPERRIGHT : + nDirection++; + case FadeEffect_FADE_FROM_LOWERLEFT : + nDirection++; + case FadeEffect_FADE_FROM_LOWERRIGHT : + nDirection += 4; + nPPTTransitionType = PPT_TRANSITION_TYPE_STRIPS; + break; + + case FadeEffect_UNCOVER_TO_LOWERRIGHT : + nDirection++; + case FadeEffect_UNCOVER_TO_LOWERLEFT : + nDirection++; + case FadeEffect_UNCOVER_TO_UPPERRIGHT : + nDirection++; + case FadeEffect_UNCOVER_TO_UPPERLEFT : + nDirection++; + case FadeEffect_UNCOVER_TO_BOTTOM : + nDirection++; + case FadeEffect_UNCOVER_TO_RIGHT : + nDirection++; + case FadeEffect_UNCOVER_TO_TOP : + nDirection++; + case FadeEffect_UNCOVER_TO_LEFT : + nPPTTransitionType = PPT_TRANSITION_TYPE_PULL; + break; + + case FadeEffect_FADE_FROM_TOP : + nDirection++; + case FadeEffect_FADE_FROM_LEFT : + nDirection++; + case FadeEffect_FADE_FROM_BOTTOM : + nDirection++; + case FadeEffect_FADE_FROM_RIGHT : + nPPTTransitionType = PPT_TRANSITION_TYPE_WIPE; + break; + + case FadeEffect_ROLL_FROM_TOP : + nDirection++; + case FadeEffect_ROLL_FROM_LEFT : + nDirection++; + case FadeEffect_ROLL_FROM_BOTTOM : + nDirection++; + case FadeEffect_ROLL_FROM_RIGHT : + nPPTTransitionType = PPT_TRANSITION_TYPE_WIPE; + break; + + case FadeEffect_FADE_TO_CENTER : + nDirection++; + case FadeEffect_FADE_FROM_CENTER : + nPPTTransitionType = PPT_TRANSITION_TYPE_ZOOM; + break; + + case FadeEffect_NONE : + nDirection = 2; + break; + } + + return nPPTTransitionType; +} + +// ----------------------------------------------------------------------- + +sal_Bool PPTWriterBase::ContainsOtherShapeThanPlaceholders( sal_Bool bForOOMLX ) +{ + sal_uInt32 nShapes = mXShapes->getCount(); + sal_Bool bOtherThanPlaceHolders = FALSE; + + if ( nShapes ) + for ( sal_uInt32 nIndex = 0; ( nIndex < nShapes ) && ( bOtherThanPlaceHolders == FALSE ); nIndex++ ) { + if ( GetShapeByIndex( nIndex ) && mType != "drawing.Page" ) { + if( bForOOMLX && + ( mType == "presentation.Page" || + mType == "presentation.Notes" ) ) { + Reference< XSimpleText > rXText( mXShape, UNO_QUERY ); + + if( rXText.is() && rXText->getString().getLength() != 0 ) + bOtherThanPlaceHolders = TRUE; + } else + bOtherThanPlaceHolders = TRUE; + } + DBG(printf("mType == %s\n", mType.GetBuffer())); + } + + return bOtherThanPlaceHolders; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx new file mode 100644 index 000000000..444502954 --- /dev/null +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -0,0 +1,1451 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <hash_map> +#include <stdio.h> +#include <oox/drawingml/chart/chartconverter.hxx> +#include <oox/core/tokens.hxx> +#include <epptooxml.hxx> +#include <epptdef.hxx> +#include <oox/export/shapes.hxx> + +#include <cppuhelper/factory.hxx> +#include <sax/fshelper.hxx> +#include <rtl/ustrbuf.hxx> +#include <filter/msfilter/escherex.hxx> +#include <tools/poly.hxx> + +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/RectanglePoint.hpp> +#include <com/sun/star/beans/Property.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <com/sun/star/presentation/AnimationSpeed.hpp> + +#include <oox/export/utils.hxx> + +// presentation namespaces +#define PNMSS FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", \ + FSNS( XML_xmlns, XML_p ), "http://schemas.openxmlformats.org/presentationml/2006/main", \ + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships" + +using ::rtl::OString; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::presentation; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::XPropertySetInfo; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::container::XIndexAccess; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::task::XStatusIndicator; +using ::com::sun::star::text::XSimpleText; +using ::sax_fastparser::FastSerializerHelper; +using ::sax_fastparser::FSHelperPtr; + +void dump_pset(Reference< XPropertySet > rXPropSet); + +#define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr() + +namespace oox { + using namespace drawingml; + namespace core { + +class PowerPointShapeExport : public ShapeExport +{ + PowerPointExport& mrExport; + PageType mePageType; + sal_Bool mbMaster; +public: + PowerPointShapeExport( FSHelperPtr pFS, PowerPointExport* pFB ); + void SetMaster( sal_Bool bMaster ); + void SetPageType( PageType ePageType ); + ShapeExport& WriteNonVisualProperties( Reference< XShape > xShape ); + ShapeExport& WriteTextShape( Reference< XShape > xShape ); + ShapeExport& WriteUnknownShape( Reference< XShape > xShape ); +}; + +PowerPointShapeExport::PowerPointShapeExport( FSHelperPtr pFS, PowerPointExport* pFB ) + : ShapeExport( XML_p, pFS, pFB ) + , mrExport( *pFB ) +{ +} + +void PowerPointShapeExport::SetMaster( sal_Bool bMaster ) +{ + mbMaster = bMaster; +} + +void PowerPointShapeExport::SetPageType( PageType ePageType ) +{ + mePageType = ePageType; +} + +ShapeExport& PowerPointShapeExport::WriteNonVisualProperties( Reference< XShape > ) +{ + GetFS()->singleElementNS( XML_p, XML_nvPr, FSEND ); + + return *this; +} + +ShapeExport& PowerPointShapeExport::WriteTextShape( Reference< XShape > xShape ) +{ + OUString sShapeType = xShape->getShapeType(); + + DBG(printf( "shape(text): %s\n", USS(sShapeType) )); + + if( sShapeType.equalsAscii( "com.sun.star.drawing.TextShape" ) ) + { + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.DateTimeShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, DateAndTime, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.FooterShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, Footer, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.HeaderShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, Header, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.NotesShape" ) ) + { + if( mePageType == NOTICE && mrExport.GetPresObj() ) + mrExport.WritePlaceholderShape( GetFS(), *this, Notes ); + else + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.OutlinerShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, Outliner, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.SlideNumberShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, SlideNumber, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.TitleTextShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, Title, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + + return *this; +} + +ShapeExport& PowerPointShapeExport::WriteUnknownShape( Reference< XShape > xShape ) +{ + OUString sShapeType = xShape->getShapeType(); + + DBG(printf( "shape(unknown): %s\n", USS(sShapeType) )); + + if( sShapeType.equalsAscii( "com.sun.star.drawing.Group" ) ) + { + Reference< XIndexAccess > rXIndexAccess( xShape, UNO_QUERY ); + + mrExport.EnterGroup( rXIndexAccess ); + DBG(printf( "enter group\n" )); + } + else if( sShapeType.equalsAscii( "com.sun.star.drawing.Group" ) ) + { + mrExport.WritePageShape( GetFS(), *this, mePageType ); + } + else if( sShapeType.equalsAscii( "com.sun.star.drawing.PageShape" ) ) + { + mrExport.WritePageShape( GetFS(), *this, mePageType ); + } + else if( sShapeType.equalsAscii( "com.sun.star.presentation.SubtitleShape" ) ) + { + if( !mrExport.WritePlaceholder( GetFS(), *this, Subtitle, mbMaster ) ) + ShapeExport::WriteTextShape( xShape ); + } + + return *this; +} + +PowerPointExport::PowerPointExport( const Reference< XMultiServiceFactory > & rSMgr ) + : XmlFilterBase( rSMgr ), + PPTWriterBase(), + mnLayoutFileIdMax( 1 ), + mnSlideIdMax( 1 << 8 ), + mnSlideMasterIdMax( 1 << 31 ), + mnShapeIdMax( 1 ), + mnPictureIdMax( 1 ) +{ + memset( mLayoutInfo, 0, sizeof(mLayoutInfo) ); +} + +PowerPointExport::~PowerPointExport() +{ +} + +bool PowerPointExport::importDocument() throw() +{ + return false; +} + +bool PowerPointExport::exportDocument() throw() +{ + DrawingML::ResetCounters(); + + addRelation( US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ), S( "ppt/presentation.xml" ) ); + + mPresentationFS = openFragmentStreamWithSerializer( US( "ppt/presentation.xml" ), + US( "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ) ); + + addRelation( mPresentationFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ), + US( "theme/theme1.xml" ) ); + + mPresentationFS->startElementNS( XML_p, XML_presentation, PNMSS, FSEND ); + + mXModel.set( getModel(), UNO_QUERY ); + mXStatusIndicator.set( getStatusIndicator(), UNO_QUERY ); + + exportPPT(); + + mPresentationFS->singleElementNS( XML_p, XML_sldSz, + XML_cx, IS( PPTtoEMU( maDestPageSize.Width ) ), + XML_cy, IS( PPTtoEMU( maDestPageSize.Height ) ), + FSEND ); + // for some reason if added before slides list it will not load the slides (alas with error reports) in mso + mPresentationFS->singleElementNS( XML_p, XML_notesSz, + XML_cx, IS( PPTtoEMU( maNotesPageSize.Width ) ), + XML_cy, IS( PPTtoEMU( maNotesPageSize.Height ) ), + FSEND ); + + mPresentationFS->endElementNS( XML_p, XML_presentation ); + mPresentationFS.reset(); + + commitStorage(); + + return true; +} + +void PowerPointExport::ImplWriteBackground( FSHelperPtr pFS, Reference< XPropertySet > rXPropSet ) +{ + FillStyle aFillStyle( FillStyle_NONE ); + if ( ImplGetPropertyValue( rXPropSet, S( "FillStyle" ) ) ) + mAny >>= aFillStyle; + + if( aFillStyle == FillStyle_BITMAP ) { + //DBG(printf ("FillStyle_BITMAP properties\n")); + //DBG(dump_pset(rXPropSet)); + } + + if( aFillStyle == FillStyle_NONE || + aFillStyle == FillStyle_GRADIENT || + aFillStyle == FillStyle_HATCH ) + return; + + pFS->startElementNS( XML_p, XML_bg, FSEND ); + pFS->startElementNS( XML_p, XML_bgPr, FSEND ); + + PowerPointShapeExport( pFS, this ).WriteFill( rXPropSet ); + + pFS->endElementNS( XML_p, XML_bgPr ); + pFS->endElementNS( XML_p, XML_bg ); +} + +#define MINIMAL_SPTREE "<p:spTree>\ + <p:nvGrpSpPr>\ + <p:cNvPr id=\"1\" name=\"\"/>\ + <p:cNvGrpSpPr/>\ + <p:nvPr/>\ + </p:nvGrpSpPr>\ + <p:grpSpPr>\ + <a:xfrm>\ + <a:off x=\"0\" y=\"0\"/>\ + <a:ext cx=\"0\" cy=\"0\"/>\ + <a:chOff x=\"0\" y=\"0\"/>\ + <a:chExt cx=\"0\" cy=\"0\"/>\ + </a:xfrm>\ + </p:grpSpPr>\ + </p:spTree>" + +#define MAIN_GROUP \ + "<p:nvGrpSpPr>\ + <p:cNvPr id=\"1\" name=\"\"/>\ + <p:cNvGrpSpPr/>\ + <p:nvPr/>\ + </p:nvGrpSpPr>\ + <p:grpSpPr>\ + <a:xfrm>\ + <a:off x=\"0\" y=\"0\"/>\ + <a:ext cx=\"0\" cy=\"0\"/>\ + <a:chOff x=\"0\" y=\"0\"/>\ + <a:chExt cx=\"0\" cy=\"0\"/>\ + </a:xfrm>\ + </p:grpSpPr>" + +#define GETA(propName) \ + ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) ) + +#define GET(variable, propName) \ + if ( GETA(propName) ) \ + mAny >>= variable; + +const char* PowerPointExport::GetSideDirection( sal_uInt8 nDirection ) +{ + const char* pDirection = NULL; + + switch( nDirection ) { + case 0: + pDirection = "r"; + break; + case 1: + pDirection = "d"; + break; + case 2: + pDirection = "l"; + break; + case 3: + pDirection = "u"; + break; + } + + return pDirection; +} + +const char* PowerPointExport::GetCornerDirection( sal_uInt8 nDirection ) +{ + const char* pDirection = NULL; + + switch( nDirection ) { + case 4: + pDirection = "rd"; + break; + case 5: + pDirection = "ld"; + break; + case 6: + pDirection = "ru"; + break; + case 7: + pDirection = "lu"; + break; + } + + return pDirection; +} + +const char* PowerPointExport::Get8Direction( sal_uInt8 nDirection ) +{ + const char* pDirection = GetSideDirection( nDirection ); + + if( !pDirection ) + pDirection = GetCornerDirection( nDirection ); + + return pDirection; +} + +void PowerPointExport::ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNum, sal_uInt16 /* nMode */, + sal_Bool bHasBackground, Reference< XPropertySet > aXBackgroundPropSet ) +{ + DBG(printf("write slide: %d\n----------------\n", nPageNum)); + + // slides list + if( nPageNum == 0 ) + mPresentationFS->startElementNS( XML_p, XML_sldIdLst, FSEND ); + + // add explicit relation of presentation to this slide + OUString sRelId = addRelation( mPresentationFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" ), + OUStringBuffer() + .appendAscii( "slides/slide" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + mPresentationFS->singleElementNS( XML_p, XML_sldId, + XML_id, I32S( GetNewSlideId() ), + FSNS( XML_r, XML_id ), USS( sRelId ), + FSEND ); + + if( nPageNum == mnPages - 1 ) + mPresentationFS->endElementNS( XML_p, XML_sldIdLst ); + + FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer() + .appendAscii( "ppt/slides/slide" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear(), + US( "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ) ); + + if( mpSlidesFSArray.size() < mnPages ) + mpSlidesFSArray.resize( mnPages ); + mpSlidesFSArray[ nPageNum ] = pFS; + + pFS->startElementNS( XML_p, XML_sld, PNMSS, FSEND ); + + pFS->startElementNS( XML_p, XML_cSld, FSEND ); + + // background + if( bHasBackground ) { + ImplWriteBackground( pFS, aXBackgroundPropSet ); + } + + WriteShapeTree( pFS, NORMAL, FALSE ); + + pFS->endElementNS( XML_p, XML_cSld ); + + FadeEffect eFadeEffect = FadeEffect_NONE; + GET( eFadeEffect, Effect ); + + OSL_TRACE("fade effect %d", eFadeEffect); + + sal_Int16 nTransitionType = 0, nTransitionSubtype = 0; + sal_Int8 nPPTTransitionType = 0; + sal_uInt8 nDirection = 0; + + if( GETA( TransitionType ) && ( mAny >>= nTransitionType ) && + GETA( TransitionSubtype ) && ( mAny >>= nTransitionSubtype ) ) + nPPTTransitionType = GetTransition( nTransitionType, nTransitionSubtype, eFadeEffect, nDirection ); + + if( !nPPTTransitionType && eFadeEffect != FadeEffect_NONE ) + nPPTTransitionType = GetTransition( eFadeEffect, nDirection ); + + if( nPPTTransitionType ) { + AnimationSpeed animationSpeed = AnimationSpeed_MEDIUM; + const char* speed = NULL; + sal_Int32 advanceTiming = -1; + sal_Int32 changeType = 0; + + if( GETA( Speed ) ) { + mAny >>= animationSpeed; + + switch( animationSpeed ) { + default: + case AnimationSpeed_MEDIUM: + speed = "med"; + break; + case AnimationSpeed_SLOW: + speed = "slow"; + break; + case AnimationSpeed_FAST: + break; + } + } + + if( GETA( Change ) ) + mAny >>= changeType; + + // 1 means automatic, 2 half automatic - not sure what it means - at least I don't see it in UI + if( changeType == 1 && GETA( Duration ) ) + mAny >>= advanceTiming; + + pFS->startElementNS( XML_p, XML_transition, + XML_spd, speed, + XML_advTm, advanceTiming != -1 ? I32S( advanceTiming*1000 ) : NULL, + FSEND ); + + sal_Int32 nTransition = 0; + const char* pDirection = NULL; + const char* pOrientation = NULL; + const char* pThruBlk = NULL; + const char* pSpokes = NULL; + char pSpokesTmp[2] = "0"; + + switch( nPPTTransitionType ) { + case PPT_TRANSITION_TYPE_BLINDS: + nTransition = XML_blinds; + pDirection = ( nDirection == 0) ? "vert" : "horz"; + break; + case PPT_TRANSITION_TYPE_CHECKER: + nTransition = XML_checker; + pDirection = ( nDirection == 1) ? "vert" : "horz"; + break; + case PPT_TRANSITION_TYPE_CIRCLE: + nTransition = XML_circle; + break; + case PPT_TRANSITION_TYPE_COMB: + nTransition = XML_comb; + pDirection = ( nDirection == 1) ? "vert" : "horz"; + break; + case PPT_TRANSITION_TYPE_COVER: + nTransition = XML_cover; + pDirection = Get8Direction( nDirection ); + break; +// we don't have cut transition AFAIK +// case PPT_TRANSITION_TYPE_CUT: +// nTransition = XML_cut; +// break; + case PPT_TRANSITION_TYPE_DIAMOND: + nTransition = XML_diamond; + break; + case PPT_TRANSITION_TYPE_DISSOLVE: + nTransition = XML_dissolve; + break; + case PPT_TRANSITION_TYPE_FADE: + nTransition = XML_fade; + pThruBlk = "true"; + break; + case PPT_TRANSITION_TYPE_SMOOTHFADE: + nTransition = XML_fade; + break; + case PPT_TRANSITION_TYPE_NEWSFLASH: + nTransition = XML_newsflash; + break; + case PPT_TRANSITION_TYPE_PLUS: + nTransition = XML_plus; + break; + case PPT_TRANSITION_TYPE_PULL: + nTransition = XML_pull; + pDirection = Get8Direction( nDirection ); + break; + case PPT_TRANSITION_TYPE_PUSH: + nTransition = XML_push; + pDirection = GetSideDirection( nDirection ); + break; + case PPT_TRANSITION_TYPE_RANDOM: + nTransition = XML_random; + break; + case PPT_TRANSITION_TYPE_RANDOM_BARS: + nTransition = XML_randomBar; + pDirection = ( nDirection == 1) ? "vert" : "horz"; + break; + case PPT_TRANSITION_TYPE_SPLIT: + nTransition = XML_split; + pDirection = ( nDirection & 1) ? "in" : "out"; + pOrientation = ( nDirection < 2) ? "horz" : "vert"; + break; + case PPT_TRANSITION_TYPE_STRIPS: + nTransition = XML_strips; + pDirection = GetCornerDirection( nDirection ); + break; + case PPT_TRANSITION_TYPE_WEDGE: + nTransition = XML_wedge; + break; + case PPT_TRANSITION_TYPE_WHEEL: + nTransition = XML_wheel; + if( nDirection != 4 && nDirection <= 9 ) { + pSpokesTmp[0] = '0' + nDirection; + pSpokes = pSpokesTmp; + } + break; + case PPT_TRANSITION_TYPE_WIPE: + nTransition = XML_wipe; + pDirection = GetSideDirection( nDirection ); + break; + case PPT_TRANSITION_TYPE_ZOOM: + nTransition = XML_zoom; + pDirection = ( nDirection == 1) ? "in" : "out"; + break; + case PPT_TRANSITION_TYPE_NONE: + default: + nTransition = 0; + } + + if( nTransition ) + pFS->singleElementNS( XML_p, nTransition, + XML_dir, pDirection, + XML_orient, pOrientation, + XML_spokes, pSpokes, + XML_thruBlk, pThruBlk, + FSEND ); + + pFS->endElementNS( XML_p, XML_transition ); + } + + pFS->endElementNS( XML_p, XML_sld ); + + // add implicit relation to slide layout + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" ), + OUStringBuffer() + .appendAscii( "../slideLayouts/slideLayout" ) + .append( GetLayoutFileId( GetLayoutOffset( mXPagePropSet ), nMasterNum ) ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + DBG(printf("----------------\n")); +} + +void PowerPointExport::ImplWriteNotes( sal_uInt32 nPageNum ) +{ + if( !mbCreateNotes || !ContainsOtherShapeThanPlaceholders( TRUE ) ) + return; + + DBG(printf("write Notes %d\n----------------\n", nPageNum)); + + FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer() + .appendAscii( "ppt/notesSlides/notesSlide" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear(), + US( "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml" ) ); + + pFS->startElementNS( XML_p, XML_notes, PNMSS, FSEND ); + + pFS->startElementNS( XML_p, XML_cSld, FSEND ); + + // background +// if( bHasBackground ) { +// ImplWriteBackground( pFS, aXBackgroundPropSet ); +// } + + WriteShapeTree( pFS, NOTICE, FALSE ); + + pFS->endElementNS( XML_p, XML_cSld ); + + pFS->endElementNS( XML_p, XML_notes ); + + // add implicit relation to slide + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" ), + OUStringBuffer() + .appendAscii( "../slides/slide" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + // add slide implicit relation to notes + if( mpSlidesFSArray.size() >= nPageNum ) + addRelation( mpSlidesFSArray[ nPageNum ]->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" ), + OUStringBuffer() + .appendAscii( "../notesSlides/notesSlide" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + // add implicit relation to notes master + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" ), + US( "../notesMasters/notesMaster1.xml" ) ); + + DBG(printf("----------------\n")); +} + +void PowerPointExport::AddLayoutIdAndRelation( FSHelperPtr pFS, sal_Int32 nLayoutFileId ) +{ + // add implicit relation of slide master to slide layout + OUString sRelId = addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" ), + OUStringBuffer() + .appendAscii( "../slideLayouts/slideLayout" ) + .append( nLayoutFileId ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + pFS->singleElementNS( XML_p, XML_sldLayoutId, + XML_id, I64S( GetNewSlideMasterId() ), + FSNS( XML_r, XML_id ), USS( sRelId ), + FSEND ); +} + +sal_Int32 PowerPointExport::nStyleLevelToken[5] = +{ + XML_lvl1pPr, + XML_lvl2pPr, + XML_lvl3pPr, + XML_lvl4pPr, + XML_lvl5pPr +}; + +void PowerPointExport::WriteTextStyleLevel( FSHelperPtr pFS, int nInstance, int nLevel ) +{ + OSL_ASSERT( nLevel >= 0 && nLevel < 5 ); + OSL_ASSERT( nInstance >= 0 && nInstance < 9 ); + + PPTExCharLevel rCharLevel = mpStyleSheet->GetCharSheet( nInstance ).maCharLevel[ nLevel ]; + PPTExParaLevel rParaLevel = mpStyleSheet->GetParaSheet( nInstance ).maParaLevel[ nLevel ]; + + pFS->startElementNS( XML_a, PowerPointExport::nStyleLevelToken[ nLevel ], + XML_algn, DrawingML::GetAlignment( rParaLevel.mnOOAdjust ), + FSEND ); + + pFS->endElementNS( XML_a, PowerPointExport::nStyleLevelToken[ nLevel ] ); +} + +void PowerPointExport::WriteTextStyle( FSHelperPtr pFS, int nInstance, sal_Int32 xmlToken ) +{ + pFS->startElementNS( XML_p, xmlToken, FSEND ); + + for( int nLevel = 0; nLevel < 5; nLevel ++ ) + WriteTextStyleLevel( pFS, nInstance, nLevel ); + + pFS->endElementNS( XML_p, xmlToken ); +} + +void PowerPointExport::WriteTextStyles( FSHelperPtr pFS ) +{ + pFS->startElementNS( XML_p, XML_txBody, FSEND ); + + WriteTextStyle( pFS, EPP_TEXTTYPE_Title, XML_titleStyle ); + WriteTextStyle( pFS, EPP_TEXTTYPE_Body, XML_bodyStyle ); + WriteTextStyle( pFS, EPP_TEXTTYPE_Other, XML_otherStyle ); + + pFS->endElementNS( XML_p, XML_txBody ); +} + +void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPropertySet > aXBackgroundPropSet ) +{ + DBG(printf("write slide master: %d\n----------------\n", nPageNum)); + + // slides list + if( nPageNum == 0 ) + mPresentationFS->startElementNS( XML_p, XML_sldMasterIdLst, FSEND ); + + OUString sRelId = addRelation( mPresentationFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" ), + OUStringBuffer() + .appendAscii( "slideMasters/slideMaster" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + mPresentationFS->singleElementNS( XML_p, XML_sldMasterId, + XML_id, OString::valueOf( (sal_Int64) GetNewSlideMasterId() ).getStr(), + FSNS( XML_r, XML_id ), USS( sRelId ), + FSEND ); + + if( nPageNum == mnMasterPages - 1 ) + mPresentationFS->endElementNS( XML_p, XML_sldMasterIdLst ); + + FSHelperPtr pFS = + openFragmentStreamWithSerializer( OUStringBuffer() + .appendAscii( "ppt/slideMasters/slideMaster" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear(), + US( "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" ) ); + if( mpMasterFSArray.size() < mnMasterPages ) + mpMasterFSArray.resize( mnMasterPages ); + mpMasterFSArray[ nPageNum ] = pFS; + + // write theme per master + WriteTheme( nPageNum ); + + // add implicit relation to the presentation theme + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ), + OUStringBuffer() + .appendAscii( "../theme/theme" ) + .append( (sal_Int32) nPageNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + pFS->startElementNS( XML_p, XML_sldMaster, PNMSS, FSEND ); + + pFS->startElementNS( XML_p, XML_cSld, FSEND ); + + ImplWriteBackground( pFS, aXBackgroundPropSet ); + WriteShapeTree( pFS, MASTER, TRUE ); + + pFS->endElementNS( XML_p, XML_cSld ); + + // color map - now it uses colors from hardcoded theme, once we eventually generate theme, this might need update + pFS->singleElementNS( XML_p, XML_clrMap, + XML_bg1, "lt1", + XML_bg2, "lt2", + XML_tx1, "dk1", + XML_tx2, "dk2", + XML_accent1, "accent1", + XML_accent2, "accent2", + XML_accent3, "accent3", + XML_accent4, "accent4", + XML_accent5, "accent5", + XML_accent6, "accent6", + XML_hlink, "hlink", + XML_folHlink, "folHlink", + FSEND ); + + // use master's id type as they have same range, mso does that as well + pFS->startElementNS( XML_p, XML_sldLayoutIdLst, FSEND ); + + int nCount = 0; + for( int i = 0; i < EPP_LAYOUT_SIZE; i++) { + + sal_Int32 nLayoutFileId = GetLayoutFileId( i, nPageNum ); + if( nLayoutFileId > 0 ) { + AddLayoutIdAndRelation( pFS, nLayoutFileId ); + nCount++; + } + } + + if( nCount == 0 ) { + // add at least empty layout, so that we don't have master page + // without layout, such master cannot be used in ppt + ImplWriteLayout( 0, nPageNum ); + AddLayoutIdAndRelation( pFS, GetLayoutFileId( 0, nPageNum ) ); + } + + pFS->endElementNS( XML_p, XML_sldLayoutIdLst ); + + // WriteTextStyles( pFS ); + + pFS->endElementNS( XML_p, XML_sldMaster ); + + DBG(printf("----------------\n")); +} + +sal_Int32 PowerPointExport::GetLayoutFileId( sal_Int32 nOffset, sal_uInt32 nMasterNum ) +{ + if( mLayoutInfo[ nOffset ].mnFileIdArray.size() <= nMasterNum ) + return 0; + + return mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ]; +} + +void PowerPointExport::ImplWriteLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum ) +{ + if( mLayoutInfo[ nOffset ].mnFileIdArray.size() < mnMasterPages ) { + mLayoutInfo[ nOffset ].mnFileIdArray.resize( mnMasterPages ); + } + + if( mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ] != 0 ) + return; + + FSHelperPtr pFS + = openFragmentStreamWithSerializer( OUStringBuffer() + .appendAscii( "ppt/slideLayouts/slideLayout" ) + .append( (sal_Int32) mnLayoutFileIdMax ) + .appendAscii( ".xml" ) + .makeStringAndClear(), + US( "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" ) ); + +// LayoutInfo& rLayoutInfo = GetLayoutInfo( mXPagePropSet ); + + // add implicit relation of slide layout to slide master + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" ), + OUStringBuffer() + .appendAscii( "../slideMasters/slideMaster" ) + .append( (sal_Int32) nMasterNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + pFS->startElementNS( XML_p, XML_sldLayout, + PNMSS, + XML_type, "title", + XML_preserve, "1", + FSEND ); + + pFS->startElementNS( XML_p, XML_cSld, + XML_name, "Title Slide", + FSEND ); + pFS->write( MINIMAL_SPTREE ); // TODO: write actual shape tree + pFS->endElementNS( XML_p, XML_cSld ); + + pFS->endElementNS( XML_p, XML_sldLayout ); + + mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ] = mnLayoutFileIdMax; + + mnLayoutFileIdMax ++; +} + +void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, sal_Bool bMaster ) +{ + PowerPointShapeExport aDML( pFS, this ); + aDML.SetMaster( bMaster ); + aDML.SetPageType( ePageType ); + sal_uInt32 nShapes; + + pFS->startElementNS( XML_p, XML_spTree, FSEND ); + pFS->write( MAIN_GROUP ); + + ResetGroupTable( nShapes = mXShapes->getCount() ); + + while( GetNextGroupEntry() ) { + + sal_uInt32 nGroups = GetGroupsClosed(); + for ( sal_uInt32 i = 0; i < nGroups; i++ ) { + DBG(printf( "leave group\n" )); + } + + if ( GetShapeByIndex( GetCurrentGroupIndex(), TRUE ) ) { + DBG(printf( "mType: \"%s\"\n", mType.GetBuffer() )); + aDML.WriteShape( mXShape ); + } + } + + pFS->endElementNS( XML_p, XML_spTree ); +} + +#define BEGIN_SHAPE pFS->startElementNS( XML_p, XML_sp, FSEND ) +#define END_SHAPE pFS->endElementNS( XML_p, XML_sp ) + +void PowerPointExport::WritePageShape( FSHelperPtr pFS, ShapeExport& rDML, PageType ePageType ) +{ + if( ePageType == NOTICE && mbPresObj ) + WritePlaceholderShape( pFS, rDML, SlideImage ); + else + rDML.WriteTextShape( mXShape ); +} + +sal_Bool PowerPointExport::WritePlaceholder( FSHelperPtr pFS, ShapeExport& rDML, PlaceholderType ePlaceholder, sal_Bool bMaster ) +{ + if( bMaster && ShapeExport::NonEmptyText( mXShape ) ) { + WritePlaceholderShape( pFS, rDML, ePlaceholder ); + + return TRUE; + } + + return FALSE; +} + +void PowerPointExport::WritePlaceholderShape( FSHelperPtr pFS, ShapeExport& rDML, PlaceholderType ePlaceholder ) +{ + BEGIN_SHAPE; + + // non visual shape properties + pFS->startElementNS( XML_p, XML_nvSpPr, FSEND ); + rDML.WriteNonVisualDrawingProperties( mXShape, IDS( PlaceHolder ) ); + pFS->startElementNS( XML_p, XML_cNvSpPr, FSEND ); + pFS->singleElementNS( XML_a, XML_spLocks, XML_noGrp, "1", FSEND ); + pFS->endElementNS( XML_p, XML_cNvSpPr ); + pFS->startElementNS( XML_p, XML_nvPr, FSEND ); + + const char* pType = NULL; + switch( ePlaceholder ) { + case SlideImage: + pType = "sldImg"; + break; + case Notes: + pType = "body"; + break; + case Header: + pType = "hdr"; + break; + case Footer: + pType = "ftr"; + break; + case SlideNumber: + pType = "sldNum"; + break; + case DateAndTime: + pType = "dt"; + break; + case Outliner: + pType = "body"; + break; + case Title: + pType = "title"; + break; + case Subtitle: + pType = "subTitle"; + break; + default: + DBG(printf("warning: unhandled placeholder type: %d\n", ePlaceholder)); + } + pFS->singleElementNS( XML_p, XML_ph, XML_type, pType, FSEND ); + pFS->endElementNS( XML_p, XML_nvPr ); + pFS->endElementNS( XML_p, XML_nvSpPr ); + + // visual shape properties + pFS->startElementNS( XML_p, XML_spPr, FSEND ); + rDML.WriteShapeTransformation( mXShape ); + rDML.WritePresetShape( "rect" ); + rDML.WriteBlipFill( mXPropSet, S( "GraphicURL" ) ); + pFS->endElementNS( XML_p, XML_spPr ); + + rDML.WriteTextBox( mXShape ); + + END_SHAPE; +} + +#define MINIMAL_THEME " <a:themeElements>\ + <a:clrScheme name=\"Office\">\ + <a:dk1>\ + <a:sysClr val=\"windowText\" lastClr=\"000000\"/>\ + </a:dk1>\ + <a:lt1>\ + <a:sysClr val=\"window\" lastClr=\"FFFFFF\"/>\ + </a:lt1>\ + <a:dk2>\ + <a:srgbClr val=\"1F497D\"/>\ + </a:dk2>\ + <a:lt2>\ + <a:srgbClr val=\"EEECE1\"/>\ + </a:lt2>\ + <a:accent1>\ + <a:srgbClr val=\"4F81BD\"/>\ + </a:accent1>\ + <a:accent2>\ + <a:srgbClr val=\"C0504D\"/>\ + </a:accent2>\ + <a:accent3>\ + <a:srgbClr val=\"9BBB59\"/>\ + </a:accent3>\ + <a:accent4>\ + <a:srgbClr val=\"8064A2\"/>\ + </a:accent4>\ + <a:accent5>\ + <a:srgbClr val=\"4BACC6\"/>\ + </a:accent5>\ + <a:accent6>\ + <a:srgbClr val=\"F79646\"/>\ + </a:accent6>\ + <a:hlink>\ + <a:srgbClr val=\"0000FF\"/>\ + </a:hlink>\ + <a:folHlink>\ + <a:srgbClr val=\"800080\"/>\ + </a:folHlink>\ + </a:clrScheme>\ + <a:fontScheme name=\"Office\">\ + <a:majorFont>\ + <a:latin typeface=\"Arial\"/>\ + <a:ea typeface=\"DejaVu Sans\"/>\ + <a:cs typeface=\"DejaVu Sans\"/>\ + </a:majorFont>\ + <a:minorFont>\ + <a:latin typeface=\"Arial\"/>\ + <a:ea typeface=\"DejaVu Sans\"/>\ + <a:cs typeface=\"DejaVu Sans\"/>\ + </a:minorFont>\ + </a:fontScheme>\ + <a:fmtScheme name=\"Office\">\ + <a:fillStyleLst>\ + <a:solidFill>\ + <a:schemeClr val=\"phClr\"/>\ + </a:solidFill>\ + <a:gradFill rotWithShape=\"1\">\ + <a:gsLst>\ + <a:gs pos=\"0\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"50000\"/>\ + <a:satMod val=\"300000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"35000\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"37000\"/>\ + <a:satMod val=\"300000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"100000\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"15000\"/>\ + <a:satMod val=\"350000\"/>\ + </a:schemeClr>\ + </a:gs>\ + </a:gsLst>\ + <a:lin ang=\"16200000\" scaled=\"1\"/>\ + </a:gradFill>\ + <a:gradFill rotWithShape=\"1\">\ + <a:gsLst>\ + <a:gs pos=\"0\">\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"51000\"/>\ + <a:satMod val=\"130000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"80000\">\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"93000\"/>\ + <a:satMod val=\"130000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"100000\">\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"94000\"/>\ + <a:satMod val=\"135000\"/>\ + </a:schemeClr>\ + </a:gs>\ + </a:gsLst>\ + <a:lin ang=\"16200000\" scaled=\"0\"/>\ + </a:gradFill>\ + </a:fillStyleLst>\ + <a:lnStyleLst>\ + <a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\ + <a:solidFill>\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"95000\"/>\ + <a:satMod val=\"105000\"/>\ + </a:schemeClr>\ + </a:solidFill>\ + <a:prstDash val=\"solid\"/>\ + </a:ln>\ + <a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\ + <a:solidFill>\ + <a:schemeClr val=\"phClr\"/>\ + </a:solidFill>\ + <a:prstDash val=\"solid\"/>\ + </a:ln>\ + <a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\ + <a:solidFill>\ + <a:schemeClr val=\"phClr\"/>\ + </a:solidFill>\ + <a:prstDash val=\"solid\"/>\ + </a:ln>\ + </a:lnStyleLst>\ + <a:effectStyleLst>\ + <a:effectStyle>\ + <a:effectLst>\ + <a:outerShdw blurRad=\"40000\" dist=\"20000\" dir=\"5400000\" rotWithShape=\"0\">\ + <a:srgbClr val=\"000000\">\ + <a:alpha val=\"38000\"/>\ + </a:srgbClr>\ + </a:outerShdw>\ + </a:effectLst>\ + </a:effectStyle>\ + <a:effectStyle>\ + <a:effectLst>\ + <a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">\ + <a:srgbClr val=\"000000\">\ + <a:alpha val=\"35000\"/>\ + </a:srgbClr>\ + </a:outerShdw>\ + </a:effectLst>\ + </a:effectStyle>\ + <a:effectStyle>\ + <a:effectLst>\ + <a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">\ + <a:srgbClr val=\"000000\">\ + <a:alpha val=\"35000\"/>\ + </a:srgbClr>\ + </a:outerShdw>\ + </a:effectLst>\ + <a:scene3d>\ + <a:camera prst=\"orthographicFront\">\ + <a:rot lat=\"0\" lon=\"0\" rev=\"0\"/>\ + </a:camera>\ + <a:lightRig rig=\"threePt\" dir=\"t\">\ + <a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/>\ + </a:lightRig>\ + </a:scene3d>\ + <a:sp3d>\ + <a:bevelT w=\"63500\" h=\"25400\"/>\ + </a:sp3d>\ + </a:effectStyle>\ + </a:effectStyleLst>\ + <a:bgFillStyleLst>\ + <a:solidFill>\ + <a:schemeClr val=\"phClr\"/>\ + </a:solidFill>\ + <a:gradFill rotWithShape=\"1\">\ + <a:gsLst>\ + <a:gs pos=\"0\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"40000\"/>\ + <a:satMod val=\"350000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"40000\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"45000\"/>\ + <a:shade val=\"99000\"/>\ + <a:satMod val=\"350000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"100000\">\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"20000\"/>\ + <a:satMod val=\"255000\"/>\ + </a:schemeClr>\ + </a:gs>\ + </a:gsLst>\ + <a:path path=\"circle\">\ + <a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/>\ + </a:path>\ + </a:gradFill>\ + <a:gradFill rotWithShape=\"1\">\ + <a:gsLst>\ + <a:gs pos=\"0\">\ + <a:schemeClr val=\"phClr\">\ + <a:tint val=\"80000\"/>\ + <a:satMod val=\"300000\"/>\ + </a:schemeClr>\ + </a:gs>\ + <a:gs pos=\"100000\">\ + <a:schemeClr val=\"phClr\">\ + <a:shade val=\"30000\"/>\ + <a:satMod val=\"200000\"/>\ + </a:schemeClr>\ + </a:gs>\ + </a:gsLst>\ + <a:path path=\"circle\">\ + <a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>\ + </a:path>\ + </a:gradFill>\ + </a:bgFillStyleLst>\ + </a:fmtScheme>\ + </a:themeElements>" + +void PowerPointExport::WriteTheme( sal_Int32 nThemeNum ) +{ + FSHelperPtr pFS = openFragmentStreamWithSerializer( OUStringBuffer() + .appendAscii( "ppt/theme/theme" ) + .append( (sal_Int32) nThemeNum + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear(), + US( "application/vnd.openxmlformats-officedocument.theme+xml" ) ); + + pFS->startElementNS( XML_a, XML_theme, + FSNS( XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main", + XML_name, "Office Theme", + FSEND ); + + pFS->write( MINIMAL_THEME ); + pFS->endElementNS( XML_a, XML_theme ); +} + +sal_Bool PowerPointExport::ImplCreateDocument() +{ + mbCreateNotes = FALSE; + + for( sal_uInt32 i = 0; i < mnPages; i++ ) + { + if ( !GetPageByIndex( i, NOTICE ) ) + return FALSE; + + if( ContainsOtherShapeThanPlaceholders( TRUE ) ) { + mbCreateNotes = TRUE; + break; + } + } + + return TRUE; +} + +sal_Bool PowerPointExport::WriteNotesMaster() +{ + DBG(printf("write Notes master\n----------------\n")); + + mPresentationFS->startElementNS( XML_p, XML_notesMasterIdLst, FSEND ); + + OUString sRelId = addRelation( mPresentationFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" ), + US( "notesMasters/notesMaster1.xml" ) ); + + mPresentationFS->singleElementNS( XML_p, XML_notesMasterId, + FSNS( XML_r, XML_id ), USS( sRelId ), + FSEND ); + + mPresentationFS->endElementNS( XML_p, XML_notesMasterIdLst ); + + FSHelperPtr pFS = + openFragmentStreamWithSerializer( US( "ppt/notesMasters/notesMaster1.xml" ), + US( "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml" ) ); + // write theme per master + WriteTheme( mnMasterPages ); + + // add implicit relation to the presentation theme + addRelation( pFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ), + OUStringBuffer() + .appendAscii( "../theme/theme" ) + .append( (sal_Int32) mnMasterPages + 1 ) + .appendAscii( ".xml" ) + .makeStringAndClear() ); + + pFS->startElementNS( XML_p, XML_notesMaster, PNMSS, FSEND ); + + pFS->startElementNS( XML_p, XML_cSld, FSEND ); + + Reference< XPropertySet > aXBackgroundPropSet; + if( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) ) && + ( mAny >>= aXBackgroundPropSet ) ) + ImplWriteBackground( pFS, aXBackgroundPropSet ); + + WriteShapeTree( pFS, NOTICE, TRUE ); + + pFS->endElementNS( XML_p, XML_cSld ); + + // color map - now it uses colors from hardcoded theme, once we eventually generate theme, this might need update + pFS->singleElementNS( XML_p, XML_clrMap, + XML_bg1, "lt1", + XML_bg2, "lt2", + XML_tx1, "dk1", + XML_tx2, "dk2", + XML_accent1, "accent1", + XML_accent2, "accent2", + XML_accent3, "accent3", + XML_accent4, "accent4", + XML_accent5, "accent5", + XML_accent6, "accent6", + XML_hlink, "hlink", + XML_folHlink, "folHlink", + FSEND ); + + pFS->endElementNS( XML_p, XML_notesMaster ); + + DBG(printf("----------------\n")); + + return TRUE; +} + +sal_Bool PowerPointExport::ImplCreateMainNotes() +{ + if( mbCreateNotes ) + return WriteNotesMaster(); + + return TRUE; +} + +drawingml::chart::ChartConverter& PowerPointExport::getChartConverter() +{ + return *mxChartConv; +} + +#define IMPL_NAME "com.sun.star.comp.Impress.oox.PowerPointExport" + +OUString SAL_CALL PowerPointExport_getImplementationName() throw() +{ + return CREATE_OUSTRING( IMPL_NAME ); +} + +uno::Sequence< OUString > SAL_CALL PowerPointExport_getSupportedServiceNames() throw() +{ + const OUString aServiceName = CREATE_OUSTRING( "com.sun.star.comp.ooxpptx" ); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL PowerPointExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + return (cppu::OWeakObject*)new PowerPointExport( rSMgr ); +} + +OUString PowerPointExport::implGetImplementationName() const +{ + return PowerPointExport_getImplementationName(); +} +} +} + +// UNO component +// ------------------------------------------ +// - component_getImplementationEnvironment - +// ------------------------------------------ + +#ifdef __cplusplus +extern "C" +{ +#endif + +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// ----------------------- +// - component_writeInfo - +// ----------------------- + +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /* pServiceManager */, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + uno::Reference< registry::XRegistryKey > xNewKey1( + static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( + ::rtl::OUString::createFromAscii( IMPL_NAME "/UNO/SERVICES/" ) ) ); + xNewKey1->createKey( oox::core::PowerPointExport_getSupportedServiceNames().getConstArray()[0] ); + + bRet = sal_True; + } + catch( registry::InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ ) +{ + uno::Reference< lang::XSingleServiceFactory > xFactory; + void* pRet = 0; + + if( rtl_str_compare( pImplName, IMPL_NAME ) == 0 ) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( IMPL_NAME ) ); + + xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), + oox::core::PowerPointExport_getImplementationName(), + oox::core::PowerPointExport_createInstance, + oox::core::PowerPointExport_getSupportedServiceNames() ) ); + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} + +#ifdef __cplusplus +} +#endif + +DBG( +void dump_pset(Reference< XPropertySet > rXPropSet) +{ + Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo (); + Sequence< beans::Property > props = info->getProperties (); + + for (int i=0; i < props.getLength (); i++) { + OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8); + printf ("%30s = ", name.getStr() ); + + Any value = rXPropSet->getPropertyValue( props [i].Name ); + + OUString strValue; + sal_Int32 intValue; + bool boolValue; + RectanglePoint pointValue; + + if( value >>= strValue ) + printf ("\"%s\"\n", USS( strValue ) ); + else if( value >>= intValue ) + printf ("%d (hex: %x)\n", intValue, intValue); + else if( value >>= boolValue ) + printf ("%d (bool)\n", boolValue); + else if( value >>= pointValue ) + printf ("%d (RectanglePoint)\n", pointValue); + else + printf ("??? <unhandled type>\n"); + } +} +); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |