summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-04-16 14:47:11 +0200
committerDaniel Rentz <dr@openoffice.org>2010-04-16 14:47:11 +0200
commit02f50ebfc8097e6bebb607b9faa82f3baff0421e (patch)
treebbd2dfcab301bd9b8273f1869b8ebbabc6fa4107 /oox
parentdc295f1cf1c99b2dbe0760c7542a92febb33a27d (diff)
npower13_objectmodules: use document frame from media descriptor
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/core/filterbase.hxx5
-rw-r--r--oox/inc/oox/helper/graphichelper.hxx4
-rw-r--r--oox/source/core/filterbase.cxx10
-rw-r--r--oox/source/helper/graphichelper.cxx28
-rw-r--r--oox/source/ppt/pptimport.cxx2
-rw-r--r--oox/source/xls/stylesbuffer.cxx2
6 files changed, 39 insertions, 12 deletions
diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx
index b2709ea4b33b..31e26d38f590 100644
--- a/oox/inc/oox/core/filterbase.hxx
+++ b/oox/inc/oox/core/filterbase.hxx
@@ -49,6 +49,7 @@ namespace com { namespace sun { namespace star {
namespace frame { class XModel; }
namespace task { class XStatusIndicator; }
namespace task { class XInteractionHandler; }
+ namespace frame { class XFrame; }
namespace io { class XInputStream; }
namespace io { class XOutputStream; }
namespace io { class XStream; }
@@ -123,6 +124,10 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
getModelFactory() const;
+ /** Returns the frame that will contain the document model. */
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >&
+ getTargetFrame() const;
+
/** Returns the status indicator (may be null). */
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >&
getStatusIndicator() const;
diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx
index dc9dddfea7e8..2d0964b37715 100644
--- a/oox/inc/oox/helper/graphichelper.hxx
+++ b/oox/inc/oox/helper/graphichelper.hxx
@@ -40,6 +40,7 @@ namespace com { namespace sun { namespace star {
namespace awt { struct Size; }
namespace awt { class XUnitConversion; }
namespace io { class XInputStream; }
+ namespace frame { class XFrame; }
namespace graphic { class XGraphic; }
namespace graphic { class XGraphicObject; }
namespace graphic { class XGraphicProvider; }
@@ -66,7 +67,8 @@ class GraphicHelper
{
public:
explicit GraphicHelper(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxTargetFrame );
virtual ~GraphicHelper();
/** Returns a system color specified by the passed XML token identifier. */
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 27a1b26fbcfd..902784cafe80 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -55,6 +55,7 @@ using ::com::sun::star::lang::IllegalArgumentException;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::frame::XFrame;
using ::com::sun::star::frame::XModel;
using ::com::sun::star::io::XInputStream;
using ::com::sun::star::io::XOutputStream;
@@ -148,6 +149,7 @@ struct FilterBaseImpl
Reference< XMultiServiceFactory > mxGlobalFactory;
Reference< XModel > mxModel;
Reference< XMultiServiceFactory > mxModelFactory;
+ Reference< XFrame > mxTargetFrame;
Reference< XInputStream > mxInStream;
Reference< XStream > mxOutStream;
Reference< XStatusIndicator > mxStatusIndicator;
@@ -261,6 +263,11 @@ const Reference< XMultiServiceFactory >& FilterBase::getModelFactory() const
return mxImpl->mxModelFactory;
}
+const Reference< XFrame >& FilterBase::getTargetFrame() const
+{
+ return mxImpl->mxTargetFrame;
+}
+
const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const
{
return mxImpl->mxStatusIndicator;
@@ -572,6 +579,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc
}
mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
+ mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() );
mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() );
mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
}
@@ -579,7 +587,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 );
+ return new GraphicHelper( mxImpl->mxGlobalFactory, mxImpl->mxTargetFrame );
}
// ============================================================================
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 6e57ac8f2b2f..6b294f61abef 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -76,7 +76,7 @@ inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm
// ============================================================================
-GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory ) :
+GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XFrame >& rxTargetFrame ) :
mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ),
maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) )
{
@@ -115,21 +115,34 @@ GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalF
maSystemPalette[ XML_windowFrame ] = 0x000000;
maSystemPalette[ XML_windowText ] = 0x000000;
- // get the metric of the output device
- if( rxGlobalFactory.is() ) try
+ // if no target frame has been passed (e.g. OLE objects), try to fallback to the active frame
+ // TODO: we need some mechanism to keep and pass the parent frame
+ Reference< XFrame > xFrame = rxTargetFrame;
+ if( !xFrame.is() && rxGlobalFactory.is() ) try
{
Reference< XFramesSupplier > xFramesSupp( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW );
- Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW );
+ xFrame = xFramesSupp->getActiveFrame();
+ }
+ catch( Exception& )
+ {
+ }
+
+ // get the metric of the output device
+ OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" );
+ maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case
+ if( xFrame.is() ) try
+ {
Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW );
mxUnitConversion.set( xDevice, UNO_QUERY );
+ OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" );
maDeviceInfo = xDevice->getInfo();
- mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0;
- mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0;
}
catch( Exception& )
{
OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" );
}
+ mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0;
+ mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0;
}
GraphicHelper::~GraphicHelper()
@@ -138,8 +151,7 @@ GraphicHelper::~GraphicHelper()
sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const
{
- const sal_Int32* pnColor = ContainerHelper::getMapElement( maSystemPalette, nToken );
- return pnColor ? *pnColor : nDefaultRgb;
+ return ContainerHelper::getMapElement( maSystemPalette, nToken, nDefaultRgb );
}
sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 578d469395db..39ad52316a92 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() ),
+ GraphicHelper( rFilter.getGlobalFactory(), rFilter.getTargetFrame() ),
mrFilter( rFilter )
{
}
diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx
index e18f47a378ed..e48104065315 100644
--- a/oox/source/xls/stylesbuffer.cxx
+++ b/oox/source/xls/stylesbuffer.cxx
@@ -305,7 +305,7 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm )
// ============================================================================
ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) :
- GraphicHelper( rHelper.getGlobalFactory() ),
+ GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame() ),
WorkbookHelper( rHelper )
{
}