LCOV - code coverage report
Current view: top level - sfx2/source/inc - templdgi.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 23 56.5 %
Date: 2012-08-25 Functions: 12 24 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     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 _SFX_TEMPDLGI_HXX
      20                 :            : #define _SFX_TEMPDLGI_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/svtreebx.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 XModuleManager; } } } }
      51                 :            : 
      52                 :            : // class DropListBox_Impl ------------------------------------------------
      53                 :            : 
      54         [ -  + ]:        120 : 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                 :          0 :     DropListBox_Impl( Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD ) :
      65                 :          0 :         SvTreeListBox( pParent, rId ), pDialog( pD ) {}
      66                 :        120 :     DropListBox_Impl( Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD ) :
      67                 :        120 :         SvTreeListBox( pParent, nWinBits ), pDialog( pD ) {}
      68                 :            : 
      69                 :            :     virtual void     MouseButtonDown( const MouseEvent& rMEvt );
      70                 :            :     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
      71                 :            :     using SvLBox::ExecuteDrop;
      72                 :            :     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
      73                 :            : 
      74                 :          0 :     sal_uInt16           GetModifier() const { return nModifier; }
      75                 :            : 
      76                 :            :     virtual long     Notify( NotifyEvent& rNEvt );
      77                 :            : };
      78                 :            : 
      79                 :            : // class SfxActionListBox ------------------------------------------------
      80                 :            : 
      81         [ -  + ]:        120 : class SfxActionListBox : public DropListBox_Impl
      82                 :            : {
      83                 :            : protected:
      84                 :            : public:
      85                 :            :     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
      86                 :            :     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, const ResId &rResId );
      87                 :            : 
      88                 :            :     virtual PopupMenu*  CreateContextMenu( void );
      89                 :            : };
      90                 :            : 
      91                 :            : // class SfxCommonTemplateDialog_Impl ------------------------------------
      92                 :            : 
      93                 :            : class SfxCommonTemplateDialog_Impl : public SfxListener
      94                 :            : {
      95                 :            : private:
      96                 :            :     class DeletionWatcher;
      97                 :            :     friend class DeletionWatcher;
      98                 :            : 
      99                 :            :     class ISfxTemplateCommon_Impl : public ISfxTemplateCommon
     100                 :            :     {
     101                 :            :     private:
     102                 :            :         SfxCommonTemplateDialog_Impl* pDialog;
     103                 :            :     public:
     104                 :        120 :         ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {}
     105         [ -  + ]:        120 :         virtual ~ISfxTemplateCommon_Impl() {}
     106                 :       1232 :         virtual SfxStyleFamily GetActualFamily() const { return pDialog->GetActualFamily(); }
     107                 :          0 :         virtual String GetSelectedEntry() const { return pDialog->GetSelectedEntry(); }
     108                 :            :     };
     109                 :            : 
     110                 :            :     ISfxTemplateCommon_Impl     aISfxTemplateCommon;
     111                 :            : 
     112                 :            :     void    ReadResource();
     113                 :            :     void    ClearResource();
     114                 :            :     void impl_clear();
     115                 :            :     void impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
     116                 :            : 
     117                 :            : protected:
     118                 :            : #define MAX_FAMILIES            5
     119                 :            : #define COUNT_BOUND_FUNC        13
     120                 :            : 
     121                 :            : #define UPDATE_FAMILY_LIST      0x0001
     122                 :            : #define UPDATE_FAMILY           0x0002
     123                 :            : 
     124                 :            :     friend class DropListBox_Impl;
     125                 :            :     friend class SfxTemplateControllerItem;
     126                 :            :     friend class SfxTemplateDialogWrapper;
     127                 :            : 
     128                 :            :     SfxBindings*                pBindings;
     129                 :            :     SfxTemplateControllerItem*  pBoundItems[COUNT_BOUND_FUNC];
     130                 :            : 
     131                 :            :     Window*                     pWindow;
     132                 :            :     SfxModule*                  pModule;
     133                 :            :     Timer*                      pTimer;
     134                 :            : 
     135                 :            :     ResId*                      m_pStyleFamiliesId;
     136                 :            :     SfxStyleFamilies*           pStyleFamilies;
     137                 :            :     SfxTemplateItem*            pFamilyState[MAX_FAMILIES];
     138                 :            :     SfxStyleSheetBasePool*      pStyleSheetPool;
     139                 :            :     SvTreeListBox*              pTreeBox;
     140                 :            :     SfxObjectShell*             pCurObjShell;
     141                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >
     142                 :            :                                 xModuleManager;
     143                 :            :     DeletionWatcher*            m_pDeletionWatcher;
     144                 :            : 
     145                 :            :     SfxActionListBox            aFmtLb;
     146                 :            :     ListBox                     aFilterLb;
     147                 :            :     Size                        aSize;
     148                 :            : 
     149                 :            :     sal_uInt16                      nActFamily; // Id in the ToolBox = Position - 1
     150                 :            :     sal_uInt16                      nActFilter; // FilterIdx
     151                 :            :     sal_uInt16                      nAppFilter; // Filter, which has set the application (for automatic)
     152                 :            : 
     153                 :            :     sal_Bool                        bDontUpdate             :1,
     154                 :            :                                 bIsWater                :1,
     155                 :            :                                 bEnabled                :1,
     156                 :            :                                 bUpdate                 :1,
     157                 :            :                                 bUpdateFamily           :1,
     158                 :            :                                 bCanEdit                :1,
     159                 :            :                                 bCanDel                 :1,
     160                 :            :                                 bCanNew                 :1,
     161                 :            :                                 bWaterDisabled          :1,
     162                 :            :                                 bNewByExampleDisabled   :1,
     163                 :            :                                 bUpdateByExampleDisabled:1,
     164                 :            :                                 bTreeDrag               :1,
     165                 :            :                                 bHierarchical           :1,
     166                 :            :                                 bBindingUpdate          :1;
     167                 :            : 
     168                 :            :     DECL_LINK( FilterSelectHdl, ListBox * );
     169                 :            :     DECL_LINK( FmtSelectHdl, SvTreeListBox * );
     170                 :            :     DECL_LINK( ApplyHdl, Control * );
     171                 :            :     DECL_LINK( DropHdl, StyleTreeListBox_Impl * );
     172                 :            :     DECL_LINK( TimeOut, Timer * );
     173                 :            : 
     174                 :            : 
     175                 :          0 :     virtual void        EnableItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {}
     176                 :          0 :     virtual void        CheckItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {}
     177                 :          0 :     virtual sal_Bool        IsCheckedItem( sal_uInt16 /*nMesId*/ ) { return sal_True; }
     178                 :          0 :     virtual void        LoadedFamilies() {}
     179                 :          0 :     virtual void        Update() { UpdateStyles_Impl(UPDATE_FAMILY_LIST); }
     180                 :            :     virtual void        InvalidateBindings();
     181                 :            :     virtual void        InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) = 0;
     182                 :            :     virtual void        EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True ) = 0;
     183                 :            :     virtual void        ClearFamilyList() = 0;
     184                 :            :     virtual void        ReplaceUpdateButtonByMenu();
     185                 :            : 
     186                 :            :         void                NewHdl( void* );
     187                 :            :     void                EditHdl( void* );
     188                 :            :     void                DeleteHdl( void* );
     189                 :            : 
     190                 :            :     sal_Bool                Execute_Impl( sal_uInt16 nId, const String& rStr, const String& rRefStr,
     191                 :            :                                       sal_uInt16 nFamily, sal_uInt16 nMask = 0,
     192                 :            :                                       sal_uInt16* pIdx = NULL, const sal_uInt16* pModifier = NULL );
     193                 :            : 
     194                 :            :     void                        UpdateStyles_Impl(sal_uInt16 nFlags);
     195                 :            :     const SfxStyleFamilyItem*   GetFamilyItem_Impl() const;
     196                 :       1662 :     sal_Bool                    IsInitialized() const { return nActFamily != 0xffff; }
     197                 :            :     void                        ResetFocus();
     198                 :            :     void                        EnableDelete();
     199                 :            :     void                        Initialize();
     200                 :            : 
     201                 :            :     void                FilterSelect( sal_uInt16 nFilterIdx, sal_Bool bForce = sal_False );
     202                 :            :     void                SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
     203                 :            :     void                SetWaterCanState( const SfxBoolItem* pItem );
     204                 :            : 
     205                 :            :     void                SelectStyle( const String& rStyle );
     206                 :            :     sal_Bool            HasSelectedStyle() const;
     207                 :            :     SfxStyleSheetBase  *GetSelectedStyle() const;
     208                 :            :     void                FillTreeBox();
     209                 :            :     void                Update_Impl();
     210                 :            :     void                UpdateFamily_Impl();
     211                 :            : 
     212                 :            :     // In which FamilyState do I have to look , in order to get the
     213                 :            :     // information of the ith Family in the pStyleFamilies.
     214                 :            :     sal_uInt16              StyleNrToInfoOffset( sal_uInt16 i );
     215                 :            : 
     216                 :            :     void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     217                 :            : 
     218                 :            :     void                FamilySelect( sal_uInt16 nId );
     219                 :            :     void                SetFamily( sal_uInt16 nId );
     220                 :            :     void                ActionSelect( sal_uInt16 nId );
     221                 :            : 
     222                 :            :     sal_Int32           LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );
     223                 :            :     void                SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter );
     224                 :            : 
     225                 :            : public:
     226                 :            :     TYPEINFO();
     227                 :            : 
     228                 :            :     SfxCommonTemplateDialog_Impl( SfxBindings* pB, SfxDockingWindow* );
     229                 :            :     SfxCommonTemplateDialog_Impl( SfxBindings* pB, ModalDialog* );
     230                 :            :     ~SfxCommonTemplateDialog_Impl();
     231                 :            : 
     232                 :            :     DECL_LINK( MenuSelectHdl, Menu * );
     233                 :            : 
     234                 :        793 :     virtual void        EnableEdit( sal_Bool b = sal_True ) { bCanEdit = b; }
     235                 :       1233 :     virtual void        EnableDel( sal_Bool b = sal_True )  { bCanDel = b; }
     236                 :        444 :     virtual void        EnableNew( sal_Bool b = sal_True )  { bCanNew = b; }
     237                 :            : 
     238                 :       1228 :     ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
     239                 :        240 :     Window*             GetWindow() { return pWindow; }
     240                 :            : 
     241                 :            :     void                EnableTreeDrag( sal_Bool b = sal_True );
     242                 :            :     void                ExecuteContextMenu_Impl( const Point& rPos, Window* pWin );
     243                 :            :     void                EnableExample_Impl( sal_uInt16 nId, sal_Bool bEnable );
     244                 :            :     SfxStyleFamily      GetActualFamily() const;
     245                 :            :     String              GetSelectedEntry() const;
     246                 :          0 :     SfxObjectShell*     GetObjectShell() const { return pCurObjShell; }
     247                 :            : 
     248                 :            :     virtual void        PrepareDeleteAction();  // disable buttons, change button text, etc. when del is going to happen
     249                 :            : 
     250                 :            :     inline sal_Bool         CanEdit( void ) const   { return bCanEdit; }
     251                 :            :     inline sal_Bool         CanDel( void ) const    { return bCanDel; }
     252                 :            :     inline sal_Bool         CanNew( void ) const    { return bCanNew; }
     253                 :            : 
     254                 :            :     // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
     255                 :            :     virtual PopupMenu*  CreateContextMenu( void );
     256                 :            : 
     257                 :            :     // converts from SFX_STYLE_FAMILY Ids to 1-5
     258                 :            :     static sal_uInt16       SfxFamilyIdToNId( SfxStyleFamily nFamily );
     259                 :            : 
     260                 :            :     void                SetAutomaticFilter();
     261                 :            : };
     262                 :            : 
     263                 :            : class DropToolBox_Impl : public ToolBox, public DropTargetHelper
     264                 :            : {
     265                 :            :     SfxTemplateDialog_Impl&     rParent;
     266                 :            : protected:
     267                 :            :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
     268                 :            :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
     269                 :            : public:
     270                 :            :     DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog);
     271                 :            :     ~DropToolBox_Impl();
     272                 :            : };
     273                 :            : // class SfxTemplateDialog_Impl ------------------------------------------
     274                 :            : 
     275                 :            : class SfxTemplateDialog_Impl :  public SfxCommonTemplateDialog_Impl
     276                 :            : {
     277                 :            : private:
     278                 :            :     friend class SfxTemplateControllerItem;
     279                 :            :     friend class SfxTemplateDialogWrapper;
     280                 :            :     friend class DropToolBox_Impl;
     281                 :            : 
     282                 :            :     SfxTemplateDialog*  m_pFloat;
     283                 :            :     sal_Bool                m_bZoomIn;
     284                 :            :     DropToolBox_Impl    m_aActionTbL;
     285                 :            :     ToolBox             m_aActionTbR;
     286                 :            : 
     287                 :            :     DECL_LINK( ToolBoxLSelect, ToolBox * );
     288                 :            :     DECL_LINK( ToolBoxRSelect, ToolBox * );
     289                 :            :     DECL_LINK( ToolBoxRClick, ToolBox * );
     290                 :            :     DECL_LINK( MenuSelectHdl, Menu* );
     291                 :            : 
     292                 :            : protected:
     293                 :            :     virtual void    Command( const CommandEvent& rMEvt );
     294                 :            :     virtual void    EnableEdit( sal_Bool = sal_True );
     295                 :            :     virtual void    EnableItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
     296                 :            :     virtual void    CheckItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
     297                 :            :     virtual sal_Bool    IsCheckedItem( sal_uInt16 nMesId );
     298                 :            :     virtual void    LoadedFamilies();
     299                 :            :     virtual void    InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten );
     300                 :            :     virtual void    EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True );
     301                 :            :     virtual void    ClearFamilyList();
     302                 :            :     virtual void    ReplaceUpdateButtonByMenu();
     303                 :            : 
     304                 :            :     void            Resize();
     305                 :            :     Size            GetMinOutputSizePixel();
     306                 :            : 
     307                 :            :     void            updateFamilyImages();
     308                 :            :     void            updateNonFamilyImages();
     309                 :            : 
     310                 :            : public:
     311                 :            :     friend class SfxTemplateDialog;
     312                 :            :     TYPEINFO();
     313                 :            : 
     314                 :            :     SfxTemplateDialog_Impl( Window* pParent, SfxBindings*, SfxTemplateDialog* pWindow );
     315                 :            :     ~SfxTemplateDialog_Impl();
     316                 :            : };
     317                 :            : 
     318                 :            : // class SfxTemplateCatalog_Impl -----------------------------------------
     319                 :            : 
     320                 :            : class SfxTemplateCatalog_Impl : public SfxCommonTemplateDialog_Impl
     321                 :            : {
     322                 :            : private:
     323                 :            :     friend class SfxTemplateControllerItem;
     324                 :            :     friend class SfxCommonTemplateDialog_Impl;
     325                 :            : 
     326                 :            :     ListBox                 aFamList;
     327                 :            :     OKButton                aOkBtn;
     328                 :            :     CancelButton            aCancelBtn;
     329                 :            :     PushButton              aNewBtn;
     330                 :            :     PushButton              aChangeBtn;
     331                 :            :     PushButton              aDelBtn;
     332                 :            :     PushButton              aOrgBtn;
     333                 :            :     HelpButton              aHelpBtn;
     334                 :            : 
     335                 :            :     SfxTemplateCatalog*     pReal;
     336                 :            :     std::vector<sal_uInt16> aFamIds;
     337                 :            :     SfxModalDefParentHelper aHelper;
     338                 :            : 
     339                 :            : protected:
     340                 :            :     virtual void    EnableItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
     341                 :            :     virtual void    CheckItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
     342                 :            :     virtual sal_Bool    IsCheckedItem( sal_uInt16 nMesId );
     343                 :            :     virtual void    InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten );
     344                 :            :     virtual void    EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True );
     345                 :            :     virtual void    ClearFamilyList();
     346                 :            :     virtual void    EnableEdit( sal_Bool = sal_True );
     347                 :            :     virtual void    EnableDel( sal_Bool = sal_True );
     348                 :            :     virtual void    EnableNew( sal_Bool = sal_True );
     349                 :            : 
     350                 :            :         using SfxCommonTemplateDialog_Impl::NewHdl;
     351                 :            :     DECL_LINK( FamListSelect, ListBox * );
     352                 :            :     DECL_LINK( OkHdl, Button * );
     353                 :            :     DECL_LINK( CancelHdl, Button * );
     354                 :            :     DECL_LINK( NewHdl, Button * );
     355                 :            :     DECL_LINK( ChangeHdl, Button * );
     356                 :            :     DECL_LINK( DelHdl, Button * );
     357                 :            :     DECL_LINK( OrgHdl, Button * );
     358                 :            : 
     359                 :            : public:
     360                 :            :     TYPEINFO();
     361                 :            :     SfxTemplateCatalog_Impl( Window* pParent, SfxBindings*, SfxTemplateCatalog* pWindow );
     362                 :            :     ~SfxTemplateCatalog_Impl();
     363                 :            : 
     364                 :            : friend class SfxTemplateCatalog;
     365                 :            : 
     366                 :            :     virtual void    PrepareDeleteAction();
     367                 :            : };
     368                 :            : 
     369                 :            : #endif // #ifndef _SFX_TEMPDLGI_HXX
     370                 :            : 
     371                 :            : 
     372                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10