diff options
author | Noel Power <noel.power@novell.com> | 2011-09-23 17:31:46 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-09-26 12:06:04 +0100 |
commit | 5609c512cd4d2899300b432d88d93cff05a05c87 (patch) | |
tree | 9d312ec779374bdc17934926fd612a09b06081c4 /oox/source | |
parent | f8f54cbb5d6a34ea74c4e92a3bdb8e34b7b101d6 (diff) |
move OCX_Control ( and subclasses ) and OCX control export to oox
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/helper/binaryoutputstream.cxx | 32 | ||||
-rw-r--r-- | oox/source/ole/axbinaryreader.cxx | 70 | ||||
-rw-r--r-- | oox/source/ole/axcontrol.cxx | 808 | ||||
-rw-r--r-- | oox/source/ole/olehelper.cxx | 426 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 |
5 files changed, 1210 insertions, 127 deletions
diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index 76f08ed67ff8..c96eeb95997f 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -40,6 +40,10 @@ namespace oox { using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; +using ::rtl::OString; +using ::rtl::OUString; +using ::rtl::OUStringToOString; + namespace { const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000; @@ -110,6 +114,34 @@ void BinaryXOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size_ } } +void +BinaryOutputStream::writeCharArrayUC( const OUString& rString, rtl_TextEncoding eTextEnc, bool bAllowNulChars ) +{ + OString sBuf( OUStringToOString( rString, eTextEnc ) ); + if( !bAllowNulChars ) + sBuf.replace( '\0', '?' ); + writeMemory( static_cast< const void* >( sBuf.getStr() ), sBuf.getLength() ); +} + +void +BinaryOutputStream::writeUnicodeArray( const ::rtl::OUString& rString, bool bAllowNulChars ) +{ + OUString sBuf( rString ); + if( !bAllowNulChars ) + sBuf.replace( '\0', '?' ); + writeArray( sBuf.getStr(), sBuf.getLength() ); +} + +void +BinaryOutputStream::writeCompressedUnicodeArray( const rtl::OUString& rString, bool bCompressed, bool bAllowNulChars ) +{ + if ( bCompressed ) + // ISO-8859-1 maps all byte values 0xHH to the same Unicode code point U+00HH + writeCharArrayUC( rString, RTL_TEXTENCODING_ISO_8859_1, bAllowNulChars ); + else + writeUnicodeArray( rString, bAllowNulChars ); +} + // ============================================================================ SequenceOutputStream::SequenceOutputStream( StreamDataSequence& rData ) : diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index af3076477c56..af9ed4fc040f 100644 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -121,76 +121,6 @@ void AxAlignedInputStream::align( size_t nSize ) // ============================================================================ -AxFontData::AxFontData() : - mnFontEffects( 0 ), - mnFontHeight( 160 ), - mnFontCharSet( WINDOWS_CHARSET_DEFAULT ), - mnHorAlign( AX_FONTDATA_LEFT ), - mbDblUnderline( false ) -{ -} - -sal_Int16 AxFontData::getHeightPoints() const -{ - /* MSO uses weird font sizes: - 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135, - 8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */ - return getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 ); -} - -void AxFontData::setHeightPoints( sal_Int16 nPoints ) -{ - mnFontHeight = getLimitedValue< sal_Int32, sal_Int32 >( ((nPoints * 4 + 1) / 3) * 15, 30, 4294967 ); -} - -bool AxFontData::importBinaryModel( BinaryInputStream& rInStrm ) -{ - AxBinaryPropertyReader aReader( rInStrm ); - aReader.readStringProperty( maFontName ); - aReader.readIntProperty< sal_uInt32 >( mnFontEffects ); - aReader.readIntProperty< sal_Int32 >( mnFontHeight ); - aReader.skipIntProperty< sal_Int32 >(); // font offset - aReader.readIntProperty< sal_uInt8 >( mnFontCharSet ); - aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family - aReader.readIntProperty< sal_uInt8 >( mnHorAlign ); - aReader.skipIntProperty< sal_uInt16 >(); // font weight - mbDblUnderline = false; - return aReader.finalizeImport(); -} - -bool AxFontData::importStdFont( BinaryInputStream& rInStrm ) -{ - StdFontInfo aFontInfo; - if( OleHelper::importStdFont( aFontInfo, rInStrm, false ) ) - { - maFontName = aFontInfo.maName; - mnFontEffects = 0; - setFlag( mnFontEffects, AX_FONTDATA_BOLD, aFontInfo.mnWeight >= OLE_STDFONT_BOLD ); - setFlag( mnFontEffects, AX_FONTDATA_ITALIC, getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) ); - setFlag( mnFontEffects, AX_FONTDATA_UNDERLINE, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) ); - setFlag( mnFontEffects, AX_FONTDATA_STRIKEOUT, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) ); - mbDblUnderline = false; - // StdFont stores font height in 1/10,000 of points - setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) ); - mnFontCharSet = aFontInfo.mnCharSet; - mnHorAlign = AX_FONTDATA_LEFT; - return true; - } - return false; -} - -bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm ) -{ - OUString aGuid = OleHelper::importGuid( rInStrm ); - if( aGuid.equalsAscii( AX_GUID_CFONT ) ) - return importBinaryModel( rInStrm ); - if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(OLE_GUID_STDFONT) ) ) - return importStdFont( rInStrm ); - return false; -} - -// ============================================================================ - namespace { bool lclReadString( AxAlignedInputStream& rInStrm, OUString& rValue, sal_uInt32 nSize, bool bArrayString ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index ef8ac40b00fe..a9e6d3724c59 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -61,8 +61,8 @@ #include "oox/helper/containerhelper.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" +#include "oox/ole/axbinarywriter.hxx" #include "tools/string.hxx" - namespace oox { namespace ole { @@ -281,6 +281,12 @@ void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, s rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) ); } +void ControlConverter::convertToMSColor( PropertySet& rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor ) const +{ + sal_uInt32 nRGB = 0; + rPropSet.getProperty( nRGB, nPropId ); + nOleColor = OleHelper::encodeOleColor( nRGB ); +} void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const { if( rPicData.hasElements() ) @@ -297,6 +303,13 @@ void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizont rPropMap.setProperty( PROP_Orientation, nScrollOrient ); } +void ControlConverter::convertToMSOrientation( PropertySet& rPropSet, bool& bHorizontal ) const +{ + sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL; + if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) ) + bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL ); +} + void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign ) const { VerticalAlignment eAlign = VerticalAlignment_TOP; @@ -420,12 +433,42 @@ void ControlConverter::convertAxBorder( PropertyMap& rPropMap, convertColor( rPropMap, PROP_BorderColor, nBorderColor ); } +void ControlConverter::convertToAxBorder( PropertySet& rPropSet, + sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect ) const +{ + sal_Int16 nBorder = API_BORDER_NONE; + rPropSet.getProperty( nBorder, PROP_Border ); + nBorderStyle = AX_BORDERSTYLE_NONE; + nSpecialEffect = AX_SPECIALEFFECT_FLAT; + switch ( nBorder ) + { + case API_BORDER_FLAT: + nBorderStyle = AX_BORDERSTYLE_SINGLE; + break; + case API_BORDER_SUNKEN: + nSpecialEffect = AX_SPECIALEFFECT_SUNKEN; + case API_BORDER_NONE: + default: + break; + }; + convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor ); +} + void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const { sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D; rPropMap.setProperty( PROP_VisualEffect, nVisualEffect ); } +void ControlConverter::convertToAxVisualEffect( PropertySet& rPropSet, sal_Int32& nSpecialEffect ) const +{ + sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT; + rPropSet.getProperty( nVisualEffect, PROP_VisualEffect ); + // is this appropriate AX_SPECIALEFFECT_XXXX value ? + if (nVisualEffect == VisualEffect::LOOK3D ) + nSpecialEffect = AX_SPECIALEFFECT_RAISED; +} + void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const { // the picture @@ -496,6 +539,39 @@ void ControlConverter::convertAxState( PropertyMap& rPropMap, rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELCTION_MULTI ); } +void ControlConverter::convertToAxState( PropertySet& rPropSet, + OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const +{ + bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN; + bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE; + + sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState; + sal_Int16 nState = API_STATE_DONTKNOW; + + sal_Bool bTmp = sal_False; + + if( bBooleanState ) + { + rPropSet.getProperty( bTmp, nPropId ); + if ( bTmp ) + nState = API_STATE_CHECKED; + else + nState = API_STATE_UNCHECKED; + } + else + rPropSet.getProperty( nState, nPropId ); + + rValue = rtl::OUString(); // empty e.g. 'don't know' + if ( nState == API_STATE_UNCHECKED ) + rValue = rtl::OUString( '0' ); + else if ( nState == API_STATE_CHECKED ) + rValue = rtl::OUString( '1' ); + + // tristate + if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) ) + nMultiSelect = AX_SELCTION_MULTI; +} + void ControlConverter::convertAxOrientation( PropertyMap& rPropMap, const AxPairData& rSize, sal_Int32 nOrientation ) const { @@ -510,6 +586,18 @@ void ControlConverter::convertAxOrientation( PropertyMap& rPropMap, convertOrientation( rPropMap, bHorizontal ); } +void ControlConverter::convertToAxOrientation( PropertySet& rPropSet, + const AxPairData& /*rSize*/, sal_Int32& nOrientation ) const +{ + bool bHorizontal = true; + convertToMSOrientation( rPropSet, bHorizontal ); + + if ( bHorizontal ) + nOrientation = AX_ORIENTATION_HORIZONTAL; + else + nOrientation = AX_ORIENTATION_VERTICAL; +} + // ============================================================================ ControlModelBase::ControlModelBase() : @@ -576,6 +664,10 @@ void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const Contr { } +void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ ) +{ +} + void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rConv.convertSize( rPropMap, maSize ); @@ -810,6 +902,10 @@ bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm ) return maFontData.importBinaryModel( rInStrm ); } +void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + maFontData.exportBinaryModel( rOutStrm ); +} void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { // font name @@ -849,6 +945,41 @@ void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlCon AxControlModelBase::convertProperties( rPropMap, rConv ); } +void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */) +{ + rPropSet.getProperty( maFontData.maFontName, PROP_FontName ); + float fontWeight = (float)0; + if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) ) + setFlag( maFontData.mnFontEffects, AX_FONTDATA_BOLD, ( fontWeight == FontWeight::BOLD ) ); + sal_Int16 nSlant = FontSlant_NONE; + if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) ) + setFlag( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, ( nSlant == FontSlant_ITALIC ) ); + + sal_Int16 nUnderLine = FontUnderline::NONE; + if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) ) + setFlag( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderLine != FontUnderline::NONE ); + sal_Int16 nStrikeout = FontStrikeout::NONE ; + if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) ) + setFlag( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, nStrikeout != FontStrikeout::NONE ); + + float fontHeight = 0.0; + if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) ) + maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) ); + + // TODO - handle textencoding + sal_Int16 nAlign = 0; + if ( rPropSet.getProperty( nAlign, PROP_Align ) ) + { + switch ( nAlign ) + { + case TextAlign::LEFT: maFontData.mnHorAlign = AX_FONTDATA_LEFT; break; + case TextAlign::RIGHT: maFontData.mnHorAlign = AX_FONTDATA_RIGHT; break; + case TextAlign::CENTER: maFontData.mnHorAlign = AX_FONTDATA_CENTER; break; + default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" ); + } + } +} + // ============================================================================ AxCommandButtonModel::AxCommandButtonModel() : @@ -901,6 +1032,50 @@ bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } + +void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm ); + aWriter.writeIntProperty< sal_uInt32 >( mnTextColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.writeStringProperty( maCaption ); + aWriter.skipProperty(); // pict pos + aWriter.writePairProperty( maSize ); + aWriter.skipProperty(); // mouse pointer + aWriter.skipProperty(); // picture data + aWriter.skipProperty(); // accelerator + aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus" + aWriter.skipProperty(); // mouse icon + aWriter.finalizeExport(); + AxFontDataModel::exportBinaryModel( rOutStrm ); +} + +void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7, + 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD, + 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20, + 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D, + 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F, + 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, + 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, + 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00, + 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, + 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42, + 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, + 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + ApiControlType AxCommandButtonModel::getControlType() const { return API_CONTROL_BUTTON; @@ -919,6 +1094,21 @@ void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const Contr AxFontDataModel::convertProperties( rPropMap, rConv ); } +void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + rPropSet.getProperty( maCaption, PROP_Label ); + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_Enabled ) ) + setFlag( mnFlags, AX_FLAGS_ENABLED, bRes ); + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + rPropSet.getProperty( mbFocusOnClick, PROP_FocusOnClick ); + + rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor ); + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + AxFontDataModel::convertFromProperties( rPropSet, rConv ); +} // ============================================================================ AxLabelModel::AxLabelModel() : @@ -966,6 +1156,69 @@ bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } +void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm ); + aWriter.writeIntProperty< sal_uInt32 >( mnTextColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.writeStringProperty( maCaption ); + aWriter.skipProperty(); // picture position + aWriter.writePairProperty( maSize ); + aWriter.skipProperty(); // mouse pointer + aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor ); + aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle ); + aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect ); + aWriter.skipProperty(); // picture + aWriter.skipProperty(); // accelerator + aWriter.skipProperty(); // mouse icon + aWriter.finalizeExport(); + AxFontDataModel::exportBinaryModel( rOutStrm ); +} + +void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + rPropSet.getProperty( maCaption, PROP_Label ); + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_Enabled ) ) + setFlag( mnFlags, AX_FLAGS_ENABLED, bRes ); + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + + rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor ); + // VerticleAlign doesn't seem to be read from binary + + // not sure about background color, how do we decide when to set + // AX_FLAGS_OPAQUE ? + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + + AxFontDataModel::convertFromProperties( rPropSet, rConv ); +} + +void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97, + 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA, + 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65, + 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, + 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, + 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00, + 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, + 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00, + 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + ApiControlType AxLabelModel::getControlType() const { return API_CONTROL_FIXEDTEXT; @@ -1043,6 +1296,50 @@ bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport(); } +void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm ); + aWriter.skipProperty(); //undefined + aWriter.skipProperty(); //undefined + aWriter.skipProperty(); //auto-size + aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle ); + aWriter.skipProperty(); // mouse pointer + aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode ); + aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect ); + aWriter.writePairProperty( maSize ); + aWriter.skipProperty(); //maPictureData ); + aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign ); + aWriter.writeBoolProperty( mbPicTiling ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.skipProperty(); // mouse icon + aWriter.finalizeExport(); +} + +void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C, + 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00, + 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67, + 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, + 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, + 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00, + 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, + 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00, + 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + ApiControlType AxImageModel::getControlType() const { return API_CONTROL_IMAGE; @@ -1153,6 +1450,46 @@ bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } +void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm, true ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnTextColor ); + aWriter.writeIntProperty< sal_Int32 >( mnMaxLength ); + aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle ); + aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars ); + aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle ); + aWriter.skipProperty(); // mouse pointer + aWriter.writePairProperty( maSize ); + aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar ); + aWriter.skipProperty(); // list width + aWriter.skipProperty(); // bound column + aWriter.skipProperty(); // text column + aWriter.skipProperty(); // column count + aWriter.skipProperty(); // mnListRows + aWriter.skipProperty(); // column info count + aWriter.skipProperty(); // mnMatchEntry + aWriter.skipProperty(); // list style + aWriter.skipProperty(); // mnShowDropButton ); + aWriter.skipProperty(); + aWriter.skipProperty(); // drop down style + aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect ); + aWriter.skipProperty(); // maValue; + aWriter.writeStringProperty( maCaption ); + aWriter.skipProperty(); // mnPicturePos ); + aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect ); + aWriter.skipProperty(); // mouse icon + aWriter.skipProperty(); // maPictureData + aWriter.skipProperty(); // accelerator + aWriter.skipProperty(); // undefined + aWriter.skipProperty(); // some bool + aWriter.writeStringProperty( maGroupName ); + aWriter.finalizeExport(); + AxFontDataModel::exportBinaryModel( rOutStrm ); +} + void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); @@ -1173,6 +1510,20 @@ ApiControlType AxToggleButtonModel::getControlType() const return API_CONTROL_BUTTON; } +void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + rPropSet.getProperty( maCaption, PROP_Label ); + + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + // need to process the image if one exists + rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); @@ -1185,6 +1536,31 @@ void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const Contro AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67, + 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, + 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, + 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00, + 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54, + 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74, + 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39, + 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + // ============================================================================ AxCheckBoxModel::AxCheckBoxModel() @@ -1210,6 +1586,44 @@ void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlCon AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + rPropSet.getProperty( maCaption, PROP_Label ); + + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + + rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect ); + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + // need to process the image if one exists + rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63, + 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, + 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, + 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, + 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B, + 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, + 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxOptionButtonModel::AxOptionButtonModel() @@ -1235,6 +1649,46 @@ void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const Contro AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + rPropSet.getProperty( maCaption, PROP_Label ); + + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + + rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect ); + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + // need to process the image if one exists + rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69, + 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, + 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, + 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00, + 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F, + 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74, + 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39, + 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + // ============================================================================ AxTextBoxModel::AxTextBoxModel() @@ -1263,6 +1717,53 @@ void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConv AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) + setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes ); + if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) ) + setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes ); + rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) ); + sal_Int16 nTmp(0); + if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) ) + mnMaxLength = nTmp; + if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) ) + mnPasswordChar = nTmp; + if ( rPropSet.getProperty( bRes, PROP_HScroll ) ) + setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes ); + if ( rPropSet.getProperty( bRes, PROP_VScroll ) ) + setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes ); + + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74, + 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, + 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, + 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F, + 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxNumericFieldModel::AxNumericFieldModel() @@ -1288,6 +1789,44 @@ void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const Contro AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) ) + setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes ); + rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) ); + if ( rPropSet.getProperty( bRes, PROP_Spin ) ) + setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes ); + + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74, + 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, + 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, + 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F, + 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxListBoxModel::AxListBoxModel() @@ -1311,6 +1850,40 @@ void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConv AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) ) + + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74, + 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, + 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, + 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F, + 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxComboBoxModel::AxComboBoxModel() @@ -1342,6 +1915,62 @@ void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlCon AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } +void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ? + // #TODO check against msocximex + mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX; + bool bRes = false; + + if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) ) + setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes ); + rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) ); + + sal_Int16 nTmp(0); + if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) ) + mnMaxLength = nTmp; + if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) ) + { + // when to choose AX_MATCHENTRY_FIRSTLETTER ? + // #TODO check against msocximex + if ( bRes ) + mnMatchEntry = AX_MATCHENTRY_COMPLETE; + } + if ( rPropSet.getProperty( bRes, PROP_Dropdown ) ) + { + rPropSet.getProperty( mnListRows, PROP_LineCount ); + if ( !mnListRows ) + mnListRows = 1; + } + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertFromProperties( rPropSet, rConv ); +} + +void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B, + 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA, + 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62, + 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, + 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, + 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, + 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F, + 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, + 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxSpinButtonModel::AxSpinButtonModel() : @@ -1400,6 +2029,28 @@ bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport(); } +void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm ); + aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.writePairProperty( maSize ); + aWriter.skipProperty(); // unused + aWriter.writeIntProperty< sal_Int32 >( mnMin ); + aWriter.writeIntProperty< sal_Int32 >( mnMax ); + aWriter.writeIntProperty< sal_Int32 >( mnPosition ); + aWriter.skipProperty(); // prev enabled + aWriter.skipProperty(); // next enabled + aWriter.writeIntProperty< sal_Int32 >( mnSmallChange ); + aWriter.writeIntProperty< sal_Int32 >( mnOrientation ); + aWriter.writeIntProperty< sal_Int32 >( mnDelay ); + aWriter.skipProperty(); // mouse icon + aWriter.skipProperty(); // mouse pointer + + aWriter.finalizeExport(); +} + void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { sal_Int32 nMin = ::std::min( mnMin, mnMax ); @@ -1418,6 +2069,47 @@ void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlC AxControlModelBase::convertProperties( rPropMap, rConv ); } +void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_Enabled ) ) + setFlag( mnFlags, AX_FLAGS_ENABLED, bRes ); + rPropSet.getProperty( mnMin, PROP_SpinValueMin ); + rPropSet.getProperty( mnMax, PROP_SpinValueMax ); + rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement ); + rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) ); + rPropSet.getProperty( mnDelay, PROP_RepeatDelay ); + rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor); + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + + rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation ); +} + +void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = + { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79, + 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA, + 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E, + 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, + 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, + 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, + 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, + 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 + }; + + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} // ============================================================================ AxScrollBarModel::AxScrollBarModel() : @@ -1482,6 +2174,54 @@ bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport(); } +void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm ) +{ + AxBinaryPropertyWriter aWriter( rOutStrm ); + aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnBackColor ); + aWriter.writeIntProperty< sal_uInt32 >( mnFlags ); + aWriter.writePairProperty( maSize ); + aWriter.skipProperty(); // mouse pointer + aWriter.writeIntProperty< sal_Int32 >( mnMin ); + aWriter.writeIntProperty< sal_Int32 >( mnMax ); + aWriter.writeIntProperty< sal_Int32 >( mnPosition ); + aWriter.skipProperty(); // unused + aWriter.skipProperty(); // prev enabled + aWriter.skipProperty(); // next enabled + aWriter.writeIntProperty< sal_Int32 >( mnSmallChange ); + aWriter.writeIntProperty< sal_Int32 >( mnLargeChange ); + aWriter.writeIntProperty< sal_Int32 >( mnOrientation ); + aWriter.writeIntProperty< sal_Int16 >( mnPropThumb ); + aWriter.writeIntProperty< sal_Int32 >( mnDelay ); + aWriter.skipProperty(); // mouse icon + aWriter.finalizeExport(); +} + +void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream ) +{ + // should be able to replace this hardcoded foo with + // proper export info from MS-OLEDS spec. + static sal_uInt8 const aCompObj[] = + { + 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF, + 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA, + 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00, + 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, + 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20, + 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F, + 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, + 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, + 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F, + 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F, + 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00, + 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) ); +} + void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); @@ -1501,6 +2241,26 @@ void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlCo AxControlModelBase::convertProperties( rPropMap, rConv ); } +void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) +{ + bool bRes = false; + if ( rPropSet.getProperty( bRes, PROP_Enabled ) ) + setFlag( mnFlags, AX_FLAGS_ENABLED, bRes ); + rPropSet.getProperty( mnDelay, PROP_RepeatDelay ); + sal_Int32 nThumbLen = 0; + mnPropThumb = AX_PROPTHUMB_ON; // default + rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor); + rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor ); + rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation ); + + rPropSet.getProperty( mnMin, PROP_ScrollValueMin ); + rPropSet.getProperty( mnMax, PROP_ScrollValueMax ); + rPropSet.getProperty( mnSmallChange, PROP_LineIncrement ); + rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement ); + rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) ); + +} + // ============================================================================ AxTabStripModel::AxTabStripModel() : @@ -1859,23 +2619,23 @@ EmbeddedControl::~EmbeddedControl() ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId ) { - OUString aClassId = rClassId.toAsciiUpperCase(); - - if( aClassId.equalsAscii( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >(); - if( aClassId.equalsAscii( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >(); - if( aClassId.equalsAscii( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >(); - if( aClassId.equalsAscii( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >(); - if( aClassId.equalsAscii( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >(); - if( aClassId.equalsAscii( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >(); - if( aClassId.equalsAscii( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >(); - if( aClassId.equalsAscii( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >(); - if( aClassId.equalsAscii( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >(); - if( aClassId.equalsAscii( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >(); - if( aClassId.equalsAscii( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >(); - if( aClassId.equalsAscii( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >(); - if( aClassId.equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 ); - if( aClassId.equalsAscii( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >(); - if( aClassId.equalsAscii( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >(); + OUString aClassId = rClassId;//.toAsciiUpperCase(); + + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 ); + if( aClassId.equalsIgnoreAsciiCaseAscii( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >(); + if( aClassId.equalsIgnoreAsciiCaseAscii( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >(); mxModel.reset(); return 0; @@ -1907,6 +2667,18 @@ bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtr return false; } +bool EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) +{ + if( mxModel.get() && rxCtrlModel.is() && (maName.getLength() > 0) ) + { + PropertySet aPropSet( rxCtrlModel ); + aPropSet.getProperty( maName, PROP_Name ); + mxModel->convertFromProperties( aPropSet, rConv ); + return true; + } + return false; +} + // ============================================================================ EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel, diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 2bcafc9a2882..6e6fa671b2d7 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -33,11 +33,23 @@ #include "oox/helper/graphichelper.hxx" #include "oox/token/tokens.hxx" #include "oox/ole/axcontrol.hxx" -#include <com/sun/star/beans/XPropertySet.hpp> #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" #include "oox/ole/olestorage.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/awt/Size.hpp> + +#include <tools/globname.hxx> +#include <unotools/streamwrap.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> + namespace oox { namespace ole { @@ -47,10 +59,27 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; using ::com::sun::star::form::XFormComponent; +using ::com::sun::star::form::XForm; using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::awt::Size; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::form::XFormsSupplier; +using ::com::sun::star::drawing::XDrawPage; +using ::com::sun::star::drawing::XDrawPageSupplier; +using ::com::sun::star::drawing::XShapes; +using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::io::XInputStream; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::XComponentContext; +using ::com::sun::star::container::XIndexContainer; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::lang::XMultiServiceFactory; + +using namespace ::com::sun::star::form; // ============================================================================ @@ -66,6 +95,7 @@ const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF; const sal_uInt32 OLE_BGRCOLOR_MASK = 0x00FFFFFF; const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF; + /** Swaps the red and blue component of the passed color. */ inline sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor ) { @@ -95,6 +125,101 @@ const sal_uInt32 OLE_STDHLINK_HASTIME = 0x00000040; /// Has creation tim const sal_uInt32 OLE_STDHLINK_HASFRAME = 0x00000080; /// Has frame. const sal_uInt32 OLE_STDHLINK_ASSTRING = 0x00000100; /// Hyperlink as simple string. +struct GUIDCNamePair +{ + const char* sGUID; + const char* sName; + GUIDCNamePair( const char* psId, const char* psName ) : sGUID( psId ), sName( psName ) {} + GUIDCNamePair() : sGUID( NULL ), sName( NULL ) {} +}; + +struct IdCntrlData +{ + sal_Int16 nId; + GUIDCNamePair aData; +}; + +const sal_Int16 TOGGLEBUTTON = -1; + +typedef std::map< sal_Int16, GUIDCNamePair > GUIDCNamePairMap; +class classIdToGUIDCNamePairMap +{ + GUIDCNamePairMap mnIdToGUIDCNamePairMap; + classIdToGUIDCNamePairMap(); +public: + static GUIDCNamePairMap& get(); +}; + +classIdToGUIDCNamePairMap::classIdToGUIDCNamePairMap() +{ + IdCntrlData initialCntrlData[] = + { + // Command button MUST be at index 0 + { FormComponentType::COMMANDBUTTON, + { AX_GUID_COMMANDBUTTON, "CommandButton"} , + }, + // Toggle button MUST be at index 1 + { TOGGLEBUTTON, + { AX_GUID_TOGGLEBUTTON, "ToggleButton"}, + }, + { FormComponentType::FIXEDTEXT, + { AX_GUID_LABEL, "Label"}, + }, + { FormComponentType::TEXTFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::LISTBOX, + { AX_GUID_LISTBOX, "ListBox"}, + }, + { FormComponentType::COMBOBOX, + { AX_GUID_COMBOBOX, "ComboBox"}, + }, + { FormComponentType::CHECKBOX, + { AX_GUID_CHECKBOX, "CheckBox"}, + }, + { FormComponentType::RADIOBUTTON, + { AX_GUID_OPTIONBUTTON, "OptionButton"}, + }, + { FormComponentType::IMAGECONTROL, + { AX_GUID_IMAGE, "Image"}, + }, + { FormComponentType::DATEFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::TIMEFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::NUMERICFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::CURRENCYFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::PATTERNFIELD, + { AX_GUID_TEXTBOX, "TextBox"}, + }, + { FormComponentType::IMAGEBUTTON, + { AX_GUID_COMMANDBUTTON, "CommandButton"}, + }, + { FormComponentType::SPINBUTTON, + { AX_GUID_SPINBUTTON, "SpinButton"}, + }, + { FormComponentType::SCROLLBAR, + { AX_GUID_SCROLLBAR, "ScrollBar"}, + } + }; + int length = SAL_N_ELEMENTS( initialCntrlData ); + IdCntrlData* pData = initialCntrlData; + for ( int index = 0; index < length; ++index, ++pData ) + mnIdToGUIDCNamePairMap[ pData->nId ] = pData->aData; +}; + +GUIDCNamePairMap& classIdToGUIDCNamePairMap::get() +{ + static classIdToGUIDCNamePairMap theInst; + return theInst.mnIdToGUIDCNamePairMap; +} + // ---------------------------------------------------------------------------- template< typename Type > @@ -331,16 +456,114 @@ lcl_getFrame( const Reference< ::com::sun::star::frame::XModel >& rxModel ) return xFrame; } -OleFormCtrlImportHelper::OleFormCtrlImportHelper( const Reference< com::sun::star::io::XInputStream > & rxInStrm, const Reference< ::com::sun::star::uno::XComponentContext >& rxCtx, const Reference< ::com::sun::star::frame::XModel >& rxModel ) : mpRoot( new ::oox::ole::OleStorage( rxCtx, rxInStrm, true ) ), mxCtx( rxCtx ), mxModel( rxModel ), maGrfHelper( rxCtx, lcl_getFrame( rxModel ), mpRoot ) +Reference< XComponentContext > +lcl_getUnoCtx() { + comphelper::ComponentContext aCtx( ::comphelper::getProcessServiceFactory() ); + return aCtx.getUNOContext(); } -OleFormCtrlImportHelper::~OleFormCtrlImportHelper() + + +class OleFormCtrlExportHelper +{ + ::oox::ole::EmbeddedControl maControl; + ::oox::ole::ControlModelBase* mpModel; + ::oox::GraphicHelper maGrfHelper; + Reference< XModel > mxDocModel; + Reference< XControlModel > mxControlModel; + + ::rtl::OUString maName; + ::rtl::OUString maTypeName; + ::rtl::OUString maFullName; + ::rtl::OUString maGUID; +public: + OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& xDocModel, const Reference< XControlModel >& xModel ); + virtual ::rtl::OUString getGUID() + { + rtl::OUString sResult; + if ( maGUID.getLength() > 2 ) + sResult = maGUID.copy(1, maGUID.getLength() - 2 ); + return sResult; + } + ::rtl::OUString getFullName() { return maFullName; } + ::rtl::OUString getTypeName() { return maTypeName; } + bool isValid() { return mpModel != NULL; } + void exportName( const Reference< XOutputStream >& rxOut ); + void exportCompObj( const Reference< XOutputStream >& rxOut ); + void exportControl( const Reference< XOutputStream >& rxOut, const ::com::sun::star::awt::Size& rSize ); +}; +OleFormCtrlExportHelper::OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& rxDocModel, const Reference< XControlModel >& xCntrlModel ) : maControl( CREATE_OUSTRING( "Unknown" ) ), mpModel( NULL ), maGrfHelper( rxCtx, lcl_getFrame( rxDocModel ), StorageRef() ), mxDocModel( rxDocModel ), mxControlModel( xCntrlModel ) +{ + // try to get the guid + Reference< com::sun::star::beans::XPropertySet > xProps( xCntrlModel, UNO_QUERY ); + if ( xProps.is() ) + { + sal_Int16 nClassId = 0; + PropertySet aPropSet( mxControlModel ); + if ( aPropSet.getProperty( nClassId, PROP_ClassId ) ) + { + // psuedo ripped from legacy msocximex + if ( nClassId == FormComponentType::COMMANDBUTTON ) + { + bool bToggle = false; + aPropSet.getProperty( bToggle, PROP_Toggle ); + if ( bToggle ) + nClassId = TOGGLEBUTTON; + } + + GUIDCNamePairMap& cntrlMap = classIdToGUIDCNamePairMap::get(); + GUIDCNamePairMap::iterator it = cntrlMap.find( nClassId ); + if ( it != cntrlMap.end() ) + { + aPropSet.getProperty(maName, PROP_Name ); + maTypeName = OUString::createFromAscii( it->second.sName ); + maFullName = CREATE_OUSTRING( "Microsoft Forms 2.0 " ) + maTypeName; + maControl = EmbeddedControl( maName ); + maGUID = OUString::createFromAscii( it->second.sGUID ); + mpModel = maControl.createModelFromGuid( maGUID ); + } + } + } +} + +void OleFormCtrlExportHelper::exportName( const Reference< XOutputStream >& rxOut ) +{ + oox::BinaryXOutputStream aOut( rxOut, false ); + aOut.writeUnicodeArray( maName ); + aOut << sal_Int32(0); +} + +void OleFormCtrlExportHelper::exportCompObj( const Reference< XOutputStream >& rxOut ) +{ + oox::BinaryXOutputStream aOut( rxOut, false ); + if ( mpModel && mpModel->getControlType() == API_CONTROL_BUTTON ) + mpModel->exportCompObj( aOut ); +} + +void OleFormCtrlExportHelper::exportControl( const Reference< XOutputStream >& rxOut, const Size& rSize ) +{ + oox::BinaryXOutputStream aOut( rxOut, false ); + if ( mpModel ) + { + ::oox::ole::ControlConverter aConv( mxDocModel, maGrfHelper ); + maControl.convertFromProperties( mxControlModel, aConv ); + mpModel->maSize.first = rSize.Width; + mpModel->maSize.second = rSize.Height; + mpModel->exportBinaryModel( aOut ); + } +} + +MSConvertOCXControls::MSConvertOCXControls( const Reference< ::com::sun::star::frame::XModel >& rxModel ) : SvxMSConvertOCXControls( rxModel ), mxCtx( lcl_getUnoCtx() ), maGrfHelper( mxCtx, lcl_getFrame( rxModel ), StorageRef() ) +{ +} + +MSConvertOCXControls::~MSConvertOCXControls() { } bool -OleFormCtrlImportHelper::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const ::rtl::OUString& rGuidString ) +MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const ::rtl::OUString& rGuidString ) { ::oox::ole::EmbeddedControl aControl( CREATE_OUSTRING( "Unknown" ) ); if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) ) @@ -354,21 +577,30 @@ OleFormCtrlImportHelper::importControlFromStream( ::oox::BinaryInputStream& rInS return rxFormComp.is(); } -bool -OleFormCtrlImportHelper::importFormControlFromCtls( Reference< XFormComponent > & rxFormComp, +sal_Bool +MSConvertOCXControls::ReadOCXCtlsStream( SotStorageStreamRef& rSrc1, Reference< XFormComponent > & rxFormComp, sal_Int32 nPos, sal_Int32 nStreamSize) { - if ( mpRoot.get() && mpRoot->isStorage() ) + if ( rSrc1.Is() ) { - if ( !mpCtlsStrm.get() ) - mpCtlsStrm.reset( new BinaryXInputStream( mpRoot->openInputStream( CREATE_OUSTRING( "Ctls" ) ), true ) ); - mpCtlsStrm->seek( nPos ); - OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( *mpCtlsStrm ); + BinaryXInputStream aCtlsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *rSrc1 ) ), true ); + aCtlsStrm.seek( nPos ); + OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aCtlsStrm ); + return importControlFromStream( aCtlsStrm, rxFormComp, aStrmClassId, nStreamSize ); + } + return sal_False; +} +bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const rtl::OUString& rStrmClassId, + sal_Int32 nStreamSize) +{ + if ( !rInStrm.isEof() ) + { + // Special processing for those html controls bool bOneOfHtmlControls = false; - if ( aStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_SELECT ) - || aStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_TEXTBOX ) ) + if ( rStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_SELECT ) + || rStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_TEXTBOX ) ) bOneOfHtmlControls = false; if ( bOneOfHtmlControls ) @@ -377,33 +609,42 @@ OleFormCtrlImportHelper::importFormControlFromCtls( Reference< XFormComponent > // in the binary stream. // Given the control stream length create a stream of nStreamSize bytes starting from // nPos ( offset by the guid already read in ) + if ( !nStreamSize ) + return false; const int nGuidSize = 0x10; StreamDataSequence aDataSeq; sal_Int32 nBytesToRead = nStreamSize - nGuidSize; while ( nBytesToRead ) - nBytesToRead -= mpCtlsStrm->readData( aDataSeq, nBytesToRead ); + nBytesToRead -= rInStrm.readData( aDataSeq, nBytesToRead ); SequenceInputStream aInSeqStream( aDataSeq ); - importControlFromStream( aInSeqStream, rxFormComp, aStrmClassId ); + importControlFromStream( aInSeqStream, rxFormComp, rStrmClassId ); } else { - importControlFromStream( *mpCtlsStrm, rxFormComp, aStrmClassId ); + importControlFromStream( rInStrm, rxFormComp, rStrmClassId ); } } return rxFormComp.is(); } -bool OleFormCtrlImportHelper::importControlFromStorage( ::oox::StorageRef xObjStrg, +sal_Bool MSConvertOCXControls::ReadOCXStorage( SotStorageRef& xOleStg, Reference< XFormComponent > & rxFormComp ) { - if ( xObjStrg.get() && xObjStrg->isStorage() ) + if ( xOleStg.Is() ) { - BinaryXInputStream aNameStream( xObjStrg->openInputStream( CREATE_OUSTRING("\3OCXNAME") ), true ); - BinaryXInputStream aInStrm( xObjStrg->openInputStream( CREATE_OUSTRING("contents") ), true ); - BinaryXInputStream aClsStrm( xObjStrg->openInputStream( CREATE_OUSTRING("\1CompObj") ), true ); + SvStorageStreamRef pNameStream = xOleStg->OpenSotStream( CREATE_OUSTRING("\3OCXNAME")); + BinaryXInputStream aNameStream( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pNameStream ) ), true ); + + SvStorageStreamRef pContents = xOleStg->OpenSotStream( CREATE_OUSTRING("contents")); + BinaryXInputStream aInStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pContents ) ), true ); + + + SvStorageStreamRef pClsStrm = xOleStg->OpenSotStream( CREATE_OUSTRING("\1CompObj") ); + BinaryXInputStream aClsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper(*pClsStrm ) ), true ); aClsStrm.skip(12); + OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aClsStrm ); - if ( importControlFromStream( aInStrm, rxFormComp, aStrmClassId ) ) + if ( importControlFromStream( aInStrm, rxFormComp, aStrmClassId, aInStrm.size() ) ) { OUString aName = aNameStream.readNulUnicodeArray(); Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY ); @@ -414,37 +655,144 @@ bool OleFormCtrlImportHelper::importControlFromStorage( ::oox::StorageRef xObjSt PropertySet aPropSet( xCtlModel ); aPropSet.setProperties( aPropMap ); } + return rxFormComp.is(); } } - return rxFormComp.is(); + return sal_False; } -bool -OleFormCtrlImportHelper::importFormControlFromObjStorage( Reference< XFormComponent > & rxFormComp ) +sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, SotStorageRef &xOleStg, + const Reference< XControlModel > &rxControlModel, + const com::sun::star::awt::Size& rSize, rtl::OUString &rName) +{ + SvGlobalName aName; + + OleFormCtrlExportHelper exportHelper( lcl_getUnoCtx(), rxModel, rxControlModel ); + + if ( !exportHelper.isValid() ) + return sal_False; + + rtl::OUString sId = exportHelper.getGUID(); + aName.MakeId(sId); + + rtl::OUString sFullName = exportHelper.getFullName(); + rName = exportHelper.getTypeName(); + xOleStg->SetClass( aName,0x5C,sFullName); + { + SvStorageStreamRef pNameStream = xOleStg->OpenSotStream( CREATE_OUSTRING("\3OCXNAME")); + Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pNameStream ); + exportHelper.exportName( xOut ); + } + { + SvStorageStreamRef pObjStream = xOleStg->OpenSotStream( CREATE_OUSTRING("\1CompObj")); + Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pObjStream ); + exportHelper.exportCompObj( xOut ); + } + { + SvStorageStreamRef pContents = xOleStg->OpenSotStream( CREATE_OUSTRING("contents")); + Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pContents ); + exportHelper.exportControl( xOut, rSize ); + } + return sal_True; +} + +#if SvxMSConvertOCXControlsRemoved +const Reference< com::sun::star::lang::XMultiServiceFactory > & MSConvertOCXControls::GetServiceFactory() { - return importControlFromStorage( mpRoot, rxFormComp ); + if ( !mxServiceFactory.is() && mxModel.is() ) + mxServiceFactory.set( mxModel, UNO_QUERY ); + return mxServiceFactory; } -bool -OleFormCtrlImportHelper::importFormControlFromObjPool( Reference< XFormComponent > & rxFormComp, - const ::rtl::OUString& rPoolName ) +const Reference< XIndexContainer >& + MSConvertOCXControls::GetFormComps() { - bool bRet = false; - if ( mpRoot.get() ) + if( !mxFormComps.is() ) { - if ( !mpPoolStrg.get() ) - mpPoolStrg = mpRoot->openSubStorage( CREATE_OUSTRING( "ObjectPool" ), false ); - if ( !mpPoolStrg.get() ) - return false; - if ( mpPoolStrg->isStorage() ) + GetDrawPage(); + if( mxDrawPage.is() ) { - StorageRef xObjStrg = mpPoolStrg->openSubStorage( rPoolName, false ); - bRet = importControlFromStorage( xObjStrg, rxFormComp ); + Reference< XFormsSupplier > xFormsSupplier( mxDrawPage, + UNO_QUERY ); + OSL_ENSURE( xFormsSupplier.is(), + "not able to get XFormsSupplier from XDrawPage" ); + + Reference< XNameContainer > xNameCont = + xFormsSupplier->getForms(); + + rtl::OUString sStdName = CREATE_OUSTRING( "WW-Standard" ); + rtl::OUString sName( sStdName ); + sal_uInt16 n = 0; + + while( xNameCont->hasByName( sName ) ) + { + sName = sStdName; + sName += String::CreateFromInt32( ++n ); + } + + const Reference< XMultiServiceFactory > &rServiceFactory + = GetServiceFactory(); + if( !rServiceFactory.is() ) + return mxFormComps; + + Reference< XInterface > xCreate = + rServiceFactory->createInstance( CREATE_OUSTRING( + "com.sun.star.form.component.Form")); + if( xCreate.is() ) + { + Reference< XPropertySet > xFormPropSet( xCreate, + UNO_QUERY ); + + Any aTmp(&sName,getCppuType((OUString *)0)); + xFormPropSet->setPropertyValue( CREATE_OUSTRING("Name"), aTmp ); + + Reference< XForm > xForm( xCreate, UNO_QUERY ); + OSL_ENSURE(xForm.is(), "No Form?"); + + Reference< XIndexContainer > xForms( xNameCont, + UNO_QUERY ); + OSL_ENSURE( xForms.is(), "XForms not available" ); + + aTmp.setValue( &xForm, + ::getCppuType((Reference < XForm >*)0)); + xForms->insertByIndex( xForms->getCount(), aTmp ); + + mxFormComps = Reference< XIndexContainer > + (xCreate, UNO_QUERY); + } } } - return bRet; + + return mxFormComps; +} +const Reference< XDrawPage >& MSConvertOCXControls::GetDrawPage() +{ + if( !mxDrawPage.is() && mxModel.is() ) + { + Reference< XDrawPageSupplier > xTxtDoc(mxModel, UNO_QUERY); + OSL_ENSURE( xTxtDoc.is(),"no XDrawPageSupplier from XModel"); + mxDrawPage = xTxtDoc->getDrawPage(); + OSL_ENSURE( mxDrawPage.is(), "no XDrawPage" ); + } + return mxDrawPage; } +const Reference< XShapes >& MSConvertOCXControls::GetShapes() +{ + if( !mxShapes.is() ) + { + GetDrawPage(); + if( mxDrawPage.is() ) + { + + mxShapes = Reference< XShapes >(mxDrawPage, + UNO_QUERY); + OSL_ENSURE( mxShapes.is(), "no XShapes from XDrawPage" ); + } + } + return mxShapes; +} +#endif // ============================================================================ } // namespace ole diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 64c76b6a684a..28320662f23d 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -85,6 +85,7 @@ CharWeightComplex CircleEndAngle CircleKind CircleStartAngle +ClassId CodeName Color ColumnGrand |