Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Initial Developer of the Original Code is
16 : * Noel Power <noel.power@novell.com>
17 : * Portions created by the Initial Developer are Copyright (C) 2010 the
18 : * Initial Developer. All Rights Reserved.
19 : *
20 : * Contributor(s):
21 : * Noel Power <noel.power@novell.com>
22 : *
23 : * For minor contributions see the git repository.
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
27 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
28 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
29 : * instead of those above.
30 : */
31 : #ifndef _MSTOOLBAR_HXX
32 : #define _MSTOOLBAR_HXX
33 : #include "filter/msfilter/msfilterdllapi.h"
34 : #include <sot/storage.hxx>
35 : #include <ostream>
36 : #include <memory>
37 : #include <vector>
38 : #include <boost/shared_ptr.hpp>
39 : #include <com/sun/star/frame/XModel.hpp>
40 : #include <com/sun/star/container/XIndexContainer.hpp>
41 : #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
42 : #include <com/sun/star/ui/ImageType.hpp>
43 : #include <com/sun/star/graphic/XGraphic.hpp>
44 : #include <com/sun/star/beans/XPropertySet.hpp>
45 : #include <vcl/bitmap.hxx>
46 : #include <cppuhelper/implbase1.hxx>
47 :
48 : class TBCHeader;
49 :
50 :
51 0 : class MSOCommandConvertor
52 : {
53 : public:
54 0 : virtual ~MSOCommandConvertor() {}
55 : virtual rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
56 : virtual rtl::OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
57 : };
58 :
59 : class SfxObjectShell;
60 :
61 0 : class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
62 : {
63 0 : struct iconcontrolitem
64 : {
65 : rtl::OUString sCommand;
66 : css::uno::Reference< css::graphic::XGraphic > image;
67 : };
68 : std::vector< iconcontrolitem > iconcommands;
69 : std::auto_ptr< MSOCommandConvertor > pMSOCmdConvertor;
70 : css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp;
71 : css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
72 : SfxObjectShell& mrDocSh;
73 : void ScaleImage( css::uno::Reference< css::graphic::XGraphic >& xGraphic, long nNewSize );
74 : public:
75 : CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
76 :
77 0 : void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
78 : css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
79 : css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager();
80 :
81 :
82 : css::uno::Any createCommandFromMacro( const rtl::OUString& sCmd );
83 :
84 : void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const rtl::OUString& sString );
85 : void applyIcons();
86 : rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
87 : rtl::OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
88 0 : SfxObjectShell& GetDocShell() { return mrDocSh; }
89 : bool createMenu( const rtl::OUString& rName, const css::uno::Reference< css::container::XIndexAccess >& xMenuDesc, bool bPersist );
90 : };
91 :
92 0 : class MSFILTER_DLLPUBLIC TBBase
93 : {
94 : friend class Indent;
95 : static int nIndent; // num spaces to indent before printing
96 : protected:
97 : void indent_printf(FILE* fp, const char* format, ... );
98 : sal_uInt32 nOffSet; // usually for debug we can store the offset in the stream to this record
99 : public:
100 112 : TBBase() : nOffSet( 0 ) {}
101 112 : virtual ~TBBase(){}
102 :
103 : virtual bool Read(SvStream &rS) = 0;
104 0 : virtual void Print( FILE* ) {} // #FIXME remove this an implement the debug routines in all the classes below to enable some sort of readable output
105 0 : sal_uInt32 GetOffset() { return nOffSet; }
106 : };
107 :
108 : class Indent
109 : {
110 : public:
111 0 : Indent( bool binit = false )
112 : {
113 0 : if ( binit )
114 0 : init();
115 : else
116 0 : TBBase::nIndent = TBBase::nIndent + 2;
117 0 : }
118 0 : ~Indent() { TBBase::nIndent = TBBase::nIndent - 2; }
119 0 : void init() { TBBase::nIndent = 0; }
120 : };
121 :
122 :
123 0 : class MSFILTER_DLLPUBLIC WString : public TBBase
124 : {
125 : rtl::OUString sString;
126 :
127 : public:
128 0 : WString(){};
129 0 : ~WString(){};
130 : bool Read(SvStream &rS);
131 0 : rtl::OUString getString(){ return sString; }
132 : };
133 :
134 : class MSFILTER_DLLPUBLIC TBCExtraInfo : public TBBase
135 : {
136 : WString wstrHelpFile;
137 : sal_Int32 idHelpContext;
138 : WString wstrTag;
139 : WString wstrOnAction;
140 : WString wstrParam;
141 : sal_Int8 tbcu;
142 : sal_Int8 tbmg;
143 :
144 : TBCExtraInfo(const TBCExtraInfo&);
145 : TBCExtraInfo& operator = ( const TBCExtraInfo&);
146 : public:
147 : TBCExtraInfo();
148 0 : ~TBCExtraInfo(){}
149 : bool Read(SvStream &rS);
150 : void Print( FILE* );
151 : rtl::OUString getOnAction();
152 : };
153 :
154 : class MSFILTER_DLLPUBLIC TBCGeneralInfo : public TBBase
155 : {
156 : sal_uInt8 bFlags;
157 : WString customText;
158 : WString descriptionText;
159 : WString tooltip;
160 : TBCExtraInfo extraInfo;
161 :
162 : public:
163 : TBCGeneralInfo();
164 0 : ~TBCGeneralInfo() {}
165 : bool Read(SvStream &rS);
166 : void Print( FILE* );
167 : bool ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
168 0 : rtl::OUString CustomText() { return customText.getString(); }
169 : rtl::OUString DescriptionText() { return descriptionText.getString(); }
170 : rtl::OUString Tooltip() { return tooltip.getString(); }
171 : };
172 :
173 : class MSFILTER_DLLPUBLIC TBCBitMap : public TBBase
174 : {
175 : friend class TBCBSpecific; // #FIXME hacky access, need to fix
176 : sal_Int32 cbDIB;
177 : Bitmap mBitMap;
178 : public:
179 : TBCBitMap();
180 : ~TBCBitMap();
181 : bool Read(SvStream &rS);
182 : void Print( FILE* );
183 : Bitmap& getBitMap();
184 : };
185 :
186 : class MSFILTER_DLLPUBLIC TBCMenuSpecific : public TBBase
187 : {
188 : sal_Int32 tbid;
189 : boost::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
190 : public:
191 : TBCMenuSpecific();
192 0 : ~TBCMenuSpecific(){}
193 : bool Read(SvStream &rS);
194 : void Print( FILE* );
195 : rtl::OUString Name();
196 : };
197 :
198 : class MSFILTER_DLLPUBLIC TBCCDData : public TBBase
199 : {
200 : sal_Int16 cwstrItems; //Signed integer that specifies the number of items in wstrList. MUST be positive.
201 : std::vector< WString > wstrList; // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
202 : sal_Int16 cwstrMRU; // Signed integer that specifies the number of most recently used string
203 : sal_Int16 iSel ; // Signed integer that specifies the zero-based index of the selected item in the wstrList field. MUST be equal to 0xFFFF (-1) or greater than or equal to 0x0000.
204 : sal_Int16 cLines; // Signed integer that specifies the suggested number of lines that the toolbar control will display at any time when displaying the elements of wstrList of available items.
205 : sal_Int16 dxWidth; // Signed integer that specifies the width in pixels that the interior of the dropdown has. This excludes the width of the toolbar control border and scroll bar.
206 : WString wstrEdit; //Structure of type WString. Editable text for editable area of the ComboBox toolbar control.
207 :
208 : public:
209 : TBCCDData();
210 : ~TBCCDData();
211 : bool Read(SvStream &rS);
212 : void Print( FILE* );
213 : };
214 :
215 0 : class TBCComboDropdownSpecific : public TBBase
216 : {
217 : boost::shared_ptr< TBCCDData > data;
218 : public:
219 : TBCComboDropdownSpecific( const TBCHeader& header );
220 : TBCComboDropdownSpecific(){}
221 : bool Read(SvStream &rS);
222 : void Print( FILE* );
223 : };
224 :
225 : class TBCBSpecific : public TBBase
226 : {
227 : sal_uInt8 bFlags;
228 : boost::shared_ptr< TBCBitMap > icon; // optional
229 : boost::shared_ptr< TBCBitMap > iconMask; // optional
230 : boost::shared_ptr< sal_uInt16 > iBtnFace; // optional
231 : boost::shared_ptr< WString > wstrAcc; // optional
232 :
233 : public:
234 : TBCBSpecific();
235 0 : ~TBCBSpecific(){}
236 : bool Read(SvStream &rS);
237 : void Print( FILE* );
238 : // #TODO just add a getGraphic member here
239 : TBCBitMap* getIcon();
240 : TBCBitMap* getIconMask();
241 0 : sal_uInt16* getBtnFace() { return iBtnFace.get(); }
242 : };
243 :
244 : /* TBCHeader.tct controlSpecificInfo type
245 :
246 : 0x01 (Button control) TBCBSpecific
247 : 0x10 (ExpandingGrid control) TBCBSpecific
248 : 0x0A (Popup control) TBCMenuSpecific
249 : 0x0C (ButtonPopup control) TBCMenuSpecific
250 : 0x0D (SplitButtonPopup control) TBCMenuSpecific
251 : 0x0E (SplitButtonMRUPopup control) TBCMenuSpecific
252 : 0x02 (Edit control) TBCComboDropdow nSpecific
253 : 0x04 (ComboBox control) TBCComboDropdow nSpecific
254 : 0x14 (GraphicCombo control) TBCComboDropdow nSpecific
255 : 0x03 (DropDown control) TBCComboDropdow nSpecific
256 : 0x06 (SplitDropDown control) TBCComboDropdow nSpecific
257 : 0x09 (GraphicDropDown control) TBCComboDropdow nSpecific
258 : 0x07 (OCXDropDown control) controlSpecificInfo MUST NOT exist
259 : 0x0F (Label control) controlSpecificInfo MUST NOT exist
260 : 0x12 (Grid control) controlSpecificInfo MUST NOT exist
261 : 0x13 (Gauge control) controlSpecificInfo MUST NOT exist
262 : 0x16 (ActiveX control) controlSpecificInfo MUST NOT exist
263 :
264 : */
265 0 : class MSFILTER_DLLPUBLIC TBCHeader : public TBBase
266 : {
267 : sal_Int8 bSignature;
268 : sal_Int8 bVersion;
269 : sal_uInt8 bFlagsTCR;
270 : sal_uInt8 tct;
271 : sal_uInt16 tcid;
272 : sal_uInt32 tbct;
273 : sal_uInt8 bPriority;
274 : boost::shared_ptr< sal_uInt16 > width; //optional
275 : boost::shared_ptr< sal_uInt16 > height; //optional
276 :
277 : public:
278 : TBCHeader();
279 : ~TBCHeader();
280 0 : sal_uInt8 getTct() const { return tct; }
281 0 : sal_uInt16 getTcID() const { return tcid; }
282 0 : bool isVisible() { return !( bFlagsTCR & 0x1 ); }
283 0 : bool isBeginGroup() { return ( bFlagsTCR & 0x2 ); }
284 : bool Read(SvStream &rS);
285 : void Print( FILE* );
286 0 : sal_uInt32 getTbct() { return tbct; };
287 : };
288 :
289 : class MSFILTER_DLLPUBLIC TBCData : public TBBase
290 : {
291 : TBCHeader rHeader;
292 : TBCGeneralInfo controlGeneralInfo;
293 : boost::shared_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct
294 : TBCData(const TBCData&);
295 : TBCData& operator = ( const TBCData&);
296 : public:
297 : TBCData( const TBCHeader& Header );
298 0 : ~TBCData(){}
299 : bool Read(SvStream &rS);
300 : void Print( FILE* );
301 : bool ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
302 0 : TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
303 : TBCMenuSpecific* getMenuSpecific();
304 : };
305 :
306 0 : class MSFILTER_DLLPUBLIC TB : public TBBase
307 : {
308 : sal_uInt8 bSignature;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
309 : sal_uInt8 bVersion; // Signed integer that specifies the toolbar version number. MUST be 0x01.
310 : sal_Int16 cCL; // Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
311 : sal_Int32 ltbid;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
312 : sal_uInt32 ltbtr;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
313 : sal_uInt16 cRowsDefault;// Unsigned integer that specifies the number of preferred rows for the toolbar when the toolbar is not docked. MUST be less than or equal to 255.
314 : sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
315 : WString name; //Structure of type WString that specifies the toolbar name
316 : public:
317 : TB();
318 0 : ~TB(){}
319 : bool Read(SvStream &rS);
320 : void Print( FILE* );
321 0 : sal_Int16 getcCL(){ return cCL; }
322 0 : WString& getName(){ return name; }
323 : bool IsEnabled();
324 0 : bool IsMenuToolbar(){ return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
325 : };
326 :
327 0 : class MSFILTER_DLLPUBLIC SRECT : public TBBase
328 : {
329 : public:
330 0 : SRECT() : left(0), top(0), right(0), bottom(0) {}
331 : sal_Int16 left;
332 : sal_Int16 top;
333 : sal_Int16 right;
334 : sal_Int16 bottom;
335 0 : bool Read( SvStream &rS ) { rS >> left >> top >> right >> bottom; return true; }
336 : void Print( FILE* fo );
337 : };
338 :
339 : typedef cppu::WeakImplHelper1< css::container::XIndexContainer > PropertyValueIndexContainer_BASE;
340 :
341 0 : class MSFILTER_DLLPUBLIC TBVisualData : public TBBase
342 : {
343 : sal_Int8 tbds;
344 : sal_Int8 tbv;
345 : sal_Int8 tbdsDock;
346 : sal_Int8 iRow;
347 :
348 : SRECT rcDock;
349 : SRECT rcFloat;
350 :
351 : public:
352 : TBVisualData();
353 0 : ~TBVisualData(){}
354 : bool Read(SvStream &rS);
355 : void Print( FILE* );
356 : };
357 : #endif
358 :
359 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|