15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
105900e8ecSAndrew Rist  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
195900e8ecSAndrew Rist  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "descriptor.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <rtl/uuid.h>
30cdf0e10cSrcweir #include <vos/mutex.hxx>
31cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
32cdf0e10cSrcweir #include <svtools/filter.hxx>
33cdf0e10cSrcweir #include <svl/itemprop.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
38cdf0e10cSrcweir #include <com/sun/star/graphic/GraphicType.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "vcl/graph.hxx"
41cdf0e10cSrcweir #include "vcl/svapp.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define UNOGRAPHIC_GRAPHICTYPE 	1
44cdf0e10cSrcweir #define UNOGRAPHIC_MIMETYPE		2
45cdf0e10cSrcweir #define UNOGRAPHIC_SIZEPIXEL	3
46cdf0e10cSrcweir #define UNOGRAPHIC_SIZE100THMM	4
47cdf0e10cSrcweir #define UNOGRAPHIC_BITSPERPIXEL	5
48cdf0e10cSrcweir #define UNOGRAPHIC_TRANSPARENT	6
49cdf0e10cSrcweir #define UNOGRAPHIC_ALPHA		7
50cdf0e10cSrcweir #define UNOGRAPHIC_ANIMATED		8
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace unographic {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // ---------------------
57cdf0e10cSrcweir // - GraphicDescriptor -
58cdf0e10cSrcweir // ---------------------
59cdf0e10cSrcweir 
60cdf0e10cSrcweir GraphicDescriptor::GraphicDescriptor() :
61cdf0e10cSrcweir 	::comphelper::PropertySetHelper( createPropertySetInfo(), SAL_NO_ACQUIRE ),
62cdf0e10cSrcweir 	mpGraphic( NULL ),
63cdf0e10cSrcweir 	meType( GRAPHIC_NONE ),
64cdf0e10cSrcweir 	mnBitsPerPixel ( 0 ),
65cdf0e10cSrcweir 	mbTransparent ( false ),
66cdf0e10cSrcweir 	mbAlpha( false ),
67cdf0e10cSrcweir 	mbAnimated( false )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // ------------------------------------------------------------------------------
72cdf0e10cSrcweir 
73cdf0e10cSrcweir GraphicDescriptor::~GraphicDescriptor()
74cdf0e10cSrcweir 	throw()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // ------------------------------------------------------------------------------
79cdf0e10cSrcweir 
80cdf0e10cSrcweir void GraphicDescriptor::init( const ::Graphic& rGraphic )
81cdf0e10cSrcweir 	throw()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	mpGraphic = &rGraphic;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // ------------------------------------------------------------------------------
87cdf0e10cSrcweir 
88cdf0e10cSrcweir void GraphicDescriptor::init( const ::rtl::OUString& rURL )
89cdf0e10cSrcweir 	throw()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rURL, STREAM_READ );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	if( pIStm )
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		implCreate( *pIStm, &rURL );
96cdf0e10cSrcweir 		delete pIStm;
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // ------------------------------------------------------------------------------
101cdf0e10cSrcweir 
102cdf0e10cSrcweir void GraphicDescriptor::init( const uno::Reference< io::XInputStream >& rxIStm, const ::rtl::OUString& rURL )
103cdf0e10cSrcweir 	throw()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rxIStm );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	if( pIStm )
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		implCreate( *pIStm, &rURL );
110cdf0e10cSrcweir 		delete pIStm;
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir // ------------------------------------------------------------------------------
115cdf0e10cSrcweir 
116cdf0e10cSrcweir bool GraphicDescriptor::isValid() const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	return( mpGraphic ? ( mpGraphic->GetType() != GRAPHIC_NONE ) : ( meType != GRAPHIC_NONE ) );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // ------------------------------------------------------------------------------
122cdf0e10cSrcweir 
123cdf0e10cSrcweir void GraphicDescriptor::implCreate( SvStream& rIStm, const ::rtl::OUString* pURL )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	String aURL;
126cdf0e10cSrcweir 	if( pURL )
127cdf0e10cSrcweir 		aURL = *pURL;
128cdf0e10cSrcweir 	::GraphicDescriptor aDescriptor( rIStm, &aURL );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	mpGraphic = NULL;
131cdf0e10cSrcweir 	maMimeType = ::rtl::OUString();
132cdf0e10cSrcweir 	meType = GRAPHIC_NONE;
133cdf0e10cSrcweir 	mnBitsPerPixel = 0;
134cdf0e10cSrcweir 	mbTransparent = false;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	if( aDescriptor.Detect( true ) && aDescriptor.GetFileFormat() != GFF_NOT )
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		const char* 			pMimeType = NULL;
139cdf0e10cSrcweir 		sal_uInt8 				cType = graphic::GraphicType::EMPTY;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		switch( aDescriptor.GetFileFormat() )
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			case( GFF_BMP ): pMimeType = MIMETYPE_BMP; cType = graphic::GraphicType::PIXEL; break;
144cdf0e10cSrcweir 			case( GFF_GIF ): pMimeType = MIMETYPE_GIF; cType = graphic::GraphicType::PIXEL; break;
145cdf0e10cSrcweir 			case( GFF_JPG ): pMimeType = MIMETYPE_JPG; cType = graphic::GraphicType::PIXEL; break;
146cdf0e10cSrcweir 			case( GFF_PCD ): pMimeType = MIMETYPE_PCD; cType = graphic::GraphicType::PIXEL; break;
147cdf0e10cSrcweir 			case( GFF_PCX ): pMimeType = MIMETYPE_PCX; cType = graphic::GraphicType::PIXEL; break;
148cdf0e10cSrcweir 			case( GFF_PNG ): pMimeType = MIMETYPE_PNG; cType = graphic::GraphicType::PIXEL; break;
149cdf0e10cSrcweir 			case( GFF_TIF ): pMimeType = MIMETYPE_TIF; cType = graphic::GraphicType::PIXEL; break;
150cdf0e10cSrcweir 			case( GFF_XBM ): pMimeType = MIMETYPE_XBM; cType = graphic::GraphicType::PIXEL; break;
151cdf0e10cSrcweir 			case( GFF_XPM ): pMimeType = MIMETYPE_XPM; cType = graphic::GraphicType::PIXEL; break;
152cdf0e10cSrcweir 			case( GFF_PBM ): pMimeType = MIMETYPE_PBM; cType = graphic::GraphicType::PIXEL; break;
153cdf0e10cSrcweir 			case( GFF_PGM ): pMimeType = MIMETYPE_PGM; cType = graphic::GraphicType::PIXEL; break;
154cdf0e10cSrcweir 			case( GFF_PPM ): pMimeType = MIMETYPE_PPM; cType = graphic::GraphicType::PIXEL; break;
155cdf0e10cSrcweir 			case( GFF_RAS ): pMimeType = MIMETYPE_RAS; cType = graphic::GraphicType::PIXEL; break;
156cdf0e10cSrcweir 			case( GFF_TGA ): pMimeType = MIMETYPE_TGA; cType = graphic::GraphicType::PIXEL; break;
157cdf0e10cSrcweir 			case( GFF_PSD ): pMimeType = MIMETYPE_PSD; cType = graphic::GraphicType::PIXEL; break;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 			case( GFF_EPS ): pMimeType = MIMETYPE_EPS; cType = graphic::GraphicType::VECTOR; break;
160cdf0e10cSrcweir 			case( GFF_DXF ): pMimeType = MIMETYPE_DXF; cType = graphic::GraphicType::VECTOR; break;
161cdf0e10cSrcweir 			case( GFF_MET ): pMimeType = MIMETYPE_MET; cType = graphic::GraphicType::VECTOR; break;
162cdf0e10cSrcweir 			case( GFF_PCT ): pMimeType = MIMETYPE_PCT; cType = graphic::GraphicType::VECTOR; break;
163cdf0e10cSrcweir 			case( GFF_SGF ): pMimeType = MIMETYPE_SGF; cType = graphic::GraphicType::VECTOR; break;
164cdf0e10cSrcweir 			case( GFF_SVM ): pMimeType = MIMETYPE_SVM; cType = graphic::GraphicType::VECTOR; break;
165cdf0e10cSrcweir 			case( GFF_WMF ): pMimeType = MIMETYPE_WMF; cType = graphic::GraphicType::VECTOR; break;
166cdf0e10cSrcweir 			case( GFF_SGV ): pMimeType = MIMETYPE_SGV; cType = graphic::GraphicType::VECTOR; break;
167cdf0e10cSrcweir 			case( GFF_EMF ): pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break;
168cdf0e10cSrcweir 			case( GFF_SVG ): pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 			default:
171cdf0e10cSrcweir 			break;
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		if( graphic::GraphicType::EMPTY != cType )
175cdf0e10cSrcweir 		{
176cdf0e10cSrcweir 			meType = ( ( graphic::GraphicType::PIXEL == cType ) ? GRAPHIC_BITMAP : GRAPHIC_GDIMETAFILE );
177cdf0e10cSrcweir 			maMimeType = String( pMimeType, RTL_TEXTENCODING_ASCII_US );
178cdf0e10cSrcweir 			maSizePixel = aDescriptor.GetSizePixel();
179cdf0e10cSrcweir 			maSize100thMM = aDescriptor.GetSize_100TH_MM();
180cdf0e10cSrcweir 			mnBitsPerPixel = aDescriptor.GetBitsPerPixel();
181cdf0e10cSrcweir 			mbTransparent = ( graphic::GraphicType::VECTOR == cType );
182cdf0e10cSrcweir 			mbAlpha = mbAnimated = false;
183cdf0e10cSrcweir 		}
184cdf0e10cSrcweir 	}
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir // ------------------------------------------------------------------------------
188cdf0e10cSrcweir 
189cdf0e10cSrcweir ::rtl::OUString GraphicDescriptor::getImplementationName_Static()
190cdf0e10cSrcweir 	throw()
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.graphic.GraphicDescriptor" ) );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // ------------------------------------------------------------------------------
196cdf0e10cSrcweir 
197cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > GraphicDescriptor::getSupportedServiceNames_Static()
198cdf0e10cSrcweir 	throw(	)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aSeq( 1 );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicDescriptor" ) );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	return aSeq;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir // ------------------------------------------------------------------------------
208cdf0e10cSrcweir 
209cdf0e10cSrcweir uno::Any SAL_CALL GraphicDescriptor::queryAggregation( const uno::Type & rType )
210cdf0e10cSrcweir 	throw( uno::RuntimeException )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	uno::Any aAny;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) )
215cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XServiceInfo >(this);
216cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) )
217cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XTypeProvider >(this);
218cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
219cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertySet >(this);
220cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) )
221cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertyState >(this);
222cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
223cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XMultiPropertySet >(this);
224cdf0e10cSrcweir 	else
225cdf0e10cSrcweir 		aAny <<= OWeakAggObject::queryAggregation( rType );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	return aAny;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir // ------------------------------------------------------------------------------
231cdf0e10cSrcweir 
232cdf0e10cSrcweir uno::Any SAL_CALL GraphicDescriptor::queryInterface( const uno::Type & rType )
233cdf0e10cSrcweir 	throw( uno::RuntimeException )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	return OWeakAggObject::queryInterface( rType );
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir // ------------------------------------------------------------------------------
239cdf0e10cSrcweir 
240cdf0e10cSrcweir void SAL_CALL GraphicDescriptor::acquire()
241cdf0e10cSrcweir 	throw()
242cdf0e10cSrcweir {
243cdf0e10cSrcweir 	OWeakAggObject::acquire();
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir // ------------------------------------------------------------------------------
247cdf0e10cSrcweir 
248cdf0e10cSrcweir void SAL_CALL GraphicDescriptor::release()
249cdf0e10cSrcweir 	throw()
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	OWeakAggObject::release();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir // ------------------------------------------------------------------------------
255cdf0e10cSrcweir 
256cdf0e10cSrcweir ::rtl::OUString SAL_CALL GraphicDescriptor::getImplementationName()
257cdf0e10cSrcweir 	throw( uno::RuntimeException )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	return getImplementationName_Static();
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir // ------------------------------------------------------------------------------
263cdf0e10cSrcweir 
264cdf0e10cSrcweir sal_Bool SAL_CALL GraphicDescriptor::supportsService( const rtl::OUString& ServiceName )
265cdf0e10cSrcweir 	throw( uno::RuntimeException )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString >	aSNL( getSupportedServiceNames() );
268cdf0e10cSrcweir     const ::rtl::OUString*				pArray = aSNL.getConstArray();
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
271cdf0e10cSrcweir         if( pArray[i] == ServiceName )
272cdf0e10cSrcweir             return true;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     return false;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // ------------------------------------------------------------------------------
278cdf0e10cSrcweir 
279cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL GraphicDescriptor::getSupportedServiceNames()
280cdf0e10cSrcweir 	throw( uno::RuntimeException )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir 	return getSupportedServiceNames_Static();
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir // ------------------------------------------------------------------------------
286cdf0e10cSrcweir 
287cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL GraphicDescriptor::getTypes()
288cdf0e10cSrcweir 	throw( uno::RuntimeException )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir 	uno::Sequence< uno::Type >	aTypes( 6 );
291cdf0e10cSrcweir 	uno::Type* 					pTypes = aTypes.getArray();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< uno::XAggregation>*)0);
294cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
295cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
296cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0);
297cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0);
298cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	return aTypes;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // ------------------------------------------------------------------------------
304cdf0e10cSrcweir 
305cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL GraphicDescriptor::getImplementationId()
306cdf0e10cSrcweir 	throw( uno::RuntimeException )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	vos::OGuard 						aGuard( Application::GetSolarMutex() );
309cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 >	aId;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	if( aId.getLength() == 0 )
312cdf0e10cSrcweir 	{
313cdf0e10cSrcweir 		aId.realloc( 16 );
314cdf0e10cSrcweir 		rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True );
315cdf0e10cSrcweir 	}
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	return aId;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir // ------------------------------------------------------------------------------
321cdf0e10cSrcweir 
322cdf0e10cSrcweir ::comphelper::PropertySetInfo* GraphicDescriptor::createPropertySetInfo()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	vos::OGuard 					aGuard( Application::GetSolarMutex() );
325cdf0e10cSrcweir 	::comphelper::PropertySetInfo*	pRet = new ::comphelper::PropertySetInfo();
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	static ::comphelper::PropertyMapEntry aEntries[] =
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "GraphicType" ), UNOGRAPHIC_GRAPHICTYPE, &::getCppuType( (const sal_Int8*)(0)), beans::PropertyAttribute::READONLY, 0 },
330cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "MimeType" ), UNOGRAPHIC_MIMETYPE, &::getCppuType( (const ::rtl::OUString*)(0)), beans::PropertyAttribute::READONLY, 0 },
331cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "SizePixel" ), UNOGRAPHIC_SIZEPIXEL, &::getCppuType( (const awt::Size*)(0)), beans::PropertyAttribute::READONLY, 0 },
332cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Size100thMM" ), UNOGRAPHIC_SIZE100THMM,	&::getCppuType( (const awt::Size*)(0)), beans::PropertyAttribute::READONLY, 0 },
333cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "BitsPerPixel" ), UNOGRAPHIC_BITSPERPIXEL, &::getCppuType( (const sal_uInt8*)(0)), beans::PropertyAttribute::READONLY, 0 },
334cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Transparent" ), UNOGRAPHIC_TRANSPARENT, &::getCppuType( (const sal_Bool*)(0)), beans::PropertyAttribute::READONLY, 0 },
335cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Alpha" ), UNOGRAPHIC_ALPHA, &::getCppuType( (const sal_Bool*)(0)), beans::PropertyAttribute::READONLY, 0 },
336cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Animated" ), UNOGRAPHIC_ANIMATED, &::getCppuType( (const sal_Bool*)(0)), beans::PropertyAttribute::READONLY, 0 },
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 		{ 0,0,0,0,0,0 }
339cdf0e10cSrcweir 	};
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 	pRet->acquire();
342cdf0e10cSrcweir 	pRet->add( aEntries );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	return pRet;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir // ------------------------------------------------------------------------------
348cdf0e10cSrcweir 
349cdf0e10cSrcweir void GraphicDescriptor::_setPropertyValues( const comphelper::PropertyMapEntry** /*ppEntries*/, const uno::Any* /*pValues*/ )
350cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
351cdf0e10cSrcweir 		   beans::PropertyVetoException,
352cdf0e10cSrcweir 		   lang::IllegalArgumentException,
353cdf0e10cSrcweir 	   	   lang::WrappedTargetException )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	// we only have readonly attributes
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir // ------------------------------------------------------------------------------
359cdf0e10cSrcweir 
360cdf0e10cSrcweir void GraphicDescriptor::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValues )
361cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	while( *ppEntries )
366cdf0e10cSrcweir 	{
367cdf0e10cSrcweir 		switch( (*ppEntries)->mnHandle )
368cdf0e10cSrcweir 		{
369cdf0e10cSrcweir 			case( UNOGRAPHIC_GRAPHICTYPE ):
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir 				const GraphicType eType( mpGraphic ? mpGraphic->GetType() : meType );
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 				*pValues <<= ( ( eType == GRAPHIC_BITMAP ? graphic::GraphicType::PIXEL :
374cdf0e10cSrcweir 								( eType == GRAPHIC_GDIMETAFILE ? graphic::GraphicType::VECTOR :
375cdf0e10cSrcweir 								graphic::GraphicType::EMPTY ) ) );
376cdf0e10cSrcweir 			}
377cdf0e10cSrcweir 			break;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 			case( UNOGRAPHIC_MIMETYPE ):
380cdf0e10cSrcweir 			{
381cdf0e10cSrcweir 				::rtl::OUString aMimeType;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 				if( mpGraphic )
384cdf0e10cSrcweir 				{
385cdf0e10cSrcweir 					if( mpGraphic->IsLink() )
386cdf0e10cSrcweir 					{
387cdf0e10cSrcweir 						const char* pMimeType;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 						switch( const_cast< Graphic* >( mpGraphic )->GetLink().GetType() )
390cdf0e10cSrcweir 						{
391cdf0e10cSrcweir 							case( GFX_LINK_TYPE_NATIVE_GIF ): pMimeType = MIMETYPE_GIF; break;
392cdf0e10cSrcweir 							case( GFX_LINK_TYPE_NATIVE_JPG ): pMimeType = MIMETYPE_JPG; break;
393cdf0e10cSrcweir 							case( GFX_LINK_TYPE_NATIVE_PNG ): pMimeType = MIMETYPE_PNG; break;
394cdf0e10cSrcweir 							case( GFX_LINK_TYPE_NATIVE_WMF ): pMimeType = MIMETYPE_WMF; break;
395cdf0e10cSrcweir 							case( GFX_LINK_TYPE_NATIVE_MET ): pMimeType = MIMETYPE_MET; break;
396*ddde725dSArmin Le Grand 							case( GFX_LINK_TYPE_NATIVE_PCT ): pMimeType = MIMETYPE_PCT; break;
397*ddde725dSArmin Le Grand 
398*ddde725dSArmin Le Grand                             // added Svg mimetype support
399*ddde725dSArmin Le Grand                             case( GFX_LINK_TYPE_NATIVE_SVG ): pMimeType = MIMETYPE_SVG; break;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 							default:
402cdf0e10cSrcweir 								pMimeType = NULL;
403cdf0e10cSrcweir 							break;
404cdf0e10cSrcweir 						}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 						if( pMimeType )
407cdf0e10cSrcweir 							aMimeType = ::rtl::OUString::createFromAscii( pMimeType );
408cdf0e10cSrcweir 					}
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 					if( !aMimeType.getLength() && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
411cdf0e10cSrcweir 						aMimeType = ::rtl::OUString::createFromAscii( MIMETYPE_VCLGRAPHIC );
412cdf0e10cSrcweir 				}
413cdf0e10cSrcweir 				else
414cdf0e10cSrcweir 					aMimeType = maMimeType;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir  				*pValues <<= aMimeType;
417cdf0e10cSrcweir 			}
418cdf0e10cSrcweir 			break;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 			case( UNOGRAPHIC_SIZEPIXEL ):
421cdf0e10cSrcweir 			{
422cdf0e10cSrcweir 				awt::Size aAWTSize( 0, 0 );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 				if( mpGraphic )
425cdf0e10cSrcweir 				{
426cdf0e10cSrcweir 					if( mpGraphic->GetType() == GRAPHIC_BITMAP )
427cdf0e10cSrcweir 					{
428cdf0e10cSrcweir 						const Size aSizePix( mpGraphic->GetBitmapEx().GetSizePixel() );
429cdf0e10cSrcweir 						aAWTSize = awt::Size( aSizePix.Width(), aSizePix.Height() );
430cdf0e10cSrcweir 					}
431cdf0e10cSrcweir 				}
432cdf0e10cSrcweir 				else
433cdf0e10cSrcweir 					aAWTSize = awt::Size( maSizePixel.Width(), maSizePixel.Height() );
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 				*pValues <<= aAWTSize;
436cdf0e10cSrcweir 			}
437cdf0e10cSrcweir 			break;
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 			case( UNOGRAPHIC_SIZE100THMM ):
440cdf0e10cSrcweir 			{
441cdf0e10cSrcweir 				awt::Size aAWTSize( 0, 0 );
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 				if( mpGraphic )
444cdf0e10cSrcweir 				{
445cdf0e10cSrcweir 					if( mpGraphic->GetPrefMapMode().GetMapUnit() != MAP_PIXEL )
446cdf0e10cSrcweir 					{
447cdf0e10cSrcweir 						const Size aSizeLog( OutputDevice::LogicToLogic( mpGraphic->GetPrefSize(), mpGraphic->GetPrefMapMode(), MAP_100TH_MM ) );
448cdf0e10cSrcweir 						aAWTSize = awt::Size( aSizeLog.Width(), aSizeLog.Height() );
449cdf0e10cSrcweir 					}
450cdf0e10cSrcweir 				}
451cdf0e10cSrcweir 				else
452cdf0e10cSrcweir 					aAWTSize = awt::Size( maSize100thMM.Width(), maSize100thMM.Height() );
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 				*pValues <<= aAWTSize;
455cdf0e10cSrcweir 			}
456cdf0e10cSrcweir 			break;
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 			case( UNOGRAPHIC_BITSPERPIXEL ):
459cdf0e10cSrcweir 			{
460cdf0e10cSrcweir 				sal_uInt16 nBitsPerPixel = 0;
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 				if( mpGraphic )
463cdf0e10cSrcweir 				{
464cdf0e10cSrcweir 					if( mpGraphic->GetType() == GRAPHIC_BITMAP )
465cdf0e10cSrcweir 						nBitsPerPixel = mpGraphic->GetBitmapEx().GetBitmap().GetBitCount();
466cdf0e10cSrcweir 				}
467cdf0e10cSrcweir 				else
468cdf0e10cSrcweir 					nBitsPerPixel = mnBitsPerPixel;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				*pValues <<= sal::static_int_cast< sal_Int8 >(nBitsPerPixel);
471cdf0e10cSrcweir 			}
472cdf0e10cSrcweir 			break;
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 			case( UNOGRAPHIC_TRANSPARENT ):
475cdf0e10cSrcweir 			{
476cdf0e10cSrcweir 				*pValues <<= static_cast< sal_Bool >( mpGraphic ? mpGraphic->IsTransparent() : mbTransparent );
477cdf0e10cSrcweir 			}
478cdf0e10cSrcweir 			break;
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 			case( UNOGRAPHIC_ALPHA ):
481cdf0e10cSrcweir 			{
482cdf0e10cSrcweir 				*pValues <<= static_cast< sal_Bool >( mpGraphic ? mpGraphic->IsAlpha() : mbAlpha );
483cdf0e10cSrcweir 			}
484cdf0e10cSrcweir 			break;
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 			case( UNOGRAPHIC_ANIMATED ):
487cdf0e10cSrcweir 			{
488cdf0e10cSrcweir 				*pValues <<= static_cast< sal_Bool >( mpGraphic ? mpGraphic->IsAnimated() : mbAnimated );
489cdf0e10cSrcweir 			}
490cdf0e10cSrcweir 			break;
491cdf0e10cSrcweir 		}
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 		++ppEntries;
494cdf0e10cSrcweir 		++pValues;
495cdf0e10cSrcweir 	}
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir }
499