1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 #ifndef INCLUDED_FILTER_MSFILTER_MSTOOLBAR_HXX
10 #define INCLUDED_FILTER_MSFILTER_MSTOOLBAR_HXX
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
; }
34 class MSOCommandConvertor
37 virtual ~MSOCommandConvertor() {}
38 virtual OUString
MSOCommandToOOCommand( sal_Int16 msoCmd
) = 0;
39 virtual OUString
MSOTCIDToOOCommand( sal_Int16 msoTCID
) = 0;
44 class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
46 struct iconcontrolitem
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
);
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
);
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
78 static int nIndent
; // num spaces to indent before printing
80 #ifdef DEBUG_FILTER_MSTOOLBAR
81 static void indent_printf(FILE* fp
, const char* format
, ... );
83 sal_uInt32 nOffSet
; // usually for debug we can store the offset in the stream to this record
85 TBBase() : nOffSet( 0 ) {}
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
97 sal_uInt32
GetOffset() { return nOffSet
; }
108 TBBase::nIndent
= TBBase::nIndent
+ 2;
110 ~Indent() { TBBase::nIndent
= TBBase::nIndent
- 2; }
114 class MSFILTER_DLLPUBLIC WString
: public TBBase
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
;
129 WString wstrOnAction
;
134 TBCExtraInfo(const TBCExtraInfo
&) = delete;
135 TBCExtraInfo
& operator = ( const TBCExtraInfo
&) = delete;
138 bool Read(SvStream
&rS
) override
;
139 #ifdef DEBUG_FILTER_MSTOOLBAR
140 virtual void Print( FILE* ) override
;
142 OUString
const & getOnAction();
145 class MSFILTER_DLLPUBLIC TBCGeneralInfo
: public TBBase
149 WString descriptionText
;
151 TBCExtraInfo extraInfo
;
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
167 virtual ~TBCBitMap() override
;
168 bool Read(SvStream
&rS
) override
;
169 #ifdef DEBUG_FILTER_MSTOOLBAR
170 virtual void Print( FILE* ) override
;
173 BitmapEx
& getBitMap() { return mBitMap
;}
176 class MSFILTER_DLLPUBLIC TBCMenuSpecific
: public TBBase
179 std::shared_ptr
< WString
> name
; //exist only if tbid equals 0x00000001
182 bool Read(SvStream
&rS
) override
;
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.
198 virtual ~TBCCDData() override
;
199 bool Read(SvStream
&rS
) override
;
202 class TBCComboDropdownSpecific
: public TBBase
204 std::shared_ptr
< TBCCDData
> data
;
206 TBCComboDropdownSpecific( const TBCHeader
& header
);
207 bool Read(SvStream
&rS
) override
;
210 class TBCBSpecific
: public TBBase
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
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
257 std::shared_ptr
< sal_uInt16
> width
; //optional
258 std::shared_ptr
< sal_uInt16
> height
; //optional
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
;
277 sal_uInt32
getTbct() { return tbct
; };
280 class MSFILTER_DLLPUBLIC TBCData
: public TBBase
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;
288 TBCData( const TBCHeader
& Header
);
289 bool Read(SvStream
&rS
) override
;
290 #ifdef DEBUG_FILTER_MSTOOLBAR
291 virtual void Print( FILE* ) override
;
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
310 bool Read(SvStream
&rS
) override
;
311 #ifdef DEBUG_FILTER_MSTOOLBAR
312 virtual void Print( FILE* ) override
;
314 sal_Int16
getcCL(){ return cCL
; }
315 WString
& getName(){ return name
; }
317 bool IsMenuToolbar(){ return ( ( ltbtr
& 0x2000000 ) == 0x2000000 ); }
320 class MSFILTER_DLLPUBLIC SRECT
: public TBBase
323 SRECT() : left(0), top(0), right(0), bottom(0) {}
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
;
335 class MSFILTER_DLLPUBLIC TBVisualData
: public TBBase
347 bool Read(SvStream
&rS
) override
;
348 #ifdef DEBUG_FILTER_MSTOOLBAR
349 virtual void Print( FILE* ) override
;
355 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */