diff options
Diffstat (limited to 'oox/inc/oox/ole')
-rw-r--r-- | oox/inc/oox/ole/axbinaryreader.hxx | 301 | ||||
-rw-r--r-- | oox/inc/oox/ole/axcontrol.hxx | 958 | ||||
-rw-r--r-- | oox/inc/oox/ole/axcontrolfragment.hxx | 83 | ||||
-rw-r--r-- | oox/inc/oox/ole/olehelper.hxx | 149 | ||||
-rw-r--r-- | oox/inc/oox/ole/oleobjecthelper.hxx | 88 | ||||
-rw-r--r-- | oox/inc/oox/ole/olestorage.hxx | 119 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbacontrol.hxx | 219 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbahelper.hxx | 114 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbainputstream.hxx | 74 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbamodule.hxx | 120 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbaproject.hxx | 215 | ||||
-rw-r--r-- | oox/inc/oox/ole/vbaprojectfilter.hxx | 79 |
12 files changed, 2519 insertions, 0 deletions
diff --git a/oox/inc/oox/ole/axbinaryreader.hxx b/oox/inc/oox/ole/axbinaryreader.hxx new file mode 100644 index 000000000000..811e7937d236 --- /dev/null +++ b/oox/inc/oox/ole/axbinaryreader.hxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_AXBINARYREADER_HXX +#define OOX_OLE_AXBINARYREADER_HXX + +#include <utility> +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/refvector.hxx" + +namespace oox { +namespace ole { + +// ============================================================================ + +/** 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 relative stream position (relative to position of + the wrapped stream at construction time). */ + virtual sal_Int64 tell() const; + /** 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. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. + @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. */ + virtual void skip( sal_Int32 nBytes ); + + /** 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. */ + template< typename Type > + inline Type readAligned() { align( sizeof( Type ) ); return readValue< Type >(); } + /** Aligns the stream according to the passed type and skips the size of the type. */ + template< typename Type > + inline void skipAligned() { align( sizeof( Type ) ); skip( sizeof( Type ) ); } + +private: + BinaryInputStream& mrInStrm; /// The wrapped input stream. + sal_Int64 mnStrmPos; /// Tracks relative position in the stream. +}; + +// ============================================================================ + +/** A pair of integer values as a property. */ +typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData; + +/** An array of string values as a property. */ +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; +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. + bool mbDblUnderline; /// True = double underline style (legacy VML drawing controls only). + + 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 +{ +public: + explicit AxBinaryPropertyReader( BinaryInputStream& rInStrm, bool b64BitPropFlags = false ); + + /** Reads the next integer property value from the stream, if the + respective flag in the property mask is set. */ + template< typename StreamType, typename DataType > + inline void readIntProperty( DataType& ornValue ) + { if( startNextProperty() ) ornValue = maInStrm.readAligned< StreamType >(); } + /** Reads the next boolean property value from the stream, if the + respective flag in the property mask is set. */ + 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( 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 a string array property from the stream, if the respective flag + in the property mask is set. */ + void readStringArrayProperty( AxStringArray& orArray ); + /** 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 ); + + /** Skips the next integer property value in the stream, if the respective + flag in the property mask is set. */ + template< typename StreamType > + inline void skipIntProperty() { if( startNextProperty() ) maInStrm.skipAligned< StreamType >(); } + /** 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 string array property in the stream, if the respective + flag in the property mask is set. */ + inline void skipStringArrayProperty() { readStringArrayProperty( maDummyStringArray ); } + /** 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 ); } + /** Has to be called for undefined properties. If the respective flag in + the mask is set, the property import cannot be finished successfully. */ + inline void skipUndefinedProperty() { ensureValid( !startNextProperty() ); } + + /** Final processing, reads contents of all complex properties. */ + bool finalizeImport(); + +private: + bool ensureValid( bool bCondition = true ); + bool startNextProperty(); + +private: + /** Base class for complex properties such as string, point, size, GUID, picture. */ + struct ComplexProperty + { + virtual ~ComplexProperty(); + virtual bool readProperty( AxAlignedInputStream& rInStrm ) = 0; + }; + + /** Complex property for a 32-bit value pair, e.g. point or size. */ + struct PairProperty : public ComplexProperty + { + AxPairData& mrPairData; + + inline explicit PairProperty( AxPairData& rPairData ) : + mrPairData( rPairData ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + /** Complex property for a string value. */ + struct StringProperty : public ComplexProperty + { + ::rtl::OUString& mrValue; + sal_uInt32 mnSize; + + inline explicit StringProperty( ::rtl::OUString& rValue, sal_uInt32 nSize ) : + mrValue( rValue ), mnSize( nSize ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + /** Complex property for an array of strings. */ + struct StringArrayProperty : public ComplexProperty + { + AxStringArray& mrArray; + sal_uInt32 mnSize; + inline explicit StringArrayProperty( AxStringArray& rArray, sal_uInt32 nSize ) : + mrArray( rArray ), mnSize( nSize ) {} + 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 + { + StreamDataSequence& mrPicData; + + inline explicit PictureProperty( StreamDataSequence& rPicData ) : + mrPicData( rPicData ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + typedef RefVector< ComplexProperty > ComplexPropVector; + +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. + AxStringArray maDummyStringArray; /// Dummy string array for unsupported properties. + sal_Int64 mnPropFlags; /// Flags specifying existing properties. + sal_Int64 mnNextProp; /// Next property to read. + sal_Int64 mnPropsEnd; /// End position of simple/large properties. + bool mbValid; /// True = stream still valid. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx new file mode 100644 index 000000000000..273bacd5121a --- /dev/null +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -0,0 +1,958 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_AXCONTROL_HXX +#define OOX_OLE_AXCONTROL_HXX + +#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" + +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; } +} } } + +namespace oox { + class BinaryInputStream; + class GraphicHelper; + class PropertyMap; +} + +namespace oox { +namespace ole { + +// ============================================================================ + +#define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}" +#define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}" +#define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}" + +const sal_uInt16 COMCTL_VERSION_50 = 5; +const sal_uInt16 COMCTL_VERSION_60 = 6; + +// ---------------------------------------------------------------------------- + +#define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-A777-00DD01143C57}" +#define AX_GUID_LABEL "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}" +#define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000B65C6F9}" +#define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}" +#define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97EF-00AA006D2776}" +#define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-A449-00AA004A803D}" +#define 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_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; + +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; + +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. */ +enum ApiControlType +{ + API_CONTROL_BUTTON, + API_CONTROL_FIXEDTEXT, + API_CONTROL_IMAGE, + API_CONTROL_CHECKBOX, + API_CONTROL_RADIOBUTTON, + API_CONTROL_EDIT, + API_CONTROL_NUMERIC, + API_CONTROL_LISTBOX, + API_CONTROL_COMBOBOX, + API_CONTROL_SPINBUTTON, + API_CONTROL_SCROLLBAR, + API_CONTROL_TABSTRIP, + API_CONTROL_PROGRESSBAR, + API_CONTROL_GROUPBOX, + API_CONTROL_FRAME, + API_CONTROL_PAGE, + API_CONTROL_MULTIPAGE, + 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 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + 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 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. */ + 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: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel; + const GraphicHelper& mrGraphicHelper; + mutable PropertySet maAddressConverter; + mutable PropertySet maRangeConverter; + bool mbDefaultColorBgr; +}; + +// ============================================================================ + +/** Base class for all models of form controls. */ +class ControlModelBase +{ +public: + 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 bool importBinaryModel( BinaryInputStream& rInStrm ) = 0; + + /** Derived classes return the UNO control type enum value. */ + virtual ApiControlType getControlType() const = 0; + /** Derived classes convert all control properties. */ + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Converts the control size to UNO properties. */ + void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. +}; + +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: + 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( bool bSupportsAlign = true ); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Returns the font height in points. */ + inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); } + +public: // direct access needed for legacy VML drawing controls + AxFontData maFontData; /// The font settings. + +private: + bool mbSupportsAlign; /// True = UNO model supports Align property. +}; + +// ============================================================================ + +/** Model for a Forms 2.0 command button. */ +class AxCommandButtonModel : public AxFontDataModel +{ +public: + explicit AxCommandButtonModel(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. +}; + +// ============================================================================ + +/** Model for a Forms 2.0 label. */ +class AxLabelModel : public AxFontDataModel +{ +public: + explicit AxLabelModel(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. + sal_uInt32 mnFlags; /// Various flags. + 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). +}; + +// ============================================================================ + +/** Model for a Forms 2.0 image. */ +class AxImageModel : public AxControlModelBase +{ +public: + explicit AxImageModel(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +private: + StreamDataSequence maPictureData; /// Binary picture stream. + sal_uInt32 mnBackColor; /// Fill color. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnBorderColor; /// Flat border color. + sal_Int32 mnBorderStyle; /// Flat border style. + sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnPicSizeMode; /// Clip, stretch, zoom. + sal_Int32 mnPicAlign; /// Anchor position of the picture. + bool mbPicTiling; /// True = picture is repeated. +}; + +// ============================================================================ + +/** Base class for a Forms 2.0 morph data control. */ +class AxMorphDataModelBase : public AxFontDataModel +{ +public: + explicit AxMorphDataModelBase(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. + ::rtl::OUString maGroupName; /// Group name for option buttons. + 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_uInt32 mnBorderColor; /// Flat border color. + sal_Int32 mnBorderStyle; /// Flat border style. + sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnDisplayStyle; /// Type of the morph control. + sal_Int32 mnMultiSelect; /// Selection mode. + sal_Int32 mnScrollBars; /// Horizontal/vertical scroll bar. + sal_Int32 mnMatchEntry; /// Auto completion mode. + sal_Int32 mnShowDropButton; /// When to show the dropdown button. + 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). +}; + +// ============================================================================ + +/** Model for a Forms 2.0 toggle button. */ +class AxToggleButtonModel : public AxMorphDataModelBase +{ +public: + explicit AxToggleButtonModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 check box. */ +class AxCheckBoxModel : public AxMorphDataModelBase +{ +public: + explicit AxCheckBoxModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 option button. */ +class AxOptionButtonModel : public AxMorphDataModelBase +{ +public: + explicit AxOptionButtonModel(); + + /** 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; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 text box. */ +class AxTextBoxModel : public AxMorphDataModelBase +{ +public: + explicit AxTextBoxModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** 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 +{ +public: + explicit AxListBoxModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 combo box. */ +class AxComboBoxModel : public AxMorphDataModelBase +{ +public: + explicit AxComboBoxModel(); + + 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 void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. + sal_Int32 mnOrientation; /// Orientation of the 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. + sal_Int32 mnSmallChange; /// Increment step size. + sal_Int32 mnDelay; /// Repeat delay in milliseconds. +}; + +// ============================================================================ + +/** Model for a Forms 2.0 scroll bar. */ +class AxScrollBarModel : public AxControlModelBase +{ +public: + explicit AxScrollBarModel(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +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. + sal_Int32 mnOrientation; /// Orientation of the buttons. + sal_Int32 mnPropThumb; /// Proportional thumb size. + sal_Int32 mnMin; /// Minimum of the value range. + sal_Int32 mnMax; /// Maximum of the value range. + sal_Int32 mnPosition; /// Value of the spin button. + sal_Int32 mnSmallChange; /// Increment step size (buttons). + sal_Int32 mnLargeChange; /// Increment step size (thumb). + sal_Int32 mnDelay; /// Repeat delay in milliseconds. +}; + +// ============================================================================ + +/** Model for a Forms 2.0 tabstrip control. */ +class AxTabStripModel : public AxFontDataModel +{ +public: + explicit AxTabStripModel(); + + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Returns the caption with the specified zero-based index. */ + ::rtl::OUString getCaption( sal_Int32 nIndex ) const; + +private: + AxStringArray maCaptions; /// Captions of all tabs. + sal_uInt32 mnBackColor; /// Fill color. + sal_uInt32 mnTextColor; /// Text color. + sal_uInt32 mnFlags; /// Various flags. + sal_Int32 mnSelectedTab; /// The index of the selected tab. + sal_uInt32 mnTabStyle; /// Visual style of the tabs. + sal_Int32 mnTabFlagCount; /// Number of entries in tab flag array. +}; + +typedef ::boost::shared_ptr< AxTabStripModel > AxTabStripModelRef; + +// ============================================================================ + +typedef ::std::vector< ::rtl::OUString > AxClassTable; + +/** Base class for ActiveX container controls. */ +class AxContainerModelBase : public AxFontDataModel +{ +public: + explicit AxContainerModelBase( bool bFontSupport = false ); + + /** 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 ); + /** Converts font settings if supported. */ + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Reads the class table structure for embedded controls following the own + model from the 'f' stream. */ + bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ); + +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). + 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. + bool mbFontSupport; /// True = control supports the font property. +}; + +typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef; + +// ============================================================================ + +/** Model for a Forms 2.0 frame control. */ +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 formpage control (a single page in a multipage control). */ +class AxFormPageModel : public AxContainerModelBase +{ +public: + explicit AxFormPageModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 multipage control. Contains the tabstrip control + (class AxTabStripModel) and the single pages (class AxFormPageModel). */ +class AxMultiPageModel : public AxContainerModelBase +{ +public: + explicit AxMultiPageModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Sets the tabstrip control model related to this multipage control. + Contains all formatting attributes of the page tabs. */ + void setTabStripModel( const AxTabStripModelRef& rxTabStrip ); + +private: + AxTabStripModelRef mxTabStrip; +}; + +// ============================================================================ + +/** 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 ); + 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. */ + 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; + + /** 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: + ControlModelRef mxModel; /// Control model containing the properties. + ::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: + explicit EmbeddedForm( + 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 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, sal_Int32& rnCtrlIndex ); + + /** 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 > + 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; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/axcontrolfragment.hxx b/oox/inc/oox/ole/axcontrolfragment.hxx new file mode 100644 index 000000000000..8688cabe68a9 --- /dev/null +++ b/oox/inc/oox/ole/axcontrolfragment.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_AXCONTROLFRAGMENT_HXX +#define OOX_OLE_AXCONTROLFRAGMENT_HXX + +#include "oox/core/fragmenthandler2.hxx" + +namespace oox { +namespace ole { + +class ControlModelBase; +class EmbeddedControl; + +// ============================================================================ + +/** Context handler for ActiveX form control model properties. */ +class AxControlPropertyContext : public ::oox::core::ContextHandler2 +{ +public: + explicit AxControlPropertyContext( + ::oox::core::FragmentHandler2& rFragment, + ControlModelBase& rModel ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + ControlModelBase& mrModel; + sal_Int32 mnPropId; /// Identifier of currently processed property. +}; + +// ============================================================================ + +/** 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, + EmbeddedControl& rControl ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + EmbeddedControl& mrControl; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx new file mode 100644 index 000000000000..ffaaf8328636 --- /dev/null +++ b/oox/inc/oox/ole/olehelper.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_OLEHELPER_HXX +#define OOX_OLE_OLEHELPER_HXX + +#include <rtl/ustring.hxx> +#include "oox/helper/binarystreambase.hxx" + +namespace oox { + class BinaryInputStream; + class GraphicHelper; +} + +namespace oox { +namespace ole { + +// ============================================================================ + +#define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}" +#define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}" +#define 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 +{ + ::rtl::OUString maTarget; + ::rtl::OUString maLocation; + ::rtl::OUString maDisplay; + ::rtl::OUString maFrame; +}; + +// ============================================================================ + +/** Static helper functions for OLE import/export. */ +class OleHelper +{ +public: + /** 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 ); + + /** 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). + */ + static ::rtl::OUString importGuid( BinaryInputStream& rInStrm ); + + /** 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, + bool bWithGuid ); + +private: + OleHelper(); // not implemented + ~OleHelper(); // not implemented +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/oox/inc/oox/ole/oleobjecthelper.hxx b/oox/inc/oox/ole/oleobjecthelper.hxx new file mode 100644 index 000000000000..659e927d203b --- /dev/null +++ b/oox/inc/oox/ole/oleobjecthelper.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_OLEOBJECTHELPER_HXX +#define OOX_OLE_OLEOBJECTHELPER_HXX + +#include "oox/helper/binarystreambase.hxx" + +namespace com { namespace sun { namespace star { + namespace awt { struct Size; } + namespace document { class XEmbeddedObjectResolver; } + namespace lang { class XMultiServiceFactory; } +} } } + +namespace oox { class PropertyMap; } + +namespace oox { +namespace ole { + +// ============================================================================ + +/** Contains generic information about an OLE object. */ +struct OleObjectInfo +{ + StreamDataSequence maEmbeddedData; /// Data of an embedded OLE object. + ::rtl::OUString maTargetLink; /// Path to external data for linked OLE object. + ::rtl::OUString maProgId; + bool mbLinked; /// True = linked OLE object, false = embedded OLE object. + bool mbShowAsIcon; /// True = show as icon, false = show contents. + bool mbAutoUpdate; + + explicit OleObjectInfo(); +}; + +// ============================================================================ + +/** Helper for OLE object handling. */ +class OleObjectHelper +{ +public: + explicit OleObjectHelper( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); + ~OleObjectHelper(); + + bool importOleObject( + PropertyMap& rPropMap, + const OleObjectInfo& rOleObject, + const ::com::sun::star::awt::Size& rObjSize ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedObjectResolver > mxResolver; + const ::rtl::OUString maEmbeddedObjScheme; + sal_Int32 mnObjectId; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/oox/inc/oox/ole/olestorage.hxx b/oox/inc/oox/ole/olestorage.hxx new file mode 100644 index 000000000000..d2c22f5aa0f6 --- /dev/null +++ b/oox/inc/oox/ole/olestorage.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_OLESTORAGE_HXX +#define OOX_OLE_OLESTORAGE_HXX + +#include "oox/helper/storagebase.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace lang { class XMultiServiceFactory; } +} } } + +namespace oox { +namespace ole { + +// ============================================================================ + +/** Implements stream access for binary OLE storages. */ +class OOX_DLLPUBLIC OleStorage : public StorageBase +{ +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::XInputStream >& rxInStream, + bool bBaseStreamAccess ); + + 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 >& rxOutStream, + bool bBaseStreamAccess ); + + virtual ~OleStorage(); + +private: + explicit OleStorage( + const OleStorage& rParentStorage, + 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; + + /** Returns the com.sun.star.embed.XStorage interface of the current storage. + + @attention + This function is not implemented for binary OLE storages. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + implGetXStorage() const; + + /** Returns the names of all elements of this storage. */ + 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 bCreateMissing ); + + /** Opens and returns the specified input stream from the storage. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + implOpenInputStream( const ::rtl::OUString& rElementName ); + + /** Opens and returns the specified output stream from the storage. */ + 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: + ::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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/vbacontrol.hxx b/oox/inc/oox/ole/vbacontrol.hxx new file mode 100644 index 000000000000..3c862a9b2046 --- /dev/null +++ b/oox/inc/oox/ole/vbacontrol.hxx @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBACONTROL_HXX +#define OOX_OLE_VBACONTROL_HXX + +#include "oox/ole/axcontrol.hxx" +#include <com/sun/star/frame/XModel.hpp> + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace uno { class XComponentContext; } +} } } + +namespace oox { class StorageBase; } + +namespace oox { +namespace ole { + +// ============================================================================ + +/** 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 the unique identifier of this control. */ + inline sal_Int32 getId() const { return mnId; } + /** Returns true, if the control is visible. */ + bool isVisible() const; + /** 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; + + /** 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 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. + 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; + /** Returns the unique identifier of this control. */ + sal_Int32 getControlId() 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( StorageBase& rStrg ); + + /** 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: + explicit VbaUserForm( + 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 ); + + /** 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::frame::XModel >& rxDocModel, + 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::uno::XComponentContext > mxCompContext; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel; + ControlConverter maConverter; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx new file mode 100644 index 000000000000..1f67a7759aa6 --- /dev/null +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAHELPER_HXX +#define OOX_OLE_VBAHELPER_HXX + +#include "oox/helper/binarystreambase.hxx" + +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_PROJECTNAME = 0x0004; +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 ); + +private: + VbaHelper(); + ~VbaHelper(); +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/vbainputstream.hxx b/oox/inc/oox/ole/vbainputstream.hxx new file mode 100644 index 000000000000..0dc644d3bc24 --- /dev/null +++ b/oox/inc/oox/ole/vbainputstream.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAINPUTSTREAM_HXX +#define OOX_OLE_VBAINPUTSTREAM_HXX + +#include <vector> +#include "oox/helper/binaryinputstream.hxx" + +namespace oox { +namespace ole { + +// ============================================================================ + +/** A non-seekable input stream that implements run-length decompression. */ +class VbaInputStream : public BinaryInputStream +{ +public: + explicit VbaInputStream( BinaryInputStream& rInStrm ); + + /** Reads nBytes bytes to the passed sequence. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. + @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. */ + virtual void skip( sal_Int32 nBytes ); + +private: + /** If no data left in chunk buffer, reads the next chunk from stream. */ + bool updateChunk(); + +private: + typedef ::std::vector< sal_uInt8 > ChunkBuffer; + + BinaryInputStream& mrInStrm; + ChunkBuffer maChunk; + size_t mnChunkPos; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/oox/inc/oox/ole/vbamodule.hxx b/oox/inc/oox/ole/vbamodule.hxx new file mode 100644 index 000000000000..a0fc68a6c3f5 --- /dev/null +++ b/oox/inc/oox/ole/vbamodule.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAMODULE_HXX +#define OOX_OLE_VBAMODULE_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.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 VBA source code into the passed Basic library. */ + void createAndImportModule( + 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 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleNameOverrides ) const; + /** Creates an empty Basic module in the passed Basic library. */ + void createEmptyModule( + 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: + /** Reads and returns the VBA source code from the passed storage. */ + ::rtl::OUString readSourceCode( + StorageBase& rVbaStrg, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleNameOverrides ) const; + + void extractOleOverrideFromAttr( const rtl::OUString& rAttribute, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleNameOverrides ) const; + + /** Creates a new Basic module and inserts it into the passed Basic library. */ + void createModule( + const ::rtl::OUString& rVBASourceCode, + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx new file mode 100644 index 000000000000..2d1b4fd60cf8 --- /dev/null +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAPROJECT_HXX +#define OOX_OLE_VBAPROJECT_HXX + +#include <map> +#include <com/sun/star/uno/XInterface.hpp> +#include "oox/helper/refvector.hxx" +#include "oox/helper/storagebase.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } + namespace frame { class XModel; } + namespace script { class XLibraryContainer; } + namespace script { namespace vba { class XVBAMacroResolver; } } + namespace uno { class XComponentContext; } +} } } + +namespace oox { class GraphicHelper; } + +namespace oox { +namespace ole { + +// ============================================================================ + +class VbaFilterConfig +{ +public: + explicit VbaFilterConfig( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + 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; +}; + +// ============================================================================ + +/** 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::uno::XComponentContext >& rxContext, + 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 ); + + /** 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. */ + 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; + + void setOleOverridesSink( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleOverridesSink ){ mxOleOverridesSink = rxOleOverridesSink; } + +protected: + /** Registers a dummy module that will be created when the VBA project is + imported. */ + void addDummyModule( const ::rtl::OUString& rName, sal_Int32 nType ); + + /** Called when the import process of the VBA project has been started. */ + virtual void prepareImport(); + /** Called when the import process of the VBA project is finished. */ + virtual void finalizeImport(); + +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 ); + + /** 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::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. + ::rtl::OUString maPrjName; /// Name of the VBA project. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxOleOverridesSink; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ole/vbaprojectfilter.hxx b/oox/inc/oox/ole/vbaprojectfilter.hxx new file mode 100644 index 000000000000..03d49dfb71f1 --- /dev/null +++ b/oox/inc/oox/ole/vbaprojectfilter.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |