LCOV - code coverage report
Current view: top level - sfx2/source/inc - templdgi.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 49 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 26 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 SfxDockingWindow;
      48             : 
      49             : namespace com { namespace sun { namespace star { namespace frame {
      50             :     class XModuleManager2;
      51             : }}}}
      52             : 
      53           0 : class DropListBox_Impl : public SvTreeListBox
      54             : {
      55             : private:
      56             :     DECL_LINK(OnAsyncExecuteDrop, void *);
      57             : 
      58             : protected:
      59             :     SfxCommonTemplateDialog_Impl* pDialog;
      60             :     sal_uInt16 nModifier;
      61             : 
      62             : public:
      63             :     DropListBox_Impl(vcl::Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD)
      64             :         : SvTreeListBox(pParent, rId)
      65             :         , pDialog(pD)
      66             :         , nModifier(0)
      67             :     {
      68             :         SetHighlightRange();
      69             :     }
      70             : 
      71           0 :     DropListBox_Impl(vcl::Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD)
      72             :         : SvTreeListBox(pParent, nWinBits)
      73             :         , pDialog(pD)
      74           0 :         , nModifier(0)
      75             :     {
      76           0 :         SetHighlightRange();
      77           0 :     }
      78             : 
      79             :     virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
      80             :     virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) SAL_OVERRIDE;
      81             :     using SvTreeListBox::ExecuteDrop;
      82             :     virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) SAL_OVERRIDE;
      83             : 
      84           0 :     sal_uInt16 GetModifier() const
      85             :     {
      86           0 :         return nModifier;
      87             :     }
      88             : 
      89             :     virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      90             : };
      91             : 
      92             : typedef std::vector<OUString> ExpandedEntries_t;
      93             : 
      94             : /** TreeListBox class for displaying the hierarchical view of the templates
      95             : */
      96           0 : class StyleTreeListBox_Impl : public DropListBox_Impl
      97             : {
      98             : private:
      99             :     SvTreeListEntry* pCurEntry;
     100             :     Link<> aDoubleClickLink;
     101             :     Link<> aDropLink;
     102             :     OUString  aParent;
     103             :     OUString aStyle;
     104             : 
     105             : protected:
     106             :     virtual void Command(const CommandEvent& rMEvt) SAL_OVERRIDE;
     107             :     virtual bool Notify(NotifyEvent& rNEvt) SAL_OVERRIDE;
     108             :     virtual bool DoubleClickHdl() SAL_OVERRIDE;
     109             :     virtual bool ExpandingHdl() SAL_OVERRIDE;
     110             :     virtual void ExpandedHdl() SAL_OVERRIDE;
     111             :     virtual TriState NotifyMoving(
     112             :                 SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
     113             :                 SvTreeListEntry*& rpNewParent, sal_uIntPtr& rNewChildPos) SAL_OVERRIDE;
     114             : public:
     115             :     StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0);
     116             : 
     117             :     void Recalc();
     118             : 
     119           0 :     void SetDoubleClickHdl(const Link<> &rLink)
     120             :     {
     121           0 :         aDoubleClickLink = rLink;
     122           0 :     }
     123           0 :     void SetDropHdl(const Link<> &rLink)
     124             :     {
     125           0 :         aDropLink = rLink;
     126           0 :     }
     127             : 
     128             :     using SvTreeListBox::GetParent;
     129             : 
     130           0 :     const OUString& GetParent() const
     131             :     {
     132           0 :         return aParent;
     133             :     }
     134           0 :     const OUString& GetStyle() const
     135             :     {
     136           0 :         return aStyle;
     137             :     }
     138             :     void MakeExpanded_Impl(ExpandedEntries_t& rEntries) const;
     139             : 
     140             :     virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
     141             : };
     142             : 
     143           0 : class SfxActionListBox : public DropListBox_Impl
     144             : {
     145             : protected:
     146             : public:
     147             :     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
     148             : 
     149             :     virtual PopupMenu*  CreateContextMenu() SAL_OVERRIDE;
     150             :     void Recalc();
     151             : };
     152             : 
     153             : class SfxCommonTemplateDialog_Impl : public SfxListener
     154             : {
     155             : private:
     156             :     class DeletionWatcher;
     157             :     friend class DeletionWatcher;
     158             : 
     159             :     bool mbIgnoreSelect;
     160             : 
     161             :     void ReadResource();
     162             :     void ClearResource();
     163             :     void impl_clear();
     164             :     DeletionWatcher* impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
     165             : 
     166             : protected:
     167             : #define MAX_FAMILIES            5
     168             : #define COUNT_BOUND_FUNC        13
     169             : 
     170             : #define UPDATE_FAMILY_LIST      0x0001
     171             : #define UPDATE_FAMILY           0x0002
     172             : 
     173             :     friend class DropListBox_Impl;
     174             :     friend class SfxTemplateControllerItem;
     175             : 
     176             :     SfxBindings* pBindings;
     177             :     SfxTemplateControllerItem* pBoundItems[COUNT_BOUND_FUNC];
     178             : 
     179             :     VclPtr<vcl::Window> pWindow;
     180             :     SfxModule* pModule;
     181             :     Idle* pIdle;
     182             : 
     183             :     ResId* m_pStyleFamiliesId;
     184             :     SfxStyleFamilies* pStyleFamilies;
     185             :     SfxTemplateItem* pFamilyState[MAX_FAMILIES];
     186             :     SfxStyleSheetBasePool* pStyleSheetPool;
     187             :     VclPtr<StyleTreeListBox_Impl> pTreeBox;
     188             :     SfxObjectShell* pCurObjShell;
     189             :     css::uno::Reference<css::frame::XModuleManager2> xModuleManager;
     190             :     DeletionWatcher* m_pDeletionWatcher;
     191             : 
     192             :     VclPtr<SfxActionListBox> aFmtLb;
     193             :     VclPtr<ListBox> aFilterLb;
     194             :     Size aSize;
     195             : 
     196             :     sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
     197             :     sal_uInt16 nActFilter; // FilterIdx
     198             :     sal_uInt16 nAppFilter; // Filter, which has set the application (for automatic)
     199             : 
     200             :     bool bDontUpdate :1;
     201             :     bool bIsWater :1;
     202             :     bool bEnabled :1;
     203             :     bool bUpdate :1;
     204             :     bool bUpdateFamily :1;
     205             :     bool bCanEdit :1;
     206             :     bool bCanDel :1;
     207             :     bool bCanNew :1;
     208             :     bool bCanHide :1;
     209             :     bool bCanShow :1;
     210             :     bool bWaterDisabled :1;
     211             :     bool bNewByExampleDisabled :1;
     212             :     bool bUpdateByExampleDisabled :1;
     213             :     bool bTreeDrag :1;
     214             :     bool bHierarchical :1;
     215             :     bool m_bWantHierarchical :1;
     216             :     bool bBindingUpdate :1;
     217             : 
     218             :     DECL_LINK( FilterSelectHdl, ListBox* );
     219             :     DECL_LINK( FmtSelectHdl, SvTreeListBox* );
     220             :     DECL_LINK( ApplyHdl, Control* );
     221             :     DECL_LINK( DropHdl, StyleTreeListBox_Impl* );
     222             :     DECL_LINK_TYPED( TimeOut, Idle*, void );
     223             : 
     224           0 :     virtual void EnableItem(sal_uInt16 /*nMesId*/, bool /*bCheck*/ = true)
     225           0 :     {}
     226           0 :     virtual void CheckItem(sal_uInt16 /*nMesId*/, bool /*bCheck*/ = true)
     227           0 :     {}
     228           0 :     virtual bool IsCheckedItem(sal_uInt16 /*nMesId*/ )
     229             :     {
     230           0 :         return true;
     231             :     }
     232           0 :     virtual void LoadedFamilies()
     233           0 :     {}
     234             :     void Update()
     235             :     {
     236             :         UpdateStyles_Impl(UPDATE_FAMILY_LIST);
     237             :     }
     238             : 
     239             :     void InvalidateBindings();
     240             :     virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pItem ) = 0;
     241             :     virtual void EnableFamilyItem( sal_uInt16 nId, bool bEnabled = true ) = 0;
     242             :     virtual void ClearFamilyList() = 0;
     243             :     virtual void ReplaceUpdateButtonByMenu();
     244             : 
     245             :     void NewHdl( void* );
     246             :     void EditHdl( void* );
     247             :     void DeleteHdl( void* );
     248             :     void HideHdl( void* );
     249             :     void ShowHdl( void* );
     250             : 
     251             :     bool Execute_Impl(sal_uInt16 nId, const OUString& rStr, const OUString& rRefStr,
     252             :                       sal_uInt16 nFamily, sal_uInt16 nMask = 0,
     253             :                       sal_uInt16* pIdx = NULL, const sal_uInt16* pModifier = NULL );
     254             : 
     255             :     void UpdateStyles_Impl(sal_uInt16 nFlags);
     256             :     const SfxStyleFamilyItem* GetFamilyItem_Impl() const;
     257           0 :     bool IsInitialized() const
     258             :     {
     259           0 :         return nActFamily != 0xffff;
     260             :     }
     261             :     void ResetFocus();
     262             :     void EnableDelete();
     263             :     void Initialize();
     264             :     void EnableHierarchical(bool);
     265             : 
     266             :     void FilterSelect( sal_uInt16 nFilterIdx, bool bForce = false );
     267             :     void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
     268             :     void SetWaterCanState( const SfxBoolItem* pItem );
     269             : 
     270             :     void SelectStyle( const OUString& rStyle );
     271             :     bool HasSelectedStyle() const;
     272             :     SfxStyleSheetBase* GetSelectedStyle() const;
     273             :     void FillTreeBox();
     274             :     void Update_Impl();
     275             :     void UpdateFamily_Impl();
     276             : 
     277             :     // In which FamilyState do I have to look , in order to get the
     278             :     // information of the ith Family in the pStyleFamilies.
     279             :     sal_uInt16 StyleNrToInfoOffset( sal_uInt16 i );
     280             : 
     281             :     void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     282             : 
     283             :     void FamilySelect( sal_uInt16 nId );
     284             :     void SetFamily( sal_uInt16 nId );
     285             :     void ActionSelect( sal_uInt16 nId );
     286             : 
     287             :     sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );
     288             :     void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter );
     289             :     SfxObjectShell* SaveSelection();
     290             : 
     291             : public:
     292             :     TYPEINFO_OVERRIDE();
     293             : 
     294             :     SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl::Window*, bool );
     295             :     virtual ~SfxCommonTemplateDialog_Impl();
     296             : 
     297             :     DECL_LINK( MenuSelectHdl, Menu * );
     298             : 
     299           0 :     virtual void EnableEdit( bool b = true )
     300             :     {
     301           0 :         bCanEdit = b;
     302           0 :     }
     303           0 :     void EnableDel( bool b = true )
     304             :     {
     305           0 :         bCanDel = b;
     306           0 :     }
     307           0 :     void EnableNew( bool b = true )
     308             :     {
     309           0 :         bCanNew = b;
     310           0 :     }
     311           0 :     void EnableHide( bool b = true )
     312             :     {
     313           0 :         bCanHide = b;
     314           0 :     }
     315           0 :     void EnableShow( bool b = true )
     316             :     {
     317           0 :         bCanShow = b;
     318           0 :     }
     319             : 
     320           0 :     vcl::Window* GetWindow()
     321             :     {
     322           0 :         return pWindow;
     323             :     }
     324             : 
     325             :     void EnableTreeDrag(bool b = true);
     326             :     void EnableExample_Impl(sal_uInt16 nId, bool bEnable);
     327             :     SfxStyleFamily GetActualFamily() const;
     328             :     OUString GetSelectedEntry() const;
     329             : 
     330           0 :     SfxObjectShell* GetObjectShell() const
     331             :     {
     332           0 :         return pCurObjShell;
     333             :     }
     334             : 
     335             :     inline bool CanEdit() const
     336             :     {
     337             :         return bCanEdit;
     338             :     }
     339             :     inline bool CanDel() const
     340             :     {
     341             :         return bCanDel;
     342             :     }
     343             :     inline bool CanNew() const
     344             :     {
     345             :         return bCanNew;
     346             :     }
     347             : 
     348             :     inline bool CanHide() const
     349             :     {
     350             :         return bCanHide;
     351             :     }
     352             : 
     353             :     inline bool CanShow() const
     354             :     {
     355             :         return bCanShow;
     356             :     }
     357             : 
     358             :     // normally for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
     359             :     PopupMenu*  CreateContextMenu();
     360             : };
     361             : 
     362           0 : class DropToolBox_Impl : public ToolBox, public DropTargetHelper
     363             : {
     364             :     SfxTemplateDialog_Impl&     rParent;
     365             : protected:
     366             :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     367             :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     368             : public:
     369             :     DropToolBox_Impl(vcl::Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog);
     370             : };
     371             : 
     372             : class SfxTemplateDialog_Impl :  public SfxCommonTemplateDialog_Impl
     373             : {
     374             : private:
     375             :     friend class SfxTemplateControllerItem;
     376             :     friend class DropToolBox_Impl;
     377             :     friend class SfxTemplatePanelControl;
     378             : 
     379             :     VclPtr<vcl::Window>         m_pFloat;
     380             :     bool                        m_bZoomIn;
     381             :     VclPtr<DropToolBox_Impl>    m_aActionTbL;
     382             :     VclPtr<ToolBox>             m_aActionTbR;
     383             : 
     384             :     DECL_LINK_TYPED( ToolBoxLSelect, ToolBox*, void );
     385             :     DECL_LINK_TYPED( ToolBoxRSelect, ToolBox*, void );
     386             :     DECL_LINK_TYPED( ToolBoxRClick, ToolBox*, void );
     387             :     DECL_LINK( MenuSelectHdl, Menu* );
     388             : 
     389             : protected:
     390             :     virtual void EnableEdit( bool = true ) SAL_OVERRIDE;
     391             :     virtual void EnableItem( sal_uInt16 nMesId, bool bCheck = true ) SAL_OVERRIDE;
     392             :     virtual void CheckItem( sal_uInt16 nMesId, bool bCheck = true ) SAL_OVERRIDE;
     393             :     virtual bool IsCheckedItem( sal_uInt16 nMesId ) SAL_OVERRIDE;
     394             :     virtual void LoadedFamilies() SAL_OVERRIDE;
     395             :     virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) SAL_OVERRIDE;
     396             :     virtual void EnableFamilyItem( sal_uInt16 nId, bool bEnabled = true ) SAL_OVERRIDE;
     397             :     virtual void ClearFamilyList() SAL_OVERRIDE;
     398             :     virtual void ReplaceUpdateButtonByMenu() SAL_OVERRIDE;
     399             : 
     400             :     void Resize();
     401             :     Size GetMinOutputSizePixel();
     402             : 
     403             :     void updateFamilyImages();
     404             :     void updateNonFamilyImages();
     405             : 
     406             : public:
     407             :     friend class SfxTemplateDialog;
     408             :     TYPEINFO_OVERRIDE();
     409             : 
     410             :     SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
     411             :     virtual ~SfxTemplateDialog_Impl();
     412             : 
     413             :     void Initialize();
     414             : };
     415             : 
     416             : #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
     417             : 
     418             : 
     419             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11