1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _GOODIES_DESCRIPTOR_HXX
25 #define _GOODIES_DESCRIPTOR_HXX
26 
27 #include <comphelper/propertysethelper.hxx>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 
30 #include <comphelper/propertysetinfo.hxx>
31 #include <vcl/graph.hxx>
32 
33 #define	MIMETYPE_BMP		"image/x-MS-bmp"
34 #define	MIMETYPE_GIF		"image/gif"
35 #define	MIMETYPE_JPG		"image/jpeg"
36 #define	MIMETYPE_PCD		"image/x-photo-cd"
37 #define	MIMETYPE_PCX		"image/x-pcx"
38 #define	MIMETYPE_PNG		"image/png"
39 #define	MIMETYPE_TIF		"image/tiff"
40 #define	MIMETYPE_XBM		"image/x-xbitmap"
41 #define	MIMETYPE_XPM		"image/x-xpixmap"
42 #define	MIMETYPE_PBM		"image/x-portable-bitmap"
43 #define	MIMETYPE_PGM		"image/x-portable-graymap"
44 #define	MIMETYPE_PPM		"image/x-portable-pixmap"
45 #define	MIMETYPE_RAS		"image/x-cmu-raster"
46 #define	MIMETYPE_TGA		"image/x-targa"
47 #define	MIMETYPE_PSD		"image/vnd.adobe.photoshop"
48 #define	MIMETYPE_EPS		"image/x-eps"
49 #define	MIMETYPE_DXF		"image/vnd.dxf"
50 #define	MIMETYPE_MET		"image/x-met"
51 #define	MIMETYPE_PCT		"image/x-pict"
52 #define	MIMETYPE_SGF		"image/x-sgf"
53 #define	MIMETYPE_SVM		"image/x-svm"
54 #define	MIMETYPE_WMF		"image/x-wmf"
55 #define MIMETYPE_SGV		"image/x-sgv"
56 #define	MIMETYPE_EMF		"image/x-emf"
57 #define	MIMETYPE_SVG		"image/svg+xml"
58 #define MIMETYPE_VCLGRAPHIC	"image/x-vclgraphic"
59 
60 using namespace com::sun::star;
61 
62 namespace comphelper { class PropertySetInfo; }
63 namespace com { namespace sun { namespace star { namespace io { class XInputStream; } } } }
64 
65 class Graphic;
66 
67 namespace unographic {
68 
69 // -------------------
70 // - GraphicProvider -
71 // -------------------
72 
73 class GraphicDescriptor : public ::cppu::OWeakAggObject,
74 						  public ::com::sun::star::lang::XServiceInfo,
75 						  public ::com::sun::star::lang::XTypeProvider,
76 						  public ::comphelper::PropertySetHelper
77 {
78 public:
79 
80 	GraphicDescriptor();
81 	~GraphicDescriptor() throw();
82 
83  	void init( const ::Graphic& rGraphic ) throw();
84 	void init( const ::rtl::OUString& rURL ) throw();
85 	void init( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxIStm, const ::rtl::OUString& rURL ) throw();
86 
87 	bool isValid() const;
88 
89     static ::rtl::OUString getImplementationName_Static() throw();
90     static ::com::sun::star::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
91 
92 protected:
93 
94 	static ::comphelper::PropertySetInfo* createPropertySetInfo();
95 
96 	// XInterface
97 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
98 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
99 	virtual void SAL_CALL acquire() throw();
100 	virtual void SAL_CALL release() throw();
101 
102 	// XServiceInfo
103     virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
104     virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
105     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
106 
107 	// XTypeProvider
108     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
109     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
110 
111 	// PropertySetHelper
112         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 );
113         virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
114 
115 private:
116 
117 	const ::Graphic*		mpGraphic;
118 	GraphicType				meType;
119 	::rtl::OUString			maMimeType;
120 	Size					maSizePixel;
121 	Size					maSize100thMM;
122 	sal_uInt16				mnBitsPerPixel;
123 	bool					mbTransparent;
124 	bool					mbAlpha;
125 	bool					mbAnimated;
126 
127 	GraphicDescriptor( const GraphicDescriptor& rDescriptor );
128 
129 	GraphicDescriptor& operator=( const GraphicDescriptor& );
130 
131 	void implCreate( SvStream& rIStm, const ::rtl::OUString* pPath );
132 };
133 
134 }
135 
136 #endif
137