diff options
Diffstat (limited to 'oox/inc/oox/ole')
-rw-r--r--[-rwxr-xr-x] | oox/inc/oox/ole/axbinaryreader.hxx | 6 | ||||
-rw-r--r-- | oox/inc/oox/ole/axcontrol.hxx | 155 | ||||
-rw-r--r-- | oox/inc/oox/ole/axcontrolfragment.hxx | 1 | ||||
-rw-r--r-- | oox/inc/oox/ole/olehelper.hxx | 5 | ||||
-rw-r--r-- | oox/inc/oox/ole/oleobjecthelper.hxx | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | oox/inc/oox/ole/olestorage.hxx | 2 | ||||
-rwxr-xr-x | oox/inc/oox/ole/vbacontrol.hxx | 20 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbahelper.hxx | 1 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbainputstream.hxx | 1 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbamodule.hxx | 2 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbaproject.hxx | 70 | ||||
-rwxr-xr-x | oox/inc/oox/ole/vbaprojectfilter.hxx | 76 |
12 files changed, 301 insertions, 41 deletions
diff --git a/oox/inc/oox/ole/axbinaryreader.hxx b/oox/inc/oox/ole/axbinaryreader.hxx index e3f102716e17..f26075ff52eb 100755..100644 --- a/oox/inc/oox/ole/axbinaryreader.hxx +++ b/oox/inc/oox/ole/axbinaryreader.hxx @@ -30,7 +30,7 @@ #include <utility> #include "oox/helper/binaryinputstream.hxx" -#include "oox/helper/containerhelper.hxx" +#include "oox/helper/refvector.hxx" namespace oox { namespace ole { @@ -92,6 +92,8 @@ typedef ::std::vector< ::rtl::OUString > AxStringArray; // ============================================================================ +const sal_Char* const AX_GUID_CFONT = "{AFC20920-DA4E-11CE-B943-00AA006887B4}"; + const sal_uInt32 AX_FONTDATA_BOLD = 0x00000001; const sal_uInt32 AX_FONTDATA_ITALIC = 0x00000002; const sal_uInt32 AX_FONTDATA_UNDERLINE = 0x00000004; @@ -111,6 +113,7 @@ struct AxFontData 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. + bool mbDblUnderline; /// True = double underline style (legacy VML drawing controls only). explicit AxFontData(); @@ -293,4 +296,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx index 8df45ece6065..8bc9cd622b2b 100644 --- a/oox/inc/oox/ole/axcontrol.hxx +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -30,6 +30,7 @@ #include <boost/shared_ptr.hpp> #include "oox/helper/binarystreambase.hxx" +#include "oox/helper/propertyset.hxx" #include "oox/ole/axbinaryreader.hxx" #include "oox/ole/olehelper.hxx" @@ -37,6 +38,7 @@ namespace com { namespace sun { namespace star { namespace awt { class XControlModel; } namespace container { class XIndexContainer; } namespace drawing { class XDrawPage; } + namespace frame { class XModel; } namespace form { class XFormsSupplier; } namespace lang { class XMultiServiceFactory; } } } } @@ -56,6 +58,9 @@ const sal_Char* const COMCTL_GUID_SCROLLBAR_60 = "{FE38753A-44A3-11D1-B5B7- 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_uInt16 COMCTL_VERSION_50 = 5; +const sal_uInt16 COMCTL_VERSION_60 = 6; + // ---------------------------------------------------------------------------- const sal_Char* const AX_GUID_COMMANDBUTTON = "{D7053240-CE69-11CD-A777-00DD01143C57}"; @@ -77,6 +82,28 @@ const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; +const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002; +const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004; +const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008; +const sal_uInt32 AX_FLAGS_COLUMNHEADS = 0x00000400; +const sal_uInt32 AX_FLAGS_ENTIREROWS = 0x00000800; +const sal_uInt32 AX_FLAGS_EXISTINGENTRIES = 0x00001000; +const sal_uInt32 AX_FLAGS_CAPTIONLEFT = 0x00002000; +const sal_uInt32 AX_FLAGS_EDITABLE = 0x00004000; +const sal_uInt32 AX_FLAGS_IMEMODE_MASK = 0x00078000; +const sal_uInt32 AX_FLAGS_DRAGENABLED = 0x00080000; +const sal_uInt32 AX_FLAGS_ENTERASNEWLINE = 0x00100000; +const sal_uInt32 AX_FLAGS_KEEPSELECTION = 0x00200000; +const sal_uInt32 AX_FLAGS_TABASCHARACTER = 0x00400000; +const sal_uInt32 AX_FLAGS_WORDWRAP = 0x00800000; +const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED = 0x02000000; +const sal_uInt32 AX_FLAGS_SELECTLINE = 0x04000000; +const sal_uInt32 AX_FLAGS_SINGLECHARSELECT = 0x08000000; +const sal_uInt32 AX_FLAGS_AUTOSIZE = 0x10000000; +const sal_uInt32 AX_FLAGS_HIDESELECTION = 0x20000000; +const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB = 0x40000000; +const sal_uInt32 AX_FLAGS_MULTILINE = 0x80000000; + const sal_Int32 AX_BORDERSTYLE_NONE = 0; const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; @@ -96,6 +123,26 @@ const sal_Int32 AX_PICALIGN_CENTER = 2; const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; +const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1; +const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2; +const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX = 3; +const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX = 4; +const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON = 5; +const sal_Int32 AX_DISPLAYSTYLE_TOGGLE = 6; +const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN = 7; + +const sal_Int32 AX_SELCTION_SINGLE = 0; +const sal_Int32 AX_SELCTION_MULTI = 1; +const sal_Int32 AX_SELCTION_EXTENDED = 2; + +const sal_Int32 AX_SHOWDROPBUTTON_NEVER = 0; +const sal_Int32 AX_SHOWDROPBUTTON_FOCUS = 1; +const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS = 2; + +const sal_Int32 AX_SCROLLBAR_NONE = 0x00; +const sal_Int32 AX_SCROLLBAR_HORIZONTAL = 0x01; +const sal_Int32 AX_SCROLLBAR_VERTICAL = 0x02; + // ---------------------------------------------------------------------------- /** Enumerates all UNO API control types supported by these filters. */ @@ -107,6 +154,7 @@ enum ApiControlType API_CONTROL_CHECKBOX, API_CONTROL_RADIOBUTTON, API_CONTROL_EDIT, + API_CONTROL_NUMERIC, API_CONTROL_LISTBOX, API_CONTROL_COMBOBOX, API_CONTROL_SPINBUTTON, @@ -147,6 +195,7 @@ class ControlConverter { public: explicit ControlConverter( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr = true ); virtual ~ControlConverter(); @@ -179,12 +228,25 @@ public: PropertyMap& rPropMap, bool bHorizontal ) const; + /** Converts the vertical alignment to UNO properties. */ + void convertVerticalAlign( + PropertyMap& rPropMap, + sal_Int32 nVerticalAlign ) 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; + /** Binds the passed control model to the passed data sources. The + implementation will check which source types are supported. */ + void bindToSources( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ::rtl::OUString& rCtrlSource, + const ::rtl::OUString& rRowSource, + sal_Int32 nRefSheet = 0 ) const; + // ActiveX (Forms 2.0) specific conversion -------------------------------- /** Converts the Forms 2.0 background formatting to UNO properties. */ @@ -238,7 +300,10 @@ public: sal_Int32 nOrientation ) const; private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel; const GraphicHelper& mrGraphicHelper; + mutable PropertySet maAddressConverter; + mutable PropertySet maRangeConverter; bool mbDefaultColorBgr; }; @@ -275,8 +340,10 @@ public: /** Converts the control size to UNO properties. */ void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -protected: +public: // direct access needed for legacy VML drawing controls AxPairData maSize; /// Size of the control in 1/100 mm. + +protected: bool mbAwtModel; /// True = AWT control model, false = form component. }; @@ -396,8 +463,10 @@ public: /** Returns the font height in points. */ inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); } -protected: +public: // direct access needed for legacy VML drawing controls AxFontData maFontData; /// The font settings. + +private: bool mbSupportsAlign; /// True = UNO model supports Align property. }; @@ -416,13 +485,14 @@ public: virtual ApiControlType getControlType() const; virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: +public: // direct access needed for legacy VML drawing controls StreamDataSequence maPictureData; /// Binary picture stream. ::rtl::OUString maCaption; /// Visible caption of the button. sal_uInt32 mnTextColor; /// Text color. sal_uInt32 mnBackColor; /// Fill color. sal_uInt32 mnFlags; /// Various flags. sal_uInt32 mnPicturePos; /// Position of the picture relative to text. + sal_Int32 mnVerticalAlign; /// Vertical alignment (legacy VML drawing controls only). bool mbFocusOnClick; /// True = take focus on click. }; @@ -440,7 +510,7 @@ public: virtual ApiControlType getControlType() const; virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: +public: // direct access needed for legacy VML drawing controls ::rtl::OUString maCaption; /// Visible caption of the button. sal_uInt32 mnTextColor; /// Text color. sal_uInt32 mnBackColor; /// Fill color. @@ -448,6 +518,7 @@ private: sal_uInt32 mnBorderColor; /// Flat border color. sal_Int32 mnBorderStyle; /// Flat border style. sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnVerticalAlign; /// Vertical alignment (legacy VML drawing controls only). }; // ============================================================================ @@ -490,7 +561,7 @@ public: virtual bool importBinaryModel( BinaryInputStream& rInStrm ); virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -protected: +public: // direct access needed for legacy VML drawing controls StreamDataSequence maPictureData; /// Binary picture stream. ::rtl::OUString maCaption; /// Visible caption of the button. ::rtl::OUString maValue; /// Current value of the control. @@ -510,6 +581,7 @@ protected: sal_Int32 mnMaxLength; /// Maximum character count. sal_Int32 mnPasswordChar; /// Password character in edit fields. sal_Int32 mnListRows; /// Number of rows in dropdown box. + sal_Int32 mnVerticalAlign; /// Vertical alignment (legacy VML drawing controls only). }; // ============================================================================ @@ -565,6 +637,18 @@ public: // ============================================================================ +/** Model for a numeric field (legacy drawing controls only). */ +class AxNumericFieldModel : public AxMorphDataModelBase +{ +public: + explicit AxNumericFieldModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + /** Model for a Forms 2.0 list box. */ class AxListBoxModel : public AxMorphDataModelBase { @@ -601,7 +685,7 @@ public: virtual ApiControlType getControlType() const; virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: +public: // direct access needed for legacy VML drawing controls sal_uInt32 mnArrowColor; /// Button arrow color. sal_uInt32 mnBackColor; /// Fill color. sal_uInt32 mnFlags; /// Various flags. @@ -627,7 +711,7 @@ public: virtual ApiControlType getControlType() const; virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: +public: // direct access needed for legacy VML drawing controls sal_uInt32 mnArrowColor; /// Button arrow color. sal_uInt32 mnBackColor; /// Fill color. sal_uInt32 mnFlags; /// Various flags. @@ -691,7 +775,7 @@ public: model from the 'f' stream. */ bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ); -protected: +public: // direct access needed for legacy VML drawing controls StreamDataSequence maPictureData; /// Binary picture stream. ::rtl::OUString maCaption; /// Visible caption of the form. AxPairData maLogicalSize; /// Logical form size (scroll area). @@ -776,14 +860,27 @@ class EmbeddedControl { public: explicit EmbeddedControl( const ::rtl::OUString& rName ); - ~EmbeddedControl(); + virtual ~EmbeddedControl(); + + /** Creates and returns the internal control model of the specified type. */ + template< typename ModelType > + inline ModelType& createModel(); + + /** Creates and returns the internal control model of the specified type. */ + template< typename ModelType, typename ParamType > + inline ModelType& createModel( const ParamType& rParam ); /** Creates and returns the internal control model according to the passed MS class identifier. */ - ControlModelRef createModel( const ::rtl::OUString& rClassId ); + ControlModelBase* createModelFromGuid( const ::rtl::OUString& rClassId ); /** Returns true, if the internal control model exists. */ inline bool hasModel() const { return mxModel.get() != 0; } + /** Returns read-only access to the internal control model. */ + inline const ControlModelBase* getModel() const { return mxModel.get(); } + /** Returns read/write access to the internal control model. */ + inline ControlModelBase* getModel() { return mxModel.get(); } + /** Returns the UNO service name needed to construct the control model. */ ::rtl::OUString getServiceName() const; @@ -797,32 +894,54 @@ private: ::rtl::OUString maName; /// Name of the control. }; +// ---------------------------------------------------------------------------- + +template< typename ModelType > +inline ModelType& EmbeddedControl::createModel() +{ + ::boost::shared_ptr< ModelType > xModel( new ModelType ); + mxModel = xModel; + xModel->setFormComponentMode(); + return *xModel; +} + +template< typename ModelType, typename ParamType > +inline ModelType& EmbeddedControl::createModel( const ParamType& rParam ) +{ + ::boost::shared_ptr< ModelType > xModel( new ModelType( rParam ) ); + mxModel = xModel; + xModel->setFormComponentMode(); + return *xModel; +} + // ============================================================================ /** A wrapper for a control form embedded directly in a draw page. */ -class EmbeddedForm : public ControlConverter +class EmbeddedForm { public: explicit EmbeddedForm( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, 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. + /** Converts the passed control and inserts the control model 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 ); + convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex ); -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 ); + /** Returns the XIndexContainer interface of the UNO control form, if existing. */ + inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > + getXForm() const { return mxFormIC; } +private: /** Creates the form that will hold the form controls. */ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > - createForm(); + createXForm(); private: + ControlConverter maControlConv; ::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; diff --git a/oox/inc/oox/ole/axcontrolfragment.hxx b/oox/inc/oox/ole/axcontrolfragment.hxx index 3c9aed61bd3e..a5273070ba8f 100644 --- a/oox/inc/oox/ole/axcontrolfragment.hxx +++ b/oox/inc/oox/ole/axcontrolfragment.hxx @@ -78,4 +78,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx index ba46d3baf6df..98085e66cfd8 100644 --- a/oox/inc/oox/ole/olehelper.hxx +++ b/oox/inc/oox/ole/olehelper.hxx @@ -100,6 +100,10 @@ public: sal_uInt32 nOleColor, bool bDefaultColorBgr = true ); + /** Returns the OLE color from the passed UNO RGB color. + */ + static sal_uInt32 encodeOleColor( sal_Int32 nRgbColor ); + /** Imports a GUID from the passed binary stream and returns its string representation (in uppercase characters). */ @@ -140,4 +144,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/oleobjecthelper.hxx b/oox/inc/oox/ole/oleobjecthelper.hxx index ef3570c4fa20..c3a58213abc9 100644 --- a/oox/inc/oox/ole/oleobjecthelper.hxx +++ b/oox/inc/oox/ole/oleobjecthelper.hxx @@ -32,8 +32,8 @@ namespace com { namespace sun { namespace star { namespace awt { struct Size; } - namespace lang { class XMultiServiceFactory; } namespace document { class XEmbeddedObjectResolver; } + namespace lang { class XMultiServiceFactory; } } } } namespace oox { class PropertyMap; } @@ -83,4 +83,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/olestorage.hxx b/oox/inc/oox/ole/olestorage.hxx index a84fadfadc92..eabcfd4d0f87 100755..100644 --- a/oox/inc/oox/ole/olestorage.hxx +++ b/oox/inc/oox/ole/olestorage.hxx @@ -31,8 +31,8 @@ #include "oox/helper/storagebase.hxx" namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } namespace container { class XNameContainer; } + namespace lang { class XMultiServiceFactory; } } } } namespace oox { diff --git a/oox/inc/oox/ole/vbacontrol.hxx b/oox/inc/oox/ole/vbacontrol.hxx index c2490b3506bf..8c4274ffda7e 100755 --- a/oox/inc/oox/ole/vbacontrol.hxx +++ b/oox/inc/oox/ole/vbacontrol.hxx @@ -32,6 +32,7 @@ namespace com { namespace sun { namespace star { namespace container { class XNameContainer; } + namespace uno { class XComponentContext; } } } } namespace oox { class StorageBase; } @@ -82,12 +83,18 @@ public: ApiControlType eCtrlType, sal_Int32 nCtrlIndex ) const; + /** Binds the passed control model to the data sources. The implementation + will check which source types are supported. */ + void bindToSources( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv ) 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. + ::rtl::OUString maControlSource; /// Linked cell for the control value in a spreadsheet. + ::rtl::OUString maRowSource; /// 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. @@ -181,11 +188,12 @@ private: // ============================================================================ -class VbaUserForm : public VbaFormControl, public ControlConverter +class VbaUserForm : public VbaFormControl { public: explicit VbaUserForm( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr = true ); @@ -198,7 +206,9 @@ public: rtl_TextEncoding eTextEnc ); private: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel; + ControlConverter maConverter; }; // ============================================================================ diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx index c1e7297d0c5b..aa7b3a081c8d 100644 --- a/oox/inc/oox/ole/vbahelper.hxx +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -54,6 +54,7 @@ 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_PROJECTNAME = 0x0004; const sal_uInt16 VBA_ID_PROJECTVERSION = 0x0009; // ============================================================================ diff --git a/oox/inc/oox/ole/vbainputstream.hxx b/oox/inc/oox/ole/vbainputstream.hxx index 4de0a91a622f..858698518968 100644 --- a/oox/inc/oox/ole/vbainputstream.hxx +++ b/oox/inc/oox/ole/vbainputstream.hxx @@ -69,4 +69,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/vbamodule.hxx b/oox/inc/oox/ole/vbamodule.hxx index 377c7abc335a..52b2261e55b5 100644 --- a/oox/inc/oox/ole/vbamodule.hxx +++ b/oox/inc/oox/ole/vbamodule.hxx @@ -28,8 +28,8 @@ #ifndef OOX_OLE_VBAMODULE_HXX #define OOX_OLE_VBAMODULE_HXX -#include <rtl/ustring.hxx> #include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> namespace com { namespace sun { namespace star { namespace container { class XNameAccess; } diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx index e8d9aa7c0f5d..40e81c923d25 100644 --- a/oox/inc/oox/ole/vbaproject.hxx +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -28,8 +28,10 @@ #ifndef OOX_OLE_VBAPROJECT_HXX #define OOX_OLE_VBAPROJECT_HXX -#include "oox/helper/storagebase.hxx" +#include <map> #include <com/sun/star/uno/XInterface.hpp> +#include "oox/helper/refvector.hxx" +#include "oox/helper/storagebase.hxx" #include "oox/dllapi.h" namespace com { namespace sun { namespace star { @@ -37,7 +39,8 @@ namespace com { namespace sun { namespace star { namespace document { class XEventsSupplier; } namespace frame { class XModel; } namespace script { class XLibraryContainer; } - namespace lang { class XMultiServiceFactory; } + namespace script { namespace vba { class XVBAMacroResolver; } } + namespace uno { class XComponentContext; } } } } namespace oox { class GraphicHelper; } @@ -51,7 +54,7 @@ class OOX_DLLPUBLIC VbaFilterConfig { public: explicit VbaFilterConfig( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const ::rtl::OUString& rConfigCompName ); ~VbaFilterConfig(); @@ -69,11 +72,52 @@ private: // ============================================================================ +/** Base class for objects that attach a amcro to a specific action. + + Purpose is to collect objects that need to attach a VBA macro to an action. + The VBA project will be loaded at a very late point of the document import + process, because it depends on an initialized core document model (e.g. + spreadsheet codenames). Some objects that want to attach a VBA macro to an + action (e.g. mouse click action for drawing shapes) are loaded long before + the VBA project. The drawback is that in most cases macros are specified + without module name, or the VBA project name is part of the macro name. + In the former case, all code modules have to be scanned for the macro to be + able to create a valid script URL. + + The import code will register these requests to attach a VBA macro with an + instance of a class derived from this base class. The derived class will + store all information needed to finally attach the macro to the action, + once the VBA project has been imported. + */ +class VbaMacroAttacherBase +{ +public: + explicit VbaMacroAttacherBase( const ::rtl::OUString& rMacroName ); + virtual ~VbaMacroAttacherBase(); + + /** Resolves the internal macro name to the related macro URL, and attaches + the macro to the object. */ + void resolveAndAttachMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAMacroResolver >& rxResolver ); + +private: + /** Called after the VBA project has been imported. Derived classes will + attach the passed script to the object represented by this instance. */ + virtual void attachMacro( const ::rtl::OUString& rScriptUrl ) = 0; + +private: + ::rtl::OUString maMacroName; +}; + +typedef ::boost::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef; + +// ============================================================================ + 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::uno::XComponentContext >& rxContext, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, const ::rtl::OUString& rConfigCompName ); virtual ~VbaProject(); @@ -87,6 +131,10 @@ public: const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr = true ); + /** Registers a macro atatcher object. For details, see description of the + VbaMacroAttacherBase class. */ + void registerMacroAttacher( const VbaMacroAttacherRef& rxAttacher ); + /** Returns true, if the document contains at least one code module. */ bool hasModules() const; /** Returns true, if the document contains the specified code module. */ @@ -101,8 +149,6 @@ protected: /** Registers a dummy module that will be created when the VBA project is imported. */ void addDummyModule( const ::rtl::OUString& rName, sal_Int32 nType ); - /** Creates all dummy modules in the document. */ - void createDummyModules(); /** Called when the import process of the VBA project has been started. */ virtual void prepareImport(); @@ -131,22 +177,28 @@ private: StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ); + + /** Attaches VBA macros to objects registered via registerMacroAttacher(). */ + void attachMacros(); + /** Copies the entire VBA project storage to the passed document model. */ void copyStorage( StorageBase& rVbaPrjStrg ); private: + typedef RefVector< VbaMacroAttacherBase > MacroAttacherVector; typedef ::std::map< ::rtl::OUString, sal_Int32 > DummyModuleMap; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - mxGlobalFactory; /// Global service factory. + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + mxCompContext; /// Component context with service manager. ::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. + MacroAttacherVector maMacroAttachers; /// Objects that want to attach a VBA macro to an action. DummyModuleMap maDummyModules; /// Additional empty modules created on import. - const ::rtl::OUString maLibName; /// Name for Basic and dialog library used for import. + ::rtl::OUString maPrjName; /// Name of the VBA project. }; // ============================================================================ diff --git a/oox/inc/oox/ole/vbaprojectfilter.hxx b/oox/inc/oox/ole/vbaprojectfilter.hxx new file mode 100755 index 000000000000..c8a0a1b0ce74 --- /dev/null +++ b/oox/inc/oox/ole/vbaprojectfilter.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * 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_VBAPROJECTFILTER_HXX +#define OOX_OLE_VBAPROJECTFILTER_HXX + +#include "oox/core/binaryfilterbase.hxx" + +namespace oox { +namespace ole { + +// ============================================================================ + +class VbaProjectFilterBase : public ::oox::core::BinaryFilterBase +{ +public: + explicit VbaProjectFilterBase( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::rtl::OUString& rAppName, + const ::rtl::OUString& rStorageName ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual bool importDocument() throw(); + virtual bool exportDocument() throw(); + +private: + virtual VbaProject* implCreateVbaProject() const; + +private: + ::rtl::OUString maAppName; + ::rtl::OUString maStorageName; +}; + +// ============================================================================ + +class WordVbaProjectFilter : public VbaProjectFilterBase +{ +public: + explicit WordVbaProjectFilter( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) + throw( ::com::sun::star::uno::RuntimeException ); + +private: + virtual ::rtl::OUString implGetImplementationName() const; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif |