1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "oox/helper/graphichelper.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/awt/XUnitConversion.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/graphic/GraphicObject.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/util/MeasureUnit.hpp> 39*cdf0e10cSrcweir #include <comphelper/seqstream.hxx> 40*cdf0e10cSrcweir #include "oox/helper/containerhelper.hxx" 41*cdf0e10cSrcweir #include "oox/helper/propertyset.hxx" 42*cdf0e10cSrcweir #include "oox/token/tokens.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace oox { 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir // ============================================================================ 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using namespace ::com::sun::star::awt; 49*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 50*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 51*cdf0e10cSrcweir using namespace ::com::sun::star::graphic; 52*cdf0e10cSrcweir using namespace ::com::sun::star::io; 53*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using ::rtl::OUString; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // ============================================================================ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir namespace { 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir return static_cast< sal_Int32 >( (fPixelPerHmm > 0.0) ? (fPixel / fPixelPerHmm + 0.5) : 0.0 ); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir } // namespace 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir // ============================================================================ 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, const Reference< XFrame >& rxTargetFrame, const StorageRef& rxStorage ) : 72*cdf0e10cSrcweir mxContext( rxContext ), 73*cdf0e10cSrcweir mxStorage( rxStorage ), 74*cdf0e10cSrcweir maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir OSL_ENSURE( mxContext.is(), "GraphicHelper::GraphicHelper - missing component context" ); 77*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( mxContext->getServiceManager(), UNO_QUERY ); 78*cdf0e10cSrcweir OSL_ENSURE( xFactory.is(), "GraphicHelper::GraphicHelper - missing service factory" ); 79*cdf0e10cSrcweir if( xFactory.is() ) 80*cdf0e10cSrcweir mxGraphicProvider.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir //! TODO: get colors from system 83*cdf0e10cSrcweir maSystemPalette[ XML_3dDkShadow ] = 0x716F64; 84*cdf0e10cSrcweir maSystemPalette[ XML_3dLight ] = 0xF1EFE2; 85*cdf0e10cSrcweir maSystemPalette[ XML_activeBorder ] = 0xD4D0C8; 86*cdf0e10cSrcweir maSystemPalette[ XML_activeCaption ] = 0x0054E3; 87*cdf0e10cSrcweir maSystemPalette[ XML_appWorkspace ] = 0x808080; 88*cdf0e10cSrcweir maSystemPalette[ XML_background ] = 0x004E98; 89*cdf0e10cSrcweir maSystemPalette[ XML_btnFace ] = 0xECE9D8; 90*cdf0e10cSrcweir maSystemPalette[ XML_btnHighlight ] = 0xFFFFFF; 91*cdf0e10cSrcweir maSystemPalette[ XML_btnShadow ] = 0xACA899; 92*cdf0e10cSrcweir maSystemPalette[ XML_btnText ] = 0x000000; 93*cdf0e10cSrcweir maSystemPalette[ XML_captionText ] = 0xFFFFFF; 94*cdf0e10cSrcweir maSystemPalette[ XML_gradientActiveCaption ] = 0x3D95FF; 95*cdf0e10cSrcweir maSystemPalette[ XML_gradientInactiveCaption ] = 0xD8E4F8; 96*cdf0e10cSrcweir maSystemPalette[ XML_grayText ] = 0xACA899; 97*cdf0e10cSrcweir maSystemPalette[ XML_highlight ] = 0x316AC5; 98*cdf0e10cSrcweir maSystemPalette[ XML_highlightText ] = 0xFFFFFF; 99*cdf0e10cSrcweir maSystemPalette[ XML_hotLight ] = 0x000080; 100*cdf0e10cSrcweir maSystemPalette[ XML_inactiveBorder ] = 0xD4D0C8; 101*cdf0e10cSrcweir maSystemPalette[ XML_inactiveCaption ] = 0x7A96DF; 102*cdf0e10cSrcweir maSystemPalette[ XML_inactiveCaptionText ] = 0xD8E4F8; 103*cdf0e10cSrcweir maSystemPalette[ XML_infoBk ] = 0xFFFFE1; 104*cdf0e10cSrcweir maSystemPalette[ XML_infoText ] = 0x000000; 105*cdf0e10cSrcweir maSystemPalette[ XML_menu ] = 0xFFFFFF; 106*cdf0e10cSrcweir maSystemPalette[ XML_menuBar ] = 0xECE9D8; 107*cdf0e10cSrcweir maSystemPalette[ XML_menuHighlight ] = 0x316AC5; 108*cdf0e10cSrcweir maSystemPalette[ XML_menuText ] = 0x000000; 109*cdf0e10cSrcweir maSystemPalette[ XML_scrollBar ] = 0xD4D0C8; 110*cdf0e10cSrcweir maSystemPalette[ XML_window ] = 0xFFFFFF; 111*cdf0e10cSrcweir maSystemPalette[ XML_windowFrame ] = 0x000000; 112*cdf0e10cSrcweir maSystemPalette[ XML_windowText ] = 0x000000; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // if no target frame has been passed (e.g. OLE objects), try to fallback to the active frame 115*cdf0e10cSrcweir // TODO: we need some mechanism to keep and pass the parent frame 116*cdf0e10cSrcweir Reference< XFrame > xFrame = rxTargetFrame; 117*cdf0e10cSrcweir if( !xFrame.is() && xFactory.is() ) try 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir Reference< XFramesSupplier > xFramesSupp( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); 120*cdf0e10cSrcweir xFrame = xFramesSupp->getActiveFrame(); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir catch( Exception& ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // get the metric of the output device 127*cdf0e10cSrcweir OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" ); 128*cdf0e10cSrcweir maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case 129*cdf0e10cSrcweir if( xFrame.is() ) try 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); 132*cdf0e10cSrcweir mxUnitConversion.set( xDevice, UNO_QUERY ); 133*cdf0e10cSrcweir OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" ); 134*cdf0e10cSrcweir maDeviceInfo = xDevice->getInfo(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir catch( Exception& ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; 141*cdf0e10cSrcweir mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir GraphicHelper::~GraphicHelper() 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // System colors and predefined colors ---------------------------------------- 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir return ContainerHelper::getMapElement( maSystemPalette, nToken, nDefaultRgb ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir OSL_ENSURE( false, "GraphicHelper::getSchemeColor - scheme colors not implemented" ); 158*cdf0e10cSrcweir return API_RGB_TRANSPARENT; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir OSL_ENSURE( false, "GraphicHelper::getPaletteColor - palette colors not implemented" ); 164*cdf0e10cSrcweir return API_RGB_TRANSPARENT; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // Device info and device dependent unit conversion --------------------------- 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir const DeviceInfo& GraphicHelper::getDeviceInfo() const 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir return maDeviceInfo; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir return lclConvertScreenPixelToHmm( fPixelX, mfPixelPerHmmX ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_Int32 GraphicHelper::convertScreenPixelYToHmm( double fPixelY ) const 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir return lclConvertScreenPixelToHmm( fPixelY, mfPixelPerHmmY ); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir Point GraphicHelper::convertScreenPixelToHmm( const Point& rPixel ) const 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir return Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir Size GraphicHelper::convertScreenPixelToHmm( const Size& rPixel ) const 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir return Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir double GraphicHelper::convertHmmToScreenPixelX( sal_Int32 nHmmX ) const 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir return nHmmX * mfPixelPerHmmX; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir double GraphicHelper::convertHmmToScreenPixelY( sal_Int32 nHmmY ) const 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir return nHmmY * mfPixelPerHmmY; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir Point GraphicHelper::convertHmmToScreenPixel( const Point& rHmm ) const 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir return Point( 207*cdf0e10cSrcweir static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.X ) + 0.5 ), 208*cdf0e10cSrcweir static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Y ) + 0.5 ) ); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir Size GraphicHelper::convertHmmToScreenPixel( const Size& rHmm ) const 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir return Size( 214*cdf0e10cSrcweir static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.Width ) + 0.5 ), 215*cdf0e10cSrcweir static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Height ) + 0.5 ) ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir Point GraphicHelper::convertAppFontToHmm( const Point& rAppFont ) const 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if( mxUnitConversion.is() ) try 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir Point aPixel = mxUnitConversion->convertPointToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); 223*cdf0e10cSrcweir return convertScreenPixelToHmm( aPixel ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir catch( Exception& ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir return Point( 0, 0 ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir Size GraphicHelper::convertAppFontToHmm( const Size& rAppFont ) const 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if( mxUnitConversion.is() ) try 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir Size aPixel = mxUnitConversion->convertSizeToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); 236*cdf0e10cSrcweir return convertScreenPixelToHmm( aPixel ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir catch( Exception& ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir return Size( 0, 0 ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir Point GraphicHelper::convertHmmToAppFont( const Point& rHmm ) const 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir if( mxUnitConversion.is() ) try 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir Point aPixel = convertHmmToScreenPixel( rHmm ); 249*cdf0e10cSrcweir return mxUnitConversion->convertPointToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir catch( Exception& ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir return Point( 0, 0 ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir Size GraphicHelper::convertHmmToAppFont( const Size& rHmm ) const 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir if( mxUnitConversion.is() ) try 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir Size aPixel = convertHmmToScreenPixel( rHmm ); 262*cdf0e10cSrcweir return mxUnitConversion->convertSizeToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir catch( Exception& ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir return Size( 0, 0 ); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // Graphics and graphic objects ---------------------------------------------- 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) const 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir Reference< XGraphic > xGraphic; 275*cdf0e10cSrcweir if( rxInStrm.is() && mxGraphicProvider.is() ) try 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 278*cdf0e10cSrcweir aArgs[ 0 ].Name = CREATE_OUSTRING( "InputStream" ); 279*cdf0e10cSrcweir aArgs[ 0 ].Value <<= rxInStrm; 280*cdf0e10cSrcweir xGraphic = mxGraphicProvider->queryGraphic( aArgs ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir catch( Exception& ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir return xGraphic; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) const 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir Reference< XGraphic > xGraphic; 291*cdf0e10cSrcweir if( rGraphicData.hasElements() ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir Reference< XInputStream > xInStrm( new ::comphelper::SequenceInputStream( rGraphicData ) ); 294*cdf0e10cSrcweir xGraphic = importGraphic( xInStrm ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir return xGraphic; 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName ) const 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir Reference< XGraphic > xGraphic; 302*cdf0e10cSrcweir OSL_ENSURE( rStreamName.getLength() > 0, "GraphicHelper::importEmbeddedGraphic - empty stream name" ); 303*cdf0e10cSrcweir if( rStreamName.getLength() > 0 ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName ); 306*cdf0e10cSrcweir if( aIt == maEmbeddedGraphics.end() ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir xGraphic = importGraphic( mxStorage->openInputStream( rStreamName ) ); 309*cdf0e10cSrcweir if( xGraphic.is() ) 310*cdf0e10cSrcweir maEmbeddedGraphics[ rStreamName ] = xGraphic; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir else 313*cdf0e10cSrcweir xGraphic = aIt->second; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir return xGraphic; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) const 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir OUString aGraphicObjUrl; 321*cdf0e10cSrcweir if( mxContext.is() && rxGraphic.is() ) try 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir Reference< XGraphicObject > xGraphicObj( GraphicObject::create( mxContext ), UNO_SET_THROW ); 324*cdf0e10cSrcweir xGraphicObj->setGraphic( rxGraphic ); 325*cdf0e10cSrcweir maGraphicObjects.push_back( xGraphicObj ); 326*cdf0e10cSrcweir aGraphicObjUrl = maGraphicObjScheme + xGraphicObj->getUniqueID(); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir catch( Exception& ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir return aGraphicObjUrl; 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) const 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir return createGraphicObject( importGraphic( rxInStrm ) ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) const 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir return createGraphicObject( importGraphic( rGraphicData ) ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir OUString GraphicHelper::importEmbeddedGraphicObject( const OUString& rStreamName ) const 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir Reference< XGraphic > xGraphic = importEmbeddedGraphic( rStreamName ); 347*cdf0e10cSrcweir return xGraphic.is() ? createGraphicObject( xGraphic ) : OUString(); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) const 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir Size aSizeHmm; 353*cdf0e10cSrcweir PropertySet aPropSet( xGraphic ); 354*cdf0e10cSrcweir if( aPropSet.getProperty( aSizeHmm, PROP_Size100thMM ) && (aSizeHmm.Width == 0) && (aSizeHmm.Height == 0) ) // MAPMODE_PIXEL used? 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir Size aSizePixel( 0, 0 ); 357*cdf0e10cSrcweir if( aPropSet.getProperty( aSizePixel, PROP_SizePixel ) ) 358*cdf0e10cSrcweir aSizeHmm = convertScreenPixelToHmm( aSizePixel ); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir return aSizeHmm; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir // ============================================================================ 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir } // namespace oox 366