Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <osl/mutex.hxx>
31 : : #include <vcl/svapp.hxx>
32 : : #include <vcl/image.hxx>
33 : : #include <vcl/metaact.hxx>
34 : : #include <vcl/msgbox.hxx>
35 : : #include <vcl/imagerepository.hxx>
36 : : #include <tools/rcid.h>
37 : : #include <tools/resid.hxx>
38 : : #include <tools/resmgr.hxx>
39 : : #include <unotools/ucbstreamhelper.hxx>
40 : : #include <svtools/filter.hxx>
41 : : #include <svtools/wmf.hxx>
42 : : #include <svl/solar.hrc>
43 : : #include <vcl/virdev.hxx>
44 : : #include <com/sun/star/io/XStream.hpp>
45 : : #include <com/sun/star/text/GraphicCrop.hpp>
46 : : #include <comphelper/servicehelper.hxx>
47 : :
48 : : #include "descriptor.hxx"
49 : : #include "graphic.hxx"
50 : : #include <svtools/grfmgr.hxx>
51 : : #include "provider.hxx"
52 : :
53 : : using namespace com::sun::star;
54 : :
55 : : namespace unographic {
56 : :
57 : : #define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
58 : :
59 : : // -------------------
60 : : // - GraphicProvider -
61 : : // -------------------
62 : :
63 : 98 : uno::Reference< uno::XInterface > SAL_CALL GraphicProvider_CreateInstance( const uno::Reference< lang::XMultiServiceFactory >& )
64 : : {
65 [ + - ]: 98 : return (static_cast< ::cppu::OWeakObject* >(new GraphicProvider ));
66 : : }
67 : :
68 : 98 : GraphicProvider::GraphicProvider()
69 : : {
70 : 98 : }
71 : :
72 : : // ------------------------------------------------------------------------------
73 : :
74 : 98 : GraphicProvider::~GraphicProvider()
75 : : {
76 [ - + ]: 196 : }
77 : :
78 : : // ------------------------------------------------------------------------------
79 : :
80 : 207 : ::rtl::OUString GraphicProvider::getImplementationName_Static()
81 : : throw()
82 : : {
83 : 207 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.graphic.GraphicProvider" ) );
84 : : }
85 : :
86 : : // ------------------------------------------------------------------------------
87 : :
88 : 98 : uno::Sequence< ::rtl::OUString > GraphicProvider::getSupportedServiceNames_Static()
89 : : throw()
90 : : {
91 : 98 : uno::Sequence< ::rtl::OUString > aSeq( 1 );
92 : :
93 [ + - ][ + - ]: 98 : aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) );
94 : :
95 : 98 : return aSeq;
96 : : }
97 : :
98 : : // ------------------------------------------------------------------------------
99 : :
100 : 0 : ::rtl::OUString SAL_CALL GraphicProvider::getImplementationName()
101 : : throw( uno::RuntimeException )
102 : : {
103 : 0 : return getImplementationName_Static();
104 : : }
105 : :
106 : : // ------------------------------------------------------------------------------
107 : :
108 : 0 : sal_Bool SAL_CALL GraphicProvider::supportsService( const ::rtl::OUString& ServiceName )
109 : : throw( uno::RuntimeException )
110 : : {
111 [ # # ]: 0 : uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
112 : 0 : const ::rtl::OUString* pArray = aSNL.getConstArray();
113 : :
114 [ # # ]: 0 : for( int i = 0; i < aSNL.getLength(); i++ )
115 [ # # ]: 0 : if( pArray[i] == ServiceName )
116 : 0 : return true;
117 : :
118 [ # # ]: 0 : return false;
119 : : }
120 : :
121 : : // ------------------------------------------------------------------------------
122 : :
123 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GraphicProvider::getSupportedServiceNames()
124 : : throw( uno::RuntimeException )
125 : : {
126 : 0 : return getSupportedServiceNames_Static();
127 : : }
128 : :
129 : : // ------------------------------------------------------------------------------
130 : :
131 : 0 : uno::Sequence< uno::Type > SAL_CALL GraphicProvider::getTypes()
132 : : throw(uno::RuntimeException)
133 : : {
134 : 0 : uno::Sequence< uno::Type > aTypes( 3 );
135 [ # # ]: 0 : uno::Type* pTypes = aTypes.getArray();
136 : :
137 [ # # ]: 0 : *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
138 [ # # ]: 0 : *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
139 [ # # ]: 0 : *pTypes++ = ::getCppuType((const uno::Reference< graphic::XGraphicProvider>*)0);
140 : :
141 : 0 : return aTypes;
142 : : }
143 : :
144 : : namespace
145 : : {
146 : : class theGraphicProviderUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theGraphicProviderUnoTunnelId > {};
147 : : }
148 : :
149 : 0 : uno::Sequence< sal_Int8 > SAL_CALL GraphicProvider::getImplementationId()
150 : : throw(uno::RuntimeException)
151 : : {
152 : 0 : return theGraphicProviderUnoTunnelId::get().getSeq();
153 : : }
154 : :
155 : : // ------------------------------------------------------------------------------
156 : :
157 : 86 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadGraphicObject( const ::rtl::OUString& rResourceURL ) const
158 : : {
159 : 86 : uno::Reference< ::graphic::XGraphic > xRet;
160 [ + + ]: 86 : if( rResourceURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
161 : : {
162 : : // graphic manager url
163 [ + - ]: 27 : String aTmpStr( rResourceURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ) );
164 : : rtl::OString aUniqueID(rtl::OUStringToOString(aTmpStr,
165 [ + - ][ + - ]: 27 : RTL_TEXTENCODING_UTF8));
166 [ + - ]: 27 : GraphicObject aGrafObj(aUniqueID);
167 : : // I don't call aGrafObj.GetXGraphic because it will call us back
168 : : // into implLoadMemory ( with "private:memorygraphic" test )
169 [ + - ]: 27 : ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
170 [ + - ]: 27 : pUnoGraphic->init( aGrafObj.GetGraphic() );
171 [ + - ][ + - ]: 27 : xRet = pUnoGraphic;
[ + - ]
172 : : }
173 : 86 : return xRet;
174 : : }
175 : :
176 : 74722 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( const ::rtl::OUString& rResourceURL ) const
177 : : {
178 : 74722 : uno::Reference< ::graphic::XGraphic > xRet;
179 : 74722 : sal_Int32 nIndex = 0;
180 : :
181 [ + + ]: 74722 : if( ( 0 == rResourceURL.getToken( 0, '/', nIndex ).compareToAscii( "private:memorygraphic" ) ) )
182 : : {
183 : 74636 : sal_Int64 nGraphicAddress = rResourceURL.getToken( 0, '/', nIndex ).toInt64();
184 : :
185 [ + - ]: 74636 : if( nGraphicAddress )
186 : : {
187 [ + - ]: 74636 : ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
188 : :
189 : 74636 : pUnoGraphic->init( *reinterpret_cast< ::Graphic* >( nGraphicAddress ) );
190 [ + - ]: 74722 : xRet = pUnoGraphic;
191 : : }
192 : : }
193 : :
194 : 74722 : return xRet;
195 : : }
196 : :
197 : : // ------------------------------------------------------------------------------
198 : :
199 : 59 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( const ::rtl::OUString& rResourceURL ) const
200 : : {
201 : 59 : uno::Reference< ::graphic::XGraphic > xRet;
202 : 59 : sal_Int32 nIndex = 0;
203 : :
204 [ - + ]: 59 : if( ( 0 == rResourceURL.getToken( 0, '/', nIndex ).compareToAscii( "private:graphicrepository" ) ) )
205 : : {
206 [ # # ]: 0 : String sPathName( rResourceURL.copy( nIndex ) );
207 [ # # ]: 0 : BitmapEx aBitmap;
208 [ # # ][ # # ]: 0 : if ( ::vcl::ImageRepository::loadImage( sPathName, aBitmap, false ) )
[ # # ]
209 : : {
210 [ # # ]: 0 : Image aImage( aBitmap );
211 [ # # ][ # # ]: 0 : xRet = aImage.GetXGraphic();
[ # # ]
212 [ # # ][ # # ]: 59 : }
213 : : }
214 : 59 : return xRet;
215 : : }
216 : :
217 : :
218 : : // ------------------------------------------------------------------------------
219 : :
220 : 59 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( const ::rtl::OUString& rResourceURL ) const
221 : : {
222 : 59 : uno::Reference< ::graphic::XGraphic > xRet;
223 : 59 : sal_Int32 nIndex = 0;
224 : :
225 [ - + ]: 59 : if( ( 0 == rResourceURL.getToken( 0, '/', nIndex ).compareToAscii( "private:standardimage" ) ) )
226 : : {
227 : 0 : rtl::OUString sImageName( rResourceURL.copy( nIndex ) );
228 [ # # ]: 0 : if ( sImageName == "info" )
229 : : {
230 [ # # ][ # # ]: 0 : xRet = InfoBox::GetStandardImage().GetXGraphic();
[ # # ][ # # ]
231 : : }
232 [ # # ]: 0 : else if ( sImageName == "warning" )
233 : : {
234 [ # # ][ # # ]: 0 : xRet = WarningBox::GetStandardImage().GetXGraphic();
[ # # ][ # # ]
235 : : }
236 [ # # ]: 0 : else if ( sImageName == "error" )
237 : : {
238 [ # # ][ # # ]: 0 : xRet = ErrorBox::GetStandardImage().GetXGraphic();
[ # # ][ # # ]
239 : : }
240 [ # # ]: 0 : else if ( sImageName == "query" )
241 : : {
242 [ # # ][ # # ]: 0 : xRet = QueryBox::GetStandardImage().GetXGraphic();
[ # # ][ # # ]
243 : 59 : }
244 : : }
245 : 59 : return xRet;
246 : : }
247 : :
248 : : // ------------------------------------------------------------------------------
249 : :
250 : 0 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadBitmap( const uno::Reference< awt::XBitmap >& xBtm ) const
251 : : {
252 : 0 : uno::Reference< ::graphic::XGraphic > xRet;
253 [ # # ][ # # ]: 0 : uno::Sequence< sal_Int8 > aBmpSeq( xBtm->getDIB() );
254 [ # # ][ # # ]: 0 : uno::Sequence< sal_Int8 > aMaskSeq( xBtm->getMaskDIB() );
255 [ # # ][ # # ]: 0 : SvMemoryStream aBmpStream( aBmpSeq.getArray(), aBmpSeq.getLength(), STREAM_READ );
256 [ # # ]: 0 : Bitmap aBmp;
257 [ # # ]: 0 : aBmpStream >> aBmp;
258 : :
259 [ # # ]: 0 : BitmapEx aBmpEx;
260 : :
261 [ # # ]: 0 : if( aMaskSeq.getLength() )
262 : : {
263 [ # # ][ # # ]: 0 : SvMemoryStream aMaskStream( aMaskSeq.getArray(), aMaskSeq.getLength(), STREAM_READ );
264 [ # # ]: 0 : Bitmap aMask;
265 [ # # ]: 0 : aMaskStream >> aMask;
266 [ # # ][ # # ]: 0 : aBmpEx = BitmapEx( aBmp, aMask );
[ # # ][ # # ]
[ # # ]
267 : : }
268 : : else
269 [ # # ][ # # ]: 0 : aBmpEx = BitmapEx( aBmp );
[ # # ]
270 : :
271 [ # # ][ # # ]: 0 : if( !aBmpEx.IsEmpty() )
272 : : {
273 [ # # ]: 0 : ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
274 : :
275 [ # # ][ # # ]: 0 : pUnoGraphic->init( aBmpEx );
276 [ # # ]: 0 : xRet = pUnoGraphic;
277 : : }
278 [ # # ][ # # ]: 0 : return xRet;
[ # # ][ # # ]
[ # # ]
279 : : }
280 : :
281 : : // ------------------------------------------------------------------------------
282 : :
283 : 59 : uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadResource( const ::rtl::OUString& rResourceURL ) const
284 : : {
285 : 59 : uno::Reference< ::graphic::XGraphic > xRet;
286 : 59 : sal_Int32 nIndex = 0;
287 : :
288 [ - + ]: 59 : if( ( 0 == rResourceURL.getToken( 0, '/', nIndex ).compareToAscii( "private:resource" ) ) )
289 : : {
290 : : rtl::OString aResMgrName(rtl::OUStringToOString(
291 [ # # ]: 0 : rResourceURL.getToken(0, '/', nIndex), RTL_TEXTENCODING_ASCII_US));
292 : :
293 [ # # ][ # # ]: 0 : ResMgr* pResMgr = ResMgr::CreateResMgr( aResMgrName.getStr(), Application::GetSettings().GetUILocale() );
[ # # ]
294 : :
295 [ # # ]: 0 : if( pResMgr )
296 : : {
297 : 0 : const ::rtl::OUString aResourceType( rResourceURL.getToken( 0, '/', nIndex ) );
298 : 0 : const ResId aResId( rResourceURL.getToken( 0, '/', nIndex ).toInt32(), *pResMgr );
299 : :
300 [ # # ]: 0 : if( !aResourceType.isEmpty() )
301 : : {
302 [ # # ]: 0 : BitmapEx aBmpEx;
303 : :
304 [ # # # # ]: 0 : if( ( 0 == aResourceType.compareToAscii( "bitmap" ) ) ||
[ # # ]
305 : 0 : ( 0 == aResourceType.compareToAscii( "bitmapex" ) ) )
306 : : {
307 : 0 : aResId.SetRT( RSC_BITMAP );
308 : :
309 [ # # ][ # # ]: 0 : if( pResMgr->IsAvailable( aResId ) )
310 : : {
311 [ # # ][ # # ]: 0 : aBmpEx = BitmapEx( aResId );
[ # # ]
312 : : }
313 : : }
314 [ # # ]: 0 : else if( 0 == aResourceType.compareToAscii( "image" ) )
315 : : {
316 : 0 : aResId.SetRT( RSC_IMAGE );
317 : :
318 [ # # ][ # # ]: 0 : if( pResMgr->IsAvailable( aResId ) )
319 : : {
320 [ # # ]: 0 : const Image aImage( aResId );
321 [ # # ][ # # ]: 0 : aBmpEx = aImage.GetBitmapEx();
[ # # ][ # # ]
322 : : }
323 : : }
324 [ # # ]: 0 : else if( 0 == aResourceType.compareToAscii( "imagelist" ) )
325 : : {
326 : 0 : aResId.SetRT( RSC_IMAGELIST );
327 : :
328 [ # # ][ # # ]: 0 : if( pResMgr->IsAvailable( aResId ) )
329 : : {
330 [ # # ]: 0 : const ImageList aImageList( aResId );
331 [ # # ][ # # ]: 0 : sal_Int32 nImageId = ( nIndex > -1 ) ? rResourceURL.getToken( 0, '/', nIndex ).toInt32() : 0;
332 : :
333 [ # # ]: 0 : if( 0 < nImageId )
334 : : {
335 [ # # ]: 0 : const Image aImage( aImageList.GetImage( sal::static_int_cast< sal_uInt16 >(nImageId) ) );
336 [ # # ][ # # ]: 0 : aBmpEx = aImage.GetBitmapEx();
[ # # ][ # # ]
337 : : }
338 : : else
339 : : {
340 [ # # ][ # # ]: 0 : aBmpEx = aImageList.GetAsHorizontalStrip();
[ # # ]
341 [ # # ]: 0 : }
342 : : }
343 : : }
344 : :
345 [ # # ][ # # ]: 0 : if( !aBmpEx.IsEmpty() )
346 : : {
347 [ # # ]: 0 : ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
348 : :
349 [ # # ][ # # ]: 0 : pUnoGraphic->init( aBmpEx );
350 [ # # ]: 0 : xRet = pUnoGraphic;
351 [ # # ]: 0 : }
352 : : }
353 : :
354 [ # # ][ # # ]: 0 : delete pResMgr;
355 : 59 : }
356 : : }
357 : :
358 : 59 : return xRet;
359 : : }
360 : :
361 : : // ------------------------------------------------------------------------------
362 : :
363 : 0 : uno::Reference< beans::XPropertySet > SAL_CALL GraphicProvider::queryGraphicDescriptor( const uno::Sequence< beans::PropertyValue >& rMediaProperties )
364 : : throw ( io::IOException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
365 : : {
366 : 0 : uno::Reference< beans::XPropertySet > xRet;
367 : :
368 : 0 : ::rtl::OUString aURL;
369 : 0 : uno::Reference< io::XInputStream > xIStm;
370 : 0 : uno::Reference< awt::XBitmap >xBtm;
371 : :
372 [ # # ][ # # ]: 0 : for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !xRet.is(); ++i )
[ # # ]
373 : : {
374 : 0 : const ::rtl::OUString aName( rMediaProperties[ i ].Name );
375 : 0 : const uno::Any aValue( rMediaProperties[ i ].Value );
376 : :
377 [ # # ]: 0 : if( COMPARE_EQUAL == aName.compareToAscii( "URL" ) )
378 : : {
379 : 0 : aValue >>= aURL;
380 : : }
381 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "InputStream" ) )
382 : : {
383 [ # # ]: 0 : aValue >>= xIStm;
384 : : }
385 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "Bitmap" ) )
386 : : {
387 [ # # ]: 0 : aValue >>= xBtm;
388 : : }
389 : 0 : }
390 : :
391 [ # # ]: 0 : if( xIStm.is() )
392 : : {
393 [ # # ]: 0 : GraphicDescriptor* pDescriptor = new GraphicDescriptor;
394 : 0 : pDescriptor->init( xIStm, aURL );
395 [ # # ][ # # ]: 0 : xRet = pDescriptor;
396 : : }
397 [ # # ]: 0 : else if( !aURL.isEmpty() )
398 : : {
399 [ # # ]: 0 : uno::Reference< ::graphic::XGraphic > xGraphic( implLoadMemory( aURL ) );
400 [ # # ]: 0 : if( !xGraphic.is() )
401 [ # # ][ # # ]: 0 : xGraphic = implLoadResource( aURL );
402 [ # # ]: 0 : if( !xGraphic.is() )
403 [ # # ][ # # ]: 0 : xGraphic = implLoadGraphicObject( aURL );
404 : :
405 [ # # ]: 0 : if ( !xGraphic.is() )
406 [ # # ][ # # ]: 0 : xGraphic = implLoadRepositoryImage( aURL );
407 : :
408 [ # # ]: 0 : if ( !xGraphic.is() )
409 [ # # ][ # # ]: 0 : xGraphic = implLoadStandardImage( aURL );
410 : :
411 [ # # ]: 0 : if( xGraphic.is() )
412 : : {
413 [ # # ][ # # ]: 0 : xRet = uno::Reference< beans::XPropertySet >( xGraphic, uno::UNO_QUERY );
414 : : }
415 : : else
416 : : {
417 [ # # ]: 0 : GraphicDescriptor* pDescriptor = new GraphicDescriptor;
418 : 0 : pDescriptor->init( aURL );
419 [ # # ][ # # ]: 0 : xRet = pDescriptor;
420 : 0 : }
421 : : }
422 [ # # ]: 0 : else if( xBtm.is() )
423 : : {
424 [ # # ]: 0 : uno::Reference< ::graphic::XGraphic > xGraphic( implLoadBitmap( xBtm ) );
425 [ # # ]: 0 : if( xGraphic.is() )
426 [ # # ][ # # ]: 0 : xRet = uno::Reference< beans::XPropertySet >( xGraphic, uno::UNO_QUERY );
427 : : }
428 : :
429 : 0 : return xRet;
430 : : }
431 : :
432 : : // ------------------------------------------------------------------------------
433 : :
434 : 74764 : uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( const uno::Sequence< ::beans::PropertyValue >& rMediaProperties )
435 : : throw ( io::IOException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
436 : : {
437 : 74764 : uno::Reference< ::graphic::XGraphic > xRet;
438 [ + - ]: 74764 : String aPath;
439 : 74764 : SvStream* pIStm = NULL;
440 : :
441 : 74764 : uno::Reference< io::XInputStream > xIStm;
442 : 74764 : uno::Reference< awt::XBitmap >xBtm;
443 : :
444 [ + - ]: 74764 : uno::Sequence< ::beans::PropertyValue > aFilterData;
445 : :
446 [ + + ][ + - ]: 149528 : for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !pIStm && !xRet.is(); ++i )
[ + - ][ + + ]
447 : : {
448 : 74764 : const ::rtl::OUString aName( rMediaProperties[ i ].Name );
449 : 74764 : const uno::Any aValue( rMediaProperties[ i ].Value );
450 : :
451 [ + + ]: 74764 : if( COMPARE_EQUAL == aName.compareToAscii( "URL" ) )
452 : : {
453 : 74722 : ::rtl::OUString aURL;
454 : 74722 : aValue >>= aURL;
455 [ + - ]: 74722 : aPath = aURL;
456 : : }
457 [ + - ]: 42 : else if( COMPARE_EQUAL == aName.compareToAscii( "InputStream" ) )
458 : : {
459 [ + - ]: 42 : aValue >>= xIStm;
460 : : }
461 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "Bitmap" ) )
462 : : {
463 [ # # ]: 0 : aValue >>= xBtm;
464 : : }
465 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "FilterData" ) )
466 : : {
467 [ # # ]: 0 : aValue >>= aFilterData;
468 : : }
469 : 74764 : }
470 : :
471 : : // Check for the goal width and height if they are defined
472 : 74764 : sal_uInt16 nExtWidth = 0;
473 : 74764 : sal_uInt16 nExtHeight = 0;
474 : 74764 : sal_uInt16 nExtMapMode = 0;
475 [ - + ]: 74764 : for( sal_Int32 i = 0; i < aFilterData.getLength(); ++i )
476 : : {
477 [ # # ]: 0 : const ::rtl::OUString aName( aFilterData[ i ].Name );
478 [ # # ]: 0 : const uno::Any aValue( aFilterData[ i ].Value );
479 : :
480 [ # # ]: 0 : if( COMPARE_EQUAL == aName.compareToAscii( "ExternalWidth" ) )
481 : : {
482 : 0 : aValue >>= nExtWidth;
483 : : }
484 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "ExternalHeight" ) )
485 : : {
486 : 0 : aValue >>= nExtHeight;
487 : : }
488 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "ExternalMapMode" ) )
489 : : {
490 : 0 : aValue >>= nExtMapMode;
491 : : }
492 : 0 : }
493 : :
494 [ + + ]: 74764 : if( xIStm.is() )
495 : : {
496 [ + - ]: 42 : pIStm = ::utl::UcbStreamHelper::CreateStream( xIStm );
497 : : }
498 [ + - ]: 74722 : else if( aPath.Len() )
499 : : {
500 [ + - ][ + - ]: 74722 : xRet = implLoadMemory( aPath );
[ + - ]
501 : :
502 [ + + ]: 74722 : if( !xRet.is() )
503 [ + - ][ + - ]: 86 : xRet = implLoadGraphicObject( aPath );
[ + - ]
504 : :
505 [ + + ]: 74722 : if( !xRet.is() )
506 [ + - ][ + - ]: 59 : xRet = implLoadResource( aPath );
[ + - ]
507 : :
508 [ + + ]: 74722 : if ( !xRet.is() )
509 [ + - ][ + - ]: 59 : xRet = implLoadRepositoryImage( aPath );
[ + - ]
510 : :
511 [ + + ]: 74722 : if ( !xRet.is() )
512 [ + - ][ + - ]: 59 : xRet = implLoadStandardImage( aPath );
[ + - ]
513 : :
514 [ + + ]: 74722 : if( !xRet.is() )
515 [ + - ]: 59 : pIStm = ::utl::UcbStreamHelper::CreateStream( aPath, STREAM_READ );
516 : : }
517 [ # # ]: 0 : else if( xBtm.is() )
518 : : {
519 [ # # ][ # # ]: 0 : xRet = implLoadBitmap( xBtm );
520 : : }
521 : :
522 [ + + ]: 74764 : if( pIStm )
523 : : {
524 [ + - ]: 44 : ::GraphicFilter& rFilter = ::GraphicFilter::GetGraphicFilter();
525 : :
526 : : {
527 [ + - ]: 44 : ::Graphic aVCLGraphic;
528 : :
529 : : // Define APM Header if goal height and width are defined
530 : 44 : WMF_EXTERNALHEADER aExtHeader;
531 : 44 : aExtHeader.xExt = nExtWidth;
532 : 44 : aExtHeader.yExt = nExtHeight;
533 : 44 : aExtHeader.mapMode = nExtMapMode;
534 : 44 : WMF_EXTERNALHEADER *pExtHeader = NULL;
535 [ - + ]: 44 : if ( nExtMapMode > 0 )
536 : 0 : pExtHeader = &aExtHeader;
537 : :
538 [ + - ][ + - ]: 88 : if( ( rFilter.ImportGraphic( aVCLGraphic, aPath, *pIStm,
[ + - ]
539 [ + - ]: 44 : GRFILTER_FORMAT_DONTKNOW, NULL, 0, pExtHeader ) == GRFILTER_OK ) &&
540 [ + - ]: 44 : ( aVCLGraphic.GetType() != GRAPHIC_NONE ) )
541 : : {
542 [ + - ]: 44 : ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
543 : :
544 : 44 : pUnoGraphic->init( aVCLGraphic );
545 [ + - ]: 44 : xRet = pUnoGraphic;
546 [ + - ]: 44 : }
547 : : }
548 : :
549 [ + - ][ + - ]: 44 : delete pIStm;
550 : : }
551 : :
552 [ + - ][ + - ]: 74764 : return xRet;
553 : : }
554 : :
555 : 0 : void ImplCalculateCropRect( ::Graphic& rGraphic, const text::GraphicCrop& rGraphicCropLogic, Rectangle& rGraphicCropPixel )
556 : : {
557 [ # # ][ # # ]: 0 : if ( rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom )
[ # # ][ # # ]
558 : : {
559 [ # # ]: 0 : Size aSourceSizePixel( rGraphic.GetSizePixel() );
560 [ # # ][ # # ]: 0 : if ( aSourceSizePixel.Width() && aSourceSizePixel.Height() )
[ # # ]
561 : : {
562 [ # # ][ # # ]: 0 : if ( rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom )
[ # # ][ # # ]
563 : : {
564 : 0 : Size aSize100thMM( 0, 0 );
565 [ # # ][ # # ]: 0 : if( rGraphic.GetPrefMapMode().GetMapUnit() != MAP_PIXEL )
[ # # ]
566 : : {
567 [ # # ][ # # ]: 0 : aSize100thMM = OutputDevice::LogicToLogic( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode(), MAP_100TH_MM );
[ # # ][ # # ]
[ # # ][ # # ]
568 : : }
569 : : else
570 : : {
571 [ # # ][ # # ]: 0 : aSize100thMM = Application::GetDefaultDevice()->PixelToLogic( rGraphic.GetPrefSize(), MAP_100TH_MM );
[ # # ][ # # ]
[ # # ]
572 : : }
573 [ # # ][ # # ]: 0 : if ( aSize100thMM.Width() && aSize100thMM.Height() )
[ # # ]
574 : : {
575 : 0 : double fSourceSizePixelWidth = static_cast<double>(aSourceSizePixel.Width());
576 : 0 : double fSourceSizePixelHeight= static_cast<double>(aSourceSizePixel.Height());
577 : 0 : rGraphicCropPixel.Left() = static_cast< sal_Int32 >((fSourceSizePixelWidth * rGraphicCropLogic.Left ) / aSize100thMM.Width());
578 : 0 : rGraphicCropPixel.Top() = static_cast< sal_Int32 >((fSourceSizePixelHeight * rGraphicCropLogic.Top ) / aSize100thMM.Height());
579 : 0 : rGraphicCropPixel.Right() = static_cast< sal_Int32 >(( fSourceSizePixelWidth * ( aSize100thMM.Width() - rGraphicCropLogic.Right ) ) / aSize100thMM.Width() );
580 : 0 : rGraphicCropPixel.Bottom() = static_cast< sal_Int32 >(( fSourceSizePixelHeight * ( aSize100thMM.Height() - rGraphicCropLogic.Bottom ) ) / aSize100thMM.Height() );
581 : : }
582 : : }
583 : : }
584 : : }
585 : 0 : }
586 : :
587 : 0 : void ImplApplyBitmapScaling( ::Graphic& rGraphic, sal_Int32 nPixelWidth, sal_Int32 nPixelHeight )
588 : : {
589 [ # # ][ # # ]: 0 : if ( nPixelWidth && nPixelHeight )
590 : : {
591 [ # # ]: 0 : BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
592 [ # # ]: 0 : MapMode aPrefMapMode( aBmpEx.GetPrefMapMode() );
593 : 0 : Size aPrefSize( aBmpEx.GetPrefSize() );
594 [ # # ]: 0 : aBmpEx.Scale( Size( nPixelWidth, nPixelHeight ) );
595 [ # # ]: 0 : aBmpEx.SetPrefMapMode( aPrefMapMode );
596 : 0 : aBmpEx.SetPrefSize( aPrefSize );
597 [ # # ][ # # ]: 0 : rGraphic = aBmpEx;
[ # # ][ # # ]
[ # # ]
598 : : }
599 : 0 : }
600 : :
601 : 0 : void ImplApplyBitmapResolution( ::Graphic& rGraphic, sal_Int32 nImageResolution, const Size& rVisiblePixelSize, const awt::Size& rLogicalSize )
602 : : {
603 [ # # ][ # # ]: 0 : if ( nImageResolution && rLogicalSize.Width && rLogicalSize.Height )
[ # # ]
604 : : {
605 : 0 : const double fImageResolution = static_cast<double>( nImageResolution );
606 : 0 : const double fSourceDPIX = ( static_cast<double>(rVisiblePixelSize.Width()) * 2540.0 ) / static_cast<double>(rLogicalSize.Width);
607 : 0 : const double fSourceDPIY = ( static_cast<double>(rVisiblePixelSize.Height()) * 2540.0 ) / static_cast<double>(rLogicalSize.Height);
608 : 0 : const sal_Int32 nSourcePixelWidth( rGraphic.GetSizePixel().Width() );
609 : 0 : const sal_Int32 nSourcePixelHeight( rGraphic.GetSizePixel().Height() );
610 : 0 : const double fSourcePixelWidth = static_cast<double>( nSourcePixelWidth );
611 : 0 : const double fSourcePixelHeight= static_cast<double>( nSourcePixelHeight );
612 : :
613 : 0 : sal_Int32 nDestPixelWidth = nSourcePixelWidth;
614 : 0 : sal_Int32 nDestPixelHeight = nSourcePixelHeight;
615 : :
616 : : // check, if the bitmap DPI exceeds the maximum DPI
617 [ # # ]: 0 : if( fSourceDPIX > fImageResolution )
618 : : {
619 : 0 : nDestPixelWidth = static_cast<sal_Int32>(( fSourcePixelWidth * fImageResolution ) / fSourceDPIX);
620 [ # # ][ # # ]: 0 : if ( !nDestPixelWidth || ( nDestPixelWidth > nSourcePixelWidth ) )
621 : 0 : nDestPixelWidth = nSourcePixelWidth;
622 : : }
623 [ # # ]: 0 : if ( fSourceDPIY > fImageResolution )
624 : : {
625 : 0 : nDestPixelHeight= static_cast<sal_Int32>(( fSourcePixelHeight* fImageResolution ) / fSourceDPIY);
626 [ # # ][ # # ]: 0 : if ( !nDestPixelHeight || ( nDestPixelHeight > nSourcePixelHeight ) )
627 : 0 : nDestPixelHeight = nSourcePixelHeight;
628 : : }
629 [ # # ][ # # ]: 0 : if ( ( nDestPixelWidth != nSourcePixelWidth ) || ( nDestPixelHeight != nSourcePixelHeight ) )
630 : 0 : ImplApplyBitmapScaling( rGraphic, nDestPixelWidth, nDestPixelHeight );
631 : : }
632 : 0 : }
633 : :
634 : 0 : void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyValue >& rFilterData )
635 : : {
636 : : /* this method applies following attributes to the graphic, in the first step the
637 : : cropping area (logical size in 100thmm) is applied, in the second step the resolution
638 : : is applied, in the third step the graphic is scaled to the corresponding pixelsize.
639 : : if a parameter value is zero or not available the corresponding step will be skipped */
640 : :
641 : 0 : sal_Int32 nPixelWidth = 0;
642 : 0 : sal_Int32 nPixelHeight= 0;
643 : 0 : sal_Int32 nImageResolution = 0;
644 : 0 : awt::Size aLogicalSize( 0, 0 );
645 : 0 : text::GraphicCrop aCropLogic( 0, 0, 0, 0 );
646 : 0 : sal_Bool bRemoveCropArea = sal_True;
647 : :
648 [ # # ]: 0 : for( sal_Int32 i = 0; i < rFilterData.getLength(); ++i )
649 : : {
650 [ # # ]: 0 : const ::rtl::OUString aName( rFilterData[ i ].Name );
651 [ # # ]: 0 : const uno::Any aValue( rFilterData[ i ].Value );
652 : :
653 [ # # ]: 0 : if( COMPARE_EQUAL == aName.compareToAscii( "PixelWidth" ) )
654 : 0 : aValue >>= nPixelWidth;
655 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "PixelHeight" ) )
656 : 0 : aValue >>= nPixelHeight;
657 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "LogicalSize" ) )
658 [ # # ]: 0 : aValue >>= aLogicalSize;
659 [ # # ]: 0 : else if (COMPARE_EQUAL == aName.compareToAscii( "GraphicCropLogic" ) )
660 [ # # ]: 0 : aValue >>= aCropLogic;
661 [ # # ]: 0 : else if (COMPARE_EQUAL == aName.compareToAscii( "RemoveCropArea" ) )
662 : 0 : aValue >>= bRemoveCropArea;
663 [ # # ]: 0 : else if (COMPARE_EQUAL == aName.compareToAscii( "ImageResolution" ) )
664 : 0 : aValue >>= nImageResolution;
665 : 0 : }
666 [ # # ][ # # ]: 0 : if ( rGraphic.GetType() == GRAPHIC_BITMAP )
667 : : {
668 [ # # ][ # # ]: 0 : Rectangle aCropPixel( Point( 0, 0 ), rGraphic.GetSizePixel() );
669 [ # # ]: 0 : ImplCalculateCropRect( rGraphic, aCropLogic, aCropPixel );
670 [ # # ]: 0 : if ( bRemoveCropArea )
671 : : {
672 [ # # ]: 0 : BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
673 [ # # ]: 0 : aBmpEx.Crop( aCropPixel );
674 [ # # ][ # # ]: 0 : rGraphic = aBmpEx;
[ # # ][ # # ]
675 : : }
676 [ # # ][ # # ]: 0 : Size aVisiblePixelSize( bRemoveCropArea ? rGraphic.GetSizePixel() : aCropPixel.GetSize() );
[ # # ]
677 [ # # ]: 0 : ImplApplyBitmapResolution( rGraphic, nImageResolution, aVisiblePixelSize, aLogicalSize );
678 [ # # ]: 0 : ImplApplyBitmapScaling( rGraphic, nPixelWidth, nPixelHeight );
679 : : }
680 [ # # ][ # # ]: 0 : else if ( ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE ) && nImageResolution )
[ # # ][ # # ]
681 : : {
682 [ # # ]: 0 : VirtualDevice aDummyVDev;
683 [ # # ][ # # ]: 0 : GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
684 [ # # ][ # # ]: 0 : Size aMtfSize( aDummyVDev.LogicToLogic( aMtf.GetPrefSize(), aMtf.GetPrefMapMode(), MAP_100TH_MM ) );
[ # # ]
685 [ # # ][ # # ]: 0 : if ( aMtfSize.Width() && aMtfSize.Height() )
[ # # ]
686 : : {
687 [ # # ]: 0 : MapMode aNewMapMode( MAP_100TH_MM );
688 [ # # ][ # # ]: 0 : aNewMapMode.SetScaleX( static_cast< double >( aLogicalSize.Width ) / static_cast< double >( aMtfSize.Width() ) );
689 [ # # ][ # # ]: 0 : aNewMapMode.SetScaleY( static_cast< double >( aLogicalSize.Height ) / static_cast< double >( aMtfSize.Height() ) );
690 [ # # ]: 0 : aDummyVDev.EnableOutput( sal_False );
691 [ # # ]: 0 : aDummyVDev.SetMapMode( aNewMapMode );
692 : :
693 [ # # ][ # # ]: 0 : for( size_t i = 0, nObjCount = aMtf.GetActionSize(); i < nObjCount; i++ )
694 : : {
695 [ # # ]: 0 : MetaAction* pAction = aMtf.GetAction( i );
696 [ # # # # : 0 : switch( pAction->GetType() )
# ]
697 : : {
698 : : // only optimizing common bitmap actions:
699 : : case( META_MAPMODE_ACTION ):
700 : : {
701 [ # # ]: 0 : const_cast< MetaAction* >( pAction )->Execute( &aDummyVDev );
702 : 0 : break;
703 : : }
704 : : case( META_PUSH_ACTION ):
705 : : {
706 : 0 : const MetaPushAction* pA = (const MetaPushAction*)pAction;
707 [ # # ]: 0 : aDummyVDev.Push( pA->GetFlags() );
708 : 0 : break;
709 : : }
710 : : case( META_POP_ACTION ):
711 : : {
712 [ # # ]: 0 : aDummyVDev.Pop();
713 : 0 : break;
714 : : }
715 : : case( META_BMPSCALE_ACTION ):
716 : : case( META_BMPEXSCALE_ACTION ):
717 : : {
718 [ # # ]: 0 : BitmapEx aBmpEx;
719 : 0 : Point aPos;
720 : 0 : Size aSize;
721 [ # # ]: 0 : if ( pAction->GetType() == META_BMPSCALE_ACTION )
722 : : {
723 [ # # ]: 0 : MetaBmpScaleAction* pScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
724 [ # # ][ # # ]: 0 : aBmpEx = pScaleAction->GetBitmap();
[ # # ]
725 : 0 : aPos = pScaleAction->GetPoint();
726 : 0 : aSize = pScaleAction->GetSize();
727 : : }
728 : : else
729 : : {
730 [ # # ]: 0 : MetaBmpExScaleAction* pScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
731 [ # # ]: 0 : aBmpEx = pScaleAction->GetBitmapEx();
732 : 0 : aPos = pScaleAction->GetPoint();
733 : 0 : aSize = pScaleAction->GetSize();
734 : : }
735 [ # # ]: 0 : ::Graphic aGraphic( aBmpEx );
736 [ # # ]: 0 : const Size aSize100thmm( aDummyVDev.LogicToPixel( aSize ) );
737 [ # # ][ # # ]: 0 : Size aSize100thmm2( aDummyVDev.PixelToLogic( aSize100thmm, MAP_100TH_MM ) );
[ # # ]
738 : :
739 : : ImplApplyBitmapResolution( aGraphic, nImageResolution,
740 [ # # ][ # # ]: 0 : aGraphic.GetSizePixel(), awt::Size( aSize100thmm2.Width(), aSize100thmm2.Height() ) );
741 : :
742 : : MetaAction* pNewAction;
743 [ # # ]: 0 : if ( pAction->GetType() == META_BMPSCALE_ACTION )
744 [ # # ][ # # ]: 0 : pNewAction = new MetaBmpScaleAction ( aPos, aSize, aGraphic.GetBitmap() );
[ # # ][ # # ]
745 : : else
746 [ # # ][ # # ]: 0 : pNewAction = new MetaBmpExScaleAction( aPos, aSize, aGraphic.GetBitmapEx() );
[ # # ][ # # ]
747 : :
748 [ # # ]: 0 : aMtf.ReplaceAction( pNewAction, i );
749 [ # # ]: 0 : pAction->Delete();
750 [ # # ][ # # ]: 0 : break;
751 : : }
752 : : default:
753 : : case( META_BMP_ACTION ):
754 : : case( META_BMPSCALEPART_ACTION ):
755 : : case( META_BMPEX_ACTION ):
756 : : case( META_BMPEXSCALEPART_ACTION ):
757 : : case( META_MASK_ACTION ):
758 : : case( META_MASKSCALE_ACTION ):
759 : 0 : break;
760 : : }
761 : : }
762 [ # # ][ # # ]: 0 : rGraphic = aMtf;
[ # # ][ # # ]
763 [ # # ][ # # ]: 0 : }
764 : : }
765 : 0 : }
766 : :
767 : : // ------------------------------------------------------------------------------
768 : :
769 : 0 : void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XGraphic >& rxGraphic, const uno::Sequence< beans::PropertyValue >& rMediaProperties )
770 : : throw ( io::IOException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
771 : : {
772 : 0 : SvStream* pOStm = NULL;
773 [ # # ]: 0 : String aPath;
774 : : sal_Int32 i;
775 : :
776 [ # # ][ # # ]: 0 : for( i = 0; ( i < rMediaProperties.getLength() ) && !pOStm; ++i )
[ # # ]
777 : : {
778 : 0 : const ::rtl::OUString aName( rMediaProperties[ i ].Name );
779 : 0 : const uno::Any aValue( rMediaProperties[ i ].Value );
780 : :
781 [ # # ]: 0 : if( COMPARE_EQUAL == aName.compareToAscii( "URL" ) )
782 : : {
783 : 0 : ::rtl::OUString aURL;
784 : :
785 : 0 : aValue >>= aURL;
786 [ # # ][ # # ]: 0 : pOStm = ::utl::UcbStreamHelper::CreateStream( aURL, STREAM_WRITE | STREAM_TRUNC );
[ # # ]
787 [ # # ]: 0 : aPath = aURL;
788 : : }
789 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "OutputStream" ) )
790 : : {
791 : 0 : uno::Reference< io::XStream > xOStm;
792 : :
793 [ # # ]: 0 : aValue >>= xOStm;
794 : :
795 [ # # ]: 0 : if( xOStm.is() )
796 [ # # ]: 0 : pOStm = ::utl::UcbStreamHelper::CreateStream( xOStm );
797 : : }
798 : 0 : }
799 : :
800 [ # # ]: 0 : if( pOStm )
801 : : {
802 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aFilterDataSeq;
803 : 0 : const char* pFilterShortName = NULL;
804 : :
805 [ # # ]: 0 : for( i = 0; i < rMediaProperties.getLength(); ++i )
806 : : {
807 : 0 : const ::rtl::OUString aName( rMediaProperties[ i ].Name );
808 : 0 : const uno::Any aValue( rMediaProperties[ i ].Value );
809 : :
810 [ # # ]: 0 : if( COMPARE_EQUAL == aName.compareToAscii( "FilterData" ) )
811 : : {
812 [ # # ]: 0 : aValue >>= aFilterDataSeq;
813 : : }
814 [ # # ]: 0 : else if( COMPARE_EQUAL == aName.compareToAscii( "MimeType" ) )
815 : : {
816 : 0 : ::rtl::OUString aMimeType;
817 : :
818 : 0 : aValue >>= aMimeType;
819 : :
820 [ # # ]: 0 : if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_BMP ) )
821 : 0 : pFilterShortName = "bmp";
822 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_EPS ) )
823 : 0 : pFilterShortName = "eps";
824 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_GIF ) )
825 : 0 : pFilterShortName = "gif";
826 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_JPG ) )
827 : 0 : pFilterShortName = "jpg";
828 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_MET ) )
829 : 0 : pFilterShortName = "met";
830 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_PNG ) )
831 : 0 : pFilterShortName = "png";
832 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_PCT ) )
833 : 0 : pFilterShortName = "pct";
834 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_PBM ) )
835 : 0 : pFilterShortName = "pbm";
836 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_PGM ) )
837 : 0 : pFilterShortName = "pgm";
838 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_PPM ) )
839 : 0 : pFilterShortName = "ppm";
840 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_RAS ) )
841 : 0 : pFilterShortName = "ras";
842 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_SVM ) )
843 : 0 : pFilterShortName = "svm";
844 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_TIF ) )
845 : 0 : pFilterShortName = "tif";
846 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_EMF ) )
847 : 0 : pFilterShortName = "emf";
848 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_WMF ) )
849 : 0 : pFilterShortName = "wmf";
850 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_XPM ) )
851 : 0 : pFilterShortName = "xpm";
852 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_SVG ) )
853 : 0 : pFilterShortName = "svg";
854 [ # # ]: 0 : else if( COMPARE_EQUAL == aMimeType.compareToAscii( MIMETYPE_VCLGRAPHIC ) )
855 : 0 : pFilterShortName = MIMETYPE_VCLGRAPHIC;
856 : : }
857 : 0 : }
858 : :
859 [ # # ]: 0 : if( pFilterShortName )
860 : : {
861 [ # # ]: 0 : ::GraphicFilter& rFilter = ::GraphicFilter::GetGraphicFilter();
862 : :
863 : : {
864 [ # # ]: 0 : const uno::Reference< XInterface > xIFace( rxGraphic, uno::UNO_QUERY );
865 : 0 : const ::Graphic* pGraphic = ::unographic::Graphic::getImplementation( xIFace );
866 : :
867 [ # # ][ # # ]: 0 : if( pGraphic && ( pGraphic->GetType() != GRAPHIC_NONE ) )
[ # # ][ # # ]
868 : : {
869 [ # # ]: 0 : ::Graphic aGraphic( *pGraphic );
870 [ # # ]: 0 : ImplApplyFilterData( aGraphic, aFilterDataSeq );
871 : :
872 : : /* sj: using a temporary memory stream, because some graphic filters are seeking behind
873 : : stream end (which leads to an invalid argument exception then). */
874 [ # # ]: 0 : SvMemoryStream aMemStrm;
875 : 0 : aMemStrm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
876 [ # # ]: 0 : if( 0 == strcmp( pFilterShortName, MIMETYPE_VCLGRAPHIC ) )
877 [ # # ]: 0 : aMemStrm << aGraphic;
878 : : else
879 : : {
880 : : rFilter.ExportGraphic( aGraphic, aPath, aMemStrm,
881 [ # # ][ # # ]: 0 : rFilter.GetExportFormatNumberForShortName( ::rtl::OUString::createFromAscii( pFilterShortName ) ),
[ # # ]
882 [ # # ][ # # ]: 0 : ( aFilterDataSeq.getLength() ? &aFilterDataSeq : NULL ) );
883 : : }
884 [ # # ]: 0 : aMemStrm.Seek( STREAM_SEEK_TO_END );
885 [ # # ][ # # ]: 0 : pOStm->Write( aMemStrm.GetData(), aMemStrm.Tell() );
[ # # ][ # # ]
886 : 0 : }
887 : : }
888 : : }
889 [ # # ][ # # ]: 0 : delete pOStm;
[ # # ]
890 [ # # ]: 0 : }
891 : 0 : }
892 : :
893 : : }
894 : :
895 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|