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 FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_
25 #define FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_
26 
27 #include <framework/fwedllapi.h>
28 #include <svl/svarray.hxx>
29 #include <tools/string.hxx>
30 #include <tools/stream.hxx>
31 #include <tools/color.hxx>
32 
33 // #110897#
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #include <com/sun/star/io/XOutputStream.hpp>
37 
38 #include <vector>
39 
40 namespace framework
41 {
42 
43 enum ImageMaskMode
44 {
45 	ImageMaskMode_Color,
46 	ImageMaskMode_Bitmap
47 };
48 
49 struct ImageItemDescriptor
50 {
ImageItemDescriptorframework::ImageItemDescriptor51 	ImageItemDescriptor() : nIndex( -1 ) {}
52 
53 	String	aCommandURL;				// URL command to dispatch
54 	long	nIndex;						// index of the bitmap inside the bitmaplist
55 };
56 
57 struct ExternalImageItemDescriptor
58 {
59 	String	aCommandURL;				// URL command to dispatch
60 	String	aURL;						// a URL to an external bitmap
61 };
62 
63 typedef ImageItemDescriptor* ImageItemDescriptorPtr;
64 SV_DECL_PTRARR_DEL( ImageItemListDescriptor, ImageItemDescriptorPtr, 10, 2)
65 
66 typedef ExternalImageItemDescriptor* ExternalImageItemDescriptorPtr;
67 SV_DECL_PTRARR_DEL( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr, 10, 2)
68 
69 struct ImageListItemDescriptor
70 {
ImageListItemDescriptorframework::ImageListItemDescriptor71     ImageListItemDescriptor() : nMaskMode( ImageMaskMode_Color ),
72                                 pImageItemList( 0 ) {}
73 
~ImageListItemDescriptorframework::ImageListItemDescriptor74     ~ImageListItemDescriptor() { delete pImageItemList; }
75 
76     String						aURL;				// an URL to a bitmap with several images inside
77     Color						aMaskColor;			// a color used as transparent
78     String						aMaskURL;			// an URL to an optional bitmap used as a mask
79     ImageMaskMode				      nMaskMode;			// an enum to describe the current mask mode
80     ImageItemListDescriptor*              pImageItemList;		// an array	of ImageItemDescriptors that describes every image
81     String						aHighContrastURL;		// an URL to an optional high contrast bitmap with serveral images inside
82     String						aHighContrastMaskURL;	// an URL to an optional high contrast bitmap as a mask
83 };
84 
85 typedef ImageListItemDescriptor* ImageListItemDescriptorPtr;
86 SV_DECL_PTRARR_DEL( ImageListDescriptor, ImageListItemDescriptorPtr, 10, 2)
87 
88 struct ImageListsDescriptor
89 {
ImageListsDescriptorframework::ImageListsDescriptor90 	ImageListsDescriptor() : pImageList( 0 ),
91 					 pExternalImageList( 0 ) {}
~ImageListsDescriptorframework::ImageListsDescriptor92 	~ImageListsDescriptor() { delete pImageList; delete pExternalImageList; }
93 
94 	ImageListDescriptor*			pImageList;
95 	ExternalImageItemListDescriptor*	pExternalImageList;
96 };
97 
98 class ImagesConfiguration
99 {
100 	public:
101 		// #110897#
102 		static sal_Bool	LoadImages(
103 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
104 			SvStream& rInStream, ImageListsDescriptor& aItems );
105 
106 		// #110897#
107 		static sal_Bool	StoreImages(
108 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
109 			SvStream& rOutStream, const ImageListsDescriptor& aItems );
110 
111         static sal_Bool LoadImages(
112 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
113             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream,
114             ImageListsDescriptor& rItems );
115 
116         static sal_Bool StoreImages(
117 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
118             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream,
119             const ImageListsDescriptor& rItems );
120 };
121 
122 } // namespace framework
123 
124 #endif // __FRAMEWORK_CLASSES_IMAGES
125