1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _GOODIES_DESCRIPTOR_HXX
29 #define _GOODIES_DESCRIPTOR_HXX
30 
31 #include <comphelper/propertysethelper.hxx>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 
34 #include <comphelper/propertysetinfo.hxx>
35 #include <vcl/graph.hxx>
36 
37 #define	MIMETYPE_BMP		"image/x-MS-bmp"
38 #define	MIMETYPE_GIF		"image/gif"
39 #define	MIMETYPE_JPG		"image/jpeg"
40 #define	MIMETYPE_PCD		"image/x-photo-cd"
41 #define	MIMETYPE_PCX		"image/x-pcx"
42 #define	MIMETYPE_PNG		"image/png"
43 #define	MIMETYPE_TIF		"image/tiff"
44 #define	MIMETYPE_XBM		"image/x-xbitmap"
45 #define	MIMETYPE_XPM		"image/x-xpixmap"
46 #define	MIMETYPE_PBM		"image/x-portable-bitmap"
47 #define	MIMETYPE_PGM		"image/x-portable-graymap"
48 #define	MIMETYPE_PPM		"image/x-portable-pixmap"
49 #define	MIMETYPE_RAS		"image/x-cmu-raster"
50 #define	MIMETYPE_TGA		"image/x-targa"
51 #define	MIMETYPE_PSD		"image/vnd.adobe.photoshop"
52 #define	MIMETYPE_EPS		"image/x-eps"
53 #define	MIMETYPE_DXF		"image/vnd.dxf"
54 #define	MIMETYPE_MET		"image/x-met"
55 #define	MIMETYPE_PCT		"image/x-pict"
56 #define	MIMETYPE_SGF		"image/x-sgf"
57 #define	MIMETYPE_SVM		"image/x-svm"
58 #define	MIMETYPE_WMF		"image/x-wmf"
59 #define MIMETYPE_SGV		"image/x-sgv"
60 #define	MIMETYPE_EMF		"image/x-emf"
61 #define	MIMETYPE_SVG		"image/svg+xml"
62 #define MIMETYPE_VCLGRAPHIC	"image/x-vclgraphic"
63 
64 using namespace com::sun::star;
65 
66 namespace comphelper { class PropertySetInfo; }
67 namespace com { namespace sun { namespace star { namespace io { class XInputStream; } } } }
68 
69 class Graphic;
70 
71 namespace unographic {
72 
73 // -------------------
74 // - GraphicProvider -
75 // -------------------
76 
77 class GraphicDescriptor : public ::cppu::OWeakAggObject,
78 						  public ::com::sun::star::lang::XServiceInfo,
79 						  public ::com::sun::star::lang::XTypeProvider,
80 						  public ::comphelper::PropertySetHelper
81 {
82 public:
83 
84 	GraphicDescriptor();
85 	~GraphicDescriptor() throw();
86 
87  	void init( const ::Graphic& rGraphic ) throw();
88 	void init( const ::rtl::OUString& rURL ) throw();
89 	void init( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxIStm, const ::rtl::OUString& rURL ) throw();
90 
91 	bool isValid() const;
92 
93     static ::rtl::OUString getImplementationName_Static() throw();
94     static ::com::sun::star::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
95 
96 protected:
97 
98 	static ::comphelper::PropertySetInfo* createPropertySetInfo();
99 
100 	// XInterface
101 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
102 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
103 	virtual void SAL_CALL acquire() throw();
104 	virtual void SAL_CALL release() throw();
105 
106 	// XServiceInfo
107     virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
108     virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
109     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
110 
111 	// XTypeProvider
112     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
113     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
114 
115 	// PropertySetHelper
116         virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
117         virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
118 
119 private:
120 
121 	const ::Graphic*		mpGraphic;
122 	GraphicType				meType;
123 	::rtl::OUString			maMimeType;
124 	Size					maSizePixel;
125 	Size					maSize100thMM;
126 	sal_uInt16				mnBitsPerPixel;
127 	bool					mbTransparent;
128 	bool					mbAlpha;
129 	bool					mbAnimated;
130 
131 	GraphicDescriptor( const GraphicDescriptor& rDescriptor );
132 
133 	GraphicDescriptor& operator=( const GraphicDescriptor& );
134 
135 	void implCreate( SvStream& rIStm, const ::rtl::OUString* pPath );
136 };
137 
138 }
139 
140 #endif
141