diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-06-03 11:12:10 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-06-03 11:12:10 +0200 |
commit | 85b12c651ea75ce0006b1b04c2eaafb998cb9837 (patch) | |
tree | 494052d2496a51dd75ae41eaa1c1c25540fd4814 /oox/source | |
parent | 1ab26b208e07f2348ccf55d12de9648b8c6594a2 (diff) |
dr76: #i111404# move image stream handling into GraphicHelper
Diffstat (limited to 'oox/source')
-rwxr-xr-x | oox/source/core/filterbase.cxx | 35 | ||||
-rw-r--r-- | oox/source/drawingml/fillpropertiesgroupcontext.cxx | 3 | ||||
-rw-r--r-- | oox/source/drawingml/graphicshapecontext.cxx | 3 | ||||
-rw-r--r-- | oox/source/helper/graphichelper.cxx | 34 | ||||
-rw-r--r-- | oox/source/ppt/pptimport.cxx | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlformatting.cxx | 5 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 9 | ||||
-rw-r--r-- | oox/source/xls/pagesettings.cxx | 2 | ||||
-rw-r--r-- | oox/source/xls/stylesbuffer.cxx | 2 |
9 files changed, 51 insertions, 44 deletions
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 902784cafe80..5ed1d7094ff3 100755 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -130,10 +130,9 @@ enum FilterDirection struct FilterBaseImpl { - typedef ::boost::shared_ptr< GraphicHelper > GraphicHelperRef; - typedef ::boost::shared_ptr< ModelObjectHelper > ModelObjHelperRef; - typedef ::boost::shared_ptr< OleObjectHelper > OleObjHelperRef; - typedef ::std::map< OUString, Reference< XGraphic > > EmbeddedGraphicMap; + typedef ::boost::shared_ptr< GraphicHelper > GraphicHelperRef; + typedef ::boost::shared_ptr< ModelObjectHelper > ModelObjHelperRef; + typedef ::boost::shared_ptr< OleObjectHelper > OleObjHelperRef; FilterDirection meDirection; SequenceAsHashMap maArguments; @@ -144,7 +143,6 @@ struct FilterBaseImpl GraphicHelperRef mxGraphicHelper; /// Graphic and graphic object handling. ModelObjHelperRef mxModelObjHelper; /// Tables to create new named drawing objects. OleObjHelperRef mxOleObjHelper; /// OLE object handling. - EmbeddedGraphicMap maEmbeddedGraphics; /// Maps all imported embedded graphics by their path. Reference< XMultiServiceFactory > mxGlobalFactory; Reference< XModel > mxModel; @@ -423,31 +421,6 @@ bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString return true; } -Reference< XGraphic > FilterBase::importEmbeddedGraphic( const OUString& rStreamName ) const -{ - Reference< XGraphic > xGraphic; - OSL_ENSURE( rStreamName.getLength() > 0, "FilterBase::importEmbeddedGraphic - empty stream name" ); - if( rStreamName.getLength() > 0 ) - { - FilterBaseImpl::EmbeddedGraphicMap::const_iterator aIt = mxImpl->maEmbeddedGraphics.find( rStreamName ); - if( aIt == mxImpl->maEmbeddedGraphics.end() ) - { - xGraphic = getGraphicHelper().importGraphic( openInputStream( rStreamName ) ); - if( xGraphic.is() ) - mxImpl->maEmbeddedGraphics[ rStreamName ] = xGraphic; - } - else - xGraphic = aIt->second; - } - return xGraphic; -} - -OUString FilterBase::importEmbeddedGraphicObject( const OUString& rStreamName ) const -{ - Reference< XGraphic > xGraphic = importEmbeddedGraphic( rStreamName ); - return xGraphic.is() ? getGraphicHelper().createGraphicObject( xGraphic ) : OUString(); -} - // com.sun.star.lang.XServiceInfo interface ----------------------------------- OUString SAL_CALL FilterBase::getImplementationName() throw( RuntimeException ) @@ -587,7 +560,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc GraphicHelper* FilterBase::implCreateGraphicHelper() const { // default: return base implementation without any special behaviour - return new GraphicHelper( mxImpl->mxGlobalFactory, mxImpl->mxTargetFrame ); + return new GraphicHelper( mxImpl->mxGlobalFactory, mxImpl->mxTargetFrame, mxImpl->mxStorage ); } // ============================================================================ diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index 8adffb265240..b9d7fa7e1142 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -27,6 +27,7 @@ #include "oox/drawingml/fillpropertiesgroupcontext.hxx" #include "oox/helper/attributelist.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/core/namespaces.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" @@ -170,7 +171,7 @@ BlipContext::BlipContext( ContextHandler& rParent, // internal picture URL OUString aFragmentPath = getFragmentPathFromRelId( aAttribs.getString( R_TOKEN( embed ), OUString() ) ); if( aFragmentPath.getLength() > 0 ) - mrBlipProps.mxGraphic = getFilter().importEmbeddedGraphic( aFragmentPath ); + mrBlipProps.mxGraphic = getFilter().getGraphicHelper().importEmbeddedGraphic( aFragmentPath ); } else if( aAttribs.hasAttribute( R_TOKEN( link ) ) ) { diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index a0335fe68ee2..16604a77469b 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -35,6 +35,7 @@ #include "oox/core/namespaces.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/helper/attributelist.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/vml/vmldrawing.hxx" #include "oox/vml/vmlshape.hxx" @@ -189,7 +190,7 @@ OUString CreateOleObjectCallback::onCreateXShape( const OUString&, const awt::Re // import and store the graphic if( aGraphicPath.getLength() > 0 ) { - Reference< graphic::XGraphic > xGraphic = mrFilter.importEmbeddedGraphic( aGraphicPath ); + Reference< graphic::XGraphic > xGraphic = mrFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath ); if( xGraphic.is() ) maShapeProps[ PROP_Graphic ] <<= xGraphic; } 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 diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 39ad52316a92..d60629b4481b 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -163,7 +163,7 @@ private: }; PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : - GraphicHelper( rFilter.getGlobalFactory(), rFilter.getTargetFrame() ), + GraphicHelper( rFilter.getGlobalFactory(), rFilter.getTargetFrame(), rFilter.getStorage() ), mrFilter( rFilter ) { } diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 3b832d9daf12..827930c22496 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -31,7 +31,6 @@ #include "oox/token/tokenmap.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/color.hxx" #include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/fillproperties.hxx" @@ -475,7 +474,7 @@ void FillModel::assignUsed( const FillModel& rSource ) moRotate.assignIfUsed( rSource.moRotate ); } -void FillModel::pushToPropMap( PropertyMap& rPropMap, ::oox::core::FilterBase& rFilter, +void FillModel::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const { /* Convert VML fill formatting to DrawingML fill formatting and let the @@ -569,7 +568,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, ::oox::core::FilterBase& r { if( moBitmapPath.has() && moBitmapPath.get().getLength() > 0 ) { - aFillProps.maBlipProps.mxGraphic = rFilter.importEmbeddedGraphic( moBitmapPath.get() ); + aFillProps.maBlipProps.mxGraphic = rGraphicHelper.importEmbeddedGraphic( moBitmapPath.get() ); if( aFillProps.maBlipProps.mxGraphic.is() ) { aFillProps.moFillType = XML_blipFill; diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 9bca05d69b24..d557a7f50354 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include "properties.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" #include "oox/core/xmlfilterbase.hxx" @@ -99,7 +100,7 @@ Reference< XShape > lclCreateXShape( const XmlFilterBase& rFilter, const OUStrin Reference< XShape > xShape; try { - Reference< XMultiServiceFactory > xFactory( rFilter.getModel(), UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xFactory( rFilter.getModelFactory(), UNO_SET_THROW ); xShape.set( xFactory->createInstance( rService ), UNO_QUERY_THROW ); } catch( Exception& ) @@ -317,7 +318,7 @@ void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) con PropertyMap aPropMap; maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); - maTypeModel.maFillModel.pushToPropMap( aPropMap, mrDrawing.getFilter(), rModelObjectHelper, rGraphicHelper ); + maTypeModel.maFillModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); PropertySet aPropSet( rxShape ); aPropSet.setProperties( aPropMap ); @@ -431,7 +432,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes // set the replacement graphic if( aGraphicPath.getLength() > 0 ) { - Reference< XGraphic > xGraphic = rFilter.importEmbeddedGraphic( aGraphicPath ); + Reference< XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath ); if( xGraphic.is() ) aOleProps[ PROP_Graphic ] <<= xGraphic; } @@ -478,7 +479,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes Reference< XShape > xShape = lclCreateAndInsertXShape( rFilter, rxShapes, CREATE_OUSTRING( "com.sun.star.drawing.GraphicObjectShape" ), rShapeRect ); if( xShape.is() ) { - OUString aGraphicUrl = rFilter.importEmbeddedGraphicObject( aGraphicPath ); + OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( aGraphicPath ); if( aGraphicUrl.getLength() > 0 ) { PropertySet aPropSet( xShape ); diff --git a/oox/source/xls/pagesettings.cxx b/oox/source/xls/pagesettings.cxx index c0b1011fdbcc..0a5ce05a37df 100644 --- a/oox/source/xls/pagesettings.cxx +++ b/oox/source/xls/pagesettings.cxx @@ -440,7 +440,7 @@ void PageSettings::importPictureData( const Relations& rRelations, const OUStrin { OUString aPicturePath = rRelations.getFragmentPathFromRelId( rRelId ); if( aPicturePath.getLength() > 0 ) - maModel.maGraphicUrl = getBaseFilter().importEmbeddedGraphicObject( aPicturePath ); + maModel.maGraphicUrl = getBaseFilter().getGraphicHelper().importEmbeddedGraphicObject( aPicturePath ); } // ============================================================================ diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index b9a11b5104ea..5a149961c0e2 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -306,7 +306,7 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) // ============================================================================ ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) : - GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame() ), + GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame(), rHelper.getBaseFilter().getStorage() ), WorkbookHelper( rHelper ) { } |