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/.
10 #define _MSTOOLBAR_HXX
11 #include "filter/msfilter/msfilterdllapi.h"
12 #include <sot/storage.hxx>
16 #include <boost/shared_ptr.hpp>
17 #include <com/sun/star/frame/XModel.hpp>
18 #include <com/sun/star/container/XIndexContainer.hpp>
19 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
20 #include <com/sun/star/ui/ImageType.hpp>
21 #include <com/sun/star/graphic/XGraphic.hpp>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <vcl/bitmap.hxx>
24 #include <cppuhelper/implbase1.hxx>
29 class MSOCommandConvertor
32 virtual ~MSOCommandConvertor() {}
33 virtual OUString
MSOCommandToOOCommand( sal_Int16 msoCmd
) = 0;
34 virtual OUString
MSOTCIDToOOCommand( sal_Int16 msoTCID
) = 0;
39 class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
41 struct iconcontrolitem
44 css::uno::Reference
< css::graphic::XGraphic
> image
;
46 std::vector
< iconcontrolitem
> iconcommands
;
47 std::auto_ptr
< MSOCommandConvertor
> pMSOCmdConvertor
;
48 css::uno::Reference
< css::ui::XUIConfigurationManagerSupplier
> m_xCfgSupp
;
49 css::uno::Reference
< css::ui::XUIConfigurationManager
> m_xAppCfgMgr
;
50 SfxObjectShell
& mrDocSh
;
51 void ScaleImage( css::uno::Reference
< css::graphic::XGraphic
>& xGraphic
, long nNewSize
);
53 CustomToolBarImportHelper( SfxObjectShell
& rDocSh
, const css::uno::Reference
< css::ui::XUIConfigurationManager
>& rxAppCfgMgr
);
55 void setMSOCommandMap( MSOCommandConvertor
* pCnvtr
) { pMSOCmdConvertor
.reset( pCnvtr
); }
56 css::uno::Reference
< css::ui::XUIConfigurationManager
> getCfgManager();
57 css::uno::Reference
< css::ui::XUIConfigurationManager
> getAppCfgManager();
60 css::uno::Any
createCommandFromMacro( const OUString
& sCmd
);
62 void addIcon( const css::uno::Reference
< css::graphic::XGraphic
>& xImage
, const OUString
& sString
);
64 OUString
MSOCommandToOOCommand( sal_Int16 msoCmd
);
65 OUString
MSOTCIDToOOCommand( sal_Int16 msoTCID
);
66 SfxObjectShell
& GetDocShell() { return mrDocSh
; }
67 bool createMenu( const OUString
& rName
, const css::uno::Reference
< css::container::XIndexAccess
>& xMenuDesc
, bool bPersist
);
70 class MSFILTER_DLLPUBLIC TBBase
73 static int nIndent
; // num spaces to indent before printing
75 void indent_printf(FILE* fp
, const char* format
, ... );
76 sal_uInt32 nOffSet
; // usually for debug we can store the offset in the stream to this record
78 TBBase() : nOffSet( 0 ) {}
81 virtual bool Read(SvStream
&rS
) = 0;
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
83 sal_uInt32
GetOffset() { return nOffSet
; }
89 Indent( bool binit
= false )
94 TBBase::nIndent
= TBBase::nIndent
+ 2;
96 ~Indent() { TBBase::nIndent
= TBBase::nIndent
- 2; }
97 void init() { TBBase::nIndent
= 0; }
101 class MSFILTER_DLLPUBLIC WString
: public TBBase
108 bool Read(SvStream
&rS
);
109 OUString
getString(){ return sString
; }
112 class MSFILTER_DLLPUBLIC TBCExtraInfo
: public TBBase
114 WString wstrHelpFile
;
115 sal_Int32 idHelpContext
;
117 WString wstrOnAction
;
122 TBCExtraInfo(const TBCExtraInfo
&);
123 TBCExtraInfo
& operator = ( const TBCExtraInfo
&);
127 bool Read(SvStream
&rS
);
129 OUString
getOnAction();
132 class MSFILTER_DLLPUBLIC TBCGeneralInfo
: public TBBase
136 WString descriptionText
;
138 TBCExtraInfo extraInfo
;
143 bool Read(SvStream
&rS
);
145 bool ImportToolBarControlData( CustomToolBarImportHelper
&, std::vector
< css::beans::PropertyValue
>& );
146 OUString
CustomText() { return customText
.getString(); }
147 OUString
DescriptionText() { return descriptionText
.getString(); }
148 OUString
Tooltip() { return tooltip
.getString(); }
151 class MSFILTER_DLLPUBLIC TBCBitMap
: public TBBase
153 friend class TBCBSpecific
; // #FIXME hacky access, need to fix
159 bool Read(SvStream
&rS
);
164 class MSFILTER_DLLPUBLIC TBCMenuSpecific
: public TBBase
167 boost::shared_ptr
< WString
> name
; //exist only if tbid equals 0x00000001
171 bool Read(SvStream
&rS
);
176 class MSFILTER_DLLPUBLIC TBCCDData
: public TBBase
178 sal_Int16 cwstrItems
; //Signed integer that specifies the number of items in wstrList. MUST be positive.
179 std::vector
< WString
> wstrList
; // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
180 sal_Int16 cwstrMRU
; // Signed integer that specifies the number of most recently used string
181 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.
182 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.
183 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.
184 WString wstrEdit
; //Structure of type WString. Editable text for editable area of the ComboBox toolbar control.
189 bool Read(SvStream
&rS
);
193 class TBCComboDropdownSpecific
: public TBBase
195 boost::shared_ptr
< TBCCDData
> data
;
197 TBCComboDropdownSpecific( const TBCHeader
& header
);
198 TBCComboDropdownSpecific(){}
199 bool Read(SvStream
&rS
);
203 class TBCBSpecific
: public TBBase
206 boost::shared_ptr
< TBCBitMap
> icon
; // optional
207 boost::shared_ptr
< TBCBitMap
> iconMask
; // optional
208 boost::shared_ptr
< sal_uInt16
> iBtnFace
; // optional
209 boost::shared_ptr
< WString
> wstrAcc
; // optional
214 bool Read(SvStream
&rS
);
216 // #TODO just add a getGraphic member here
217 TBCBitMap
* getIcon();
218 TBCBitMap
* getIconMask();
219 sal_uInt16
* getBtnFace() { return iBtnFace
.get(); }
222 /* TBCHeader.tct controlSpecificInfo type
224 0x01 (Button control) TBCBSpecific
225 0x10 (ExpandingGrid control) TBCBSpecific
226 0x0A (Popup control) TBCMenuSpecific
227 0x0C (ButtonPopup control) TBCMenuSpecific
228 0x0D (SplitButtonPopup control) TBCMenuSpecific
229 0x0E (SplitButtonMRUPopup control) TBCMenuSpecific
230 0x02 (Edit control) TBCComboDropdow nSpecific
231 0x04 (ComboBox control) TBCComboDropdow nSpecific
232 0x14 (GraphicCombo control) TBCComboDropdow nSpecific
233 0x03 (DropDown control) TBCComboDropdow nSpecific
234 0x06 (SplitDropDown control) TBCComboDropdow nSpecific
235 0x09 (GraphicDropDown control) TBCComboDropdow nSpecific
236 0x07 (OCXDropDown control) controlSpecificInfo MUST NOT exist
237 0x0F (Label control) controlSpecificInfo MUST NOT exist
238 0x12 (Grid control) controlSpecificInfo MUST NOT exist
239 0x13 (Gauge control) controlSpecificInfo MUST NOT exist
240 0x16 (ActiveX control) controlSpecificInfo MUST NOT exist
243 class MSFILTER_DLLPUBLIC TBCHeader
: public TBBase
252 boost::shared_ptr
< sal_uInt16
> width
; //optional
253 boost::shared_ptr
< sal_uInt16
> height
; //optional
258 sal_uInt8
getTct() const { return tct
; }
259 sal_uInt16
getTcID() const { return tcid
; }
260 bool isVisible() { return !( bFlagsTCR
& 0x1 ); }
261 bool isBeginGroup() { return ( bFlagsTCR
& 0x2 ); }
262 bool Read(SvStream
&rS
);
264 sal_uInt32
getTbct() { return tbct
; };
267 class MSFILTER_DLLPUBLIC TBCData
: public TBBase
270 TBCGeneralInfo controlGeneralInfo
;
271 boost::shared_ptr
< TBBase
> controlSpecificInfo
; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct
272 TBCData(const TBCData
&);
273 TBCData
& operator = ( const TBCData
&);
275 TBCData( const TBCHeader
& Header
);
277 bool Read(SvStream
&rS
);
279 bool ImportToolBarControl( CustomToolBarImportHelper
&, std::vector
< css::beans::PropertyValue
>&, bool& bBeginGroup
, bool bIsMenuBar
);
280 TBCGeneralInfo
& getGeneralInfo() { return controlGeneralInfo
; }
281 TBCMenuSpecific
* getMenuSpecific();
284 class MSFILTER_DLLPUBLIC TB
: public TBBase
286 sal_uInt8 bSignature
;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
287 sal_uInt8 bVersion
; // Signed integer that specifies the toolbar version number. MUST be 0x01.
288 sal_Int16 cCL
; // Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
289 sal_Int32 ltbid
;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
290 sal_uInt32 ltbtr
;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
291 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.
292 sal_uInt16 bFlags
; //Unsigned integer of type TBFlags.
293 WString name
; //Structure of type WString that specifies the toolbar name
297 bool Read(SvStream
&rS
);
299 sal_Int16
getcCL(){ return cCL
; }
300 WString
& getName(){ return name
; }
302 bool IsMenuToolbar(){ return ( ( ltbtr
& 0x2000000 ) == 0x2000000 ); }
305 class MSFILTER_DLLPUBLIC SRECT
: public TBBase
308 SRECT() : left(0), top(0), right(0), bottom(0) {}
313 bool Read( SvStream
&rS
) { rS
>> left
>> top
>> right
>> bottom
; return true; }
314 void Print( FILE* fo
);
317 typedef cppu::WeakImplHelper1
< css::container::XIndexContainer
> PropertyValueIndexContainer_BASE
;
319 class MSFILTER_DLLPUBLIC TBVisualData
: public TBBase
332 bool Read(SvStream
&rS
);
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */