LibreOffice Module filter (master) 1
mstoolbar.hxx
Go to the documentation of this file.
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
12#include <memory>
13#include <string_view>
14#include <vector>
15
16#include <com/sun/star/uno/Any.hxx>
17#include <com/sun/star/uno/Reference.hxx>
19#include <rtl/ustring.hxx>
20#include <sal/types.h>
21#include <tools/stream.hxx>
22#include <vcl/bitmapex.hxx>
23
24namespace com::sun::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}
31
32class TBCHeader;
33
35{
36public:
38 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
39 virtual OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
40};
41
42class SfxObjectShell;
43
45{
47 {
48 OUString sCommand;
49 css::uno::Reference< css::graphic::XGraphic > image;
50 };
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;
56 static void ScaleImage( css::uno::Reference< css::graphic::XGraphic >& xGraphic, tools::Long nNewSize );
57public:
58 CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
59
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() const { return m_xAppCfgMgr;}
63
64
65 static css::uno::Any createCommandFromMacro( std::u16string_view sCmd );
66
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 );
73};
74
76{
77friend class Indent;
78 static int nIndent; // num spaces to indent before printing
79protected:
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
84public:
85 TBBase() : nOffSet( 0 ) {}
86 virtual ~TBBase(){}
87
88 TBBase(TBBase const &) = default;
89 TBBase(TBBase &&) = default;
90 TBBase & operator =(TBBase const &) = default;
91 TBBase & operator =(TBBase &&) = default;
92
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() const { return nOffSet; }
98};
99
101{
102public:
103 Indent( bool binit )
104 {
105 if ( binit )
106 TBBase::nIndent = 0;
107 else
109 }
111};
112
113
115{
116 OUString sString;
117
118public:
120 bool Read(SvStream &rS) override;
121 const OUString& getString() const { return sString; }
122};
123
125{
127 sal_Int32 idHelpContext;
133
134 TBCExtraInfo(const TBCExtraInfo&) = delete;
135 TBCExtraInfo& operator = ( const TBCExtraInfo&) = delete;
136public:
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() const;
143};
144
146{
152
153public:
155 bool Read(SvStream &rS) override;
156 void ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
157 OUString const & CustomText() { return customText.getString(); }
158};
159
160class TBCBitMap final : public TBBase
161{
162friend class TBCBSpecific; // #FIXME hacky access, need to fix
163 sal_Int32 cbDIB;
165public:
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
174};
175
177{
178 sal_Int32 tbid;
179 std::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
180public:
182 bool Read(SvStream &rS) override;
183 OUString Name();
184};
185
186class TBCCDData final : public TBBase
187{
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.
195
196public:
197 TBCCDData();
198 virtual ~TBCCDData() override;
199 bool Read(SvStream &rS) override;
200};
201
203{
204 std::shared_ptr< TBCCDData > data;
205public:
206 TBCComboDropdownSpecific( const TBCHeader& header );
207 bool Read(SvStream &rS) override;
208};
209
210class TBCBSpecific final : public TBBase
211{
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
217
218public:
219 TBCBSpecific();
220 bool Read(SvStream &rS) override;
221 // #TODO just add a getGraphic member here
224 sal_uInt16* getBtnFace() { return iBtnFace.get(); }
225};
226
227/* TBCHeader.tct controlSpecificInfo type
228
2290x01 (Button control) TBCBSpecific
2300x10 (ExpandingGrid control) TBCBSpecific
2310x0A (Popup control) TBCMenuSpecific
2320x0C (ButtonPopup control) TBCMenuSpecific
2330x0D (SplitButtonPopup control) TBCMenuSpecific
2340x0E (SplitButtonMRUPopup control) TBCMenuSpecific
2350x02 (Edit control) TBCComboDropdow nSpecific
2360x04 (ComboBox control) TBCComboDropdow nSpecific
2370x14 (GraphicCombo control) TBCComboDropdow nSpecific
2380x03 (DropDown control) TBCComboDropdow nSpecific
2390x06 (SplitDropDown control) TBCComboDropdow nSpecific
2400x09 (GraphicDropDown control) TBCComboDropdow nSpecific
2410x07 (OCXDropDown control) controlSpecificInfo MUST NOT exist
2420x0F (Label control) controlSpecificInfo MUST NOT exist
2430x12 (Grid control) controlSpecificInfo MUST NOT exist
2440x13 (Gauge control) controlSpecificInfo MUST NOT exist
2450x16 (ActiveX control) controlSpecificInfo MUST NOT exist
246
247*/
249{
254 sal_uInt16 tcid;
255 sal_uInt32 tbct;
257 std::shared_ptr< sal_uInt16 > width; //optional
258 std::shared_ptr< sal_uInt16 > height; //optional
259
260public:
261 TBCHeader();
262 virtual ~TBCHeader() override;
263
264 TBCHeader(TBCHeader const &) = default;
265 TBCHeader(TBCHeader &&) = default;
266 TBCHeader & operator =(TBCHeader const &) = default;
267 TBCHeader & operator =(TBCHeader &&) = default;
268
269 sal_uInt8 getTct() const { return tct; }
270 sal_uInt16 getTcID() const { return tcid; }
271 bool isVisible() const { return !( bFlagsTCR & 0x1 ); }
272 bool isBeginGroup() const { 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() const { return tbct; };
278};
279
281{
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;
287public:
288 TBCData( 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();
296};
297
298class MSFILTER_DLLPUBLIC TB final : public TBBase
299{
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
308public:
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() const { return cCL; }
315 WString& getName(){ return name; }
316 bool IsEnabled() const;
317 bool IsMenuToolbar() const { return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
318};
319
320class MSFILTER_DLLPUBLIC SRECT final : public TBBase
321{
322public:
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
332};
333
334
336{
341
344
345public:
346 TBVisualData();
347 bool Read(SvStream &rS) override;
348#ifdef DEBUG_FILTER_MSTOOLBAR
349 virtual void Print( FILE* ) override;
350#endif
351};
352
353#endif
354
355/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp
Definition: mstoolbar.hxx:53
SfxObjectShell & mrDocSh
Definition: mstoolbar.hxx:55
std::vector< iconcontrolitem > iconcommands
Definition: mstoolbar.hxx:51
const css::uno::Reference< css::ui::XUIConfigurationManager > & getAppCfgManager() const
Definition: mstoolbar.hxx:62
css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr
Definition: mstoolbar.hxx:54
SfxObjectShell & GetDocShell()
Definition: mstoolbar.hxx:71
std::unique_ptr< MSOCommandConvertor > pMSOCmdConvertor
Definition: mstoolbar.hxx:52
void setMSOCommandMap(MSOCommandConvertor *pCnvtr)
Definition: mstoolbar.hxx:60
Indent(bool binit)
Definition: mstoolbar.hxx:103
virtual ~MSOCommandConvertor()
Definition: mstoolbar.hxx:37
virtual OUString MSOCommandToOOCommand(sal_Int16 msoCmd)=0
virtual OUString MSOTCIDToOOCommand(sal_Int16 msoTCID)=0
sal_Int16 right
Definition: mstoolbar.hxx:326
sal_Int16 bottom
Definition: mstoolbar.hxx:327
sal_Int16 left
Definition: mstoolbar.hxx:324
sal_Int16 top
Definition: mstoolbar.hxx:325
bool Read(SvStream &rS) override
Definition: mstoolbar.hxx:328
SvStream & ReadInt16(sal_Int16 &rInt16)
virtual ~TBBase()
Definition: mstoolbar.hxx:86
TBBase()
Definition: mstoolbar.hxx:85
virtual bool Read(SvStream &rS)=0
sal_uInt32 GetOffset() const
Definition: mstoolbar.hxx:97
sal_uInt32 nOffSet
Definition: mstoolbar.hxx:83
static int nIndent
Definition: mstoolbar.hxx:78
TBBase(TBBase &&)=default
TBBase(TBBase const &)=default
std::shared_ptr< TBCBitMap > icon
Definition: mstoolbar.hxx:213
std::shared_ptr< TBCBitMap > iconMask
Definition: mstoolbar.hxx:214
TBCBitMap * getIcon()
Definition: mstoolbar.cxx:626
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:562
sal_uInt8 bFlags
Definition: mstoolbar.hxx:212
std::shared_ptr< sal_uInt16 > iBtnFace
Definition: mstoolbar.hxx:215
TBCBitMap * getIconMask()
Definition: mstoolbar.cxx:632
std::shared_ptr< WString > wstrAcc
Definition: mstoolbar.hxx:216
sal_uInt16 * getBtnFace()
Definition: mstoolbar.hxx:224
BitmapEx mBitMap
Definition: mstoolbar.hxx:164
BitmapEx & getBitMap()
Definition: mstoolbar.hxx:173
virtual ~TBCBitMap() override
Definition: mstoolbar.cxx:722
sal_Int32 cbDIB
Definition: mstoolbar.hxx:163
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:726
WString wstrEdit
Definition: mstoolbar.hxx:194
virtual ~TBCCDData() override
Definition: mstoolbar.cxx:672
sal_Int16 cwstrMRU
Definition: mstoolbar.hxx:190
sal_Int16 cLines
Definition: mstoolbar.hxx:192
sal_Int16 dxWidth
Definition: mstoolbar.hxx:193
sal_Int16 cwstrItems
Definition: mstoolbar.hxx:188
sal_Int16 iSel
Definition: mstoolbar.hxx:191
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:676
std::vector< WString > wstrList
Definition: mstoolbar.hxx:189
std::shared_ptr< TBCCDData > data
Definition: mstoolbar.hxx:204
TBCComboDropdownSpecific(const TBCHeader &header)
Definition: mstoolbar.cxx:637
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:643
TBCGeneralInfo & getGeneralInfo()
Definition: mstoolbar.hxx:294
TBCGeneralInfo controlGeneralInfo
Definition: mstoolbar.hxx:283
TBCData(const TBCData &)=delete
TBCHeader rHeader
Definition: mstoolbar.hxx:282
std::shared_ptr< TBBase > controlSpecificInfo
Definition: mstoolbar.hxx:284
TBCExtraInfo(const TBCExtraInfo &)=delete
sal_Int8 tbmg
Definition: mstoolbar.hxx:132
sal_Int32 idHelpContext
Definition: mstoolbar.hxx:127
WString wstrHelpFile
Definition: mstoolbar.hxx:126
sal_Int8 tbcu
Definition: mstoolbar.hxx:131
WString wstrTag
Definition: mstoolbar.hxx:128
WString wstrOnAction
Definition: mstoolbar.hxx:129
WString wstrParam
Definition: mstoolbar.hxx:130
TBCExtraInfo extraInfo
Definition: mstoolbar.hxx:151
OUString const & CustomText()
Definition: mstoolbar.hxx:157
WString tooltip
Definition: mstoolbar.hxx:150
WString descriptionText
Definition: mstoolbar.hxx:149
WString customText
Definition: mstoolbar.hxx:148
sal_uInt8 bFlags
Definition: mstoolbar.hxx:147
sal_uInt8 tct
Definition: mstoolbar.hxx:253
sal_uInt8 bFlagsTCR
Definition: mstoolbar.hxx:252
TBCHeader(TBCHeader const &)=default
sal_uInt16 getTcID() const
Definition: mstoolbar.hxx:270
sal_uInt8 getTct() const
Definition: mstoolbar.hxx:269
bool isVisible() const
Definition: mstoolbar.hxx:271
sal_uInt8 bPriority
Definition: mstoolbar.hxx:256
TBCHeader(TBCHeader &&)=default
std::shared_ptr< sal_uInt16 > width
Definition: mstoolbar.hxx:257
sal_uInt32 getTbct() const
Definition: mstoolbar.hxx:277
std::shared_ptr< sal_uInt16 > height
Definition: mstoolbar.hxx:258
sal_Int8 bVersion
Definition: mstoolbar.hxx:251
sal_uInt16 tcid
Definition: mstoolbar.hxx:254
sal_uInt32 tbct
Definition: mstoolbar.hxx:255
bool isBeginGroup() const
Definition: mstoolbar.hxx:272
sal_Int8 bSignature
Definition: mstoolbar.hxx:250
sal_Int32 tbid
Definition: mstoolbar.hxx:178
std::shared_ptr< WString > name
Definition: mstoolbar.hxx:179
sal_Int8 tbdsDock
Definition: mstoolbar.hxx:339
sal_Int8 iRow
Definition: mstoolbar.hxx:340
sal_Int8 tbds
Definition: mstoolbar.hxx:337
sal_Int8 tbv
Definition: mstoolbar.hxx:338
sal_uInt8 bSignature
Definition: mstoolbar.hxx:300
sal_uInt16 bFlags
Definition: mstoolbar.hxx:306
sal_Int32 ltbid
Definition: mstoolbar.hxx:303
sal_uInt16 cRowsDefault
Definition: mstoolbar.hxx:305
sal_Int16 getcCL() const
Definition: mstoolbar.hxx:314
bool IsMenuToolbar() const
Definition: mstoolbar.hxx:317
sal_uInt32 ltbtr
Definition: mstoolbar.hxx:304
sal_Int16 cCL
Definition: mstoolbar.hxx:302
sal_uInt8 bVersion
Definition: mstoolbar.hxx:301
WString name
Definition: mstoolbar.hxx:307
WString & getName()
Definition: mstoolbar.hxx:315
const OUString & getString() const
Definition: mstoolbar.hxx:121
OUString sString
Definition: mstoolbar.hxx:116
OString right
OString top
OString bottom
const char * name
#define MSFILTER_DLLPUBLIC
def Print(s)
Shape IDs per cluster in DGG atom.
long Long
css::uno::Reference< css::graphic::XGraphic > image
Definition: mstoolbar.hxx:49
OUString Name
unsigned char sal_uInt8
signed char sal_Int8
sal_uInt64 left