LCOV - code coverage report
Current view: top level - include/filter/msfilter - mstoolbar.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 41 4.9 %
Date: 2014-11-03 Functions: 2 56 3.6 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <filter/msfilter/msfilterdllapi.h>
      12             : #include <sot/storage.hxx>
      13             : #include <ostream>
      14             : #include <memory>
      15             : #include <vector>
      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>
      25             : 
      26             : class TBCHeader;
      27             : 
      28             : 
      29           0 : class MSOCommandConvertor
      30             : {
      31             : public:
      32           0 :     virtual ~MSOCommandConvertor() {}
      33             :     virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
      34             :     virtual OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
      35             : };
      36             : 
      37             : class SfxObjectShell;
      38             : 
      39           0 : class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
      40             : {
      41           0 :     struct iconcontrolitem
      42             :     {
      43             :         OUString sCommand;
      44             :         css::uno::Reference< css::graphic::XGraphic > image;
      45             :     };
      46             :     std::vector< iconcontrolitem > iconcommands;
      47             :     std::unique_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 );
      52             : public:
      53             :     CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
      54             : 
      55           0 :     void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
      56             :     css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
      57           0 :     css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager() { return m_xAppCfgMgr;}
      58             : 
      59             : 
      60             :     css::uno::Any createCommandFromMacro( const OUString& sCmd );
      61             : 
      62             :     void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const OUString& sString );
      63             :     void applyIcons();
      64             :     OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
      65             :     OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
      66           0 :     SfxObjectShell& GetDocShell() { return mrDocSh; }
      67             :     bool createMenu( const OUString& rName, const css::uno::Reference< css::container::XIndexAccess >& xMenuDesc, bool bPersist );
      68             : };
      69             : 
      70           0 : class MSFILTER_DLLPUBLIC TBBase
      71             : {
      72             : friend class Indent;
      73             :     static int nIndent; // num spaces to indent before printing
      74             : protected:
      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
      77             : public:
      78         560 :     TBBase() : nOffSet( 0 ) {}
      79         560 :     virtual ~TBBase(){}
      80             : 
      81             :     virtual bool Read(SvStream &rS) = 0;
      82             : #if OSL_DEBUG_LEVEL > 1
      83             :     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             : #endif
      85           0 :     sal_uInt32 GetOffset() { return nOffSet; }
      86             : };
      87             : 
      88             : class Indent
      89             : {
      90             : public:
      91             :     Indent( bool binit = false )
      92             :     {
      93             :         if ( binit )
      94             :             init();
      95             :         else
      96             :             TBBase::nIndent = TBBase::nIndent + 2;
      97             :     }
      98             :     ~Indent() { TBBase::nIndent = TBBase::nIndent - 2; }
      99             :     void init() { TBBase::nIndent = 0; }
     100             : };
     101             : 
     102             : 
     103           0 : class MSFILTER_DLLPUBLIC WString : public TBBase
     104             : {
     105             :     OUString sString;
     106             : 
     107             : public:
     108           0 :     WString(){};
     109           0 :     virtual ~WString(){};
     110             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     111           0 :     OUString getString(){ return sString; }
     112             : };
     113             : 
     114             : class MSFILTER_DLLPUBLIC TBCExtraInfo : public TBBase
     115             : {
     116             :     WString wstrHelpFile;
     117             :     sal_Int32 idHelpContext;
     118             :     WString wstrTag;
     119             :     WString wstrOnAction;
     120             :     WString wstrParam;
     121             :     sal_Int8 tbcu;
     122             :     sal_Int8 tbmg;
     123             : 
     124             :     TBCExtraInfo(const TBCExtraInfo&);
     125             :     TBCExtraInfo& operator = ( const TBCExtraInfo&);
     126             : public:
     127             :     TBCExtraInfo();
     128           0 :     virtual ~TBCExtraInfo(){}
     129             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     130             : #if OSL_DEBUG_LEVEL > 1
     131             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     132             : #endif
     133             :     OUString getOnAction();
     134             : };
     135             : 
     136             : class MSFILTER_DLLPUBLIC TBCGeneralInfo  : public TBBase
     137             : {
     138             :     sal_uInt8 bFlags;
     139             :     WString customText;
     140             :     WString descriptionText;
     141             :     WString tooltip;
     142             :     TBCExtraInfo extraInfo;
     143             : 
     144             : public:
     145             :     TBCGeneralInfo();
     146           0 :     virtual ~TBCGeneralInfo() {}
     147             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     148             : #if OSL_DEBUG_LEVEL > 1
     149             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     150             : #endif
     151             :     bool ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
     152           0 :     OUString CustomText() { return customText.getString(); }
     153             :     OUString DescriptionText() { return descriptionText.getString(); }
     154             :     OUString Tooltip() { return tooltip.getString(); }
     155             : };
     156             : 
     157             : class MSFILTER_DLLPUBLIC TBCBitMap : public TBBase
     158             : {
     159             : friend class TBCBSpecific; // #FIXME hacky access, need to fix
     160             :     sal_Int32 cbDIB;
     161             :     Bitmap mBitMap;
     162             : public:
     163             :     TBCBitMap();
     164             :     virtual ~TBCBitMap();
     165             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     166             : #if OSL_DEBUG_LEVEL > 1
     167             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     168             : #endif
     169             :    // #FIXME Const-ness
     170           0 :     Bitmap& getBitMap() { return mBitMap;}
     171             : };
     172             : 
     173             : class MSFILTER_DLLPUBLIC TBCMenuSpecific : public TBBase
     174             : {
     175             :     sal_Int32 tbid;
     176             :     boost::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
     177             : public:
     178             :     TBCMenuSpecific();
     179           0 :     virtual ~TBCMenuSpecific(){}
     180             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     181             : #if OSL_DEBUG_LEVEL > 1
     182             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     183             : #endif
     184             :     OUString Name();
     185             : };
     186             : 
     187             : class MSFILTER_DLLPUBLIC TBCCDData : public TBBase
     188             : {
     189             :     sal_Int16 cwstrItems; //Signed integer that specifies the number of items in wstrList. MUST be positive.
     190             :     std::vector< WString > wstrList;  // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
     191             :     sal_Int16 cwstrMRU; // Signed integer that specifies the number of most recently used string
     192             :     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.
     193             :     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.
     194             :     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.
     195             :     WString wstrEdit; //Structure of type WString. Editable text for editable area of the ComboBox toolbar control.
     196             : 
     197             : public:
     198             :     TBCCDData();
     199             :     virtual ~TBCCDData();
     200             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     201             : #if OSL_DEBUG_LEVEL > 1
     202             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     203             : #endif
     204             : };
     205             : 
     206           0 : class TBCComboDropdownSpecific : public TBBase
     207             : {
     208             :     boost::shared_ptr< TBCCDData > data;
     209             : public:
     210             :     TBCComboDropdownSpecific( const TBCHeader& header );
     211             :     TBCComboDropdownSpecific(){}
     212             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     213             : #if OSL_DEBUG_LEVEL > 1
     214             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     215             : #endif
     216             : };
     217             : 
     218             : class TBCBSpecific :  public TBBase
     219             : {
     220             :     sal_uInt8 bFlags;
     221             :     boost::shared_ptr< TBCBitMap > icon; // optional
     222             :     boost::shared_ptr< TBCBitMap > iconMask; // optional
     223             :     boost::shared_ptr< sal_uInt16 > iBtnFace; // optional
     224             :     boost::shared_ptr< WString > wstrAcc; // optional
     225             : 
     226             : public:
     227             :     TBCBSpecific();
     228           0 :     virtual ~TBCBSpecific(){}
     229             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     230             : #if OSL_DEBUG_LEVEL > 1
     231             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     232             : #endif
     233             :     // #TODO just add a getGraphic member here
     234             :     TBCBitMap* getIcon();
     235             :     TBCBitMap* getIconMask();
     236           0 :     sal_uInt16* getBtnFace() { return iBtnFace.get(); }
     237             : };
     238             : 
     239             : /* TBCHeader.tct                   controlSpecificInfo type
     240             : 
     241             : 0x01 (Button control)              TBCBSpecific
     242             : 0x10 (ExpandingGrid control)       TBCBSpecific
     243             : 0x0A (Popup control)               TBCMenuSpecific
     244             : 0x0C (ButtonPopup control)         TBCMenuSpecific
     245             : 0x0D (SplitButtonPopup control)    TBCMenuSpecific
     246             : 0x0E (SplitButtonMRUPopup control) TBCMenuSpecific
     247             : 0x02 (Edit control)                TBCComboDropdow nSpecific
     248             : 0x04 (ComboBox control)            TBCComboDropdow nSpecific
     249             : 0x14 (GraphicCombo control)        TBCComboDropdow nSpecific
     250             : 0x03 (DropDown control)            TBCComboDropdow nSpecific
     251             : 0x06 (SplitDropDown control)       TBCComboDropdow nSpecific
     252             : 0x09 (GraphicDropDown control)     TBCComboDropdow nSpecific
     253             : 0x07 (OCXDropDown control)         controlSpecificInfo MUST NOT exist
     254             : 0x0F (Label control)               controlSpecificInfo MUST NOT exist
     255             : 0x12 (Grid control)                controlSpecificInfo MUST NOT exist
     256             : 0x13 (Gauge control)               controlSpecificInfo MUST NOT exist
     257             : 0x16 (ActiveX control)             controlSpecificInfo MUST NOT exist
     258             : 
     259             : */
     260           0 : class MSFILTER_DLLPUBLIC TBCHeader : public TBBase
     261             : {
     262             :     sal_Int8 bSignature;
     263             :     sal_Int8 bVersion;
     264             :     sal_uInt8 bFlagsTCR;
     265             :     sal_uInt8 tct;
     266             :     sal_uInt16 tcid;
     267             :     sal_uInt32 tbct;
     268             :     sal_uInt8 bPriority;
     269             :     boost::shared_ptr< sal_uInt16 > width;  //optional
     270             :     boost::shared_ptr< sal_uInt16 > height; //optional
     271             : 
     272             : public:
     273             :     TBCHeader();
     274             :     virtual ~TBCHeader();
     275           0 :     sal_uInt8 getTct() const { return tct; }
     276           0 :     sal_uInt16 getTcID() const { return tcid; }
     277           0 :     bool isVisible() { return !( bFlagsTCR & 0x1 ); }
     278           0 :     bool isBeginGroup() { return ( bFlagsTCR & 0x2 ) != 0; }
     279             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     280             : #if OSL_DEBUG_LEVEL > 1
     281             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     282             : #endif
     283           0 :     sal_uInt32 getTbct() { return tbct; };
     284             : };
     285             : 
     286             : class MSFILTER_DLLPUBLIC TBCData : public TBBase
     287             : {
     288             :     TBCHeader rHeader;
     289             :     TBCGeneralInfo controlGeneralInfo;
     290             :     boost::shared_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct
     291             :     TBCData(const TBCData&);
     292             :     TBCData& operator = ( const TBCData&);
     293             : public:
     294             :     TBCData( const TBCHeader& Header );
     295           0 :     virtual ~TBCData(){}
     296             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     297             : #if OSL_DEBUG_LEVEL > 1
     298             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     299             : #endif
     300             :     bool ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
     301           0 :     TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
     302             :     TBCMenuSpecific* getMenuSpecific();
     303             : };
     304             : 
     305           0 : class MSFILTER_DLLPUBLIC TB : public TBBase
     306             : {
     307             :     sal_uInt8 bSignature;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
     308             :     sal_uInt8 bVersion; // Signed integer that specifies the toolbar version number. MUST be 0x01.
     309             :     sal_Int16 cCL; // Signed integer that SHOULD  specify the number of toolbar controls contained in this toolbar.
     310             :     sal_Int32 ltbid;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
     311             :     sal_uInt32 ltbtr;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
     312             :     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.
     313             :     sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
     314             :     WString name; //Structure of type WString that specifies the toolbar name
     315             : public:
     316             :     TB();
     317           0 :     virtual ~TB(){}
     318             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     319             : #if OSL_DEBUG_LEVEL > 1
     320             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     321             : #endif
     322           0 :     sal_Int16 getcCL(){ return cCL; }
     323           0 :     WString& getName(){ return name; }
     324             :     bool IsEnabled();
     325           0 :     bool IsMenuToolbar(){ return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
     326             : };
     327             : 
     328           0 : class MSFILTER_DLLPUBLIC SRECT : public TBBase
     329             : {
     330             : public:
     331           0 :     SRECT() : left(0), top(0), right(0), bottom(0) {}
     332             :     sal_Int16 left;
     333             :     sal_Int16 top;
     334             :     sal_Int16 right;
     335             :     sal_Int16 bottom;
     336           0 :     bool Read( SvStream &rS ) SAL_OVERRIDE { rS.ReadInt16( left ).ReadInt16( top ).ReadInt16( right ).ReadInt16( bottom ); return true; }
     337             : #if OSL_DEBUG_LEVEL > 1
     338             :     virtual void Print( FILE* fo ) SAL_OVERRIDE;
     339             : #endif
     340             : };
     341             : 
     342             : typedef cppu::WeakImplHelper1< css::container::XIndexContainer > PropertyValueIndexContainer_BASE;
     343             : 
     344           0 : class MSFILTER_DLLPUBLIC TBVisualData : public TBBase
     345             : {
     346             :     sal_Int8 tbds;
     347             :     sal_Int8 tbv;
     348             :     sal_Int8 tbdsDock;
     349             :     sal_Int8 iRow;
     350             : 
     351             :     SRECT rcDock;
     352             :     SRECT rcFloat;
     353             : 
     354             : public:
     355             :     TBVisualData();
     356           0 :     virtual ~TBVisualData(){}
     357             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     358             : #if OSL_DEBUG_LEVEL > 1
     359             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     360             : #endif
     361             : };
     362             : 
     363             : #endif
     364             : 
     365             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10