diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-05-21 16:46:32 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-05-21 16:46:32 +0200 |
commit | f7961a7f856f7ff6d1db953756afaa1bad413943 (patch) | |
tree | 9ae91660cb08c7dd223d11b0a62a956dccafd3e1 /oox/source/helper | |
parent | 9ab3e6e31798adb32145948f64c4c41363be6ec8 (diff) |
dr76: #i103453# import visual area for embedded documents
Diffstat (limited to 'oox/source/helper')
-rw-r--r-- | oox/source/helper/attributelist.cxx | 174 |
1 files changed, 90 insertions, 84 deletions
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 4e121497c452..5479fae46f82 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -72,22 +72,9 @@ sal_Unicode lclGetXChar( const sal_Unicode*& rpcStr, const sal_Unicode* pcEnd ) } // namespace -// ============================================================================ - -AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) : - mxAttribs( rxAttribs ) -{ - OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" ); -} - -bool AttributeList::hasAttribute( sal_Int32 nElement ) const -{ - return mxAttribs->hasAttribute( nElement ); -} - -// static string conversion ----------------------------------------------- +// ---------------------------------------------------------------------------- -OUString AttributeList::decodeXString( const OUString& rValue ) +OUString AttributeConversion::decodeXString( const OUString& rValue ) { // string shorter than one encoded character - no need to decode if( rValue.getLength() < XSTRING_ENCCHAR_LEN ) @@ -100,127 +87,146 @@ OUString AttributeList::decodeXString( const OUString& rValue ) return aBuffer.makeStringAndClear(); } -double AttributeList::decodeDouble( const OUString& rValue ) +double AttributeConversion::decodeDouble( const OUString& rValue ) { return rValue.toDouble(); } -sal_Int32 AttributeList::decodeInteger( const OUString& rValue ) +sal_Int32 AttributeConversion::decodeInteger( const OUString& rValue ) { return rValue.toInt32(); } -sal_uInt32 AttributeList::decodeUnsigned( const OUString& rValue ) +sal_uInt32 AttributeConversion::decodeUnsigned( const OUString& rValue ) { return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64(), 0, SAL_MAX_UINT32 ); } -sal_Int64 AttributeList::decodeHyper( const OUString& rValue ) +sal_Int64 AttributeConversion::decodeHyper( const OUString& rValue ) { return rValue.toInt64(); } -sal_Int32 AttributeList::decodeIntegerHex( const OUString& rValue ) +sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue ) { return rValue.toInt32( 16 ); } -sal_uInt32 AttributeList::decodeUnsignedHex( const OUString& rValue ) +sal_uInt32 AttributeConversion::decodeUnsignedHex( const OUString& rValue ) { return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64( 16 ), 0, SAL_MAX_UINT32 ); } -sal_Int64 AttributeList::decodeHyperHex( const OUString& rValue ) +sal_Int64 AttributeConversion::decodeHyperHex( const OUString& rValue ) { return rValue.toInt64( 16 ); } +// ============================================================================ + +AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) : + mxAttribs( rxAttribs ) +{ + OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" ); +} + +bool AttributeList::hasAttribute( sal_Int32 nAttrToken ) const +{ + return mxAttribs->hasAttribute( nAttrToken ); +} + // optional return values ----------------------------------------------------- -OptValue< sal_Int32 > AttributeList::getToken( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getToken( sal_Int32 nAttrToken ) const { - sal_Int32 nToken = mxAttribs->getOptionalValueToken( nElement, XML_TOKEN_INVALID ); + sal_Int32 nToken = mxAttribs->getOptionalValueToken( nAttrToken, XML_TOKEN_INVALID ); return OptValue< sal_Int32 >( nToken != XML_TOKEN_INVALID, nToken ); } -OptValue< OUString > AttributeList::getString( sal_Int32 nElement ) const +OptValue< OUString > AttributeList::getString( sal_Int32 nAttrToken ) const { - return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), mxAttribs->getOptionalValue( nElement ) ); + // check if the attribute exists (empty string may be different to missing attribute) + if( mxAttribs->hasAttribute( nAttrToken ) ) + return OptValue< OUString >( mxAttribs->getOptionalValue( nAttrToken ) ); + return OptValue< OUString >(); } -OptValue< OUString > AttributeList::getXString( sal_Int32 nElement ) const +OptValue< OUString > AttributeList::getXString( sal_Int32 nAttrToken ) const { - return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), decodeXString( mxAttribs->getOptionalValue( nElement ) ) ); + // check if the attribute exists (empty string may be different to missing attribute) + if( mxAttribs->hasAttribute( nAttrToken ) ) + return OptValue< OUString >( AttributeConversion::decodeXString( mxAttribs->getOptionalValue( nAttrToken ) ) ); + return OptValue< OUString >(); } -OptValue< double > AttributeList::getDouble( sal_Int32 nElement ) const +OptValue< double > AttributeList::getDouble( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< double >( bValid, bValid ? decodeDouble( aValue ) : 0.0 ); + return OptValue< double >( bValid, bValid ? AttributeConversion::decodeDouble( aValue ) : 0.0 ); } -OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int32 >( bValid, bValid ? decodeInteger( aValue ) : 0 ); + return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeInteger( aValue ) : 0 ); } -OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nElement ) const +OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_uInt32 >( bValid, decodeUnsigned( aValue ) ); + return OptValue< sal_uInt32 >( bValid, AttributeConversion::decodeUnsigned( aValue ) ); } -OptValue< sal_Int64 > AttributeList::getHyper( sal_Int32 nElement ) const +OptValue< sal_Int64 > AttributeList::getHyper( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int64 >( bValid, bValid ? decodeHyper( aValue ) : 0 ); + return OptValue< sal_Int64 >( bValid, bValid ? AttributeConversion::decodeHyper( aValue ) : 0 ); } -OptValue< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int32 >( bValid, bValid ? decodeIntegerHex( aValue ) : 0 ); + return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeIntegerHex( aValue ) : 0 ); } -OptValue< sal_uInt32 > AttributeList::getUnsignedHex( sal_Int32 nElement ) const +OptValue< sal_uInt32 > AttributeList::getUnsignedHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_uInt32 >( bValid, bValid ? decodeUnsignedHex( aValue ) : 0 ); + return OptValue< sal_uInt32 >( bValid, bValid ? AttributeConversion::decodeUnsignedHex( aValue ) : 0 ); } -OptValue< sal_Int64 > AttributeList::getHyperHex( sal_Int32 nElement ) const +OptValue< sal_Int64 > AttributeList::getHyperHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int64 >( bValid, bValid ? decodeHyperHex( aValue ) : 0 ); + return OptValue< sal_Int64 >( bValid, bValid ? AttributeConversion::decodeHyperHex( aValue ) : 0 ); } -OptValue< bool > AttributeList::getBool( sal_Int32 nElement ) const +OptValue< bool > AttributeList::getBool( sal_Int32 nAttrToken ) const { // boolean attributes may be "t", "f", "true", "false", "on", "off", "1", or "0" - switch( getToken( nElement, -1 ) ) + switch( getToken( nAttrToken, XML_TOKEN_INVALID ) ) { - case XML_t: return OptValue< bool >( true, true ); // used in VML - case XML_true: return OptValue< bool >( true, true ); - case XML_on: return OptValue< bool >( true, true ); - case XML_f: return OptValue< bool >( true, false ); // used in VML - case XML_false: return OptValue< bool >( true, false ); - case XML_off: return OptValue< bool >( true, false ); + case XML_t: return OptValue< bool >( true ); // used in VML + case XML_true: return OptValue< bool >( true ); + case XML_on: return OptValue< bool >( true ); + case XML_f: return OptValue< bool >( false ); // used in VML + case XML_false: return OptValue< bool >( false ); + case XML_off: return OptValue< bool >( false ); } - OptValue< sal_Int32 > onValue = getInteger( nElement ); + OptValue< sal_Int32 > onValue = getInteger( nAttrToken ); return OptValue< bool >( onValue.has(), onValue.get() != 0 ); } -OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nElement ) const +OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); DateTime aDateTime; bool bValid = (aValue.getLength() == 19) && (aValue[ 4 ] == '-') && (aValue[ 7 ] == '-') && (aValue[ 10 ] == 'T') && (aValue[ 13 ] == ':') && (aValue[ 16 ] == ':'); @@ -238,16 +244,16 @@ OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nElement ) const // defaulted return values ---------------------------------------------------- -sal_Int32 AttributeList::getToken( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return mxAttribs->getOptionalValueToken( nElement, nDefault ); + return mxAttribs->getOptionalValueToken( nAttrToken, nDefault ); } -OUString AttributeList::getString( sal_Int32 nElement, const OUString& rDefault ) const +OUString AttributeList::getString( sal_Int32 nAttrToken, const OUString& rDefault ) const { try { - return mxAttribs->getValue( nElement ); + return mxAttribs->getValue( nAttrToken ); } catch( Exception& ) { @@ -255,54 +261,54 @@ OUString AttributeList::getString( sal_Int32 nElement, const OUString& rDefault return rDefault; } -OUString AttributeList::getXString( sal_Int32 nElement, const OUString& rDefault ) const +OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const { - return getXString( nElement ).get( rDefault ); + return getXString( nAttrToken ).get( rDefault ); } -double AttributeList::getDouble( sal_Int32 nElement, double fDefault ) const +double AttributeList::getDouble( sal_Int32 nAttrToken, double fDefault ) const { - return getDouble( nElement ).get( fDefault ); + return getDouble( nAttrToken ).get( fDefault ); } -sal_Int32 AttributeList::getInteger( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return getInteger( nElement ).get( nDefault ); + return getInteger( nAttrToken ).get( nDefault ); } -sal_uInt32 AttributeList::getUnsigned( sal_Int32 nElement, sal_uInt32 nDefault ) const +sal_uInt32 AttributeList::getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const { - return getUnsigned( nElement ).get( nDefault ); + return getUnsigned( nAttrToken ).get( nDefault ); } -sal_Int64 AttributeList::getHyper( sal_Int32 nElement, sal_Int64 nDefault ) const +sal_Int64 AttributeList::getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const { - return getHyper( nElement ).get( nDefault ); + return getHyper( nAttrToken ).get( nDefault ); } -sal_Int32 AttributeList::getIntegerHex( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return getIntegerHex( nElement ).get( nDefault ); + return getIntegerHex( nAttrToken ).get( nDefault ); } -sal_uInt32 AttributeList::getUnsignedHex( sal_Int32 nElement, sal_uInt32 nDefault ) const +sal_uInt32 AttributeList::getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const { - return getUnsignedHex( nElement ).get( nDefault ); + return getUnsignedHex( nAttrToken ).get( nDefault ); } -sal_Int64 AttributeList::getHyperHex( sal_Int32 nElement, sal_Int64 nDefault ) const +sal_Int64 AttributeList::getHyperHex( sal_Int32 nAttrToken, sal_Int64 nDefault ) const { - return getHyperHex( nElement ).get( nDefault ); + return getHyperHex( nAttrToken ).get( nDefault ); } -bool AttributeList::getBool( sal_Int32 nElement, bool bDefault ) const +bool AttributeList::getBool( sal_Int32 nAttrToken, bool bDefault ) const { - return getBool( nElement ).get( bDefault ); + return getBool( nAttrToken ).get( bDefault ); } -DateTime AttributeList::getDateTime( sal_Int32 nElement, const DateTime& rDefault ) const +DateTime AttributeList::getDateTime( sal_Int32 nAttrToken, const DateTime& rDefault ) const { - return getDateTime( nElement ).get( rDefault ); + return getDateTime( nAttrToken ).get( rDefault ); } // ============================================================================ |