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