LCOV - code coverage report
Current view: top level - sfx2/source/inc - templdgi.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 29 0.0 %
Date: 2014-04-14 Functions: 0 31 0.0 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
      20             : #define INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
      21             : 
      22             : class SfxTemplateControllerItem;
      23             : 
      24             : #include <vcl/button.hxx>
      25             : #include <vcl/toolbox.hxx>
      26             : #include <vcl/lstbox.hxx>
      27             : #include <svl/lstner.hxx>
      28             : #include <svtools/treelistbox.hxx>
      29             : #include <svl/eitem.hxx>
      30             : 
      31             : #include <rsc/rscsfx.hxx>
      32             : #include <tools/rtti.hxx>
      33             : 
      34             : #include <sfx2/childwin.hxx>
      35             : #include <sfx2/templdlg.hxx>
      36             : 
      37             : class SfxStyleFamilies;
      38             : class SfxStyleFamilyItem;
      39             : class SfxTemplateItem;
      40             : class SfxBindings;
      41             : class SfxStyleSheetBase;
      42             : class SfxStyleSheetBasePool;
      43             : class SvTreeListBox ;
      44             : class StyleTreeListBox_Impl;
      45             : class SfxTemplateDialog_Impl;
      46             : class SfxCommonTemplateDialog_Impl;
      47             : class SfxTemplateDialogWrapper;
      48             : class SfxDockingWindow;
      49             : 
      50             : namespace com { namespace sun { namespace star { namespace frame { class XModuleManager2; } } } }
      51             : 
      52             : // class DropListBox_Impl ------------------------------------------------
      53             : 
      54           0 : class DropListBox_Impl : public SvTreeListBox
      55             : {
      56             : private:
      57             :     DECL_LINK(OnAsyncExecuteDrop, void *);
      58             : 
      59             : protected:
      60             :     SfxCommonTemplateDialog_Impl* pDialog;
      61             :     sal_uInt16                    nModifier;
      62             : 
      63             : public:
      64             :     DropListBox_Impl( Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD )
      65             :         : SvTreeListBox(pParent, rId)
      66             :         , pDialog(pD)
      67             :         , nModifier(0)
      68             :     {}
      69           0 :     DropListBox_Impl( Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD )
      70             :         : SvTreeListBox(pParent, nWinBits)
      71             :         , pDialog(pD)
      72           0 :         , nModifier(0)
      73           0 :     {}
      74             :     virtual void     MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      75             :     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
      76             :     using SvTreeListBox::ExecuteDrop;
      77             :     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
      78             : 
      79           0 :     sal_uInt16           GetModifier() const { return nModifier; }
      80             : 
      81             :     virtual bool     Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      82             : };
      83             : 
      84             : typedef std::vector<OUString> ExpandedEntries_t;
      85             : 
      86             : /*  [Description]
      87             : 
      88             :     TreeListBox class for displaying the hierarchical view of the templates
      89             : */
      90             : 
      91           0 : class StyleTreeListBox_Impl : public DropListBox_Impl
      92             : {
      93             : private:
      94             :     SvTreeListEntry*                pCurEntry;
      95             :     Link                            aDoubleClickLink;
      96             :     Link                            aDropLink;
      97             :     OUString                        aParent;
      98             :     OUString                        aStyle;
      99             : 
     100             : protected:
     101             :     virtual void    Command( const CommandEvent& rMEvt ) SAL_OVERRIDE;
     102             :     virtual bool    Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     103             :     virtual bool    DoubleClickHdl() SAL_OVERRIDE;
     104             :     virtual bool    ExpandingHdl() SAL_OVERRIDE;
     105             :     virtual void    ExpandedHdl() SAL_OVERRIDE;
     106             :     virtual TriState NotifyMoving(SvTreeListEntry*  pTarget,
     107             :                                      SvTreeListEntry*  pEntry,
     108             :                                      SvTreeListEntry*& rpNewParent,
     109             :                                      sal_uIntPtr&        rNewChildPos) SAL_OVERRIDE;
     110             : public:
     111             :     StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0);
     112             : 
     113           0 :     void            SetDoubleClickHdl(const Link &rLink) { aDoubleClickLink = rLink; }
     114           0 :     void            SetDropHdl(const Link &rLink) { aDropLink = rLink; }
     115             :     using SvTreeListBox::GetParent;
     116           0 :     const OUString& GetParent() const { return aParent; }
     117           0 :     const OUString& GetStyle() const { return aStyle; }
     118             :     void            MakeExpanded_Impl(ExpandedEntries_t& rEntries) const;
     119             : 
     120             :     virtual PopupMenu* CreateContextMenu( void ) SAL_OVERRIDE;
     121             : };
     122             : 
     123             : // class SfxActionListBox ------------------------------------------------
     124             : 
     125           0 : class SfxActionListBox : public DropListBox_Impl
     126             : {
     127             : protected:
     128             : public:
     129             :     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
     130             : 
     131             :     virtual PopupMenu*  CreateContextMenu( void ) SAL_OVERRIDE;
     132             : };
     133             : 
     134             : // class SfxCommonTemplateDialog_Impl ------------------------------------
     135             : 
     136             : class SfxCommonTemplateDialog_Impl : public SfxListener
     137             : {
     138             : private:
     139             :     class DeletionWatcher;
     140             :     friend class DeletionWatcher;
     141             :     bool mbIgnoreSelect;
     142             :     class ISfxTemplateCommon_Impl : public ISfxTemplateCommon
     143             :     {
     144             :     private:
     145             :         SfxCommonTemplateDialog_Impl* pDialog;
     146             :     public:
     147           0 :         ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {}
     148           0 :         virtual ~ISfxTemplateCommon_Impl() {}
     149           0 :         virtual SfxStyleFamily GetActualFamily() const SAL_OVERRIDE { return pDialog->GetActualFamily(); }
     150           0 :         virtual OUString GetSelectedEntry() const SAL_OVERRIDE { return pDialog->GetSelectedEntry(); }
     151             :     };
     152             : 
     153             :     ISfxTemplateCommon_Impl     aISfxTemplateCommon;
     154             : 
     155             :     void    ReadResource();
     156             :     void    ClearResource();
     157             :     void impl_clear();
     158             :     void impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
     159             : 
     160             : protected:
     161             : #define MAX_FAMILIES            5
     162             : #define COUNT_BOUND_FUNC        13
     163             : 
     164             : #define UPDATE_FAMILY_LIST      0x0001
     165             : #define UPDATE_FAMILY           0x0002
     166             : 
     167             :     friend class DropListBox_Impl;
     168             :     friend class SfxTemplateControllerItem;
     169             :     friend class SfxTemplateDialogWrapper;
     170             : 
     171             :     SfxBindings*                pBindings;
     172             :     SfxTemplateControllerItem*  pBoundItems[COUNT_BOUND_FUNC];
     173             : 
     174             :     Window*                     pWindow;
     175             :     SfxModule*                  pModule;
     176             :     Timer*                      pTimer;
     177             : 
     178             :     ResId*                      m_pStyleFamiliesId;
     179             :     SfxStyleFamilies*           pStyleFamilies;
     180             :     SfxTemplateItem*            pFamilyState[MAX_FAMILIES];
     181             :     SfxStyleSheetBasePool*      pStyleSheetPool;
     182             :     StyleTreeListBox_Impl*      pTreeBox;
     183             :     SfxObjectShell*             pCurObjShell;
     184             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >
     185             :                                 xModuleManager;
     186             :     DeletionWatcher*            m_pDeletionWatcher;
     187             : 
     188             :     SfxActionListBox            aFmtLb;
     189             :     ListBox                     aFilterLb;
     190             :     Size                        aSize;
     191             : 
     192             :     sal_uInt16                      nActFamily; // Id in the ToolBox = Position - 1
     193             :     sal_uInt16                      nActFilter; // FilterIdx
     194             :     sal_uInt16                      nAppFilter; // Filter, which has set the application (for automatic)
     195             : 
     196             :     bool                        bDontUpdate             :1,
     197             :                                 bIsWater                :1,
     198             :                                 bEnabled                :1,
     199             :                                 bUpdate                 :1,
     200             :                                 bUpdateFamily           :1,
     201             :                                 bCanEdit                :1,
     202             :                                 bCanDel                 :1,
     203             :                                 bCanNew                 :1,
     204             :                                 bCanHide                :1,
     205             :                                 bCanShow                :1,
     206             :                                 bWaterDisabled          :1,
     207             :                                 bNewByExampleDisabled   :1,
     208             :                                 bUpdateByExampleDisabled:1,
     209             :                                 bTreeDrag               :1,
     210             :                                 bHierarchical           :1,
     211             :                                 m_bWantHierarchical     :1,
     212             :                                 bBindingUpdate          :1;
     213             : 
     214             :     DECL_LINK( FilterSelectHdl, ListBox * );
     215             :     DECL_LINK( FmtSelectHdl, SvTreeListBox * );
     216             :     DECL_LINK( ApplyHdl, Control * );
     217             :     DECL_LINK( DropHdl, StyleTreeListBox_Impl * );
     218             :     DECL_LINK( TimeOut, Timer * );
     219             : 
     220             : 
     221           0 :     virtual void        EnableItem( sal_uInt16 /*nMesId*/, bool /*bCheck*/ = true ) {}
     222           0 :     virtual void        CheckItem( sal_uInt16 /*nMesId*/, bool /*bCheck*/ = true ) {}
     223           0 :     virtual bool        IsCheckedItem( sal_uInt16 /*nMesId*/ ) { return true; }
     224           0 :     virtual void        LoadedFamilies() {}
     225           0 :     virtual void        Update() { UpdateStyles_Impl(UPDATE_FAMILY_LIST); }
     226             :     virtual void        InvalidateBindings();
     227             :     virtual void        InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) = 0;
     228             :     virtual void        EnableFamilyItem( sal_uInt16 nId, bool bEnabled = true ) = 0;
     229             :     virtual void        ClearFamilyList() = 0;
     230             :     virtual void        ReplaceUpdateButtonByMenu();
     231             : 
     232             :     void                NewHdl( void* );
     233             :     void                EditHdl( void* );
     234             :     void                DeleteHdl( void* );
     235             :     void                HideHdl( void* );
     236             :     void                ShowHdl( void* );
     237             : 
     238             :     bool                Execute_Impl( sal_uInt16 nId, const OUString& rStr, const OUString& rRefStr,
     239             :                                       sal_uInt16 nFamily, sal_uInt16 nMask = 0,
     240             :                                       sal_uInt16* pIdx = NULL, const sal_uInt16* pModifier = NULL );
     241             : 
     242             :     void                        UpdateStyles_Impl(sal_uInt16 nFlags);
     243             :     const SfxStyleFamilyItem*   GetFamilyItem_Impl() const;
     244           0 :     bool                    IsInitialized() const { return nActFamily != 0xffff; }
     245             :     void                        ResetFocus();
     246             :     void                        EnableDelete();
     247             :     void                        Initialize();
     248             :     void                        EnableHierarchical(bool);
     249             : 
     250             :     void                FilterSelect( sal_uInt16 nFilterIdx, bool bForce = false );
     251             :     void                SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
     252             :     void                SetWaterCanState( const SfxBoolItem* pItem );
     253             : 
     254             :     void                SelectStyle( const OUString& rStyle );
     255             :     bool            HasSelectedStyle() const;
     256             :     SfxStyleSheetBase  *GetSelectedStyle() const;
     257             :     void                FillTreeBox();
     258             :     void                Update_Impl();
     259             :     void                UpdateFamily_Impl();
     260             : 
     261             :     // In which FamilyState do I have to look , in order to get the
     262             :     // information of the ith Family in the pStyleFamilies.
     263             :     sal_uInt16              StyleNrToInfoOffset( sal_uInt16 i );
     264             : 
     265             :     void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     266             : 
     267             :     void                FamilySelect( sal_uInt16 nId );
     268             :     void                SetFamily( sal_uInt16 nId );
     269             :     void                ActionSelect( sal_uInt16 nId );
     270             : 
     271             :     sal_Int32           LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );
     272             :     void                SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter );
     273             :     SfxObjectShell *    SaveSelection();
     274             : 
     275             : public:
     276             :     TYPEINFO_OVERRIDE();
     277             : 
     278             :     SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window*, bool );
     279             :     virtual ~SfxCommonTemplateDialog_Impl();
     280             : 
     281             :     DECL_LINK( MenuSelectHdl, Menu * );
     282             : 
     283           0 :     virtual void        EnableEdit( bool b = true ) { bCanEdit = b; }
     284           0 :     virtual void        EnableDel( bool b = true )  { bCanDel = b; }
     285           0 :     virtual void        EnableNew( bool b = true )  { bCanNew = b; }
     286           0 :     virtual void        EnableHide( bool b = true )  { bCanHide = b; }
     287           0 :     virtual void        EnableShow( bool b = true )  { bCanShow = b; }
     288             : 
     289           0 :     ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
     290           0 :     Window*             GetWindow() { return pWindow; }
     291             : 
     292             :     void                EnableTreeDrag( bool b = true );
     293             :     void                ExecuteContextMenu_Impl( const Point& rPos, Window* pWin );
     294             :     void                EnableExample_Impl( sal_uInt16 nId, bool bEnable );
     295             :     SfxStyleFamily      GetActualFamily() const;
     296             :     OUString            GetSelectedEntry() const;
     297           0 :     SfxObjectShell*     GetObjectShell() const { return pCurObjShell; }
     298             : 
     299             :     virtual void        PrepareDeleteAction();  // disable buttons, change button text, etc. when del is going to happen
     300             : 
     301             :     inline bool         CanEdit( void ) const   { return bCanEdit; }
     302             :     inline bool         CanDel( void ) const    { return bCanDel; }
     303             :     inline bool         CanNew( void ) const    { return bCanNew; }
     304             :     inline bool         CanHide( void ) const    { return bCanHide; }
     305             :     inline bool         CanShow( void ) const    { return bCanShow; }
     306             : 
     307             :     // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
     308             :     virtual PopupMenu*  CreateContextMenu( void );
     309             : 
     310             :     // converts from SFX_STYLE_FAMILY Ids to 1-5
     311             :     static sal_uInt16       SfxFamilyIdToNId( SfxStyleFamily nFamily );
     312             : 
     313             :     void                SetAutomaticFilter();
     314             : };
     315             : 
     316             : class DropToolBox_Impl : public ToolBox, public DropTargetHelper
     317             : {
     318             :     SfxTemplateDialog_Impl&     rParent;
     319             : protected:
     320             :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     321             :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     322             : public:
     323             :     DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog);
     324             :     virtual ~DropToolBox_Impl();
     325             : };
     326             : // class SfxTemplateDialog_Impl ------------------------------------------
     327             : 
     328             : class SfxTemplateDialog_Impl :  public SfxCommonTemplateDialog_Impl
     329             : {
     330             : private:
     331             :     friend class SfxTemplateControllerItem;
     332             :     friend class SfxTemplateDialogWrapper;
     333             :     friend class DropToolBox_Impl;
     334             :     friend class SfxTemplatePanelControl;
     335             : 
     336             :     Window* m_pFloat;
     337             :     bool            m_bZoomIn;
     338             :     DropToolBox_Impl    m_aActionTbL;
     339             :     ToolBox             m_aActionTbR;
     340             : 
     341             :     DECL_LINK( ToolBoxLSelect, ToolBox * );
     342             :     DECL_LINK( ToolBoxRSelect, ToolBox * );
     343             :     DECL_LINK( ToolBoxRClick, ToolBox * );
     344             :     DECL_LINK( MenuSelectHdl, Menu* );
     345             : 
     346             : protected:
     347             :     virtual void    Command( const CommandEvent& rMEvt );
     348             :     virtual void    EnableEdit( bool = true ) SAL_OVERRIDE;
     349             :     virtual void    EnableItem( sal_uInt16 nMesId, bool bCheck = true ) SAL_OVERRIDE;
     350             :     virtual void    CheckItem( sal_uInt16 nMesId, bool bCheck = true ) SAL_OVERRIDE;
     351             :     virtual bool    IsCheckedItem( sal_uInt16 nMesId ) SAL_OVERRIDE;
     352             :     virtual void    LoadedFamilies() SAL_OVERRIDE;
     353             :     virtual void    InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) SAL_OVERRIDE;
     354             :     virtual void    EnableFamilyItem( sal_uInt16 nId, bool bEnabled = true ) SAL_OVERRIDE;
     355             :     virtual void    ClearFamilyList() SAL_OVERRIDE;
     356             :     virtual void    ReplaceUpdateButtonByMenu() SAL_OVERRIDE;
     357             : 
     358             :     void            Resize();
     359             :     Size            GetMinOutputSizePixel();
     360             : 
     361             :     void            updateFamilyImages();
     362             :     void            updateNonFamilyImages();
     363             : 
     364             : public:
     365             :     friend class SfxTemplateDialog;
     366             :     TYPEINFO_OVERRIDE();
     367             : 
     368             :     SfxTemplateDialog_Impl( SfxBindings*, SfxTemplateDialog* pDlgWindow );
     369             :     SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
     370             :     virtual ~SfxTemplateDialog_Impl();
     371             : 
     372             :     void Initialize (void);
     373             : };
     374             : 
     375             : #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
     376             : 
     377             : 
     378             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10