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