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
11 #include <filter/msfilter/msfilterdllapi.h>
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>
28 class MSOCommandConvertor
31 virtual ~MSOCommandConvertor() {}
32 virtual OUString
MSOCommandToOOCommand( sal_Int16 msoCmd
) = 0;
33 virtual OUString
MSOTCIDToOOCommand( sal_Int16 msoTCID
) = 0;
38 class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
40 struct iconcontrolitem
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
);
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
);
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
72 static int nIndent
; // num spaces to indent before printing
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
77 TBBase() : nOffSet( 0 ) {}
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
84 sal_uInt32
GetOffset() { return nOffSet
; }
90 Indent( bool binit
= false )
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
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
;
118 WString wstrOnAction
;
123 TBCExtraInfo(const TBCExtraInfo
&) SAL_DELETED_FUNCTION
;
124 TBCExtraInfo
& operator = ( const TBCExtraInfo
&) SAL_DELETED_FUNCTION
;
127 virtual ~TBCExtraInfo(){}
128 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
129 #if OSL_DEBUG_LEVEL > 1
130 virtual void Print( FILE* ) SAL_OVERRIDE
;
132 OUString
getOnAction();
135 class MSFILTER_DLLPUBLIC TBCGeneralInfo
: public TBBase
139 WString descriptionText
;
141 TBCExtraInfo extraInfo
;
145 virtual ~TBCGeneralInfo() {}
146 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
147 #if OSL_DEBUG_LEVEL > 1
148 virtual void Print( FILE* ) SAL_OVERRIDE
;
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
163 virtual ~TBCBitMap();
164 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
165 #if OSL_DEBUG_LEVEL > 1
166 virtual void Print( FILE* ) SAL_OVERRIDE
;
169 Bitmap
& getBitMap() { return mBitMap
;}
172 class MSFILTER_DLLPUBLIC TBCMenuSpecific
: public TBBase
175 std::shared_ptr
< WString
> name
; //exist only if tbid equals 0x00000001
178 virtual ~TBCMenuSpecific(){}
179 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
180 #if OSL_DEBUG_LEVEL > 1
181 virtual void Print( FILE* ) SAL_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();
199 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
200 #if OSL_DEBUG_LEVEL > 1
201 virtual void Print( FILE* ) SAL_OVERRIDE
;
205 class TBCComboDropdownSpecific
: public TBBase
207 std::shared_ptr
< TBCCDData
> data
;
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
;
217 class TBCBSpecific
: public TBBase
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
227 virtual ~TBCBSpecific(){}
228 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
229 #if OSL_DEBUG_LEVEL > 1
230 virtual void Print( FILE* ) SAL_OVERRIDE
;
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
268 std::shared_ptr
< sal_uInt16
> width
; //optional
269 std::shared_ptr
< sal_uInt16
> height
; //optional
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
;
282 sal_uInt32
getTbct() { return tbct
; };
285 class MSFILTER_DLLPUBLIC TBCData
: public TBBase
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
;
293 TBCData( const TBCHeader
& Header
);
295 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
296 #if OSL_DEBUG_LEVEL > 1
297 virtual void Print( FILE* ) SAL_OVERRIDE
;
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
317 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
318 #if OSL_DEBUG_LEVEL > 1
319 virtual void Print( FILE* ) SAL_OVERRIDE
;
321 sal_Int16
getcCL(){ return cCL
; }
322 WString
& getName(){ return name
; }
324 bool IsMenuToolbar(){ return ( ( ltbtr
& 0x2000000 ) == 0x2000000 ); }
327 class MSFILTER_DLLPUBLIC SRECT
: public TBBase
330 SRECT() : left(0), top(0), right(0), bottom(0) {}
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
;
342 class MSFILTER_DLLPUBLIC TBVisualData
: public TBBase
354 virtual ~TBVisualData(){}
355 bool Read(SvStream
&rS
) SAL_OVERRIDE
;
356 #if OSL_DEBUG_LEVEL > 1
357 virtual void Print( FILE* ) SAL_OVERRIDE
;
363 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */