Bump version to 6.4-15
[LibreOffice.git] / include / filter / msfilter / mstoolbar.hxx
blob284d55fd2ea99b49f4a009f071cbf4eb59173bb7
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 <memory>
13 #include <vector>
15 #include <com/sun/star/uno/Any.hxx>
16 #include <com/sun/star/uno/Reference.hxx>
17 #include <filter/msfilter/msfilterdllapi.h>
18 #include <rtl/ustring.hxx>
19 #include <sal/types.h>
20 #include <tools/stream.hxx>
21 #include <vcl/bitmapex.hxx>
23 namespace com { namespace sun { namespace star {
24 namespace beans { struct PropertyValue; }
25 namespace container { class XIndexAccess; }
26 namespace graphic { class XGraphic; }
27 namespace ui { class XUIConfigurationManager; }
28 namespace ui { class XUIConfigurationManagerSupplier; }
29 } } }
31 class TBCHeader;
33 class MSOCommandConvertor
35 public:
36 virtual ~MSOCommandConvertor() {}
37 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
38 virtual OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
41 class SfxObjectShell;
43 class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
45 struct iconcontrolitem
47 OUString sCommand;
48 css::uno::Reference< css::graphic::XGraphic > image;
50 std::vector< iconcontrolitem > iconcommands;
51 std::unique_ptr< MSOCommandConvertor > pMSOCmdConvertor;
52 css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp;
53 css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
54 SfxObjectShell& mrDocSh;
55 static void ScaleImage( css::uno::Reference< css::graphic::XGraphic >& xGraphic, long nNewSize );
56 public:
57 CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
59 void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
60 css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
61 const css::uno::Reference< css::ui::XUIConfigurationManager >& getAppCfgManager() const { return m_xAppCfgMgr;}
64 static css::uno::Any createCommandFromMacro( const OUString& sCmd );
66 void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const OUString& sString );
67 void applyIcons();
68 OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
69 OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
70 SfxObjectShell& GetDocShell() { return mrDocSh; }
71 bool createMenu( const OUString& rName, const css::uno::Reference< css::container::XIndexAccess >& xMenuDesc );
74 class MSFILTER_DLLPUBLIC TBBase
76 friend class Indent;
77 static int nIndent; // num spaces to indent before printing
78 protected:
79 #ifdef DEBUG_FILTER_MSTOOLBAR
80 static void indent_printf(FILE* fp, const char* format, ... );
81 #endif
82 sal_uInt32 nOffSet; // usually for debug we can store the offset in the stream to this record
83 public:
84 TBBase() : nOffSet( 0 ) {}
85 virtual ~TBBase(){}
87 TBBase(TBBase const &) = default;
88 TBBase(TBBase &&) = default;
89 TBBase & operator =(TBBase const &) = default;
90 TBBase & operator =(TBBase &&) = default;
92 virtual bool Read(SvStream &rS) = 0;
93 #ifdef DEBUG_FILTER_MSTOOLBAR
94 virtual void Print( FILE* ) {} // #FIXME remove this an implement the debug routines in all the classes below to enable some sort of readable output
95 #endif
96 sal_uInt32 GetOffset() const { return nOffSet; }
99 class Indent
101 public:
102 Indent( bool binit )
104 if ( binit )
105 TBBase::nIndent = 0;
106 else
107 TBBase::nIndent = TBBase::nIndent + 2;
109 ~Indent() { TBBase::nIndent = TBBase::nIndent - 2; }
113 class MSFILTER_DLLPUBLIC WString final : public TBBase
115 OUString sString;
117 public:
118 WString(){};
119 bool Read(SvStream &rS) override;
120 const OUString& getString() const { return sString; }
123 class MSFILTER_DLLPUBLIC TBCExtraInfo final : public TBBase
125 WString wstrHelpFile;
126 sal_Int32 idHelpContext;
127 WString wstrTag;
128 WString wstrOnAction;
129 WString wstrParam;
130 sal_Int8 tbcu;
131 sal_Int8 tbmg;
133 TBCExtraInfo(const TBCExtraInfo&) = delete;
134 TBCExtraInfo& operator = ( const TBCExtraInfo&) = delete;
135 public:
136 TBCExtraInfo();
137 bool Read(SvStream &rS) override;
138 #ifdef DEBUG_FILTER_MSTOOLBAR
139 virtual void Print( FILE* ) override;
140 #endif
141 OUString const & getOnAction() const;
144 class MSFILTER_DLLPUBLIC TBCGeneralInfo final : public TBBase
146 sal_uInt8 bFlags;
147 WString customText;
148 WString descriptionText;
149 WString tooltip;
150 TBCExtraInfo extraInfo;
152 public:
153 TBCGeneralInfo();
154 bool Read(SvStream &rS) override;
155 void ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
156 OUString const & CustomText() { return customText.getString(); }
159 class MSFILTER_DLLPUBLIC TBCBitMap final : public TBBase
161 friend class TBCBSpecific; // #FIXME hacky access, need to fix
162 sal_Int32 cbDIB;
163 BitmapEx mBitMap;
164 public:
165 TBCBitMap();
166 virtual ~TBCBitMap() override;
167 bool Read(SvStream &rS) override;
168 #ifdef DEBUG_FILTER_MSTOOLBAR
169 virtual void Print( FILE* ) override;
170 #endif
171 // #FIXME Const-ness
172 BitmapEx& getBitMap() { return mBitMap;}
175 class MSFILTER_DLLPUBLIC TBCMenuSpecific final : public TBBase
177 sal_Int32 tbid;
178 std::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
179 public:
180 TBCMenuSpecific();
181 bool Read(SvStream &rS) override;
182 OUString Name();
185 class MSFILTER_DLLPUBLIC TBCCDData final : public TBBase
187 sal_Int16 cwstrItems; //Signed integer that specifies the number of items in wstrList. MUST be positive.
188 std::vector< WString > wstrList; // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
189 sal_Int16 cwstrMRU; // Signed integer that specifies the number of most recently used string
190 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.
191 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.
192 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.
193 WString wstrEdit; //Structure of type WString. Editable text for editable area of the ComboBox toolbar control.
195 public:
196 TBCCDData();
197 virtual ~TBCCDData() override;
198 bool Read(SvStream &rS) override;
201 class TBCComboDropdownSpecific final : public TBBase
203 std::shared_ptr< TBCCDData > data;
204 public:
205 TBCComboDropdownSpecific( const TBCHeader& header );
206 bool Read(SvStream &rS) override;
209 class TBCBSpecific : public TBBase
211 sal_uInt8 bFlags;
212 std::shared_ptr< TBCBitMap > icon; // optional
213 std::shared_ptr< TBCBitMap > iconMask; // optional
214 std::shared_ptr< sal_uInt16 > iBtnFace; // optional
215 std::shared_ptr< WString > wstrAcc; // optional
217 public:
218 TBCBSpecific();
219 bool Read(SvStream &rS) override;
220 // #TODO just add a getGraphic member here
221 TBCBitMap* getIcon();
222 TBCBitMap* getIconMask();
223 sal_uInt16* getBtnFace() { return iBtnFace.get(); }
226 /* TBCHeader.tct controlSpecificInfo type
228 0x01 (Button control) TBCBSpecific
229 0x10 (ExpandingGrid control) TBCBSpecific
230 0x0A (Popup control) TBCMenuSpecific
231 0x0C (ButtonPopup control) TBCMenuSpecific
232 0x0D (SplitButtonPopup control) TBCMenuSpecific
233 0x0E (SplitButtonMRUPopup control) TBCMenuSpecific
234 0x02 (Edit control) TBCComboDropdow nSpecific
235 0x04 (ComboBox control) TBCComboDropdow nSpecific
236 0x14 (GraphicCombo control) TBCComboDropdow nSpecific
237 0x03 (DropDown control) TBCComboDropdow nSpecific
238 0x06 (SplitDropDown control) TBCComboDropdow nSpecific
239 0x09 (GraphicDropDown control) TBCComboDropdow nSpecific
240 0x07 (OCXDropDown control) controlSpecificInfo MUST NOT exist
241 0x0F (Label control) controlSpecificInfo MUST NOT exist
242 0x12 (Grid control) controlSpecificInfo MUST NOT exist
243 0x13 (Gauge control) controlSpecificInfo MUST NOT exist
244 0x16 (ActiveX control) controlSpecificInfo MUST NOT exist
247 class MSFILTER_DLLPUBLIC TBCHeader : public TBBase
249 sal_Int8 bSignature;
250 sal_Int8 bVersion;
251 sal_uInt8 bFlagsTCR;
252 sal_uInt8 tct;
253 sal_uInt16 tcid;
254 sal_uInt32 tbct;
255 sal_uInt8 bPriority;
256 std::shared_ptr< sal_uInt16 > width; //optional
257 std::shared_ptr< sal_uInt16 > height; //optional
259 public:
260 TBCHeader();
261 virtual ~TBCHeader() override;
263 TBCHeader(TBCHeader const &) = default;
264 TBCHeader(TBCHeader &&) = default;
265 TBCHeader & operator =(TBCHeader const &) = default;
266 TBCHeader & operator =(TBCHeader &&) = default;
268 sal_uInt8 getTct() const { return tct; }
269 sal_uInt16 getTcID() const { return tcid; }
270 bool isVisible() const { return !( bFlagsTCR & 0x1 ); }
271 bool isBeginGroup() const { return ( bFlagsTCR & 0x2 ) != 0; }
272 bool Read(SvStream &rS) override;
273 #ifdef DEBUG_FILTER_MSTOOLBAR
274 virtual void Print( FILE* ) override;
275 #endif
276 sal_uInt32 getTbct() const { return tbct; };
279 class MSFILTER_DLLPUBLIC TBCData final : public TBBase
281 TBCHeader rHeader;
282 TBCGeneralInfo controlGeneralInfo;
283 std::shared_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct
284 TBCData(const TBCData&) = delete;
285 TBCData& operator = ( const TBCData&) = delete;
286 public:
287 TBCData( const TBCHeader& Header );
288 bool Read(SvStream &rS) override;
289 #ifdef DEBUG_FILTER_MSTOOLBAR
290 virtual void Print( FILE* ) override;
291 #endif
292 void ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
293 TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
294 TBCMenuSpecific* getMenuSpecific();
297 class MSFILTER_DLLPUBLIC TB final : public TBBase
299 sal_uInt8 bSignature;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
300 sal_uInt8 bVersion; // Signed integer that specifies the toolbar version number. MUST be 0x01.
301 sal_Int16 cCL; // Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
302 sal_Int32 ltbid;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
303 sal_uInt32 ltbtr;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
304 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.
305 sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
306 WString name; //Structure of type WString that specifies the toolbar name
307 public:
308 TB();
309 bool Read(SvStream &rS) override;
310 #ifdef DEBUG_FILTER_MSTOOLBAR
311 virtual void Print( FILE* ) override;
312 #endif
313 sal_Int16 getcCL() const { return cCL; }
314 WString& getName(){ return name; }
315 bool IsEnabled() const;
316 bool IsMenuToolbar() const { return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
319 class MSFILTER_DLLPUBLIC SRECT final : public TBBase
321 public:
322 SRECT() : left(0), top(0), right(0), bottom(0) {}
323 sal_Int16 left;
324 sal_Int16 top;
325 sal_Int16 right;
326 sal_Int16 bottom;
327 bool Read( SvStream &rS ) override { rS.ReadInt16( left ).ReadInt16( top ).ReadInt16( right ).ReadInt16( bottom ); return true; }
328 #ifdef DEBUG_FILTER_MSTOOLBAR
329 virtual void Print( FILE* fo ) override;
330 #endif
334 class MSFILTER_DLLPUBLIC TBVisualData final : public TBBase
336 sal_Int8 tbds;
337 sal_Int8 tbv;
338 sal_Int8 tbdsDock;
339 sal_Int8 iRow;
341 SRECT rcDock;
342 SRECT rcFloat;
344 public:
345 TBVisualData();
346 bool Read(SvStream &rS) override;
347 #ifdef DEBUG_FILTER_MSTOOLBAR
348 virtual void Print( FILE* ) override;
349 #endif
352 #endif
354 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */