summaryrefslogtreecommitdiff
path: root/oox/source/helper
diff options
context:
space:
mode:
authorHenning Brinkmann <hbrinkm@openoffice.org>2010-07-30 13:50:02 +0200
committerHenning Brinkmann <hbrinkm@openoffice.org>2010-07-30 13:50:02 +0200
commitf2bb77e41ec206154e21a738fb9c1013e8879171 (patch)
tree3824e5de971c5c40c5de62ada85a300c161e6a0e /oox/source/helper
parent3be39ba02ea20768b3e8abb43233fb183d434317 (diff)
parent8020ded902edd58fd3e6da8f0192483f67dd9399 (diff)
writerfilter09: merged DEV300_m85
Diffstat (limited to 'oox/source/helper')
-rw-r--r--oox/source/helper/attributelist.cxx174
-rw-r--r--oox/source/helper/graphichelper.cxx34
2 files changed, 123 insertions, 85 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 );
}
// ============================================================================
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 6b294f61abef..455778f939f7 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -76,8 +76,9 @@ inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm
// ============================================================================
-GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XFrame >& rxTargetFrame ) :
+GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XFrame >& rxTargetFrame, const StorageRef& rxStorage ) :
mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ),
+ mxStorage( rxStorage ),
maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) )
{
::comphelper::ComponentContext aContext( rxGlobalFactory );
@@ -149,6 +150,8 @@ GraphicHelper::~GraphicHelper()
{
}
+// System colors and predefined colors ----------------------------------------
+
sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const
{
return ContainerHelper::getMapElement( maSystemPalette, nToken, nDefaultRgb );
@@ -166,6 +169,8 @@ sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const
return API_RGB_TRANSPARENT;
}
+// Device info and device dependent unit conversion ---------------------------
+
const DeviceInfo& GraphicHelper::getDeviceInfo() const
{
return maDeviceInfo;
@@ -267,6 +272,8 @@ Size GraphicHelper::convertHmmToAppFont( const Size& rHmm ) const
return Size( 0, 0 );
}
+// Graphics and graphic objects ----------------------------------------------
+
Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) const
{
Reference< XGraphic > xGraphic;
@@ -294,6 +301,25 @@ Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rG
return xGraphic;
}
+Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName ) const
+{
+ Reference< XGraphic > xGraphic;
+ OSL_ENSURE( rStreamName.getLength() > 0, "GraphicHelper::importEmbeddedGraphic - empty stream name" );
+ if( rStreamName.getLength() > 0 )
+ {
+ EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName );
+ if( aIt == maEmbeddedGraphics.end() )
+ {
+ xGraphic = importGraphic( mxStorage->openInputStream( rStreamName ) );
+ if( xGraphic.is() )
+ maEmbeddedGraphics[ rStreamName ] = xGraphic;
+ }
+ else
+ xGraphic = aIt->second;
+ }
+ return xGraphic;
+}
+
OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) const
{
OUString aGraphicObjUrl;
@@ -320,6 +346,12 @@ OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicD
return createGraphicObject( importGraphic( rGraphicData ) );
}
+OUString GraphicHelper::importEmbeddedGraphicObject( const OUString& rStreamName ) const
+{
+ Reference< XGraphic > xGraphic = importEmbeddedGraphic( rStreamName );
+ return xGraphic.is() ? createGraphicObject( xGraphic ) : OUString();
+}
+
// ============================================================================
} // namespace oox