diff options
Diffstat (limited to 'oox/inc/oox')
40 files changed, 2418 insertions, 641 deletions
diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index b086538db73e..31e26d38f590 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -49,6 +49,7 @@ namespace com { namespace sun { namespace star { namespace frame { class XModel; } namespace task { class XStatusIndicator; } namespace task { class XInteractionHandler; } + namespace frame { class XFrame; } namespace io { class XInputStream; } namespace io { class XOutputStream; } namespace io { class XStream; } @@ -123,6 +124,10 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getModelFactory() const; + /** Returns the frame that will contain the document model. */ + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& + getTargetFrame() const; + /** Returns the status indicator (may be null). */ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& getStatusIndicator() const; @@ -145,12 +150,12 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate + @param bCreateMissing True = create missing sub storages (for export filters). */ StorageRef openSubStorage( const ::rtl::OUString& rStorageName, - bool bCreate ) const; + bool bCreateMissing ) const; /** Opens and returns the specified input stream from the base storage. @@ -189,20 +194,6 @@ public: /** Returns a helper for the handling of OLE obejcts. */ ::oox::ole::OleObjectHelper& getOleObjectHelper() const; - /** Returns information about the output device. */ - const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; - /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelX( double fPixelX ) const; - /** Converts the passed value from vertical screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelY( double fPixelY ) const; - - /** Returns a system color specified by the passed XML token identifier. */ - sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; - /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - /** Derived classes may implement to resolve a palette index to an RGB color. */ - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - /** Requests a password from the media descriptor or from the user. On success, the password will be inserted into the media descriptor. */ ::rtl::OUString requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const; @@ -282,6 +273,10 @@ private: void setMediaDescriptor( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq ); + /** Derived classes may create a specialized graphic helper, e.g. for + resolving palette colors. */ + virtual GraphicHelper* implCreateGraphicHelper() const; + virtual ::rtl::OUString implGetImplementationName() const = 0; virtual StorageRef implCreateStorage( diff --git a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx index e38311394046..0b5a7f6374a4 100644 --- a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx +++ b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx @@ -2,14 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: chartdrawingfragment.hxx,v $ - * - * $Revision: 1.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/oox/inc/oox/drawingml/color.hxx b/oox/inc/oox/drawingml/color.hxx index 830959b77db9..51e9501205cf 100644 --- a/oox/inc/oox/drawingml/color.hxx +++ b/oox/inc/oox/drawingml/color.hxx @@ -35,7 +35,7 @@ #include <rtl/ustring.hxx> #include "oox/helper/helper.hxx" -namespace oox { namespace core { class FilterBase; } } +namespace oox { class GraphicHelper; } namespace oox { namespace drawingml { @@ -90,7 +90,7 @@ public: bool isPlaceHolder() const { return meMode == COLOR_PH; } /** Returns the final RGB color value. @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ - sal_Int32 getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; + sal_Int32 getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Returns true, if the color has a transparence set. */ bool hasTransparence() const; diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx index 4e4b82cd5acd..44e91d6e797b 100644 --- a/oox/inc/oox/drawingml/customshapeproperties.hxx +++ b/oox/inc/oox/drawingml/customshapeproperties.hxx @@ -43,9 +43,7 @@ #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> -#ifndef __com_sun_star_beans_PropertyValues_hpp__ #include <com/sun/star/beans/PropertyValues.hpp> -#endif #include <com/sun/star/drawing/ProjectionMode.hpp> #include <com/sun/star/drawing/XShape.hpp> @@ -69,8 +67,7 @@ public: virtual ~CustomShapeProperties(); void apply( const CustomShapePropertiesPtr& ); - void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, - const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, + void pushToPropSet( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; void setShapePresetType( const rtl::OUString& rShapePresetType ){ maShapePresetType = rShapePresetType; }; diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index be6561c970d3..42457e6f4dde 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -35,6 +35,7 @@ #include "oox/helper/helper.hxx" namespace oox { + class GraphicHelper; class ModelObjectHelper; class PropertyMap; class PropertySet; @@ -156,8 +157,8 @@ struct FillProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -165,8 +166,8 @@ struct FillProperties /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -184,13 +185,13 @@ struct GraphicProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/drawingml/lineproperties.hxx b/oox/inc/oox/drawingml/lineproperties.hxx index 9a538db30156..0f034a89f65b 100644 --- a/oox/inc/oox/drawingml/lineproperties.hxx +++ b/oox/inc/oox/drawingml/lineproperties.hxx @@ -104,16 +104,16 @@ struct LineProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property map. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/dump/biffdumper.hxx b/oox/inc/oox/dump/biffdumper.hxx index 5a7e390d19a4..e9016fdf0b2b 100644 --- a/oox/inc/oox/dump/biffdumper.hxx +++ b/oox/inc/oox/dump/biffdumper.hxx @@ -217,7 +217,7 @@ protected: void dumpDffClientRect(); void dumpEmbeddedDff(); - void dumpOcxControl(); + void dumpControl(); private: typedef ::boost::shared_ptr< BiffSharedData > BiffSharedDataRef; @@ -242,7 +242,7 @@ void BiffObjectBase::writeRectItem( const String& rName, Type nLeft, Type nTop, Type nWidth, Type nHeight, const NameListWrapper& rListWrp, FormatType eFmtType ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeValueItem( "x-pos", nLeft, eFmtType, rListWrp ); writeValueItem( "y-pos", nTop, eFmtType, rListWrp ); @@ -508,6 +508,10 @@ protected: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); }; // ============================================================================ diff --git a/oox/inc/oox/dump/dumperbase.hxx b/oox/inc/oox/dump/dumperbase.hxx index ecca5751c16c..f65eeceebf27 100644 --- a/oox/inc/oox/dump/dumperbase.hxx +++ b/oox/inc/oox/dump/dumperbase.hxx @@ -61,6 +61,7 @@ namespace comphelper { namespace oox { class BinaryOutputStream; + class TextInputStream; } namespace oox { namespace core { @@ -576,43 +577,41 @@ protected: // ============================================================================ // ============================================================================ -typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > ConfigInputStreamRef; - class ConfigItemBase { public: virtual ~ConfigItemBase(); - void readConfigBlock( const ConfigInputStreamRef& rxStrm ); + void readConfigBlock( TextInputStream& rStrm ); protected: inline explicit ConfigItemBase() {} virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); void readConfigBlockContents( - const ConfigInputStreamRef& rxStrm ); + TextInputStream& rStrm ); private: enum LineType { LINETYPE_DATA, LINETYPE_END }; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, ::rtl::OUString& orKey, ::rtl::OUString& orData ) const; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm ) const; + TextInputStream& rStrm ) const; void processConfigItem( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); }; @@ -673,12 +672,12 @@ protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); @@ -721,7 +720,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -750,7 +749,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -777,7 +776,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -917,14 +916,14 @@ public: protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); private: bool readConfigFile( const ::rtl::OUString& rFileUrl ); template< typename ListType > - void readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ); + void readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ); void createShortList( const ::rtl::OUString& rData ); void createUnitConverter( const ::rtl::OUString& rData ); @@ -960,11 +959,11 @@ template< typename ListType > } template< typename ListType > -void SharedConfigData::readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ) +void SharedConfigData::readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ) { NameListRef xList = createNameList< ListType >( rListName ); if( xList.get() ) - xList->readConfigBlock( rxStrm ); + xList->readConfigBlock( rStrm ); } // ============================================================================ @@ -1182,7 +1181,7 @@ typedef ::boost::shared_ptr< Output > OutputRef; class IndentGuard { public: - inline explicit IndentGuard( Output& rOut ) : mrOut( rOut ) { mrOut.incIndent(); } + inline explicit IndentGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.incIndent(); } inline ~IndentGuard() { mrOut.decIndent(); } private: IndentGuard( const IndentGuard& ); @@ -1196,17 +1195,17 @@ private: class TableGuard { public: - inline explicit TableGuard( Output& rOut, sal_Int32 nW1 ) : - mrOut( rOut ) { mrOut.startTable( nW1 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } - inline explicit TableGuard( Output& rOut, size_t nColCount, + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } + inline explicit TableGuard( const OutputRef& rxOut, size_t nColCount, const sal_Int32* pnColWidths ) : - mrOut( rOut ) { mrOut.startTable( nColCount, pnColWidths ); } + mrOut( *rxOut ) { mrOut.startTable( nColCount, pnColWidths ); } inline ~TableGuard() { mrOut.endTable(); } inline void tab() { mrOut.tab(); } inline void tab( size_t nCol ) { mrOut.tab( nCol ); } @@ -1222,8 +1221,8 @@ private: class ItemGuard { public: - inline explicit ItemGuard( Output& rOut, const String& rName = EMPTY_STRING ) : - mrOut( rOut ) { mrOut.startItem( rName ); } + inline explicit ItemGuard( const OutputRef& rxOut, const String& rName = EMPTY_STRING ) : + mrOut( *rxOut ) { mrOut.startItem( rName ); } inline ~ItemGuard() { mrOut.endItem(); } inline void cont() { mrOut.contItem(); } private: @@ -1238,7 +1237,7 @@ private: class MultiItemsGuard { public: - inline explicit MultiItemsGuard( Output& rOut ) : mrOut( rOut ) { mrOut.startMultiItems(); } + inline explicit MultiItemsGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.startMultiItems(); } inline ~MultiItemsGuard() { mrOut.endMultiItems(); } private: MultiItemsGuard( const MultiItemsGuard& ); @@ -1280,7 +1279,8 @@ class ObjectBase : public Base public: virtual ~ObjectBase(); - inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxConfig->getFactory(); } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& + getFactory() const { return mxConfig->getFactory(); } void dump(); @@ -1333,6 +1333,10 @@ protected: const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); + void addPreferredStream( const String& rStrmName ); void addPreferredStorage( const String& rStrgPath ); @@ -1355,7 +1359,7 @@ private: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rItemName, - const ::rtl::OUString& rSysOutPath, + const ::rtl::OUString& rSysPath, bool bIsStrg, bool bIsStrm ); private: @@ -1397,10 +1401,6 @@ protected: // ------------------------------------------------------------------------ - inline Output& out() const { return *mxOut; } - - // ------------------------------------------------------------------------ - void writeEmptyItem( const String& rName ); void writeInfoItem( const String& rName, const String& rData ); void writeCharItem( const String& rName, sal_Unicode cData ); @@ -1451,7 +1451,7 @@ protected: template< typename Type > void writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' ); -private: +protected: OutputRef mxOut; }; @@ -1472,14 +1472,14 @@ void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWr template< typename Type > void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeName( cfg(), nData, rListWrp ); } template< typename Type > void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); addNameToItem( nData, rListWrp ); } @@ -1487,7 +1487,7 @@ void OutputObjectBase::writeDecItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1495,7 +1495,7 @@ void OutputObjectBase::writeHexItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeShortHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1503,7 +1503,7 @@ void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const template< typename Type > void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeBin( nData ); addNameToItem( nData, rListWrp ); } @@ -1511,7 +1511,7 @@ void OutputObjectBase::writeBinItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeFix( nData ); addNameToItem( nData, rListWrp ); } @@ -1519,7 +1519,7 @@ void OutputObjectBase::writeFixItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); aItem.cont(); mxOut->writeBool( nData != 0 ); @@ -1533,7 +1533,7 @@ void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatTy writeDecBoolItem( rName, nData, rListWrp ); else { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeValue( nData, eFmtType ); addNameToItem( nData, rListWrp ); } @@ -1549,7 +1549,7 @@ void OutputObjectBase::writeValueItem( const ItemFormat& rItemFmt, Type nData ) template< typename Type > void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData1 ); mxOut->writeChar( cSep ); mxOut->writeDec( nData2 ); @@ -1558,7 +1558,7 @@ void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type template< typename Type > void OutputObjectBase::writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData1 ); mxOut->writeChar( cSep ); mxOut->writeHex( nData2 ); @@ -1586,7 +1586,6 @@ protected: // ------------------------------------------------------------------------ - inline BinaryInputStream& in() const { return *mxStrm; } ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > getXInputStream() const; @@ -1655,7 +1654,7 @@ protected: template< typename Type > void dumpHexPair( const String& rName, sal_Unicode cSep = ',' ); -private: +protected: BinaryInputStreamRef mxStrm; }; @@ -1822,16 +1821,12 @@ public: rtl_TextEncoding eTextEnc ); protected: + virtual bool implIsValid() const; virtual void implDump(); virtual void implDumpLine( const ::rtl::OUString& rLine, sal_uInt32 nLine ); private: - bool readCharLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readUcs2Line( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - -private: - rtl_TextEncoding meTextEnc; + ::boost::shared_ptr< TextInputStream > mxTextStrm; }; // ============================================================================ diff --git a/oox/inc/oox/dump/oledumper.hxx b/oox/inc/oox/dump/oledumper.hxx index 539ca2a412d1..a0e9cd55e337 100644 --- a/oox/inc/oox/dump/oledumper.hxx +++ b/oox/inc/oox/dump/oledumper.hxx @@ -43,7 +43,26 @@ namespace dump { // ============================================================================ // ============================================================================ -class StdFontObject : public InputObjectBase +class OleInputObjectBase : public InputObjectBase +{ +protected: + inline explicit OleInputObjectBase() {} + + ::rtl::OUString dumpAnsiString32( const String& rName ); + ::rtl::OUString dumpUniString32( const String& rName ); + + sal_Int32 dumpStdClipboardFormat( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpAnsiString32OrStdClip( const String& rName ); + ::rtl::OUString dumpUniString32OrStdClip( const String& rName ); + + void writeOleColorItem( const String& rName, sal_uInt32 nColor ); + sal_uInt32 dumpOleColor( const String& rName ); +}; + +// ============================================================================ +// ============================================================================ + +class StdFontObject : public OleInputObjectBase { public: explicit StdFontObject( const InputObjectBase& rParent ); @@ -54,7 +73,7 @@ protected: // ============================================================================ -class StdPicObject : public InputObjectBase +class StdPicObject : public OleInputObjectBase { public: explicit StdPicObject( const InputObjectBase& rParent ); @@ -65,7 +84,7 @@ protected: // ============================================================================ -class StdHlinkObject : public InputObjectBase +class StdHlinkObject : public OleInputObjectBase { public: explicit StdHlinkObject( const InputObjectBase& rParent ); @@ -87,7 +106,27 @@ private: // ============================================================================ // ============================================================================ -class OlePropertyStreamObject : public BinaryStreamObject +class OleStreamObject : public OleInputObjectBase +{ +public: + explicit OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ + +class OleCompObjObject : public OleStreamObject +{ +public: + explicit OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + +protected: + virtual void implDump(); +}; + +// ============================================================================ +// ============================================================================ + +class OlePropertyStreamObject : public InputObjectBase { public: explicit OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); @@ -146,35 +185,140 @@ protected: // ============================================================================ // ============================================================================ -struct OcxFormSiteInfo +class ComCtlObjectBase : public OleInputObjectBase { - ::rtl::OUString maProgId; - sal_Int32 mnId; - sal_uInt32 mnLength; - bool mbInStream; +protected: + explicit ComCtlObjectBase( + const InputObjectBase& rParent, + sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual void implDump(); + virtual void implDumpProperties() = 0; + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); + +private: + bool dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor = SAL_MAX_UINT16, sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + bool dumpComCtlSize(); + bool dumpComCtlData( sal_uInt32& ornCommonPartSize ); + bool dumpComCtlCommon( sal_uInt32 nPartSize ); + bool dumpComCtlComplex(); - inline explicit OcxFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +protected: + sal_uInt32 mnDataId5; + sal_uInt32 mnDataId6; + sal_uInt16 mnVersion; + bool mbCommonPart; + bool mbComplexPart; }; -typedef ::std::vector< OcxFormSiteInfo > OcxFormSiteInfoVector; +// ============================================================================ -// ---------------------------------------------------------------------------- +class ComCtlScrollBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); -struct OcxFormSharedData +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlProgressBarObject : public ComCtlObjectBase { - OUStringVector maClassInfoProgIds; - OcxFormSiteInfoVector maSiteInfos; +public: + explicit ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlSliderObject : public ComCtlObjectBase +{ +public: + explicit ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); }; // ============================================================================ + +class ComCtlUpDownObject : public ComCtlObjectBase +{ +public: + explicit ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + // ============================================================================ -class OcxPropertyObjectBase : public InputObjectBase +class ComCtlImageListObject : public ComCtlObjectBase { +public: + explicit ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + protected: - inline explicit OcxPropertyObjectBase() {} + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; + +// ============================================================================ + +class ComCtlTabStripObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); +}; + +// ============================================================================ + +class ComCtlTreeViewObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + +private: + sal_uInt32 mnStringFlags; +}; + +// ============================================================================ + +class ComCtlStatusBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; - using InputObjectBase::construct; +// ============================================================================ +// ============================================================================ + +class AxPropertyObjectBase : public OleInputObjectBase +{ +protected: + inline explicit AxPropertyObjectBase() {} + + using OleInputObjectBase::construct; void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, @@ -213,19 +357,19 @@ protected: inline bool dumpBoolProperty() { return startNextProperty(); } inline sal_Int32 dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); } - inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-MOUSEPTR" ); } + inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OLE-MOUSEPTR" ); } template< typename Type > - inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-BORDERSTYLE" ); } + inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-BORDERSTYLE" ); } template< typename Type > - inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-SPECIALEFFECT" ); } - inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "OCX-ENABLED" ); } - inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "OCX-ORIENTATION" ); } - inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "OCX-CONV-MS" ); } - inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "OCX-IMAGEPOS" ); } - inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-IMAGESIZEMODE" ); } - inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "OCX-IMAGEALIGN" ); } - - sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "OCX-FLAGS" ); + inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-SPECIALEFFECT" ); } + inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "AX-ENABLED" ); } + inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "AX-ORIENTATION" ); } + inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "AX-CONV-MS" ); } + inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "AX-IMAGEPOS" ); } + inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "AX-IMAGESIZEMODE" ); } + inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "AX-IMAGEALIGN" ); } + + sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "AX-FLAGS" ); sal_uInt32 dumpColorProperty( sal_uInt32 nDefault ); sal_Unicode dumpUnicodeProperty(); void dumpUnknownProperty(); @@ -241,7 +385,7 @@ protected: void dumpToPosition( sal_Int64 nPos ); private: - void constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ); + void constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags ); void dumpVersion(); ::rtl::OUString dumpString( const String& rName, sal_uInt32 nSize, bool bArray ); @@ -285,13 +429,13 @@ private: // ---------------------------------------------------------------------------- template< typename Type > -void OcxPropertyObjectBase::alignInput() +void AxPropertyObjectBase::alignInput() { - in().skip( (sizeof( Type ) - ((in().tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); + mxStrm->skip( (sizeof( Type ) - ((mxStrm->tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); } template< typename Type > -Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -302,7 +446,7 @@ Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrappe } template< typename Type > -Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -314,10 +458,10 @@ Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrappe // ============================================================================ -class OcxCFontNewObject : public OcxPropertyObjectBase +class AxCFontNewObject : public AxPropertyObjectBase { public: - explicit OcxCFontNewObject( const InputObjectBase& rParent ); + explicit AxCFontNewObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -325,10 +469,10 @@ protected: // ============================================================================ -class OcxColumnInfoObject : public OcxPropertyObjectBase +class AxColumnInfoObject : public AxPropertyObjectBase { public: - explicit OcxColumnInfoObject( const InputObjectBase& rParent ); + explicit AxColumnInfoObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -336,10 +480,10 @@ protected: // ============================================================================ -class OcxCommandButtonObject : public OcxPropertyObjectBase +class AxCommandButtonObject : public AxPropertyObjectBase { public: - explicit OcxCommandButtonObject( const InputObjectBase& rParent ); + explicit AxCommandButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -348,10 +492,10 @@ protected: // ============================================================================ -class OcxMorphControlObject : public OcxPropertyObjectBase +class AxMorphControlObject : public AxPropertyObjectBase { public: - explicit OcxMorphControlObject( const InputObjectBase& rParent ); + explicit AxMorphControlObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -367,10 +511,10 @@ private: // ============================================================================ -class OcxLabelObject : public OcxPropertyObjectBase +class AxLabelObject : public AxPropertyObjectBase { public: - explicit OcxLabelObject( const InputObjectBase& rParent ); + explicit AxLabelObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -379,10 +523,10 @@ protected: // ============================================================================ -class OcxImageObject : public OcxPropertyObjectBase +class AxImageObject : public AxPropertyObjectBase { public: - explicit OcxImageObject( const InputObjectBase& rParent ); + explicit AxImageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -390,10 +534,10 @@ protected: // ============================================================================ -class OcxScrollBarObject : public OcxPropertyObjectBase +class AxScrollBarObject : public AxPropertyObjectBase { public: - explicit OcxScrollBarObject( const InputObjectBase& rParent ); + explicit AxScrollBarObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -401,10 +545,10 @@ protected: // ============================================================================ -class OcxSpinButtonObject : public OcxPropertyObjectBase +class AxSpinButtonObject : public AxPropertyObjectBase { public: - explicit OcxSpinButtonObject( const InputObjectBase& rParent ); + explicit AxSpinButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -412,10 +556,10 @@ protected: // ============================================================================ -class OcxTabStripObject : public OcxPropertyObjectBase +class AxTabStripObject : public AxPropertyObjectBase { public: - explicit OcxTabStripObject( const InputObjectBase& rParent ); + explicit AxTabStripObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -426,181 +570,188 @@ private: }; // ============================================================================ +// ============================================================================ -class OcxControlObject : public InputObjectBase +class FormControlStreamObject : public OleInputObjectBase { public: - explicit OcxControlObject( - const InputObjectBase& rParent, - const ::rtl::OUString& rProgId, - sal_Int64 nLength ); + explicit FormControlStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + const ::rtl::OUString* pProgId = 0 ); + explicit FormControlStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString* pProgId = 0 ); protected: virtual void implDump(); private: + void constructFormCtrlStrmObj( const ::rtl::OUString* pProgId ); + +private: ::rtl::OUString maProgId; - sal_Int64 mnLength; + bool mbReadGuid; }; // ============================================================================ +// ============================================================================ -class OcxGuidControlObject : public InputObjectBase +struct VbaFormSiteInfo { -public: - explicit OcxGuidControlObject( - const InputObjectBase& rParent, - sal_Int64 nLength ); - explicit OcxGuidControlObject( - const OutputObjectBase& rParent, - const BinaryInputStreamRef& rxStrm ); - explicit OcxGuidControlObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName ); + ::rtl::OUString maProgId; + sal_Int32 mnId; + sal_uInt32 mnLength; + bool mbInStream; -protected: - virtual void implDump(); + inline explicit VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +}; -private: - sal_Int64 mnLength; +typedef ::std::vector< VbaFormSiteInfo > VbaFormSiteInfoVector; + +// ============================================================================ + +struct VbaFormSharedData +{ + OUStringVector maClassInfoProgIds; + VbaFormSiteInfoVector maSiteInfos; }; // ============================================================================ -class OcxControlsStreamObject : public InputObjectBase +class VbaFormClassInfoObject : public AxPropertyObjectBase { public: - explicit OcxControlsStreamObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + explicit VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; // ============================================================================ -// ============================================================================ -class OcxPageObject : public OcxPropertyObjectBase +class VbaFormSiteObject : public AxPropertyObjectBase { public: - explicit OcxPageObject( const InputObjectBase& rParent ); + explicit VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: virtual void implDumpShortProperties(); + +private: + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxMultiPageObject : public OcxPropertyObjectBase +class VbaFormDesignExtObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageObject( const InputObjectBase& rParent ); + explicit VbaFormDesignExtObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - sal_Int32 mnPageCount; }; // ============================================================================ -class OcxMultiPageStreamObject : public InputObjectBase +class VbaFStreamObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageStreamObject( + explicit VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + void dumpClassInfos(); + void dumpFormSites( sal_uInt32 nCount ); + void dumpSiteData(); + void dumpDesignExtender(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; + sal_uInt32 mnFlags; }; // ============================================================================ -// ============================================================================ -class OcxFormClassInfoObject : public OcxPropertyObjectBase +class VbaOStreamObject : public OleInputObjectBase { public: - explicit OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaOStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormSiteObject : public OcxPropertyObjectBase +class VbaPageObject : public AxPropertyObjectBase { public: - explicit OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - -private: - OcxFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormDesignExtObject : public OcxPropertyObjectBase +class VbaMultiPageObject : public AxPropertyObjectBase { public: - explicit OcxFormDesignExtObject( const InputObjectBase& rParent ); + explicit VbaMultiPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + sal_Int32 mnPageCount; }; // ============================================================================ -class OcxFormObject : public OcxPropertyObjectBase +class VbaXStreamObject : public InputObjectBase { public: - explicit OcxFormObject( + explicit VbaXStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - void dumpClassInfos(); - void dumpFormSites( sal_uInt32 nCount ); - void dumpSiteData(); - void dumpDesignExtender(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; - sal_uInt32 mnFlags; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormStorageObject : public OleStorageObject +class VbaContainerStorageObject : public OleStorageObject { public: - explicit OcxFormStorageObject( + explicit VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); @@ -621,7 +772,7 @@ private: bool isFormStorage( const ::rtl::OUString& rStrgPath ) const; private: - OcxFormSharedData maFormData; + VbaFormSharedData maFormData; }; // ============================================================================ @@ -713,7 +864,7 @@ private: // ============================================================================ -class VbaFormStorageObject : public OcxFormStorageObject +class VbaFormStorageObject : public VbaContainerStorageObject { public: explicit VbaFormStorageObject( @@ -759,6 +910,23 @@ private: // ============================================================================ // ============================================================================ +class ActiveXStorageObject : public VbaContainerStorageObject +{ +public: + explicit ActiveXStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath ); + +protected: + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ +// ============================================================================ + } // namespace dump } // namespace oox diff --git a/oox/inc/oox/dump/xlsbdumper.hxx b/oox/inc/oox/dump/xlsbdumper.hxx index 95723f6b8d4e..345202f67a4a 100644 --- a/oox/inc/oox/dump/xlsbdumper.hxx +++ b/oox/inc/oox/dump/xlsbdumper.hxx @@ -98,7 +98,7 @@ private: private: typedef ::boost::shared_ptr< RecordInputStream > RecordInputStreamRef; - RecordInputStreamRef mxStrm; + RecordInputStreamRef mxBiffStrm; NameListRef mxErrCodes; }; diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx index 19933ca03c04..8f58e2de4d9e 100644 --- a/oox/inc/oox/helper/binaryinputstream.hxx +++ b/oox/inc/oox/helper/binaryinputstream.hxx @@ -34,6 +34,8 @@ namespace oox { +class BinaryOutputStream; + // ============================================================================ /** Interface for binary input stream classes. @@ -108,6 +110,8 @@ public: False = NUL characters are replaced by question marks (default). */ ::rtl::OUString readUnicodeArray( sal_Int32 nChars, bool bAllowNulChars = false ); + /** Copies nBytes bytes from the current position to the passed output stream. */ + void copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); private: /** Used by the readValue() template functions to read built-in types. @@ -216,6 +220,71 @@ typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef; // ============================================================================ +/** Wraps a BinaryInputStream and provides access to a specific part of the + stream data. + + @descr + Provides access to the stream data block starting at the current + position of the stream, and with a specific length. If the wrapped + stream is seekable, this wrapper will treat the position the wrapped + has at construction time as position "0" (therefore the class name). + */ +class RelativeInputStream : public BinaryInputStream +{ +public: + /** Constructs the wrapper object for the passed stream. + + @attention + The passed input stream MUST live at least as long as this stream + wrapper. The stream MUST NOT be changed from outside as long as + this stream wrapper is used to read from it. + + @param nLength + If specified, restricts the amount of data that can be read from + the passed input stream. + */ + explicit RelativeInputStream( + BinaryInputStream& rInStrm, + sal_Int64 nLength = SAL_MAX_INT64 ); + + /** Returns whether the wrapped stream is seekable. */ + virtual bool isSeekable() const; + /** Returns the size of the data block in the wrapped stream offered by + this wrapper. */ + virtual sal_Int64 getLength() const; + /** Returns the current relative stream position. */ + virtual sal_Int64 tell() const; + /** Seeks the stream to the passed relative position, if the wrapped stream + is seekable. */ + virtual void seek( sal_Int64 nPos ); + + /** Reads nBytes bytes to the passed sequence. Does not read out of the + data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. Does not read out of + the data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. This works for + non-seekable streams too. Does not seek out of the data block. */ + virtual void skip( sal_Int32 nBytes ); + + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline RelativeInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + +private: + BinaryInputStream& mrInStrm; + sal_Int64 mnStartPos; + sal_Int64 mnRelPos; + sal_Int64 mnLength; +}; + +typedef ::boost::shared_ptr< RelativeInputStream > RelativeInputStreamRef; + +// ============================================================================ + } // namespace oox #endif diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx index b229dbd18901..d2f0f8b36ffa 100644 --- a/oox/inc/oox/helper/binaryoutputstream.hxx +++ b/oox/inc/oox/helper/binaryoutputstream.hxx @@ -34,8 +34,6 @@ namespace oox { -class BinaryInputStream; - // ============================================================================ /** Interface for binary output stream classes. @@ -50,9 +48,6 @@ public: /** Derived classes implement writing from the (existing) buffer pMem. */ virtual void writeMemory( const void* pMem, sal_Int32 nBytes ) = 0; - /** Copies nBytes bytes from the current position of the passed input stream. */ - void copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); - /** Writes a value to the stream and converts it to platform byte order. Supported types: SAL integers (8 to 64 bit), float, double. */ template< typename Type > diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 18d868660faa..abe4c5f1c274 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -38,7 +38,8 @@ typedef ::com::sun::star::uno::Sequence< sal_Int8 > StreamDataSequence; // ============================================================================ -/** Base interface for seekable binary stream classes. */ +/** Base interface for binary stream classes. Implemenetations may or may not + support seeking the stream. */ class BinaryStreamBase { public: @@ -46,11 +47,14 @@ public: /** Derived classes return whether the stream is seekable. Default: false. */ virtual bool isSeekable() const; - /** Derived classes returns the size of the stream, if seekable, otherwise/default: -1. */ + /** Derived classes return the size of the stream, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 getLength() const; - /** Derived classes return the current stream position, if seekable, otherwise/default: -1. */ + /** Derived classes return the current stream position, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 tell() const; - /** Derived classes implement seeking the stream to the passed position, if seekable. */ + /** Derived classes implement seeking the stream to the passed position, if + the stream is seekable. */ virtual void seek( sal_Int64 nPos ); /** Returns true, if the stream position is invalid (EOF). This flag turns @@ -63,6 +67,9 @@ public: inline void seekToStart() { seek( 0 ); } /** Seeks the stream to the end, if stream is seekable. */ inline void seekToEnd() { seek( getLength() ); } + /** Seeks the stream forward to a position that is a multiple of the passed + block size, relative to the passed stream position, if stream is seekable. */ + void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); protected: inline explicit BinaryStreamBase() : mbEof( false ) {} diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index a077c667ae4c..f4f3717eac3f 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -84,34 +84,86 @@ public: Does *not* check whether the last element is an empty reference. */ inline sal_Int32 getLastIndex() const { return static_cast< sal_Int32 >( this->size() ) - 1; } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > - inline void forEach( const FunctorType& rFunctor ) const + inline void forEach( FunctorType aFunctor ) const { - ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); + ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( aFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } + + /** Calls the passed functor for every contained object. Passes the index as + first argument and the object reference as second argument to rFunctor. */ + template< typename FunctorType > + inline void forEachWithIndex( const FunctorType& rFunctor ) const + { + ::std::for_each( this->begin(), this->end(), ForEachFunctorWithIndex< FunctorType >( rFunctor ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index to the member function. */ + template< typename FuncType > + inline void forEachMemWithIndex( FuncType pFunc ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType > + inline void forEachMemWithIndex( FuncType pFunc, ParamType aParam ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + /** Searches for an element by using the passed functor that takes a constant reference of the object type (const ObjType&). */ template< typename FunctorType > @@ -125,17 +177,26 @@ private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rxValue ) const { if( rxValue.get() ) mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( *rxValue ); } + }; + + template< typename FunctorType > + struct ForEachFunctorWithIndex + { + FunctorType maFunctor; + sal_Int32 mnIndex; + inline explicit ForEachFunctorWithIndex( const FunctorType& rFunctor ) : maFunctor( rFunctor ), mnIndex( 0 ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( mnIndex, *rxValue ); ++mnIndex; } }; template< typename FunctorType > struct FindFunctor { - const FunctorType& mrFunctor; - inline explicit FindFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline bool operator()( const value_type& rxValue ) const { return rxValue.get() && mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit FindFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline bool operator()( const value_type& rxValue ) { return rxValue.get() && maFunctor( *rxValue ); } }; inline const value_type* getRef( sal_Int32 nIndex ) const @@ -173,41 +234,53 @@ public: return pxRef && pxRef->get(); } - /** Returns a reference to the object accossiated to the passed key, or 0 on error. */ + /** Returns a reference to the object accossiated to the passed key, or an + empty reference on error. */ inline mapped_type get( key_type nKey ) const { if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef; return mapped_type(); } - /** Calls the passed functor for every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > inline void forEach( const FunctorType& rFunctor ) const { ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } /** Calls the passed functor for every contained object. Passes the key as first argument and the object reference as second argument to rFunctor. */ template< typename FunctorType > @@ -240,21 +313,29 @@ public: forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object. + Passes the object key as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithKey( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( *rValue.second ); } }; template< typename FunctorType > struct ForEachFunctorWithKey { - const FunctorType& mrFunctor; - inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( rValue.first, *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( rValue.first, *rValue.second ); } }; inline const mapped_type* getRef( key_type nKey ) const @@ -453,7 +534,7 @@ public: /** Returns the reference to an existing element of the passed vector, or the passed default value, if the passed index is out of bounds. */ template< typename Type > - static Type& getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); + static Type& getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); /** Returns the pointer to an existing element of the passed map, or a null pointer, if an element with the passed key does not exist. */ @@ -522,7 +603,7 @@ const Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVec } template< typename Type > -Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) +Type& ContainerHelper::getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) { return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault; } diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index d6e01d0fff6b..2d0964b37715 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -29,24 +29,31 @@ #define OOX_HELPER_GRAPHICHELPER_HXX #include <deque> +#include <map> #include <rtl/ustring.hxx> +#include <com/sun/star/awt/DeviceInfo.hpp> #include <com/sun/star/uno/Reference.hxx> #include "oox/helper/binarystreambase.hxx" namespace com { namespace sun { namespace star { - namespace uno { class XComponentContext; } - namespace lang { class XMultiServiceFactory; } + namespace awt { struct Point; } + namespace awt { struct Size; } + namespace awt { class XUnitConversion; } namespace io { class XInputStream; } + namespace frame { class XFrame; } namespace graphic { class XGraphic; } namespace graphic { class XGraphicObject; } namespace graphic { class XGraphicProvider; } + namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } } } } namespace oox { // ============================================================================ -/** Provides helper functions for graphics and graphic objects handling. +/** Provides helper functions for colors, device measurement conversion, + graphics, and graphic objects handling. All createGraphicObject() and importGraphicObject() functions create persistent graphic objects internally and store them in an internal @@ -60,39 +67,84 @@ class GraphicHelper { public: explicit GraphicHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); - ~GraphicHelper(); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxTargetFrame ); + virtual ~GraphicHelper(); + + /** Returns a system color specified by the passed XML token identifier. */ + sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; + + /** Returns information about the output device. */ + const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; + + /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const; + /** Converts the passed value from vertical screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const; + /** Converts the passed point from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Point convertScreenPixelToHmm( const ::com::sun::star::awt::Point& rPixel ) const; + /** Converts the passed size from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Size convertScreenPixelToHmm( const ::com::sun::star::awt::Size& rPixel ) const; + + /** Converts the passed value from 1/100 mm to horizontal screen pixels. */ + double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const; + /** Converts the passed value from 1/100 mm to vertical screen pixels. */ + double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const; + /** Converts the passed point from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Point convertHmmToScreenPixel( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Size convertHmmToScreenPixel( const ::com::sun::star::awt::Size& rHmm ) const; + + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Point convertAppFontToHmm( const ::com::sun::star::awt::Point& rAppFont ) const; + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Size convertAppFontToHmm( const ::com::sun::star::awt::Size& rAppFont ) const; + + /** Converts the passed point from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Point convertHmmToAppFont( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Size convertHmmToAppFont( const ::com::sun::star::awt::Size& rHmm ) const; /** Imports a graphic from the passed input stream. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > importGraphic( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Imports a graphic from the passed binary memory block. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > - importGraphic( const StreamDataSequence& rGraphicData ); + importGraphic( const StreamDataSequence& rGraphicData ) const; /** Creates a persistent graphic object from the passed graphic. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString createGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); + const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const; /** Creates a persistent graphic object from the passed input stream. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString importGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Creates a persistent graphic object from the passed binary memory block. @return The URL of the created and internally cached graphic object. */ - ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ); + ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ) const; private: + typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > > GraphicObjectDeque; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicProvider > mxGraphicProvider; - GraphicObjectDeque maGraphicObjects; - const ::rtl::OUString maGraphicObjScheme; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion; + ::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info. + SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values. + mutable GraphicObjectDeque maGraphicObjects; /// Caches all created graphic objects to keep them alive. + const ::rtl::OUString maGraphicObjScheme; /// The URL scheme name for graphic objects. + double mfPixelPerHmmX; /// Number of screen pixels per 1/100 mm in X direction. + double mfPixelPerHmmY; /// Number of screen pixels per 1/100 mm in Y direction. }; // ============================================================================ diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx index 5884855bc50d..c68fe9ce83f8 100644 --- a/oox/inc/oox/helper/helper.hxx +++ b/oox/inc/oox/helper/helper.hxx @@ -69,7 +69,29 @@ namespace oox { #define OUSTRING_TO_CSTR( str ) \ ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr() -// ============================================================================ +// Common constants =========================================================== + +const sal_uInt8 WINDOWS_CHARSET_ANSI = 0; +const sal_uInt8 WINDOWS_CHARSET_DEFAULT = 1; +const sal_uInt8 WINDOWS_CHARSET_SYMBOL = 2; +const sal_uInt8 WINDOWS_CHARSET_APPLE_ROMAN = 77; +const sal_uInt8 WINDOWS_CHARSET_SHIFTJIS = 128; +const sal_uInt8 WINDOWS_CHARSET_HANGEUL = 129; +const sal_uInt8 WINDOWS_CHARSET_JOHAB = 130; +const sal_uInt8 WINDOWS_CHARSET_GB2312 = 134; +const sal_uInt8 WINDOWS_CHARSET_BIG5 = 136; +const sal_uInt8 WINDOWS_CHARSET_GREEK = 161; +const sal_uInt8 WINDOWS_CHARSET_TURKISH = 162; +const sal_uInt8 WINDOWS_CHARSET_VIETNAMESE = 163; +const sal_uInt8 WINDOWS_CHARSET_HEBREW = 177; +const sal_uInt8 WINDOWS_CHARSET_ARABIC = 178; +const sal_uInt8 WINDOWS_CHARSET_BALTIC = 186; +const sal_uInt8 WINDOWS_CHARSET_RUSSIAN = 204; +const sal_uInt8 WINDOWS_CHARSET_THAI = 222; +const sal_uInt8 WINDOWS_CHARSET_EASTERN = 238; +const sal_uInt8 WINDOWS_CHARSET_OEM = 255; + +// ---------------------------------------------------------------------------- const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color for API calls. const sal_Int32 API_RGB_BLACK = 0x00000; /// Black color for API calls. diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx index cead2ad74fb1..a9ef27e8cb98 100644 --- a/oox/inc/oox/helper/modelobjecthelper.hxx +++ b/oox/inc/oox/helper/modelobjecthelper.hxx @@ -53,7 +53,7 @@ class ModelObjectHelper { public: explicit ModelObjectHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory ); /** Returns true, if the model contains a line marker with the passed name. */ bool hasLineMarker( const ::rtl::OUString& rMarkerName ) const; diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx index bdb81c6c3e83..a1769374d959 100644 --- a/oox/inc/oox/helper/propertyset.hxx +++ b/oox/inc/oox/helper/propertyset.hxx @@ -92,6 +92,10 @@ public: template< typename Type > inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const; + /** Gets the specified property from the property set. + @return the property value, or an empty Any, if the property is missing. */ + ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const; + /** Gets the specified boolean property from the property set. @return true = property contains true; false = property contains false or error occured. */ bool getBoolProperty( sal_Int32 nPropId ) const; diff --git a/oox/inc/oox/helper/storagebase.hxx b/oox/inc/oox/helper/storagebase.hxx index b23032fe2ac0..5a179e73cf75 100644 --- a/oox/inc/oox/helper/storagebase.hxx +++ b/oox/inc/oox/helper/storagebase.hxx @@ -28,12 +28,8 @@ #ifndef OOX_HELPER_STORAGEBASE_HXX #define OOX_HELPER_STORAGEBASE_HXX -#include <vector> -#include <map> -#include <boost/shared_ptr.hpp> -#include <rtl/ustring.hxx> -#include <com/sun/star/uno/Reference.hxx> -#include <oox/dllapi.h> +#include "oox/dllapi.h" +#include "oox/helper/containerhelper.hxx" namespace com { namespace sun { namespace star { namespace embed { class XStorage; } @@ -71,6 +67,13 @@ public: /** Returns true, if the object represents a valid storage. */ bool isStorage() const; + /** Returns true, if the object represents the root storage. */ + bool isRootStorage() const; + + /** Returns true, if the storage operates in read-only mode (based on an + input stream). */ + bool isReadOnly() const; + /** Returns the com.sun.star.embed.XStorage interface of the current storage. */ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getXStorage() const; @@ -81,7 +84,8 @@ public: /** Returns the full path of this storage. */ ::rtl::OUString getPath() const; - /** Fills the passed vector with the names of all elements of this storage. */ + /** Fills the passed vector with the names of all direct elements of this + storage. */ void getElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. @@ -89,10 +93,11 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate - True = create missing sub storages (for export filters). + @param bCreateMissing + True = create missing sub storages (for export filters). Must be + false for storages based on input streams. */ - StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreate ); + StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. @@ -116,13 +121,27 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > openOutputStream( const ::rtl::OUString& rStreamName ); - /** Commits the changes to the storage and all the substorages. (in case it is transacted object) + /** Copies the specified element from this storage to the passed + destination storage. + + @param rElementName + The name of the embedded storage or stream. The name may contain + slashes to specify an element in an embedded substorage. In this + case, the element will be copied to the same substorage in the + destination storage. */ - void commit(); + void copyToStorage( StorageBase& rDestStrg, const ::rtl::OUString& rElementName ); + + /** Copies all streams of this storage and of all substorages to the passed + destination. */ + void copyStorageToStorage( StorageBase& rDestStrg ); + + /** Commits the changes to the storage and all substorages. */ + void commit(); protected: /** Special constructor for sub storage objects. */ - explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName ); + explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName, bool bReadOnly ); private: StorageBase( const StorageBase& ); @@ -149,19 +168,24 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ) = 0; - StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + /** Commits the current storage. */ + virtual void implCommit() const = 0; + + /** Helper that opens and caches the specified direct substorage. */ + StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); private: - typedef ::std::map< ::rtl::OUString, StorageRef > SubStorageMap; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > XInputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > XStreamRef; + typedef RefMap< ::rtl::OUString, StorageBase > SubStorageMap; SubStorageMap maSubStorages; /// Map of direct sub storages. - XInputStreamRef mxInStream; /// Cached base input stream (to keep it alive). - XStreamRef mxOutStream; /// Cached base output stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + mxInStream; /// Cached base input stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > + mxOutStream; /// Cached base output stream (to keep it alive). + ::rtl::OUString maParentPath; /// Full path of parent storage. ::rtl::OUString maStorageName; /// Name of this storage, if it is a substorage. - const StorageBase* mpParentStorage; /// Parent storage if this is a sub storage. bool mbBaseStreamAccess; /// True = access base streams with empty stream name. + bool mbReadOnly; /// True = storage opened read-only (based on input stream). }; // ============================================================================ @@ -169,4 +193,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/helper/textinputstream.hxx b/oox/inc/oox/helper/textinputstream.hxx new file mode 100755 index 000000000000..1e74825ee713 --- /dev/null +++ b/oox/inc/oox/helper/textinputstream.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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 OOX_HELPER_RECORDINPUTSTREAM_HXX +#define OOX_HELPER_RECORDINPUTSTREAM_HXX + +#include "oox/helper/binaryinputstream.hxx" + +namespace oox { + +// ============================================================================ + +class TextInputStream +{ +public: + explicit TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc ); + + /** Returns true, if the wrapped input stream is in EOF state. */ + bool isEof() const; + /** Reads a text line from the stream. */ + ::rtl::OUString readLine(); + +private: + BinaryInputStream& mrInStrm; + rtl_TextEncoding meTextEnc; + sal_Unicode mcLastEolChar; +}; + +// ============================================================================ + +} // namespace oox + +#endif + diff --git a/oox/inc/oox/helper/zipstorage.hxx b/oox/inc/oox/helper/zipstorage.hxx index b6eef63b47de..0c9a15c10077 100644 --- a/oox/inc/oox/helper/zipstorage.hxx +++ b/oox/inc/oox/helper/zipstorage.hxx @@ -69,7 +69,7 @@ private: virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > @@ -79,6 +79,9 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ); + /** Commits the current storage. */ + virtual void implCommit() const; + private: typedef ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > XStorageRef; @@ -90,4 +93,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axbinaryreader.hxx b/oox/inc/oox/ole/axbinaryreader.hxx index 3db0bae7cee4..d036e958a446 100644..100755 --- a/oox/inc/oox/ole/axbinaryreader.hxx +++ b/oox/inc/oox/ole/axbinaryreader.hxx @@ -28,6 +28,7 @@ #ifndef OOX_OLE_AXBINARYREADER_HXX #define OOX_OLE_AXBINARYREADER_HXX +#include <utility> #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/containerhelper.hxx" @@ -36,15 +37,24 @@ namespace ole { // ============================================================================ -/** A wrapper for an unseekable binary input stream. */ +/** A wrapper for a binary input stream that supports aligned read operations. + + The implementation does not support seeking back the wrapped stream. All + seeking operations (tell, seek, align) are performed relative to the + position of the wrapped stream at construction time of this wrapper. It is + possible to construct this wrapper with an unseekable input stream without + loosing any functionality. + */ class AxAlignedInputStream : public BinaryInputStream { public: explicit AxAlignedInputStream( BinaryInputStream& rInStrm ); - /** Return the current stream position (relative to position at construction time). */ + /** Return the current relative stream position (relative to position of + the wrapped stream at construction time). */ virtual sal_Int64 tell() const; - /** Seeks the stream to the passed position, if it is behind the current position. */ + /** Seeks the stream to the passed relative position, if it is behind the + current position. */ virtual void seek( sal_Int64 nPos ); /** Reads nBytes bytes to the passed sequence. @@ -56,7 +66,8 @@ public: /** Seeks the stream forward by the passed number of bytes. */ virtual void skip( sal_Int32 nBytes ); - /** Aligns the stream to a multiple of the passed size. */ + /** Aligns the stream to a multiple of the passed size (relative to the + position of the wrapped stream at construction time). */ void align( size_t nSize ); /** Aligns the stream according to the passed type and reads an atomar value. */ @@ -73,6 +84,50 @@ private: // ============================================================================ +/** A pair of integer values as a property. */ +typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData; + +// ============================================================================ + +const sal_uInt32 AX_FONTDATA_BOLD = 0x00000001; +const sal_uInt32 AX_FONTDATA_ITALIC = 0x00000002; +const sal_uInt32 AX_FONTDATA_UNDERLINE = 0x00000004; +const sal_uInt32 AX_FONTDATA_STRIKEOUT = 0x00000008; +const sal_uInt32 AX_FONTDATA_DISABLED = 0x00002000; +const sal_uInt32 AX_FONTDATA_AUTOCOLOR = 0x40000000; + +const sal_Int32 AX_FONTDATA_LEFT = 1; +const sal_Int32 AX_FONTDATA_RIGHT = 2; +const sal_Int32 AX_FONTDATA_CENTER = 3; + +/** All entries of a font property. */ +struct AxFontData +{ + ::rtl::OUString maFontName; /// Name of the used font. + sal_uInt32 mnFontEffects; /// Font effect flags. + sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). + sal_Int32 mnFontCharSet; /// Windows character set of the font. + sal_Int32 mnHorAlign; /// Horizontal text alignment. + + explicit AxFontData(); + + /** Converts the internal representation of the font height to points. */ + sal_Int16 getHeightPoints() const; + /** Converts the passed font height from points to the internal representation. */ + void setHeightPoints( sal_Int16 nPoints ); + + /** Reads the font data settings from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream that contains + an OLE StdFont structure. */ + bool importStdFont( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream depending on + the GUID preceding the actual font data. */ + bool importGuidAndFont( BinaryInputStream& rInStrm ); +}; + +// ============================================================================ + /** Import helper to read simple and complex ActiveX form control properties from a binary input stream. */ class AxBinaryPropertyReader @@ -90,10 +145,16 @@ public: void readBoolProperty( bool& orbValue, bool bReverse = false ); /** Reads the next pair property from the stream, if the respective flag in the property mask is set. */ - void readPairProperty( sal_Int32& ornValue1, sal_Int32& ornValue2 ); + void readPairProperty( AxPairData& orPairData ); /** Reads the next string property from the stream, if the respective flag in the property mask is set. */ void readStringProperty( ::rtl::OUString& orValue ); + /** Reads the next GUID property from the stream, if the respective flag + in the property mask is set. The GUID will be enclosed in braces. */ + void readGuidProperty( ::rtl::OUString& orGuid ); + /** Reads the next font property from the stream, if the respective flag in + the property mask is set. */ + void readFontProperty( AxFontData& orFontData ); /** Reads the next picture property from the stream, if the respective flag in the property mask is set. */ void readPictureProperty( StreamDataSequence& orPicData ); @@ -105,9 +166,18 @@ public: /** Skips the next boolean property value in the stream, if the respective flag in the property mask is set. */ inline void skipBoolProperty() { startNextProperty(); } + /** Skips the next pair property in the stream, if the respective flag in + the property mask is set. */ + void skipPairProperty() { readPairProperty( maDummyPairData ); } /** Skips the next string property in the stream, if the respective flag in the property mask is set. */ inline void skipStringProperty() { readStringProperty( maDummyString ); } + /** Skips the next GUID property in the stream, if the respective flag in + the property mask is set. */ + inline void skipGuidProperty() { readGuidProperty( maDummyString ); } + /** Skips the next font property in the stream, if the respective flag in + the property mask is set. */ + inline void skipFontProperty() { readFontProperty( maDummyFontData ); } /** Skips the next picture property in the stream, if the respective flag in the property mask is set. */ inline void skipPictureProperty() { readPictureProperty( maDummyPicData ); } @@ -133,11 +203,10 @@ private: /** Complex property for a 32-bit value pair, e.g. point or size. */ struct PairProperty : public ComplexProperty { - sal_Int32& mrnValue1; - sal_Int32& mrnValue2; + AxPairData& mrPairData; - inline explicit PairProperty( sal_Int32& rnValue1, sal_Int32& rnValue2 ) : - mrnValue1( rnValue1 ), mrnValue2( rnValue2 ) {} + inline explicit PairProperty( AxPairData& rPairData ) : + mrPairData( rPairData ) {} virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; @@ -152,6 +221,26 @@ private: virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; + /** Complex property for a GUID value. */ + struct GuidProperty : public ComplexProperty + { + ::rtl::OUString& mrGuid; + + inline explicit GuidProperty( ::rtl::OUString& rGuid ) : + mrGuid( rGuid ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + /** Stream property for a font structure. */ + struct FontProperty : public ComplexProperty + { + AxFontData& mrFontData; + + inline explicit FontProperty( AxFontData& rFontData ) : + mrFontData( rFontData ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + /** Stream property for a picture or mouse icon. */ struct PictureProperty : public ComplexProperty { @@ -168,6 +257,8 @@ private: AxAlignedInputStream maInStrm; /// The input stream to read from. ComplexPropVector maLargeProps; /// Stores info for all used large properties. ComplexPropVector maStreamProps; /// Stores info for all used stream data properties. + AxPairData maDummyPairData; /// Dummy pair for unsupported properties. + AxFontData maDummyFontData; /// Dummy font for unsupported properties. StreamDataSequence maDummyPicData; /// Dummy picture for unsupported properties. ::rtl::OUString maDummyString; /// Dummy string for unsupported properties. sal_Int64 mnPropFlags; /// Flags specifying existing properties. diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx index b5a5741d134d..7c533334cc49 100644 --- a/oox/inc/oox/ole/axcontrol.hxx +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -28,82 +28,389 @@ #ifndef OOX_OLE_AXCONTROL_HXX #define OOX_OLE_AXCONTROL_HXX -#include <memory> +#include <boost/shared_ptr.hpp> #include "oox/helper/binarystreambase.hxx" +#include "oox/ole/axbinaryreader.hxx" +#include "oox/ole/olehelper.hxx" namespace com { namespace sun { namespace star { namespace awt { class XControlModel; } + namespace container { class XIndexContainer; } + namespace drawing { class XDrawPage; } + namespace form { class XFormsSupplier; } + namespace lang { class XMultiServiceFactory; } } } } namespace oox { class BinaryInputStream; + class GraphicHelper; class PropertyMap; } namespace oox { namespace ole { -class AxControlHelper; +// ============================================================================ + +const sal_Char* const COMCTL_GUID_SCROLLBAR_60 = "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_50 = "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_60 = "{35053A22-8589-11D1-B16A-00C0F0283628}"; + +// ---------------------------------------------------------------------------- + +const sal_Char* const AX_GUID_COMMANDBUTTON = "{D7053240-CE69-11CD-A777-00DD01143C57}"; +const sal_Char* const AX_GUID_LABEL = "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}"; +const sal_Char* const AX_GUID_IMAGE = "{4C599241-6926-101B-9992-00000B65C6F9}"; +const sal_Char* const AX_GUID_TOGGLEBUTTON = "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_CHECKBOX = "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_OPTIONBUTTON = "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_TEXTBOX = "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_LISTBOX = "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_COMBOBOX = "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_SPINBUTTON = "{79176FB0-B7F2-11CE-97EF-00AA006D2776}"; +const sal_Char* const AX_GUID_SCROLLBAR = "{DFD181E0-5E2F-11CE-A449-00AA004A803D}"; +const sal_Char* const AX_GUID_FRAME = "{6E182020-F460-11CE-9BCD-00AA00608E01}"; + +const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; +const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; +const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; +const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; +const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; + +const sal_Int32 AX_BORDERSTYLE_NONE = 0; +const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; + +const sal_Int32 AX_SPECIALEFFECT_FLAT = 0; +const sal_Int32 AX_SPECIALEFFECT_RAISED = 1; +const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2; +const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3; +const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6; + +const sal_Int32 AX_PICSIZE_CLIP = 0; +const sal_Int32 AX_PICSIZE_STRETCH = 1; +const sal_Int32 AX_PICSIZE_ZOOM = 3; + +const sal_Int32 AX_PICALIGN_TOPLEFT = 0; +const sal_Int32 AX_PICALIGN_TOPRIGHT = 1; +const sal_Int32 AX_PICALIGN_CENTER = 2; +const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; +const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; + +// ---------------------------------------------------------------------------- + +/** Enumerates all UNO API control types supported by these filters. */ +enum ApiControlType +{ + API_CONTROL_BUTTON, + API_CONTROL_FIXEDTEXT, + API_CONTROL_IMAGE, + API_CONTROL_CHECKBOX, + API_CONTROL_RADIOBUTTON, + API_CONTROL_EDIT, + API_CONTROL_LISTBOX, + API_CONTROL_COMBOBOX, + API_CONTROL_SPINBUTTON, + API_CONTROL_SCROLLBAR, + API_CONTROL_PROGRESSBAR, + API_CONTROL_GROUPBOX, + API_CONTROL_DIALOG +}; + +// ============================================================================ + +/** Specifies how a form control supports transparent background. */ +enum ApiTransparencyMode +{ + API_TRANSPARENCY_NOTSUPPORTED, /// Control does not support transparency. + API_TRANSPARENCY_VOID, /// Transparency is enabled by missing fill color. + API_TRANSPARENCY_PAINTTRANSPARENT /// Transparency is enabled by the 'PaintTransparent' property. +}; + +/** Specifies how a form control supports the DefaultState property. */ +enum ApiDefaultStateMode +{ + API_DEFAULTSTATE_BOOLEAN, /// Control does not support tri-state, state is given as boolean. + API_DEFAULTSTATE_SHORT, /// Control does not support tri-state, state is given as short. + API_DEFAULTSTATE_TRISTATE /// Control supports tri-state, state is given as short. +}; + +// ---------------------------------------------------------------------------- + +/** A base class with useful helper functions for something that is able to + convert ActiveX and ComCtl form controls. + */ +class ControlConverter +{ +public: + explicit ControlConverter( + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + virtual ~ControlConverter(); + + // Generic conversion ----------------------------------------------------- + + /** Converts the passed position in 1/100 mm to UNO properties. */ + void convertPosition( + PropertyMap& rPropMap, + const AxPairData& rPos ) const; + + /** Converts the passed size in 1/100 mm to UNO properties. */ + void convertSize( + PropertyMap& rPropMap, + const AxPairData& rSize ) const; + + /** Converts the passed encoded OLE color to UNO properties. */ + void convertColor( + PropertyMap& rPropMap, + sal_Int32 nPropId, + sal_uInt32 nOleColor ) const; + + /** Converts the passed StdPic picture stream to UNO properties. */ + void convertPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData ) const; + + /** Converts the control orientation to UNO properties. */ + void convertOrientation( + PropertyMap& rPropMap, + bool bHorizontal ) const; + + /** Converts common scrollbar settings to UNO properties. */ + void convertScrollBar( + PropertyMap& rPropMap, + sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition, + sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const; + + // ActiveX (Forms 2.0) specific conversion -------------------------------- + + /** Converts the Forms 2.0 background formatting to UNO properties. */ + void convertAxBackground( + PropertyMap& rPropMap, + sal_uInt32 nBackColor, + sal_uInt32 nFlags, + ApiTransparencyMode eTranspMode ) const; + + /** Converts the Forms 2.0 border formatting to UNO properties. */ + void convertAxBorder( + PropertyMap& rPropMap, + sal_uInt32 nBorderColor, + sal_Int32 nBorderStyle, + sal_Int32 nSpecialEffect ) const; + + /** Converts the Forms 2.0 special effect to UNO properties. */ + void convertAxVisualEffect( + PropertyMap& rPropMap, + sal_Int32 nSpecialEffect ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_uInt32 nPicPos ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_Int32 nPicSizeMode, + sal_Int32 nPicAlign, + bool bPicTiling ) const; + + /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO + properties. */ + void convertAxState( + PropertyMap& rPropMap, + const ::rtl::OUString& rValue, + sal_Int32 nMultiSelect, + ApiDefaultStateMode eDefStateMode, + bool bAwtModel ) const; + + /** Converts the Forms 2.0 control orientation to UNO properties. */ + void convertAxOrientation( + PropertyMap& rPropMap, + const AxPairData& rSize, + sal_Int32 nOrientation ) const; + +private: + const GraphicHelper& mrGraphicHelper; + bool mbDefaultColorBgr; +}; // ============================================================================ -/** Base class for all models of ActiveX form controls. */ -class AxControlModelBase +/** Base class for all models of form controls. */ +class ControlModelBase { public: - virtual ~AxControlModelBase(); + explicit ControlModelBase(); + virtual ~ControlModelBase(); + + /** Sets this control model to AWT model mode. */ + inline void setAwtModelMode() { mbAwtModel = true; } + /** Sets this control model to form component mode. */ + inline void setFormComponentMode() { mbAwtModel = false; } + + /** Returns the UNO service name used to construct the AWT control model, + or the control form component. */ + ::rtl::OUString getServiceName() const; /** Derived classes set specific OOXML properties at the model structure. */ virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); /** Derived classes set binary data (picture, mouse icon) at the model structure. */ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); /** Derived classes import a form control model from the passed input stream. */ - virtual void importBinaryModel( BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0; - /** Derived classes return the UNO service name used to construct the control component. */ - virtual ::rtl::OUString getServiceName() const = 0; + /** Derived classes return the UNO control type enum value. */ + virtual ApiControlType getControlType() const = 0; /** Derived classes convert all control properties. */ - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Converts the control size to UNO properties. */ + void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - explicit AxControlModelBase(); + AxPairData maSize; /// Size of the control in 1/100 mm. + bool mbAwtModel; /// True = AWT control model, false = form component. +}; + +typedef ::boost::shared_ptr< ControlModelBase > ControlModelRef; + +// ============================================================================ + +/** Base class for all models of ComCtl form controls. */ +class ComCtlModelBase : public ControlModelBase +{ +public: + explicit ComCtlModelBase( + sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ) = 0; + virtual void importCommonExtraData( BinaryInputStream& rInStrm ); + virtual void importCommonTrailingData( BinaryInputStream& rInStrm ); + +private: + /** Returns the data part identifier according to the model version. */ + sal_uInt32 getDataPartId() const; + + bool readPartHeader( BinaryInputStream& rInStrm, + sal_uInt32 nExpPartId, + sal_uInt16 nExpMajor = SAL_MAX_UINT16, + sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + + bool importSizePart( BinaryInputStream& rInStrm ); + bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize ); + bool importComplexPart( BinaryInputStream& rInStrm ); + +protected: + StdFontInfo maFontData; /// Font formatting. + StreamDataSequence maMouseIcon; /// Binary picture stream for mouse icon. + sal_uInt32 mnFlags; /// Common flags for ComCtl controls. + const sal_uInt16 mnVersion; /// Current version of the ComCtl control model. + +private: + sal_uInt32 mnDataPartId5; /// Identifier for version 5.0 control data. + sal_uInt32 mnDataPartId6; /// Identifier for version 6.0 control data. + bool mbCommonPart; /// True = the COMCTL_COMMONDATA part exists. + bool mbComplexPart; /// True = the COMCTL_COMPLEXDATA part exists. +}; + +// ============================================================================ + +/** Model for a ComCtl scroll bar. */ +class ComCtlScrollBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlScrollBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + sal_uInt32 mnScrollBarFlags; /// Special flags for scroll bar model. + sal_Int32 mnLargeChange; /// Increment step size (thumb). + sal_Int32 mnSmallChange; /// Increment step size (buttons). + sal_Int32 mnMin; /// Minimum of the value range. + sal_Int32 mnMax; /// Maximum of the value range. + sal_Int32 mnPosition; /// Value of the spin button. +}; + +// ============================================================================ + +/** Model for a ComCtl progress bar. */ +class ComCtlProgressBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlProgressBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - sal_Int32 mnWidth; - sal_Int32 mnHeight; + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + float mfMin; /// Minimum of the value range. + float mfMax; /// Maximum of the value range. + sal_uInt16 mnVertical; /// 0 = horizontal, 1 = vertical. + sal_uInt16 mnSmooth; /// 0 = progress blocks, 1 = pixel resolution. }; // ============================================================================ +/** Base class for all models of Form 2.0 form controls. */ +class AxControlModelBase : public ControlModelBase +{ +public: + explicit AxControlModelBase(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); +}; + +// ============================================================================ + +/** Base class for Forms 2.0 controls supporting text formatting. */ class AxFontDataModel : public AxControlModelBase { public: - explicit AxFontDataModel(); + explicit AxFontDataModel( bool bSupportsAlign = true ); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: - ::rtl::OUString maFontName; /// Name of the used font. - sal_uInt32 mnFontEffects; /// Font effect flags. - sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). - sal_Int32 mnFontCharSet; /// Windows character set of the font. - sal_Int32 mnHorAlign; /// Horizontal text alignment. + /** Returns the font height in points. */ + inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); } + +protected: + AxFontData maFontData; /// The font settings. + bool mbSupportsAlign; /// True = UNO model supports Align property. }; // ============================================================================ +/** Model for a Forms 2.0 command button. */ class AxCommandButtonModel : public AxFontDataModel { public: explicit AxCommandButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -117,15 +424,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 label. */ class AxLabelModel : public AxFontDataModel { public: explicit AxLabelModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: ::rtl::OUString maCaption; /// Visible caption of the button. @@ -139,16 +448,18 @@ private: // ============================================================================ +/** Model for a Forms 2.0 image. */ class AxImageModel : public AxControlModelBase { public: explicit AxImageModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -164,15 +475,16 @@ private: // ============================================================================ -class AxMorphDataModel : public AxFontDataModel +/** Base class for a Forms 2.0 morph data control. */ +class AxMorphDataModelBase : public AxFontDataModel { public: - explicit AxMorphDataModel(); + explicit AxMorphDataModelBase(); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: StreamDataSequence maPictureData; /// Binary picture stream. @@ -198,81 +510,92 @@ protected: // ============================================================================ -class AxToggleButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 toggle button. */ +class AxToggleButtonModel : public AxMorphDataModelBase { public: explicit AxToggleButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxCheckBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 check box. */ +class AxCheckBoxModel : public AxMorphDataModelBase { public: explicit AxCheckBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxOptionButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 option button. */ +class AxOptionButtonModel : public AxMorphDataModelBase { public: explicit AxOptionButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + /** Returns the group name used to goup several option buttons gogether. */ + inline const ::rtl::OUString& getGroupName() const { return maGroupName; } + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxTextBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 text box. */ +class AxTextBoxModel : public AxMorphDataModelBase { public: explicit AxTextBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxListBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 list box. */ +class AxListBoxModel : public AxMorphDataModelBase { public: explicit AxListBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxComboBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 combo box. */ +class AxComboBoxModel : public AxMorphDataModelBase { public: explicit AxComboBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ +/** Model for a Forms 2.0 spin button. */ class AxSpinButtonModel : public AxControlModelBase { public: explicit AxSpinButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -288,15 +611,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 scroll bar. */ class AxScrollBarModel : public AxControlModelBase { public: explicit AxScrollBarModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -314,39 +639,130 @@ private: // ============================================================================ -/** Container for all ActiveX form control model implementations. */ -class AxControl +typedef ::std::vector< ::rtl::OUString > AxClassTable; + +/** Base class for ActiveX container controls. */ +class AxContainerModelBase : public AxFontDataModel { public: - explicit AxControl( const ::rtl::OUString& rName ); - ~AxControl(); + explicit AxContainerModelBase(); + + /** Allows to set single properties specified by XML token identifier. */ + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Reads the leading structure in the 'f' stream containing the model for + this control. */ + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the class table structure for embedded controls following the own + model from the 'f' stream. */ + bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ); + +protected: + StreamDataSequence maPictureData; /// Binary picture stream. + ::rtl::OUString maCaption; /// Visible caption of the form. + AxPairData maLogicalSize; /// Logical form size (scroll area). + AxPairData maScrollPos; /// Scroll position. + sal_uInt32 mnBackColor; /// Fill color. + sal_uInt32 mnTextColor; /// Text color. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnBorderColor; /// Flat border color. + sal_Int32 mnBorderStyle; /// Flat border style. + sal_Int32 mnScrollBars; /// Horizontal/vertical scroll bar. + sal_Int32 mnCycleType; /// Cycle in all forms or in this form. + sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnPicAlign; /// Anchor position of the picture. + sal_Int32 mnPicSizeMode; /// Clip, stretch, zoom. + bool mbPicTiling; /// True = picture is repeated. +}; + +typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef; + +// ============================================================================ + +/** Model for a Forms 2.0 frame (group box). */ +class AxFrameModel : public AxContainerModelBase +{ +public: + explicit AxFrameModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 user form. */ +class AxUserFormModel : public AxContainerModelBase +{ +public: + explicit AxUserFormModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** A form control embedded in a document draw page. Contains a specific model + structure according to the type of the control. */ +class EmbeddedControl +{ +public: + explicit EmbeddedControl( const ::rtl::OUString& rName ); + ~EmbeddedControl(); /** Creates and returns the internal control model according to the passed MS class identifier. */ - AxControlModelBase* createModel( const ::rtl::OUString& rClassId ); - /** Imports a form control model from the passed input stream. */ - void importBinaryModel( BinaryInputStream& rInStrm ); + ControlModelRef createModel( const ::rtl::OUString& rClassId ); - /** Returns the internal control model. */ - inline const AxControlModelBase* getModel() const { return mxModel.get(); } - /** Returns the MS class identifier used to create the internal control model. */ - inline const ::rtl::OUString& getClassId() const { return maClassId; } + /** Returns true, if the internal control model exists. */ + inline bool hasModel() const { return mxModel.get() != 0; } + /** Returns the UNO service name needed to construct the control model. */ + ::rtl::OUString getServiceName() const; - /** Creates and returns the UNO form component object for this control and - inserts it into the form wrapped by the passed helper. */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > - convertAndInsert( AxControlHelper& rHelper ) const; + /** Converts all control properties and inserts them into the passed model. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv ) const; private: - ::std::auto_ptr< AxControlModelBase > mxModel; - ::rtl::OUString maClassId; /// Class identifier of the control model. + ControlModelRef mxModel; /// Control model containing the properties. ::rtl::OUString maName; /// Name of the control. }; // ============================================================================ +/** A wrapper for a control form embedded directly in a draw page. */ +class EmbeddedForm : public ControlConverter +{ +public: + explicit EmbeddedForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Converts the passed ActiveX control and inserts it into the form. + @return The API control model, if conversion was successful. */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > + convertAndInsert( const EmbeddedControl& rControl ); + +private: + /** Tries to insert the passed control model into the form. */ + bool insertControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel ); + + /** Creates the form that will hold the form controls. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > + createForm(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxModelFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier > mxFormsSupp; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxFormIC; +}; + +// ============================================================================ + } // namespace ole } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axcontrolfragment.hxx b/oox/inc/oox/ole/axcontrolfragment.hxx index 9bccbd11a0de..3c9aed61bd3e 100644 --- a/oox/inc/oox/ole/axcontrolfragment.hxx +++ b/oox/inc/oox/ole/axcontrolfragment.hxx @@ -33,8 +33,8 @@ namespace oox { namespace ole { -class AxControl; -class AxControlModelBase; +class ControlModelBase; +class EmbeddedControl; // ============================================================================ @@ -44,32 +44,32 @@ class AxControlPropertyContext : public ::oox::core::ContextHandler2 public: explicit AxControlPropertyContext( ::oox::core::FragmentHandler2& rFragment, - AxControlModelBase& rModel ); + ControlModelBase& rModel ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControlModelBase& mrModel; + ControlModelBase& mrModel; sal_Int32 mnPropId; /// Identifier of currently processed property. }; // ============================================================================ -/** Fragment handler for an ActiveX form control fragment. */ +/** Fragment handler for an embedded ActiveX form control fragment. */ class AxControlFragment : public ::oox::core::FragmentHandler2 { public: explicit AxControlFragment( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, - AxControl& rControl ); + EmbeddedControl& rControl ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControl& mrControl; + EmbeddedControl& mrControl; }; // ============================================================================ diff --git a/oox/inc/oox/ole/axcontrolhelper.hxx b/oox/inc/oox/ole/axcontrolhelper.hxx deleted file mode 100644 index d34cf45f3654..000000000000 --- a/oox/inc/oox/ole/axcontrolhelper.hxx +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * - * 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 OOX_OLE_AXCONTROLHELPER_HXX -#define OOX_OLE_AXCONTROLHELPER_HXX - -#include <com/sun/star/uno/Reference.hxx> - -namespace com { namespace sun { namespace star { - namespace graphic { class XGraphic; } - namespace drawing { class XDrawPage; } - namespace form { class XForm; } -} } } - -namespace oox { namespace core { class FilterBase; } } - -namespace oox { -namespace ole { - -// ============================================================================ - -const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; -const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; -const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; -const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; -const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; - -// ============================================================================ - -enum AxDefaultColorMode -{ - AX_DEFAULTCOLORMODE_BGR, /// OLE default color type is interpreted as BGR color. - AX_DEFAULTCOLORMODE_PALETTE /// OLE default color type is interpreted as palette color. -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form control filters. */ -class AxControlHelper -{ -public: - explicit AxControlHelper( - const ::oox::core::FilterBase& rFilter, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - virtual ~AxControlHelper(); - - /** Returns the filter object that imports/exports the form controls. */ - inline const ::oox::core::FilterBase& getFilter() const { return mrFilter; } - /** Returns the UNO form used to insert the control models. */ - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - getControlForm() const; - /** Returns the UNO RGB color from the passed encoded OLE color. */ - sal_Int32 convertColor( sal_uInt32 nAxColor ) const; - -protected: - /** Derived classes returns the UNO form of the current context. Called exactly once. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const = 0; - -private: - const ::oox::core::FilterBase& mrFilter; - const AxDefaultColorMode meColorMode; - mutable ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > mxForm; - mutable bool mbHasFormQuerried; -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form controls embedded in a - document. */ -class AxEmbeddedControlHelper : public AxControlHelper -{ -public: - explicit AxEmbeddedControlHelper( - const ::oox::core::FilterBase& rFilter, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - -protected: - /** Creates and returns the standard UNO form in the wrapped draw page. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const; - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; -}; - -// ============================================================================ - -} // namespace ole -} // namespace oox - -#endif - diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx index 91ca73a38a67..ba46d3baf6df 100644 --- a/oox/inc/oox/ole/olehelper.hxx +++ b/oox/inc/oox/ole/olehelper.hxx @@ -31,13 +31,49 @@ #include <rtl/ustring.hxx> #include "oox/helper/binarystreambase.hxx" -namespace oox { class BinaryInputStream; } +namespace oox { + class BinaryInputStream; + class GraphicHelper; +} namespace oox { namespace ole { // ============================================================================ +const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; + +// ============================================================================ + +const sal_uInt16 OLE_STDFONT_NORMAL = 400; +const sal_uInt16 OLE_STDFONT_BOLD = 700; + +const sal_uInt8 OLE_STDFONT_ITALIC = 0x02; +const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04; +const sal_uInt8 OLE_STDFONT_STRIKE = 0x08; + +/** Stores data about a StdFont font structure. */ +struct StdFontInfo +{ + ::rtl::OUString maName; /// Font name. + sal_uInt32 mnHeight; /// Font height (1/10,000 points). + sal_uInt16 mnWeight; /// Font weight (normal/bold). + sal_uInt16 mnCharSet; /// Font charset. + sal_uInt8 mnFlags; /// Font flags. + + explicit StdFontInfo(); + explicit StdFontInfo( + const ::rtl::OUString& rName, + sal_uInt32 nHeight, + sal_uInt16 nWeight = OLE_STDFONT_NORMAL, + sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI, + sal_uInt8 nFlags = 0 ); +}; + +// ============================================================================ + /** Stores data about a StdHlink hyperlink. */ struct StdHlinkInfo { @@ -53,14 +89,45 @@ struct StdHlinkInfo class OleHelper { public: - /** Imports a GUID from the passed binary stream and returns its string representation. */ + /** Returns the UNO RGB color from the passed encoded OLE color. + + @param bDefaultColorBgr + True = OLE default color type is treated as BGR color. + False = OLE default color type is treated as palette color. + */ + static sal_Int32 decodeOleColor( + const GraphicHelper& rGraphicHelper, + sal_uInt32 nOleColor, + bool bDefaultColorBgr = true ); + + /** Imports a GUID from the passed binary stream and returns its string + representation (in uppercase characters). + */ static ::rtl::OUString importGuid( BinaryInputStream& rInStrm ); - /** Imports an OLE StdPic picture from the current position of the passed binary stream. */ - static bool importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid ); + /** Imports an OLE StdFont font structure from the current position of the + passed binary stream. + */ + static bool importStdFont( + StdFontInfo& orFontInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); + + /** Imports an OLE StdPic picture from the current position of the passed + binary stream. + */ + static bool importStdPic( + StreamDataSequence& orGraphicData, + BinaryInputStream& rInStrm, + bool bWithGuid ); - /** Imports an OLE StdHlink from the current position of the passed binary stream. */ - static bool importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bWithGuid ); + /** Imports an OLE StdHlink from the current position of the passed binary + stream. + */ + static bool importStdHlink( + StdHlinkInfo& orHlinkInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); private: OleHelper(); // not implemented diff --git a/oox/inc/oox/helper/olestorage.hxx b/oox/inc/oox/ole/olestorage.hxx index a8174a167729..a84fadfadc92 100644..100755 --- a/oox/inc/oox/helper/olestorage.hxx +++ b/oox/inc/oox/ole/olestorage.hxx @@ -25,18 +25,18 @@ * ************************************************************************/ -#ifndef OOX_HELPER_OLESTORAGE_HXX -#define OOX_HELPER_OLESTORAGE_HXX +#ifndef OOX_OLE_OLESTORAGE_HXX +#define OOX_OLE_OLESTORAGE_HXX #include "oox/helper/storagebase.hxx" namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } namespace container { class XNameContainer; } - namespace container { class XNameAccess; } } } } namespace oox { +namespace ole { // ============================================================================ @@ -51,7 +51,7 @@ public: explicit OleStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxStream, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, bool bBaseStreamAccess ); virtual ~OleStorage(); @@ -59,9 +59,19 @@ public: private: explicit OleStorage( const OleStorage& rParentStorage, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxElementsAccess, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxStorage, + const ::rtl::OUString& rElementName, + bool bReadOnly ); + explicit OleStorage( + const OleStorage& rParentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, const ::rtl::OUString& rElementName ); + /** Initializes the API storage object for input. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ); + /** Initializes the API storage object for input/output. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ); + /** Returns true, if the object represents a valid storage. */ virtual bool implIsStorage() const; @@ -77,7 +87,7 @@ private: virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > @@ -87,17 +97,20 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ); -private: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > XNameContainerRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > XNameAccessRef; + /** Commits the current storage. */ + virtual void implCommit() const; - XNameContainerRef mxStorage; /// Complete storage based on input or output stream. - XNameAccessRef mxElements; /// Access to elements of current sub storage. +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxFactory; /// Factory for storage/stream creation. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxStorage; /// Access to elements of this sub storage. + const OleStorage* mpParentStorage; /// Parent OLE storage that contains this storage. }; // ============================================================================ +} // namespace ole } // namespace oox #endif - diff --git a/oox/inc/oox/ole/vbacontrol.hxx b/oox/inc/oox/ole/vbacontrol.hxx new file mode 100755 index 000000000000..ec1c25be6952 --- /dev/null +++ b/oox/inc/oox/ole/vbacontrol.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * 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 OOX_OLE_VBACONTROL_HXX +#define OOX_OLE_VBACONTROL_HXX + +#include "oox/ole/axcontrol.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } +} } } + +namespace oox { class StorageBase; } + +namespace oox { +namespace ole { + +class VbaFormControl; + +// ============================================================================ + +/** Common properties for all controls that are part of a VBA user form or of + another container control in a VBA user form. */ +class VbaSiteModel +{ +public: + explicit VbaSiteModel(); + virtual ~VbaSiteModel(); + + /** Allows to set single properties specified by XML token identifier. */ + void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Imports the site model data from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + + /** Returns the programmatical name of the control. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the position of the control in its parent. */ + inline const AxPairData& getPosition() const { return maPos; } + /** Returns true, if this control is a container control. */ + bool isContainer() const; + /** Returns the length of the stream data for stream based controls. */ + sal_uInt32 getStreamLength() const; + /** Returns the name of the substorage for the container control data. */ + ::rtl::OUString getSubStorageName() const; + /** Returns the tab index of the control. */ + inline sal_Int16 getTabIndex() const { return mnTabIndex; } + + /** Tries to create the control model according to the site model. */ + ControlModelRef createControlModel( const AxClassTable& rClassTable ) const; + /** Converts all form site properties. */ + void convertProperties( + PropertyMap& rPropMap, + const ControlConverter& rConv, + ApiControlType eCtrlType, + sal_Int32 nCtrlIndex ) const; + +protected: + ::rtl::OUString maName; /// Name of the control. + ::rtl::OUString maTag; /// User defined tag. + ::rtl::OUString maToolTip; /// Tool tip for the control. + ::rtl::OUString maLinkedCell; /// Linked cell for the control value in a spreadsheet. + ::rtl::OUString maSourceRange; /// Source data for the control in a spreadsheet. + AxPairData maPos; /// Position in parent container. + sal_Int32 mnId; /// Control identifier. + sal_Int32 mnHelpContextId; /// Help context identifier. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnStreamLen; /// Size of control stream data. + sal_Int16 mnTabIndex; /// Tab order index. + sal_uInt16 mnClassIdOrCache; /// Class name identifier or GUID cache index. + sal_uInt16 mnGroupId; /// Group identifier for grouped controls. +}; + +typedef ::boost::shared_ptr< VbaSiteModel > VbaSiteModelRef; + +// ============================================================================ + +/** A control that is embedded in a VBA user form or in another container + control in a VBA user form. + + The control may be a 'simple' control with its data stored in the 'o' + stream, or it may be a container control with its data stored in an own + substorage. + */ +class VbaFormControl +{ +public: + explicit VbaFormControl(); + virtual ~VbaFormControl(); + + /** Imports the model from the passed stream or storage, depending on the + control's type. Imports all embedded controls, if this is a container. */ + void importModelOrStorage( + BinaryInputStream& rInStrm, + StorageBase& rStrg, + const AxClassTable& rClassTable ); + + /** Returns the programmatical name of the control. */ + ::rtl::OUString getControlName() const; + + /** Creates the UNO control model, inserts it into the passed container, + and converts all control properties. */ + void createAndConvert( + sal_Int32 nCtrlIndex, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC, + const ControlConverter& rConv ) const; + +protected: + /** Creates and imports the control model containing properties of the control. */ + void importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable ); + /** Creates and imports the control model, and imports all embedded + controls from the passed substorage. */ + void importStorage( StorageBase& rStrg, const AxClassTable& rClassTable ); + + /** Converts all control properties, and inserts and converts embedded controls. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv, + sal_Int32 nCtrlIndex ) const; + +private: + typedef RefVector< VbaFormControl > VbaFormControlVector; + typedef VbaFormControlVector::value_type VbaFormControlRef; + + /** Creates the control model according to the current site model. */ + void createControlModel( const AxClassTable& rClassTable ); + /** Imports the site model data containing common properties of the control. */ + bool importSiteModel( BinaryInputStream& rInStrm ); + + /** Imports the site models of all embedded controls from the 'f' stream. */ + bool importEmbeddedSiteModels( BinaryInputStream& rInStrm ); + /* Final processing of all embedded controls after import. */ + void finalizeEmbeddedControls(); + + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + /** Moves all embedded controls from their relative position in this + control to an absolute position in the parent of this control. */ + void moveEmbeddedToAbsoluteParent(); + + /** Functor for comparing controls by their tab index. */ + static bool compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight ); + +protected: + VbaSiteModelRef mxSiteModel; /// Common control properties. + ControlModelRef mxCtrlModel; /// Specific control properties. + +private: + VbaFormControlVector maControls; /// All embedded form controls. + AxClassTable maClassTable; /// Class identifiers for exotic embedded controls. +}; + +// ============================================================================ + +class VbaUserForm : public VbaFormControl, public ControlConverter +{ +public: + explicit VbaUserForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Imports the form and its embedded controls, and inserts the form with + all its controls into the passed dialog library. */ + void importForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, + const ::rtl::OUString& rModuleName, + rtl_TextEncoding eTextEnc ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx new file mode 100755 index 000000000000..76dc1c736025 --- /dev/null +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * 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 OOX_OLE_VBAHELPER_HXX +#define OOX_OLE_VBAHELPER_HXX + +#include "oox/helper/binarystreambase.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } +} } } + +namespace oox { class BinaryInputStream; } + +namespace oox { +namespace ole { + +// Directory stream record identifiers ======================================== + +const sal_uInt16 VBA_ID_MODULECOOKIE = 0x002C; +const sal_uInt16 VBA_ID_MODULEDOCSTRING = 0x001C; +const sal_uInt16 VBA_ID_MODULEDOCSTRINGUNICODE = 0x0048; +const sal_uInt16 VBA_ID_MODULEEND = 0x002B; +const sal_uInt16 VBA_ID_MODULEHELPCONTEXT = 0x001E; +const sal_uInt16 VBA_ID_MODULENAME = 0x0019; +const sal_uInt16 VBA_ID_MODULENAMEUNICODE = 0x0047; +const sal_uInt16 VBA_ID_MODULEOFFSET = 0x0031; +const sal_uInt16 VBA_ID_MODULEPRIVATE = 0x0028; +const sal_uInt16 VBA_ID_MODULEREADONLY = 0x0025; +const sal_uInt16 VBA_ID_MODULESTREAMNAME = 0x001A; +const sal_uInt16 VBA_ID_MODULESTREAMNAMEUNICODE = 0x0032; +const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT = 0x0022; +const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL = 0x0021; +const sal_uInt16 VBA_ID_PROJECTCODEPAGE = 0x0003; +const sal_uInt16 VBA_ID_PROJECTEND = 0x0010; +const sal_uInt16 VBA_ID_PROJECTMODULES = 0x000F; +const sal_uInt16 VBA_ID_PROJECTVERSION = 0x0009; + +// ============================================================================ + +/** Static helper functions for the VBA filters. */ +class VbaHelper +{ +public: + /** Returns the full Basic script URL from a VBA module and macro name. + The script is assumed to be in a document library. */ + static ::rtl::OUString getBasicScriptUrl( + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Reads the next record from the VBA directory stream 'dir'. + + @param rnRecId (out parameter) The record identifier of the new record. + @param rRecData (out parameter) The contents of the new record. + @param rInStrm The 'dir' stream. + + @return True = next record successfully read. False on any error, or + if the stream is EOF. + */ + static bool readDirRecord( + sal_uInt16& rnRecId, + StreamDataSequence& rRecData, + BinaryInputStream& rInStrm ); + + /** Extracts a key/value pair from a string separated by an equality sign. + + @param rKey (out parameter) The key before the separator. + @param rValue (out parameter) The value following the separator. + @param rCodeLine The source key/value pair. + + @return True = Equality sign separator found, and the returned key and + value are not empty. False otherwise. + */ + static bool extractKeyValue( + ::rtl::OUString& rKey, + ::rtl::OUString& rValue, + const ::rtl::OUString& rKeyValue ); + + /** Removes whitespace characters from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @return True = at least one whitespace character found and removed + from rCodeLine. False = rCodeLine is empty or does not start with + a whitespace character. + */ + static bool eatWhitespace( ::rtl::OUString& rCodeLine ); + + /** Removes the passed keyword from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @param rKeyword The keyword to be removed from the beginning of the + rCodeLine string. + + @return True = rCodeLine starts with the passed keyword (case + insensitive), and is followed by whitespace characters, or it ends + right after the keyword. The keyword and the following whitespace + characters have been removed from rCodeLine. False = rCodeLine is + empty or does not start with the specified keyword, or the keyword + is not followed by whitespace characters. + */ + static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword ); + + /** Returns the VBA source code of the specified module, or an empty + string, if the module does not exist. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA code module. + */ + static ::rtl::OUString getSourceCode( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName ); + + /** Checks, if a macro with the specified name exists in the passed VBA + source code. + + @param rSourceCode The VBA source code. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::rtl::OUString& rSourceCode, + const ::rtl::OUString& rMacroName ); + + /** Checks, if a macro with the specified name exists in the specified + module. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA module to check for the macro. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub <rMacroName> ( <rMacroArgs> ) + <rMacroCode> + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType> + <rMacroCode> + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + static bool insertMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + /** Tries to attach a VBA macro to an event of the passed events supplier. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rLibraryName The name of the Basic library containing the macro. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + */ + static bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + +private: + VbaHelper(); + ~VbaHelper(); +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbamodule.hxx b/oox/inc/oox/ole/vbamodule.hxx new file mode 100755 index 000000000000..3b529ceee129 --- /dev/null +++ b/oox/inc/oox/ole/vbamodule.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * 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 OOX_OLE_VBAMODULE_HXX +#define OOX_OLE_VBAMODULE_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Reference.hxx> + +namespace com { namespace sun { namespace star { + namespace container { class XNameAccess; } + namespace container { class XNameContainer; } + namespace frame { class XModel; } +} } } + +namespace oox { + class BinaryInputStream; + class StorageBase; +} + +namespace oox { +namespace ole { + +// ============================================================================ + +class VbaModule +{ +public: + explicit VbaModule( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rName, + rtl_TextEncoding eTextEnc, + bool bExecutable ); + + /** Returns the module type (com.sun.star.script.ModuleType constant). */ + inline sal_Int32 getType() const { return mnType; } + /** Sets the passed module type. */ + inline void setType( sal_Int32 nType ) { mnType = nType; } + + /** Returns the name of the module. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the stream name of the module. */ + inline const ::rtl::OUString& getStreamName() const { return maStreamName; } + + /** Imports all records for this module until the MODULEEND record. */ + void importDirRecords( BinaryInputStream& rDirStrm ); + /** Imports the Basic source code into the passed Basic library. */ + void importSourceCode( + StorageBase& rVbaStrg, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::rtl::OUString maName; + ::rtl::OUString maStreamName; + ::rtl::OUString maDocString; + rtl_TextEncoding meTextEnc; + sal_Int32 mnType; + sal_uInt32 mnOffset; + bool mbReadOnly; + bool mbPrivate; + bool mbExecutable; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx new file mode 100755 index 000000000000..0422ccbd0cf8 --- /dev/null +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -0,0 +1,289 @@ +/************************************************************************* + * + * 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 OOX_OLE_VBAPROJECT_HXX +#define OOX_OLE_VBAPROJECT_HXX + +#include "oox/helper/storagebase.hxx" +#include <com/sun/star/uno/XInterface.hpp> +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } + namespace frame { class XModel; } + namespace script { class XLibraryContainer; } + namespace lang { class XMultiServiceFactory; } +} } } + +namespace oox { class GraphicHelper; } + +namespace oox { +namespace ole { + +// ============================================================================ + +class OOX_DLLPUBLIC VbaFilterConfig +{ +public: + explicit VbaFilterConfig( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::rtl::OUString& rConfigCompName ); + ~VbaFilterConfig(); + + /** Returns true, if the VBA source code and forms should be imported. */ + bool isImportVba() const; + /** Returns true, if the VBA source code should be imported executable. */ + bool isImportVbaExecutable() const; + /** Returns true, if the VBA source code and forms should be exported. */ + bool isExportVba() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + mxConfigAccess; +}; + +// ============================================================================ + +class OOX_DLLPUBLIC VbaProject : public VbaFilterConfig +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rConfigCompName ); + virtual ~VbaProject(); + + /** Imports the entire VBA project from the passed storage. + + @param rVbaPrjStrg The root storage of the entire VBA project. + */ + void importVbaProject( + StorageBase& rVbaPrjStrg, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Returns true, if the document contains at least one code module. */ + bool hasModules() const; + /** Returns true, if the document contains the specified code module. */ + bool hasModule( const ::rtl::OUString& rModuleName ) const; + + /** Returns true, if the document contains at least one dialog. */ + bool hasDialogs() const; + /** Returns true, if the document contains the specified dialog. */ + bool hasDialog( const ::rtl::OUString& rDialogName ) const; + + // Insert VBA code modules and VBA macros into modules -------------------- + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub <rMacroName> ( <rMacroArgs> ) + <rMacroCode> + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType> + <rMacroCode> + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + bool insertMacro( + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + // Attach VBA macros to generic or document events ------------------------ + + /** Tries to attach the specified VBA macro to an event directly. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to a document event directly. + + @descr The function checks if the specified macro exists and attaches + it to the document event. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified document event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to an event via a generated + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + + /** Tries to attach the specified VBA macro to a document event via a + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + document event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + +private: + VbaProject( const VbaProject& ); + VbaProject& operator=( const VbaProject& ); + + /** Returns the Basic or dialog library container. */ + ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > + getLibraryContainer( sal_Int32 nPropId ); + /** Opens a Basic or dialog library (creates missing if specified). */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + openLibrary( sal_Int32 nPropId, bool bCreateMissing ); + /** Creates and returns the Basic library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createBasicLibrary(); + /** Creates and returns the dialog library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createDialogLibrary(); + /** Imports the VBA code modules and forms. */ + void importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ); + /** Copies the entire VBA project storage to the passed document model. */ + void copyStorage( StorageBase& rVbaPrjStrg ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxGlobalFactory; /// Global service factory. + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxBasicLib; /// The Basic library of the document used for import. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxDialogLib; /// The dialog library of the document used for import. + const ::rtl::OUString maLibName; /// Name for Basic and dialog library used for import. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ppt/pptimport.hxx b/oox/inc/oox/ppt/pptimport.hxx index 7d04e1c492fa..c4ee29447c64 100644 --- a/oox/inc/oox/ppt/pptimport.hxx +++ b/oox/inc/oox/ppt/pptimport.hxx @@ -53,8 +53,6 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const oox::drawingml::table::TableStyleListPtr getTableStyles(); @@ -66,7 +64,10 @@ public: std::vector< SlidePersistPtr >& getMasterPages(){ return maMasterPages; }; std::vector< SlidePersistPtr >& getNotesPages(){ return maNotesPages; }; + sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; private: diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx index 1af14903793b..2312514d7117 100644 --- a/oox/inc/oox/vml/vmldrawing.hxx +++ b/oox/inc/oox/vml/vmldrawing.hxx @@ -39,7 +39,7 @@ namespace com { namespace sun { namespace star { } } } namespace oox { namespace core { class XmlFilterBase; } } -namespace oox { namespace ole { class AxControlHelper; } } +namespace oox { namespace ole { class EmbeddedForm; } } namespace oox { namespace vml { @@ -110,8 +110,8 @@ public: inline ShapeContainer& getShapes() { return *mxShapes; } /** Returns read access to the container of shapes and templates. */ inline const ShapeContainer& getShapes() const { return *mxShapes; } - /** Returns the helper object used to process ActiveX form controls. */ - ::oox::ole::AxControlHelper& getControlHelper() const; + /** Returns the form object used to process ActiveX form controls. */ + ::oox::ole::EmbeddedForm& getControlForm() const; /** Registers the passed embedded OLE object. The related shape will then load the OLE object data from the specified fragment. */ @@ -146,12 +146,8 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, const ShapeClientData& rClientData ) const; -protected: - /** Derived classes may create a specialized form control helper object. */ - virtual ::oox::ole::AxControlHelper* createControlHelper() const; - private: - typedef ::std::auto_ptr< ::oox::ole::AxControlHelper > AxControlHelperPtr; + typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm > EmbeddedFormPtr; typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr; typedef ::std::map< ::rtl::OUString, OleObjectInfo > OleObjectInfoMap; typedef ::std::map< ::rtl::OUString, ControlInfo > ControlInfoMap; @@ -159,7 +155,7 @@ private: ::oox::core::XmlFilterBase& mrFilter; /// Filter object that imports/exports the VML drawing. ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; /// UNO draw page used to insert the shapes. - mutable AxControlHelperPtr mxCtrlHelper;/// Form control helper. + mutable EmbeddedFormPtr mxCtrlForm; /// The control form used to process ActiveX controls. ShapeContainerPtr mxShapes; /// All shapes and shape templates. OleObjectInfoMap maOleObjects; /// Info about all embedded OLE objects, mapped by shape id. ControlInfoMap maControls; /// Info about all embedded form controls, mapped by control name. diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx index b997c7451fe4..1a9c1811cf6b 100644 --- a/oox/inc/oox/vml/vmlformatting.hxx +++ b/oox/inc/oox/vml/vmlformatting.hxx @@ -30,8 +30,11 @@ #include "oox/helper/helper.hxx" -namespace oox { class PropertyMap; } -namespace oox { namespace core { class FilterBase; } } +namespace oox { + class GraphicHelper; + class ModelObjectHelper; + class PropertyMap; +} namespace oox { namespace vml { @@ -71,7 +74,7 @@ public: /** Converts the passed VML measure string to EMU (English Metric Units). - @param rFilter The core filter object needed to perform pixel + @param rGraphicHelper The graphic helper needed to perform pixel conversion according to the current output device. @param rValue The VML measure value. This is a floating-point value @@ -88,7 +91,7 @@ public: pixel. Set to false if omitted measure unit means EMU. */ static sal_Int32 decodeMeasureToEmu( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -96,14 +99,14 @@ public: /** Converts the passed VML measure string to 1/100 mm. - @param rFilter See above. + @param rGraphicHelper See above. @param rValue See above. @param nRefValue See above. @param bPixelX See above. @param bDefaultAsPixel See above. */ static sal_Int32 decodeMeasureToHmm( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -147,7 +150,8 @@ struct StrokeModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ @@ -172,7 +176,8 @@ struct FillModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index f425b983ada2..b4f36c113c3d 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -493,6 +493,8 @@ const sal_uInt16 BIFF_ID_TOPMARGIN = 0x0028; const sal_uInt16 BIFF_ID_TXO = 0x01B6; const sal_uInt16 BIFF_ID_UNCALCED = 0x005E; const sal_uInt16 BIFF_ID_USESELFS = 0x0160; +const sal_uInt16 BIFF_ID_VBAPROJECT = 0x00D3; +const sal_uInt16 BIFF_ID_VBAPROJECTEMPTY = 0x01BD; const sal_uInt16 BIFF_ID_VCENTER = 0x0084; const sal_uInt16 BIFF_ID_VERPAGEBREAKS = 0x001A; const sal_uInt16 BIFF_ID_WINDOW1 = 0x003D; diff --git a/oox/inc/oox/xls/excelfilter.hxx b/oox/inc/oox/xls/excelfilter.hxx index 5da8b50d7f92..b5d7a97f33b5 100644 --- a/oox/inc/oox/xls/excelfilter.hxx +++ b/oox/inc/oox/xls/excelfilter.hxx @@ -34,22 +34,23 @@ namespace oox { namespace xls { -// ============================================================================ +class WorkbookData; -class WorkbookHelper; +// ============================================================================ class ExcelFilterBase { +public: + void registerWorkbookData( WorkbookData& rData ); + WorkbookData& getWorkbookData() const; + void unregisterWorkbookData(); + protected: explicit ExcelFilterBase(); virtual ~ExcelFilterBase(); - void setWorkbookHelper( WorkbookHelper& rHelper ); - WorkbookHelper& getWorkbookHelper() const; - void clearWorkbookHelper(); - private: - WorkbookHelper* mpHelper; /// Nonowning pointer to helper base. + WorkbookData* mpData; }; // ============================================================================ @@ -64,15 +65,13 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles(); virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; @@ -88,9 +87,8 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; diff --git a/oox/inc/oox/xls/excelvbaproject.hxx b/oox/inc/oox/xls/excelvbaproject.hxx new file mode 100755 index 000000000000..6a517d13cd88 --- /dev/null +++ b/oox/inc/oox/xls/excelvbaproject.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * 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 OOX_XLS_EXCELVBAPROJECT_HXX +#define OOX_XLS_EXCELVBAPROJECT_HXX + +#include "oox/ole/vbaproject.hxx" +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace sheet { class XSpreadsheetDocument; } +} } } + +namespace oox { +namespace xls { + +// ============================================================================ + +/** Special implementation of the VBA project for the Excel filters. */ +class OOX_DLLPUBLIC VbaProject : public ::oox::ole::VbaProject +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument ); + + /** Attaches all document and sheet events to existing VBA macros. */ + void attachToEvents(); + +private: + /** Attaches VBA macros to all supported document events. */ + void attachToDocumentEvents( const ::rtl::OUString& rCodeName ); + + /** Attaches VBA macros to all supported sheet events. */ + void attachToSheetEvents( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rCodeName ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > + mxDocument; +}; + +// ============================================================================ + +} // namespace xls +} // namespace oox + +#endif diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx index 7eb00d4bd57d..4fa9c964108e 100644 --- a/oox/inc/oox/xls/stylesbuffer.hxx +++ b/oox/inc/oox/xls/stylesbuffer.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/table/CellVertJustify.hpp> #include <com/sun/star/table/TableBorder.hpp> #include "oox/helper/containerhelper.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/drawingml/color.hxx" #include "oox/xls/numberformatsbuffer.hxx" @@ -78,6 +79,22 @@ const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; /// Relative character h // ============================================================================ +/** Special implementation of the GraphicHelper for Excel palette and scheme + colors. + */ +class ExcelGraphicHelper : public GraphicHelper, public WorkbookHelper +{ +public: + explicit ExcelGraphicHelper( const WorkbookHelper& rHelper ); + + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; +}; + +// ============================================================================ + class Color : public ::oox::drawingml::Color { public: @@ -205,7 +222,7 @@ struct ApiScriptFontName { ::rtl::OUString maName; /// Font name. sal_Int16 mnFamily; /// Font family. - sal_Int16 mnCharSet; /// Font character set. + sal_Int16 mnTextEnc; /// Font text encoding. explicit ApiScriptFontName(); }; diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 90c0f33c3c50..0ff8c0f9d3e5 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -29,9 +29,8 @@ #define OOX_XLS_WORKBOOKHELPER_HXX #include <boost/shared_ptr.hpp> -#include <osl/time.h> #include <rtl/ref.hxx> -#include <com/sun/star/uno/Reference.hxx> +#include "oox/helper/storagebase.hxx" #include "oox/xls/biffhelper.hxx" namespace com { namespace sun { namespace star { @@ -72,87 +71,8 @@ namespace oox { namespace drawingml { namespace oox { namespace xls { -// DEBUG ====================================================================== - -// Set this define to 1 to show the load/save time of a document in an assertion (nonpro only). -#define OOX_SHOW_LOADSAVE_TIME 0 - -// ---------------------------------------------------------------------------- - -#define OOX_LOADSAVE_TIMER( eTimerType ) (void)0 - -#if OSL_DEBUG_LEVEL > 0 -namespace dbg { - -// ---------------------------------------------------------------------------- - -#if OOX_SHOW_LOADSAVE_TIME > 0 - -enum TimerType -{ - TIMER_IMPORTFORMULA, - TIMER_IMPORTSHEETFRAGMENT, - TIMER_ONCREATESHEETCONTEXT, - TIMER_IMPORTROW, - TIMER_CONVERTROWFORMAT, - TIMER_CONVERTCOLUMNFORMAT, - TIMER_IMPORTCELL, - TIMER_ONENDSHEETELEMENT, - TIMER_SETCELL, - TIMER_SETCELLFORMAT, - TIMER_MERGECELLFORMAT, - TIMER_WRITECELLPROPERTIES, - TIMER_FINALIZESHEETDATA, - TIMER_FINALIZEDRAWING, - TIMER_FINALIZEBOOKDATA, - - // TIMER_TOTAL must be the last entry! - TIMER_TOTAL -}; - -// ---------------------------------------------------------------------------- - -struct TimeCount; - -class Timer -{ -public: - explicit Timer( TimeCount& rTimeCount ); - ~Timer(); -private: - TimeCount& mrTimeCount; - TimeValue maStartTime; -}; - -// ---------------------------------------------------------------------------- - -#undef OOX_LOADSAVE_TIMER -#define OOX_LOADSAVE_TIMER( TimerType ) ::oox::xls::dbg::Timer aDbgTimer##TimerType( getTimeCount( ::oox::xls::dbg::TIMER_##TimerType ) ) - -#endif - -// ---------------------------------------------------------------------------- - -struct WorkbookData; - -class WorkbookHelper -{ -protected: - explicit WorkbookHelper( WorkbookData& rBookData ); - explicit WorkbookHelper( const WorkbookHelper& rCopy ); - virtual ~WorkbookHelper(); -#if OOX_SHOW_LOADSAVE_TIME > 0 -public: - TimeCount& getTimeCount( TimerType eType ) const; -#endif -private: - WorkbookData& mrDbgBookData; -}; - -// ---------------------------------------------------------------------------- - -} // namespace dbg -#endif +class ExcelFilter; +class ExcelBiffFilter; // ============================================================================ @@ -201,14 +121,15 @@ class BiffCodecHelper; object of type WorkbookData containing global workbook settings, buffers, converters, etc. Nearly all classes in this filter implementation are derived directly or indirectly from this class. + + This class contains just a simple reference to the WorkbookData object to + prevent circular references, as the WorkbookData object contains a lot of + objects derived from this class. */ class WorkbookHelper -#if OSL_DEBUG_LEVEL > 0 - : public dbg::WorkbookHelper -#endif { public: - /*implicit*/ WorkbookHelper( WorkbookData& rBookData ); + inline /*implicit*/ WorkbookHelper( WorkbookData& rBookData ) : mrBookData( rBookData ) {} virtual ~WorkbookHelper(); // filter ----------------------------------------------------------------- @@ -229,6 +150,8 @@ public: /** Sets the index of the current sheet in the Calc document. */ void setCurrentSheetIndex( sal_Int16 nSheet ); + /** Sets the VBA project storage. */ + void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ); /** Final conversion after importing the workbook. */ void finalizeWorkbookImport(); @@ -334,7 +257,7 @@ public: /** Returns the page and print settings converter. */ PageSettingsConverter& getPageSettingsConverter() const; - // OOX specific ----------------------------------------------------------- + // OOX specific (MUST NOT be called in BIFF filter) ----------------------- /** Returns the base OOX filter object. Must not be called, if current filter is not the OOX filter. */ @@ -344,7 +267,7 @@ public: the full path to the fragment stream. */ bool importOoxFragment( const ::rtl::Reference< ::oox::core::FragmentHandler >& rxHandler ); - // BIFF specific ---------------------------------------------------------- + // BIFF specific (MUST NOT be called in OOX filter) ----------------------- /** Returns the base BIFF filter object. */ ::oox::core::BinaryFilterBase& getBiffFilter() const; @@ -392,8 +315,8 @@ struct WorkbookDataOwner class WorkbookHelperRoot : private prv::WorkbookDataOwner, public WorkbookHelper { public: - explicit WorkbookHelperRoot( ::oox::core::XmlFilterBase& rFilter ); - explicit WorkbookHelperRoot( ::oox::core::BinaryFilterBase& rFilter, BiffType eBiff ); + explicit WorkbookHelperRoot( ExcelFilter& rFilter ); + explicit WorkbookHelperRoot( ExcelBiffFilter& rFilter, BiffType eBiff ); /** Returns true, if this helper refers to a valid document. */ bool isValid() const; @@ -409,4 +332,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/xls/worksheetsettings.hxx b/oox/inc/oox/xls/worksheetsettings.hxx index c96f12605911..17e22dc5342c 100644 --- a/oox/inc/oox/xls/worksheetsettings.hxx +++ b/oox/inc/oox/xls/worksheetsettings.hxx @@ -120,6 +120,8 @@ public: void importPassword( BiffInputStream& rStrm ); /** Imports protection settings from the SHEETPROTECTION record. */ void importSheetProtection( BiffInputStream& rStrm ); + /** Imports the VBA code module name from the CODENAME record. */ + void importCodeName( BiffInputStream& rStrm ); /** Imports phonetic settings from the PHONETICPR record. */ void importPhoneticPr( BiffInputStream& rStrm ); |