LCOV - code coverage report
Current view: top level - sc/source/ui/inc - anyrefdg.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-08-25 Functions: 0 25 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 26 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_ANYREFDG_HXX
      30                 :            : #define SC_ANYREFDG_HXX
      31                 :            : 
      32                 :            : #include <vcl/button.hxx>
      33                 :            : #include <vcl/edit.hxx>
      34                 :            : #include <vcl/accel.hxx>
      35                 :            : #include <sfx2/basedlgs.hxx>
      36                 :            : #include <sfx2/tabdlg.hxx>
      37                 :            : #include "address.hxx"
      38                 :            : #include "cell.hxx"
      39                 :            : #include "compiler.hxx"
      40                 :            : #include "formula/funcutl.hxx"
      41                 :            : #include "IAnyRefDialog.hxx"
      42                 :            : #include "scresid.hxx"
      43                 :            : #include "scmod.hxx"
      44                 :            : 
      45                 :            : #include <memory>
      46                 :            : 
      47                 :            : class SfxObjectShell;
      48                 :            : class ScRange;
      49                 :            : class ScDocument;
      50                 :            : class ScTabViewShell;
      51                 :            : class ScRefHandler;
      52                 :            : class ScRangeList;
      53                 :            : 
      54                 :            : class ScFormulaReferenceHelper
      55                 :            : {
      56                 :            :     IAnyRefDialog*      m_pDlg;
      57                 :            :     ::std::auto_ptr<ScFormulaCell>      pRefCell;
      58                 :            :     ::std::auto_ptr<ScCompiler>         pRefComp;
      59                 :            :     formula::RefEdit*    pRefEdit;               // active input field
      60                 :            :     formula::RefButton*  pRefBtn;                // associated button
      61                 :            :     Window*             m_pWindow;
      62                 :            :     SfxBindings*        m_pBindings;
      63                 :            :     ::std::auto_ptr<Accelerator>
      64                 :            :                         pAccel;                 // for Enter/Escape
      65                 :            :     sal_Bool*               pHiddenMarks;           // Mark field for hidden Controls
      66                 :            :     SCTAB               nRefTab;                // used for ShowReference
      67                 :            : 
      68                 :            :     String              sOldDialogText;         // Original title of the dialog window
      69                 :            :     Size                aOldDialogSize;         // Original size of the dialog window
      70                 :            :     Point               aOldEditPos;            // Original position of the input field
      71                 :            :     Size                aOldEditSize;           // Original size of the input field
      72                 :            :     Point               aOldButtonPos;          // Original position of the button
      73                 :            : 
      74                 :            :     sal_Bool                bEnableColorRef;
      75                 :            :     sal_Bool                bHighLightRef;
      76                 :            :     sal_Bool                bAccInserted;
      77                 :            : 
      78                 :            :     DECL_LINK( AccelSelectHdl, Accelerator* );
      79                 :            : 
      80                 :            : public:
      81                 :            :     ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings);
      82                 :            :     ~ScFormulaReferenceHelper();
      83                 :            : 
      84                 :            :     void                ShowSimpleReference( const XubString& rStr );
      85                 :            :     void                ShowFormulaReference( const XubString& rStr );
      86                 :            :     bool                ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
      87                 :            :     void                Init();
      88                 :            : 
      89                 :            :     void                ShowReference( const XubString& rStr );
      90                 :            :     void                ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      91                 :            :     void                HideReference( sal_Bool bDoneRefMode = sal_True );
      92                 :            :     void                RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      93                 :            :     void                RefInputDone( sal_Bool bForced = false );
      94                 :            :     void                ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      95                 :            : 
      96                 :          0 :     inline void         SetWindow(Window* _pWindow) { m_pWindow = _pWindow; }
      97                 :            :     sal_Bool                DoClose( sal_uInt16 nId );
      98                 :            :     void                SetDispatcherLock( sal_Bool bLock );
      99                 :            :     void                EnableSpreadsheets( sal_Bool bFlag = sal_True, sal_Bool bChildren = sal_True );
     100                 :            :     void                ViewShellChanged( ScTabViewShell* pScViewShell );
     101                 :            : 
     102                 :            :     static              void enableInput(sal_Bool _bInput);
     103                 :            : 
     104                 :            : protected:
     105                 :            :     Window      *       GetWindow(){ return m_pWindow; }
     106                 :            : 
     107                 :            : public:
     108                 :          0 :     bool                CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; }
     109 [ #  # ][ #  # ]:          0 :     bool                CanInputDone( sal_Bool bForced ){   return pRefEdit && (bForced || !pRefBtn);   }
                 [ #  # ]
     110                 :            : };
     111                 :            : 
     112                 :            : //============================================================================
     113                 :            : 
     114                 :            : class SC_DLLPUBLIC ScRefHandler : //public SfxModelessDialog,
     115                 :            :                     public IAnyRefDialog
     116                 :            : {
     117                 :            :     Window &    m_rWindow;
     118                 :            :     bool        m_bInRefMode;
     119                 :            : 
     120                 :            : public:
     121                 :          0 :     operator Window *(){ return &m_rWindow; }
     122                 :            :     Window  * operator ->() { return static_cast<Window *>(*this); }
     123                 :            :     friend class        formula::RefButton;
     124                 :            :     friend class        formula::RefEdit;
     125                 :            : 
     126                 :            : private:
     127                 :            :     ScFormulaReferenceHelper
     128                 :            :                         m_aHelper;
     129                 :            :     SfxBindings*        pMyBindings;
     130                 :            : 
     131                 :            :     Window*             pActiveWin;
     132                 :            :     Timer               aTimer;
     133                 :            :     String              aDocName;               // document on which the dialog was opened
     134                 :            : 
     135                 :            :     DECL_LINK( UpdateFocusHdl, void* );
     136                 :            : 
     137                 :            : 
     138                 :            : protected:
     139                 :            :     virtual sal_Bool        DoClose( sal_uInt16 nId );
     140                 :            : 
     141                 :            :     void                SetDispatcherLock( sal_Bool bLock );
     142                 :            : 
     143                 :            :     //Overwrite TWindow will implemented by ScRefHdlrImplBase
     144                 :            :     //virtual long        PreNotify( NotifyEvent& rNEvt );
     145                 :            : 
     146                 :            :     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     147                 :            :     virtual void        RefInputDone( sal_Bool bForced = false );
     148                 :            :     void                ShowSimpleReference( const XubString& rStr );
     149                 :            :     void                ShowFormulaReference( const XubString& rStr );
     150                 :            : 
     151                 :            :     bool                ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
     152                 :            : 
     153                 :            :     void preNotify(const NotifyEvent& rEvent, const bool bBindRef);
     154                 :            :     void stateChanged(const StateChangedType nStateChange, const bool bBindRef);
     155                 :            : 
     156                 :            : public:
     157                 :            :                         ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
     158                 :            :                                      Window* pParent, sal_uInt16 nResId*/, bool bBindRef );
     159                 :            :     virtual             ~ScRefHandler();
     160                 :            : 
     161                 :            :     virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
     162                 :            :     virtual void        AddRefEntry();
     163                 :            : 
     164                 :            :     virtual sal_Bool        IsRefInputMode() const;
     165                 :            :     virtual sal_Bool        IsTableLocked() const;
     166                 :            :     virtual sal_Bool        IsDocAllowed( SfxObjectShell* pDocSh ) const;
     167                 :            : 
     168                 :            :     virtual void        ShowReference( const XubString& rStr );
     169                 :            :     virtual void        HideReference( sal_Bool bDoneRefMode = sal_True );
     170                 :            : 
     171                 :            :     virtual void        ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     172                 :            :     virtual void        ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     173                 :            : 
     174                 :            :     virtual void        ViewShellChanged( ScTabViewShell* pScViewShell );
     175                 :            :     void                SwitchToDocument();
     176                 :            :     //SfxBindings&        GetBindings();
     177                 :            : 
     178                 :            :     virtual void        SetActive() = 0;
     179                 :            : //  virtual sal_Bool        Close();
     180                 :            :     //Overwrite TWindow will implemented by ScRefHdlrImplBase
     181                 :            :     //virtual void        StateChanged( StateChangedType nStateChange );
     182                 :            : 
     183                 :            : public:
     184                 :            :     bool                EnterRefMode();
     185                 :            :     bool                LeaveRefMode();
     186                 :            :     inline  bool        CanInputStart( const formula::RefEdit *pEdit );
     187                 :            :     inline  bool        CanInputDone( sal_Bool bForced );
     188                 :            : };
     189                 :            : 
     190                 :            : //============================================================================
     191                 :            : 
     192                 :            : template<  class TWindow, bool bBindRef = true >
     193                 :            : class ScRefHdlrImplBase:public TWindow, public ScRefHandler
     194                 :            : {
     195                 :            : public:
     196                 :            :     //Overwrite TWindow
     197                 :            :     virtual long        PreNotify( NotifyEvent& rNEvt );
     198                 :            :     virtual void        StateChanged( StateChangedType nStateChange );
     199                 :            : 
     200                 :            : private:
     201                 :            :     template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     202                 :            :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     203                 :            :         TParentWindow* pParent, TResId nResId);
     204                 :            : 
     205                 :            :     template<class TParentWindow, class TResId, class TArg>
     206                 :            :     ScRefHdlrImplBase( TParentWindow* pParent, TResId nResId, const TArg &rArg, SfxBindings *pB = NULL );
     207                 :            : 
     208                 :            :     ~ScRefHdlrImplBase();
     209                 :            : 
     210                 :            :     template<class, class, bool> friend struct ScRefHdlrImpl;
     211                 :            : };
     212                 :            : 
     213                 :            : template<class TWindow, bool bBindRef>
     214                 :            : template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     215                 :          0 : ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     216 [ #  # ][ #  # ]:          0 :                  TParentWindow* pParent, TResId nResId):TWindow(pB, pCW, pParent, ScResId(static_cast<sal_uInt16>( nResId ) ) ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
     217                 :            : 
     218                 :            : template<class TWindow, bool bBindRef >
     219                 :            : template<class TParentWindow, class TResId, class TArg>
     220                 :          0 : ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB /*= NULL*/ )
     221                 :          0 : :TWindow( pParent, ScResId(static_cast<sal_uInt16>( nResIdP )), rArg ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
     222                 :            : 
     223                 :            : template<class TWindow, bool bBindRef >
     224 [ #  # ][ #  # ]:          0 : ScRefHdlrImplBase<TWindow,bBindRef>::~ScRefHdlrImplBase(){}
     225                 :            : 
     226                 :            : template<class TWindow, bool bBindRef>
     227                 :          0 : long ScRefHdlrImplBase<TWindow, bBindRef>::PreNotify( NotifyEvent& rNEvt )
     228                 :            : {
     229                 :          0 :     ScRefHandler::preNotify( rNEvt, bBindRef );
     230                 :          0 :     return TWindow::PreNotify( rNEvt );
     231                 :            : }
     232                 :            : 
     233                 :            : template<class TWindow, bool bBindRef>
     234                 :          0 : void ScRefHdlrImplBase<TWindow, bBindRef>::StateChanged( StateChangedType nStateChange )
     235                 :            : {
     236                 :          0 :     TWindow::StateChanged( nStateChange );
     237                 :          0 :     ScRefHandler::stateChanged( nStateChange, bBindRef );
     238                 :          0 : }
     239                 :            : 
     240                 :            : //============================================================================
     241                 :            : template<class TDerived, class TBase, bool bBindRef = true>
     242                 :            : struct ScRefHdlrImpl: ScRefHdlrImplBase<TBase, bBindRef >
     243                 :            : {
     244                 :            :     enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
     245                 :            : 
     246                 :            :     template<class T1, class T2, class T3, class T4>
     247                 :          0 :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4 )
     248                 :            :     {
     249 [ #  # ][ #  # ]:          0 :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     250                 :          0 :     }
     251                 :            : 
     252                 :          0 :     ~ScRefHdlrImpl()
     253                 :            :     {
     254         [ #  # ]:          0 :         SC_MOD()->UnregisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
           [ #  #  #  # ]
     255                 :          0 :     }
     256                 :            : };
     257                 :            : //============================================================================
     258         [ #  # ]:          0 : struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
     259                 :            : {
     260                 :            :     template<class T1, class T2, class T3, class T4>
     261                 :          0 :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4){}
     262                 :            : };
     263                 :            : //============================================================================
     264                 :            : 
     265                 :          0 : inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit )
     266                 :            : {
     267                 :          0 :     return m_aHelper.CanInputStart( pEdit );
     268                 :            : }
     269                 :            : 
     270                 :          0 : inline  bool ScRefHandler::CanInputDone( sal_Bool bForced )
     271                 :            : {
     272                 :          0 :     return m_aHelper.CanInputDone( bForced );
     273                 :            : }
     274                 :            : 
     275                 :            : #endif // SC_ANYREFDG_HXX
     276                 :            : 
     277                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10