bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / filter / msfilter / mstoolbar.hxx
blobd29ea04a00238d028a752a9d97382ef4e86bfc4f
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
12 #include <cstdio>
13 #include <memory>
14 #include <vector>
16 #include <com/sun/star/uno/Any.hxx>
17 #include <com/sun/star/uno/Reference.hxx>
18 #include <filter/msfilter/msfilterdllapi.h>
19 #include <rtl/ustring.hxx>
20 #include <sal/types.h>
21 #include <tools/stream.hxx>
22 #include <vcl/bitmapex.hxx>
24 namespace com { namespace sun { namespace star {
25 namespace beans { struct PropertyValue; }
26 namespace container { class XIndexAccess; }
27 namespace graphic { class XGraphic; }
28 namespace ui { class XUIConfigurationManager; }
29 namespace ui { class XUIConfigurationManagerSupplier; }
30 } } }
32 class TBCHeader;
34 class MSOCommandConvertor
36 public:
37 virtual ~MSOCommandConvertor() {}
38 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
39 virtual OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
42 class SfxObjectShell;
44 class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
46 struct iconcontrolitem
48 OUString sCommand;
49 css::uno::Reference< css::graphic::XGraphic > image;
51 std::vector< iconcontrolitem > iconcommands;
52 std::unique_ptr< MSOCommandConvertor > pMSOCmdConvertor;
53 css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp;
54 css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
55 SfxObjectShell& mrDocSh;
56 static void ScaleImage( css::uno::Reference< css::graphic::XGraphic >& xGraphic, long nNewSize );
57 public:
58 CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
60 void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
61 css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
62 const css::uno::Reference< css::ui::XUIConfigurationManager >& getAppCfgManager() { return m_xAppCfgMgr;}
65 static css::uno::Any createCommandFromMacro( const OUString& sCmd );
67 void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const OUString& sString );
68 void applyIcons();
69 OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
70 OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
71 SfxObjectShell& GetDocShell() { return mrDocSh; }
72 bool createMenu( const OUString& rName, const css::uno::Reference< css::container::XIndexAccess >& xMenuDesc );
75 class MSFILTER_DLLPUBLIC TBBase
77 friend class Indent;
78 static int nIndent; // num spaces to indent before printing
79 protected:
80 #ifdef DEBUG_FILTER_MSTOOLBAR
81 static void indent_printf(FILE* fp, const char* format, ... );
82 #endif
83 sal_uInt32 nOffSet; // usually for debug we can store the offset in the stream to this record
84 public:
85 TBBase() : nOffSet( 0 ) {}
86 virtual ~TBBase(){}
88 TBBase(TBBase const &) = default;
89 TBBase(TBBase &&) = default;
90 TBBase & operator =(TBBase const &) = default;
91 TBBase & operator =(TBBase &&) = default;
93 virtual bool Read(SvStream &rS) = 0;
94 #ifdef DEBUG_FILTER_MSTOOLBAR
95 virtual void Print( FILE* ) {} // #FIXME remove this an implement the debug routines in all the classes below to enable some sort of readable output
96 #endif
97 sal_uInt32 GetOffset() { return nOffSet; }
100 class Indent
102 public:
103 Indent( bool binit )
105 if ( binit )
106 TBBase::nIndent = 0;
107 else
108 TBBase::nIndent = TBBase::nIndent + 2;
110 ~Indent() { TBBase::nIndent = TBBase::nIndent - 2; }
114 class MSFILTER_DLLPUBLIC WString : public TBBase
116 OUString sString;
118 public:
119 WString(){};
120 bool Read(SvStream &rS) override;
121 const OUString& getString(){ return sString; }
124 class MSFILTER_DLLPUBLIC TBCExtraInfo : public TBBase
126 WString wstrHelpFile;
127 sal_Int32 idHelpContext;
128 WString wstrTag;
129 WString wstrOnAction;
130 WString wstrParam;
131 sal_Int8 tbcu;
132 sal_Int8 tbmg;
134 TBCExtraInfo(const TBCExtraInfo&) = delete;
135 TBCExtraInfo& operator = ( const TBCExtraInfo&) = delete;
136 public:
137 TBCExtraInfo();
138 bool Read(SvStream &rS) override;
139 #ifdef DEBUG_FILTER_MSTOOLBAR
140 virtual void Print( FILE* ) override;
141 #endif
142 OUString const & getOnAction();
145 class MSFILTER_DLLPUBLIC TBCGeneralInfo : public TBBase
147 sal_uInt8 bFlags;
148 WString customText;
149 WString descriptionText;
150 WString tooltip;
151 TBCExtraInfo extraInfo;
153 public:
154 TBCGeneralInfo();
155 bool Read(SvStream &rS) override;
156 void ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
157 OUString const & CustomText() { return customText.getString(); }
160 class MSFILTER_DLLPUBLIC TBCBitMap : public TBBase
162 friend class TBCBSpecific; // #FIXME hacky access, need to fix
163 sal_Int32 cbDIB;
164 BitmapEx mBitMap;
165 public:
166 TBCBitMap();
167 virtual ~TBCBitMap() override;
168 bool Read(SvStream &rS) override;
169 #ifdef DEBUG_FILTER_MSTOOLBAR
170 virtual void Print( FILE* ) override;
171 #endif
172 // #FIXME Const-ness
173 BitmapEx& getBitMap() { return mBitMap;}
176 class MSFILTER_DLLPUBLIC TBCMenuSpecific : public TBBase
178 sal_Int32 tbid;
179 std::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
180 public:
181 TBCMenuSpecific();
182 bool Read(SvStream &rS) override;
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() override;
199 bool Read(SvStream &rS) override;
202 class TBCComboDropdownSpecific : public TBBase
204 std::shared_ptr< TBCCDData > data;
205 public:
206 TBCComboDropdownSpecific( const TBCHeader& header );
207 bool Read(SvStream &rS) override;
210 class TBCBSpecific : public TBBase
212 sal_uInt8 bFlags;
213 std::shared_ptr< TBCBitMap > icon; // optional
214 std::shared_ptr< TBCBitMap > iconMask; // optional
215 std::shared_ptr< sal_uInt16 > iBtnFace; // optional
216 std::shared_ptr< WString > wstrAcc; // optional
218 public:
219 TBCBSpecific();
220 bool Read(SvStream &rS) override;
221 // #TODO just add a getGraphic member here
222 TBCBitMap* getIcon();
223 TBCBitMap* getIconMask();
224 sal_uInt16* getBtnFace() { return iBtnFace.get(); }
227 /* TBCHeader.tct controlSpecificInfo type
229 0x01 (Button control) TBCBSpecific
230 0x10 (ExpandingGrid control) TBCBSpecific
231 0x0A (Popup control) TBCMenuSpecific
232 0x0C (ButtonPopup control) TBCMenuSpecific
233 0x0D (SplitButtonPopup control) TBCMenuSpecific
234 0x0E (SplitButtonMRUPopup control) TBCMenuSpecific
235 0x02 (Edit control) TBCComboDropdow nSpecific
236 0x04 (ComboBox control) TBCComboDropdow nSpecific
237 0x14 (GraphicCombo control) TBCComboDropdow nSpecific
238 0x03 (DropDown control) TBCComboDropdow nSpecific
239 0x06 (SplitDropDown control) TBCComboDropdow nSpecific
240 0x09 (GraphicDropDown control) TBCComboDropdow nSpecific
241 0x07 (OCXDropDown control) controlSpecificInfo MUST NOT exist
242 0x0F (Label control) controlSpecificInfo MUST NOT exist
243 0x12 (Grid control) controlSpecificInfo MUST NOT exist
244 0x13 (Gauge control) controlSpecificInfo MUST NOT exist
245 0x16 (ActiveX control) controlSpecificInfo MUST NOT exist
248 class MSFILTER_DLLPUBLIC TBCHeader : public TBBase
250 sal_Int8 bSignature;
251 sal_Int8 bVersion;
252 sal_uInt8 bFlagsTCR;
253 sal_uInt8 tct;
254 sal_uInt16 tcid;
255 sal_uInt32 tbct;
256 sal_uInt8 bPriority;
257 std::shared_ptr< sal_uInt16 > width; //optional
258 std::shared_ptr< sal_uInt16 > height; //optional
260 public:
261 TBCHeader();
262 virtual ~TBCHeader() override;
264 TBCHeader(TBCHeader const &) = default;
265 TBCHeader(TBCHeader &&) = default;
266 TBCHeader & operator =(TBCHeader const &) = default;
267 TBCHeader & operator =(TBCHeader &&) = default;
269 sal_uInt8 getTct() const { return tct; }
270 sal_uInt16 getTcID() const { return tcid; }
271 bool isVisible() { return !( bFlagsTCR & 0x1 ); }
272 bool isBeginGroup() { return ( bFlagsTCR & 0x2 ) != 0; }
273 bool Read(SvStream &rS) override;
274 #ifdef DEBUG_FILTER_MSTOOLBAR
275 virtual void Print( FILE* ) override;
276 #endif
277 sal_uInt32 getTbct() { return tbct; };
280 class MSFILTER_DLLPUBLIC TBCData : public TBBase
282 TBCHeader rHeader;
283 TBCGeneralInfo controlGeneralInfo;
284 std::shared_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct
285 TBCData(const TBCData&) = delete;
286 TBCData& operator = ( const TBCData&) = delete;
287 public:
288 TBCData( const TBCHeader& Header );
289 bool Read(SvStream &rS) override;
290 #ifdef DEBUG_FILTER_MSTOOLBAR
291 virtual void Print( FILE* ) override;
292 #endif
293 void ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
294 TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
295 TBCMenuSpecific* getMenuSpecific();
298 class MSFILTER_DLLPUBLIC TB : public TBBase
300 sal_uInt8 bSignature;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
301 sal_uInt8 bVersion; // Signed integer that specifies the toolbar version number. MUST be 0x01.
302 sal_Int16 cCL; // Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
303 sal_Int32 ltbid;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
304 sal_uInt32 ltbtr;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
305 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.
306 sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
307 WString name; //Structure of type WString that specifies the toolbar name
308 public:
309 TB();
310 bool Read(SvStream &rS) override;
311 #ifdef DEBUG_FILTER_MSTOOLBAR
312 virtual void Print( FILE* ) override;
313 #endif
314 sal_Int16 getcCL(){ return cCL; }
315 WString& getName(){ return name; }
316 bool IsEnabled();
317 bool IsMenuToolbar(){ return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
320 class MSFILTER_DLLPUBLIC SRECT : public TBBase
322 public:
323 SRECT() : left(0), top(0), right(0), bottom(0) {}
324 sal_Int16 left;
325 sal_Int16 top;
326 sal_Int16 right;
327 sal_Int16 bottom;
328 bool Read( SvStream &rS ) override { rS.ReadInt16( left ).ReadInt16( top ).ReadInt16( right ).ReadInt16( bottom ); return true; }
329 #ifdef DEBUG_FILTER_MSTOOLBAR
330 virtual void Print( FILE* fo ) override;
331 #endif
335 class MSFILTER_DLLPUBLIC TBVisualData : public TBBase
337 sal_Int8 tbds;
338 sal_Int8 tbv;
339 sal_Int8 tbdsDock;
340 sal_Int8 iRow;
342 SRECT rcDock;
343 SRECT rcFloat;
345 public:
346 TBVisualData();
347 bool Read(SvStream &rS) override;
348 #ifdef DEBUG_FILTER_MSTOOLBAR
349 virtual void Print( FILE* ) override;
350 #endif
353 #endif
355 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */