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