diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-06-15 20:02:53 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-06-15 20:02:53 +0200 |
commit | 614e369c4cb48ea4bcafcae6c29f412e20a4e6a7 (patch) | |
tree | 94db359dfc245e110cad55b7d698cda439ffd390 /oox/source/ole | |
parent | f98601b66a4bdfea70771cac44eb8f45faf70e33 (diff) |
mib16: contributed bugfixes and various new symbols in VBA compatibility implementation
Diffstat (limited to 'oox/source/ole')
-rwxr-xr-x | oox/source/ole/axbinaryreader.cxx | 62 | ||||
-rw-r--r-- | oox/source/ole/axcontrol.cxx | 143 | ||||
-rwxr-xr-x | oox/source/ole/vbacontrol.cxx | 12 |
3 files changed, 192 insertions, 25 deletions
diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index cb7e292b8cf4..68a18932bf42 100755 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -156,6 +156,30 @@ bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm ) // ============================================================================ +namespace { + +bool lclReadString( AxAlignedInputStream& rInStrm, OUString& rValue, sal_uInt32 nSize, bool bArrayString ) +{ + bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED ); + sal_uInt32 nBufSize = nSize & AX_STRING_SIZEMASK; + // Unicode: simple strings store byte count, array strings store char count + sal_Int32 nChars = static_cast< sal_Int32 >( nBufSize / ((bCompressed || bArrayString) ? 1 : 2) ); + bool bValidChars = nChars <= 65536; + OSL_ENSURE( bValidChars, "lclReadString - string too long" ); + sal_Int64 nEndPos = rInStrm.tell() + nChars * (bCompressed ? 1 : 2); + nChars = ::std::min< sal_Int32 >( nChars, 65536 ); + rValue = bCompressed ? + // ISO-8859-1 maps all byte values xx to the same Unicode code point U+00xx + rInStrm.readCharArrayUC( nChars, RTL_TEXTENCODING_ISO_8859_1 ) : + rInStrm.readUnicodeArray( nChars ); + rInStrm.seek( nEndPos ); + return bValidChars; +} + +} // namespace + +// ---------------------------------------------------------------------------- + AxBinaryPropertyReader::ComplexProperty::~ComplexProperty() { } @@ -168,19 +192,22 @@ bool AxBinaryPropertyReader::PairProperty::readProperty( AxAlignedInputStream& r bool AxBinaryPropertyReader::StringProperty::readProperty( AxAlignedInputStream& rInStrm ) { - bool bCompressed = getFlag( mnSize, AX_STRING_COMPRESSED ); - sal_uInt32 nBufSize = mnSize & AX_STRING_SIZEMASK; - sal_Int64 nEndPos = rInStrm.tell() + nBufSize; - sal_Int32 nChars = static_cast< sal_Int32 >( nBufSize / (bCompressed ? 1 : 2) ); - bool bValidChars = nChars <= 65536; - OSL_ENSURE( bValidChars, "StringProperty::readProperty - string too long" ); - nChars = ::std::min< sal_Int32 >( nChars, 65536 ); - mrValue = bCompressed ? - // ISO-8859-1 maps all byte values xx to the same Unicode code point U+00xx - rInStrm.readCharArrayUC( nChars, RTL_TEXTENCODING_ISO_8859_1 ) : - rInStrm.readUnicodeArray( nChars ); - rInStrm.seek( nEndPos ); - return bValidChars; + return lclReadString( rInStrm, mrValue, mnSize, false ); +} + +bool AxBinaryPropertyReader::StringArrayProperty::readProperty( AxAlignedInputStream& rInStrm ) +{ + sal_Int64 nEndPos = rInStrm.tell() + mnSize; + while( rInStrm.tell() < nEndPos ) + { + OUString aString; + if( !lclReadString( rInStrm, aString, rInStrm.readuInt32(), true ) ) + return false; + mrArray.push_back( aString ); + // every array string is aligned on 4 byte boundries + rInStrm.align( 4 ); + } + return true; } bool AxBinaryPropertyReader::GuidProperty::readProperty( AxAlignedInputStream& rInStrm ) @@ -238,6 +265,15 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) } } +void AxBinaryPropertyReader::readStringArrayProperty( AxStringArray& orArray ) +{ + if( startNextProperty() ) + { + sal_uInt32 nSize = maInStrm.readAligned< sal_uInt32 >(); + maLargeProps.push_back( ComplexPropVector::value_type( new StringArrayProperty( orArray, nSize ) ) ); + } +} + void AxBinaryPropertyReader::readGuidProperty( ::rtl::OUString& orGuid ) { if( startNextProperty() ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 95d5c7dc67b7..12664e02899f 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -128,6 +128,7 @@ const sal_uInt32 AX_IMAGE_DEFFLAGS = 0x0000001B; const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B; const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B; const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B; +const sal_uInt32 AX_TABSTRIP_DEFFLAGS = 0x0000001B; const sal_uInt16 AX_POS_TOPLEFT = 0; const sal_uInt16 AX_POS_TOP = 1; @@ -186,6 +187,10 @@ const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1; const sal_Int32 AX_PROPTHUMB_ON = -1; const sal_Int32 AX_PROPTHUMB_OFF = 0; +const sal_uInt32 AX_TABSTRIP_TABS = 0; +const sal_uInt32 AX_TABSTRIP_BUTTONS = 1; +const sal_uInt32 AX_TABSTRIP_NONE = 2; + const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004; const sal_uInt32 AX_CONTAINER_HASDESIGNEXT = 0x00004000; const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000; @@ -231,14 +236,6 @@ ControlConverter::~ControlConverter() // Generic conversion --------------------------------------------------------- -void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const -{ - // size is given in 1/100 mm, UNO needs AppFont units - Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( Size( rSize.first, rSize.second ) ); - rPropMap.setProperty( PROP_Width, aAppFontSize.Width ); - rPropMap.setProperty( PROP_Height, aAppFontSize.Height ); -} - void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const { // position is given in 1/100 mm, UNO needs AppFont units @@ -247,6 +244,14 @@ void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y ); } +void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const +{ + // size is given in 1/100 mm, UNO needs AppFont units + Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( Size( rSize.first, rSize.second ) ); + rPropMap.setProperty( PROP_Width, aAppFontSize.Width ); + rPropMap.setProperty( PROP_Height, aAppFontSize.Height ); +} + void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const { rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) ); @@ -1362,7 +1367,69 @@ void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlCo // ============================================================================ -AxContainerModelBase::AxContainerModelBase() : +AxTabStripModel::AxTabStripModel() : + AxFontDataModel( false ), // no support for Align property + mnBackColor( AX_SYSCOLOR_BUTTONFACE ), + mnTextColor( AX_SYSCOLOR_BUTTONTEXT ), + mnFlags( AX_TABSTRIP_DEFFLAGS ), + mnSelectedTab( -1 ), + mnTabStyle( AX_TABSTRIP_TABS ), + mnTabFlagCount( 0 ) +{ +} + +bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readIntProperty< sal_Int32 >( mnSelectedTab ); + aReader.readIntProperty< sal_uInt32 >( mnBackColor ); + aReader.readIntProperty< sal_uInt32 >( mnTextColor ); + aReader.skipUndefinedProperty(); + aReader.readPairProperty( maSize ); + aReader.readStringArrayProperty( maCaptions ); + aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer + aReader.skipUndefinedProperty(); + aReader.skipIntProperty< sal_uInt32 >(); // tab orientation + aReader.readIntProperty< sal_uInt32 >( mnTabStyle ); + aReader.skipBoolProperty(); // multiple rows + aReader.skipIntProperty< sal_uInt32 >(); // fixed width + aReader.skipIntProperty< sal_uInt32 >(); // fixed height + aReader.skipBoolProperty(); // tooltips + aReader.skipUndefinedProperty(); + aReader.skipStringArrayProperty(); // tooltip strings + aReader.skipUndefinedProperty(); + aReader.skipStringArrayProperty(); // tab names + aReader.readIntProperty< sal_uInt32 >( mnFlags ); + aReader.skipBoolProperty(); // new version + aReader.skipIntProperty< sal_uInt32 >(); // tabs allocated + aReader.skipStringArrayProperty(); // tags + aReader.readIntProperty< sal_uInt32 >( mnTabFlagCount ); + aReader.skipStringArrayProperty(); // accelerators + aReader.skipPictureProperty(); // mouse icon + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); +} + +ApiControlType AxTabStripModel::getControlType() const +{ + return API_CONTROL_TABSTRIP; +} + +void AxTabStripModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE ); + rPropMap.setProperty( PROP_MultiPageValue, mnSelectedTab ); + rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor ); + AxFontDataModel::convertProperties( rPropMap, rConv ); +} + +OUString AxTabStripModel::getCaption( sal_Int32 nIndex ) const +{ + return ContainerHelper::getVectorElement( maCaptions, nIndex, OUString() ); +} + +// ============================================================================ + +AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) : AxFontDataModel( false ), // no support for Align property maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ), maScrollPos( 0, 0 ), @@ -1376,7 +1443,8 @@ AxContainerModelBase::AxContainerModelBase() : mnSpecialEffect( AX_SPECIALEFFECT_FLAT ), mnPicAlign( AX_PICALIGN_CENTER ), mnPicSizeMode( AX_PICSIZE_CLIP ), - mbPicTiling( false ) + mbPicTiling( false ), + mbFontSupport( bFontSupport ) { setAwtModelMode(); // different default size for frame @@ -1423,6 +1491,15 @@ bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport(); } +void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + if( mbFontSupport ) + { + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + AxFontDataModel::convertProperties( rPropMap, rConv ); + } +} + bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ) { bool bValid = true; @@ -1457,7 +1534,8 @@ bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClass // ============================================================================ -AxFrameModel::AxFrameModel() +AxFrameModel::AxFrameModel() : + AxContainerModelBase( true ) { } @@ -1475,6 +1553,49 @@ void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConver // ============================================================================ +AxFormPageModel::AxFormPageModel() +{ +} + +ApiControlType AxFormPageModel::getControlType() const +{ + return API_CONTROL_PAGE; +} + +void AxFormPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Title, maCaption ); + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) ); + rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); +} + +// ============================================================================ + +AxMultiPageModel::AxMultiPageModel() +{ +} + +ApiControlType AxMultiPageModel::getControlType() const +{ + return API_CONTROL_MULTIPAGE; +} + +void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) ); + if( mxTabStrip.get() ) + mxTabStrip->convertProperties( rPropMap, rConv ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); +} + +void AxMultiPageModel::setTabStripModel( const AxTabStripModelRef& rxTabStrip ) +{ + mxTabStrip = rxTabStrip; +} + +// ============================================================================ + AxUserFormModel::AxUserFormModel() { } diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index b43e8289a592..4952b956bae4 100755 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -231,6 +231,11 @@ void VbaSiteModel::moveRelative( const AxPairData& rDistance ) maPos.second += rDistance.second; } +bool VbaSiteModel::isVisible() const +{ + return getFlag( mnFlags, VBA_SITE_VISIBLE ); +} + bool VbaSiteModel::isContainer() const { return !getFlag( mnFlags, VBA_SITE_OSTREAM ); @@ -326,7 +331,7 @@ void VbaSiteModel::convertProperties( PropertyMap& rPropMap, if( (0 <= nCtrlIndex) && (nCtrlIndex <= SAL_MAX_INT16) ) rPropMap.setProperty( PROP_TabIndex, static_cast< sal_Int16 >( nCtrlIndex ) ); // progress bar and group box support TabIndex, but not Tabstop... - if( (eCtrlType != API_CONTROL_PROGRESSBAR) && (eCtrlType != API_CONTROL_GROUPBOX) ) + if( (eCtrlType != API_CONTROL_PROGRESSBAR) && (eCtrlType != API_CONTROL_GROUPBOX) && (eCtrlType != API_CONTROL_FRAME) && (eCtrlType != API_CONTROL_PAGE) ) rPropMap.setProperty( PROP_Tabstop, getFlag( mnFlags, VBA_SITE_TABSTOP ) ); rConv.convertPosition( rPropMap, maPos ); } @@ -367,6 +372,11 @@ OUString VbaFormControl::getControlName() const return mxSiteModel.get() ? mxSiteModel->getName() : OUString(); } +sal_Int32 VbaFormControl::getControlId() const +{ + return mxSiteModel.get() ? mxSiteModel->getId() : -1; +} + void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex, const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const { |