LCOV - code coverage report
Current view: top level - include/filter/msfilter - mstoolbar.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 41 4.9 %
Date: 2015-06-13 12:38:46 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 <ostream>
      13             : #include <memory>
      14             : #include <vector>
      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>
      24             : 
      25             : class TBCHeader;
      26             : 
      27             : 
      28           0 : class MSOCommandConvertor
      29             : {
      30             : public:
      31           0 :     virtual ~MSOCommandConvertor() {}
      32             :     virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd ) = 0;
      33             :     virtual OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0;
      34             : };
      35             : 
      36             : class SfxObjectShell;
      37             : 
      38           0 : class MSFILTER_DLLPUBLIC CustomToolBarImportHelper
      39             : {
      40           0 :     struct iconcontrolitem
      41             :     {
      42             :         OUString sCommand;
      43             :         css::uno::Reference< css::graphic::XGraphic > image;
      44             :     };
      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 );
      51             : public:
      52             :     CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
      53             : 
      54           0 :     void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
      55             :     css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
      56           0 :     css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager() { return m_xAppCfgMgr;}
      57             : 
      58             : 
      59             :     static css::uno::Any createCommandFromMacro( const OUString& sCmd );
      60             : 
      61             :     void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const OUString& sString );
      62             :     void applyIcons();
      63             :     OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
      64             :     OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
      65           0 :     SfxObjectShell& GetDocShell() { return mrDocSh; }
      66             :     bool createMenu( const OUString& rName, const css::uno::Reference< css::container::XIndexAccess >& xMenuDesc, bool bPersist );
      67             : };
      68             : 
      69           0 : class MSFILTER_DLLPUBLIC TBBase
      70             : {
      71             : friend class Indent;
      72             :     static int nIndent; // num spaces to indent before printing
      73             : protected:
      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
      76             : public:
      77         347 :     TBBase() : nOffSet( 0 ) {}
      78         347 :     virtual ~TBBase(){}
      79             : 
      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
      83             : #endif
      84           0 :     sal_uInt32 GetOffset() { return nOffSet; }
      85             : };
      86             : 
      87             : class Indent
      88             : {
      89             : public:
      90             :     Indent( bool binit = false )
      91             :     {
      92             :         if ( binit )
      93             :             init();
      94             :         else
      95             :             TBBase::nIndent = TBBase::nIndent + 2;
      96             :     }
      97             :     ~Indent() { TBBase::nIndent = TBBase::nIndent - 2; }
      98             :     static void init() { TBBase::nIndent = 0; }
      99             : };
     100             : 
     101             : 
     102           0 : class MSFILTER_DLLPUBLIC WString : public TBBase
     103             : {
     104             :     OUString sString;
     105             : 
     106             : public:
     107           0 :     WString(){};
     108           0 :     virtual ~WString(){};
     109             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     110           0 :     OUString getString(){ return sString; }
     111             : };
     112             : 
     113             : class MSFILTER_DLLPUBLIC TBCExtraInfo : public TBBase
     114             : {
     115             :     WString wstrHelpFile;
     116             :     sal_Int32 idHelpContext;
     117             :     WString wstrTag;
     118             :     WString wstrOnAction;
     119             :     WString wstrParam;
     120             :     sal_Int8 tbcu;
     121             :     sal_Int8 tbmg;
     122             : 
     123             :     TBCExtraInfo(const TBCExtraInfo&) SAL_DELETED_FUNCTION;
     124             :     TBCExtraInfo& operator = ( const TBCExtraInfo&) SAL_DELETED_FUNCTION;
     125             : public:
     126             :     TBCExtraInfo();
     127           0 :     virtual ~TBCExtraInfo(){}
     128             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     129             : #if OSL_DEBUG_LEVEL > 1
     130             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     131             : #endif
     132             :     OUString getOnAction();
     133             : };
     134             : 
     135             : class MSFILTER_DLLPUBLIC TBCGeneralInfo  : public TBBase
     136             : {
     137             :     sal_uInt8 bFlags;
     138             :     WString customText;
     139             :     WString descriptionText;
     140             :     WString tooltip;
     141             :     TBCExtraInfo extraInfo;
     142             : 
     143             : public:
     144             :     TBCGeneralInfo();
     145           0 :     virtual ~TBCGeneralInfo() {}
     146             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     147             : #if OSL_DEBUG_LEVEL > 1
     148             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     149             : #endif
     150             :     bool ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
     151           0 :     OUString CustomText() { return customText.getString(); }
     152             :     OUString DescriptionText() { return descriptionText.getString(); }
     153             :     OUString Tooltip() { return tooltip.getString(); }
     154             : };
     155             : 
     156             : class MSFILTER_DLLPUBLIC TBCBitMap : public TBBase
     157             : {
     158             : friend class TBCBSpecific; // #FIXME hacky access, need to fix
     159             :     sal_Int32 cbDIB;
     160             :     Bitmap mBitMap;
     161             : public:
     162             :     TBCBitMap();
     163             :     virtual ~TBCBitMap();
     164             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     165             : #if OSL_DEBUG_LEVEL > 1
     166             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     167             : #endif
     168             :    // #FIXME Const-ness
     169           0 :     Bitmap& getBitMap() { return mBitMap;}
     170             : };
     171             : 
     172             : class MSFILTER_DLLPUBLIC TBCMenuSpecific : public TBBase
     173             : {
     174             :     sal_Int32 tbid;
     175             :     std::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
     176             : public:
     177             :     TBCMenuSpecific();
     178           0 :     virtual ~TBCMenuSpecific(){}
     179             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     180             : #if OSL_DEBUG_LEVEL > 1
     181             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     182             : #endif
     183             :     OUString Name();
     184             : };
     185             : 
     186             : class MSFILTER_DLLPUBLIC TBCCDData : 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             : 
     196             : public:
     197             :     TBCCDData();
     198             :     virtual ~TBCCDData();
     199             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     200             : #if OSL_DEBUG_LEVEL > 1
     201             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     202             : #endif
     203             : };
     204             : 
     205           0 : class TBCComboDropdownSpecific : public TBBase
     206             : {
     207             :     std::shared_ptr< TBCCDData > data;
     208             : public:
     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;
     214             : #endif
     215             : };
     216             : 
     217             : class TBCBSpecific :  public TBBase
     218             : {
     219             :     sal_uInt8 bFlags;
     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
     224             : 
     225             : public:
     226             :     TBCBSpecific();
     227           0 :     virtual ~TBCBSpecific(){}
     228             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     229             : #if OSL_DEBUG_LEVEL > 1
     230             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     231             : #endif
     232             :     // #TODO just add a getGraphic member here
     233             :     TBCBitMap* getIcon();
     234             :     TBCBitMap* getIconMask();
     235           0 :     sal_uInt16* getBtnFace() { return iBtnFace.get(); }
     236             : };
     237             : 
     238             : /* TBCHeader.tct                   controlSpecificInfo type
     239             : 
     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
     257             : 
     258             : */
     259           0 : class MSFILTER_DLLPUBLIC TBCHeader : public TBBase
     260             : {
     261             :     sal_Int8 bSignature;
     262             :     sal_Int8 bVersion;
     263             :     sal_uInt8 bFlagsTCR;
     264             :     sal_uInt8 tct;
     265             :     sal_uInt16 tcid;
     266             :     sal_uInt32 tbct;
     267             :     sal_uInt8 bPriority;
     268             :     std::shared_ptr< sal_uInt16 > width;  //optional
     269             :     std::shared_ptr< sal_uInt16 > height; //optional
     270             : 
     271             : public:
     272             :     TBCHeader();
     273             :     virtual ~TBCHeader();
     274           0 :     sal_uInt8 getTct() const { return tct; }
     275           0 :     sal_uInt16 getTcID() const { return tcid; }
     276           0 :     bool isVisible() { return !( bFlagsTCR & 0x1 ); }
     277           0 :     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;
     281             : #endif
     282           0 :     sal_uInt32 getTbct() { return tbct; };
     283             : };
     284             : 
     285             : class MSFILTER_DLLPUBLIC TBCData : public TBBase
     286             : {
     287             :     TBCHeader rHeader;
     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;
     292             : public:
     293             :     TBCData( const TBCHeader& Header );
     294           0 :     virtual ~TBCData(){}
     295             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     296             : #if OSL_DEBUG_LEVEL > 1
     297             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     298             : #endif
     299             :     bool ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
     300           0 :     TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
     301             :     TBCMenuSpecific* getMenuSpecific();
     302             : };
     303             : 
     304           0 : class MSFILTER_DLLPUBLIC TB : public TBBase
     305             : {
     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
     314             : public:
     315             :     TB();
     316           0 :     virtual ~TB(){}
     317             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     318             : #if OSL_DEBUG_LEVEL > 1
     319             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     320             : #endif
     321           0 :     sal_Int16 getcCL(){ return cCL; }
     322           0 :     WString& getName(){ return name; }
     323             :     bool IsEnabled();
     324           0 :     bool IsMenuToolbar(){ return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
     325             : };
     326             : 
     327           0 : class MSFILTER_DLLPUBLIC SRECT : public TBBase
     328             : {
     329             : public:
     330           0 :     SRECT() : left(0), top(0), right(0), bottom(0) {}
     331             :     sal_Int16 left;
     332             :     sal_Int16 top;
     333             :     sal_Int16 right;
     334             :     sal_Int16 bottom;
     335           0 :     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;
     338             : #endif
     339             : };
     340             : 
     341             : 
     342           0 : class MSFILTER_DLLPUBLIC TBVisualData : public TBBase
     343             : {
     344             :     sal_Int8 tbds;
     345             :     sal_Int8 tbv;
     346             :     sal_Int8 tbdsDock;
     347             :     sal_Int8 iRow;
     348             : 
     349             :     SRECT rcDock;
     350             :     SRECT rcFloat;
     351             : 
     352             : public:
     353             :     TBVisualData();
     354           0 :     virtual ~TBVisualData(){}
     355             :     bool Read(SvStream &rS) SAL_OVERRIDE;
     356             : #if OSL_DEBUG_LEVEL > 1
     357             :     virtual void Print( FILE* ) SAL_OVERRIDE;
     358             : #endif
     359             : };
     360             : 
     361             : #endif
     362             : 
     363             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11