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