LCOV - code coverage report
Current view: top level - sc/source/ui/inc - anyrefdg.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 35 0.0 %
Date: 2014-04-14 Functions: 0 53 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             : 
      20             : #ifndef SC_ANYREFDG_HXX
      21             : #define SC_ANYREFDG_HXX
      22             : 
      23             : #include <vcl/button.hxx>
      24             : #include <vcl/edit.hxx>
      25             : #include <vcl/accel.hxx>
      26             : #include <sfx2/basedlgs.hxx>
      27             : #include <sfx2/tabdlg.hxx>
      28             : #include "address.hxx"
      29             : #include "compiler.hxx"
      30             : #include "formula/funcutl.hxx"
      31             : #include "IAnyRefDialog.hxx"
      32             : #include "scresid.hxx"
      33             : #include "scmod.hxx"
      34             : 
      35             : #include <memory>
      36             : 
      37             : class SfxObjectShell;
      38             : class ScRange;
      39             : class ScDocument;
      40             : class ScTabViewShell;
      41             : class ScRefHandler;
      42             : class ScRangeList;
      43             : 
      44             : class ScFormulaReferenceHelper
      45             : {
      46             :     IAnyRefDialog*      m_pDlg;
      47             :     ::std::auto_ptr<ScCompiler>         pRefComp;
      48             :     formula::RefEdit*    pRefEdit;               // active input field
      49             :     formula::RefButton*  pRefBtn;                // associated button
      50             :     Window*             m_pWindow;
      51             :     SfxBindings*        m_pBindings;
      52             :     ::std::auto_ptr<Accelerator>
      53             :                         pAccel;                 // for Enter/Escape
      54             :     ::std::vector<Window*> m_aHiddenWidgets;    // vector of hidden Controls
      55             :     sal_Int32           m_nOldBorderWidth;      // border width for expanded dialog
      56             :     SCTAB               nRefTab;                // used for ShowReference
      57             : 
      58             :     OUString            sOldDialogText;         // Original title of the dialog window
      59             :     Size                aOldDialogSize;         // Original size of the dialog window
      60             :     Point               aOldEditPos;            // Original position of the input field
      61             :     Size                aOldEditSize;           // Original size of the input field
      62             :     long                mnOldEditWidthReq;
      63             :     Point               aOldButtonPos;          // Original position of the button
      64             :     Window*             mpOldEditParent;        // Original parent of the edit field and the button
      65             :     bool                mbOldDlgLayoutEnabled;  // Original layout state of parent dialog
      66             :     bool                mbOldEditParentLayoutEnabled;  // Original layout state of edit widget parent
      67             : 
      68             :     bool                bEnableColorRef;
      69             :     bool                bHighlightRef;
      70             :     bool                bAccInserted;
      71             : 
      72             :     DECL_LINK( AccelSelectHdl, Accelerator* );
      73             : 
      74             : public:
      75             :     ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings);
      76             :     ~ScFormulaReferenceHelper();
      77             : 
      78             :     void                ShowSimpleReference(const OUString& rStr);
      79             :     void                ShowFormulaReference(const OUString& rStr);
      80             :     bool                ParseWithNames( ScRangeList& rRanges, const OUString& rStr, ScDocument* pDoc );
      81             :     void                Init();
      82             : 
      83             :     void                ShowReference(const OUString& rStr);
      84             :     void                ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      85             :     void                HideReference( bool bDoneRefMode = true );
      86             :     void                RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      87             :     void                RefInputDone( bool bForced = false );
      88             :     void                ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      89             : 
      90           0 :     inline void         SetWindow(Window* _pWindow) { m_pWindow = _pWindow; }
      91             :     bool                DoClose( sal_uInt16 nId );
      92             :     void                SetDispatcherLock( bool bLock );
      93             :     void                EnableSpreadsheets( bool bFlag = true, bool bChildren = true );
      94             :     void                ViewShellChanged();
      95             : 
      96             :     static              void enableInput(bool _bInput);
      97             : 
      98             : protected:
      99             :     Window      *       GetWindow(){ return m_pWindow; }
     100             : 
     101             : public:
     102           0 :     bool                CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; }
     103           0 :     bool                CanInputDone( bool bForced ){   return pRefEdit && (bForced || !pRefBtn);   }
     104             : };
     105             : 
     106             : class SC_DLLPUBLIC ScRefHandler :
     107             :                     public IAnyRefDialog
     108             : {
     109             :     Window &    m_rWindow;
     110             :     bool        m_bInRefMode;
     111             : 
     112             : public:
     113           0 :     operator Window *(){ return &m_rWindow; }
     114             :     Window  * operator ->() { return static_cast<Window *>(*this); }
     115             :     friend class        formula::RefButton;
     116             :     friend class        formula::RefEdit;
     117             : 
     118             : private:
     119             :     ScFormulaReferenceHelper
     120             :                         m_aHelper;
     121             :     SfxBindings*        pMyBindings;
     122             : 
     123             :     Window*             pActiveWin;
     124             :     Timer               aTimer;
     125             :     OUString            aDocName;               // document on which the dialog was opened
     126             : 
     127             :     DECL_LINK( UpdateFocusHdl, void* );
     128             : 
     129             : 
     130             : protected:
     131             :     virtual bool        DoClose( sal_uInt16 nId );
     132             : 
     133             :     void                SetDispatcherLock( bool bLock );
     134             : 
     135             :     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) SAL_OVERRIDE;
     136             :     virtual void        RefInputDone( bool bForced = false ) SAL_OVERRIDE;
     137             :     void                ShowSimpleReference(const OUString& rStr);
     138             :     void                ShowFormulaReference(const OUString& rStr);
     139             : 
     140             :     bool                ParseWithNames( ScRangeList& rRanges, const OUString& rStr, ScDocument* pDoc );
     141             : 
     142             :     void preNotify(const NotifyEvent& rEvent, const bool bBindRef);
     143             :     void stateChanged(const StateChangedType nStateChange, const bool bBindRef);
     144             : 
     145             : public:
     146             :                         ScRefHandler( Window &rWindow, SfxBindings* pB, bool bBindRef );
     147             :     virtual             ~ScRefHandler();
     148             : 
     149             :     virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) SAL_OVERRIDE = 0;
     150             :     virtual void        AddRefEntry() SAL_OVERRIDE;
     151             : 
     152             :     virtual bool        IsRefInputMode() const SAL_OVERRIDE;
     153             :     virtual bool        IsTableLocked() const SAL_OVERRIDE;
     154             :     virtual bool        IsDocAllowed( SfxObjectShell* pDocSh ) const SAL_OVERRIDE;
     155             : 
     156             :     virtual void        ShowReference(const OUString& rStr) SAL_OVERRIDE;
     157             :     virtual void        HideReference( bool bDoneRefMode = true ) SAL_OVERRIDE;
     158             : 
     159             :     virtual void        ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) SAL_OVERRIDE;
     160             :     virtual void        ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) SAL_OVERRIDE;
     161             : 
     162             :     virtual void        ViewShellChanged() SAL_OVERRIDE;
     163             :     void                SwitchToDocument();
     164             : 
     165             :     virtual void        SetActive() SAL_OVERRIDE = 0;
     166             : 
     167             : public:
     168             :     bool                EnterRefMode();
     169             :     bool                LeaveRefMode();
     170             :     inline  bool        CanInputStart( const formula::RefEdit *pEdit );
     171             :     inline  bool        CanInputDone( bool bForced );
     172             : };
     173             : 
     174             : 
     175           0 : class ScRefHdlModalImpl : public ModalDialog, public ScRefHandler
     176             : {
     177             : public:
     178             : 
     179             :     virtual bool        PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     180             :     virtual void        StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
     181             : protected:
     182             :     ScRefHdlModalImpl(Window* pParent, const OString& rID,
     183             :         const OUString& rUIXMLDescription);
     184             : 
     185             : private:
     186             : };
     187             : 
     188             : template<  class TWindow, bool bBindRef = true >
     189             : class ScRefHdlrImplBase: public TWindow, public ScRefHandler
     190             : {
     191             : public:
     192             :     virtual bool        PreNotify( NotifyEvent& rNEvt );
     193             :     virtual void        StateChanged( StateChangedType nStateChange );
     194             : 
     195             : private:
     196             :     template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     197             :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     198             :         TParentWindow* pParent, TResId nResId );
     199             : 
     200             :     template<class TBindings, class TChildWindow, class TParentWindow >
     201             :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     202             :         TParentWindow* pParent, const OString& rID, const OUString& rUIXMLDescription );
     203             : 
     204             :     template<class TParentWindow, class TResId, class TArg>
     205             :     ScRefHdlrImplBase( TParentWindow* pParent, TResId nResId, const TArg &rArg, SfxBindings *pB = NULL );
     206             : 
     207             :     template<class TParentWindow, class TArg>
     208             :     ScRefHdlrImplBase( TParentWindow* pParent, const OString& rID, const OUString& rUIXMLDescription, const TArg &rArg, SfxBindings *pB = NULL );
     209             : 
     210             :     virtual ~ScRefHdlrImplBase();
     211             : 
     212             :     template<class, class, bool> friend struct ScRefHdlrImpl;
     213             : };
     214             : 
     215             : template<class TWindow, bool bBindRef>
     216             : template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     217             : ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     218             :                  TParentWindow* pParent, TResId nResId)
     219             :     : TWindow(pB, pCW, pParent, ScResId(static_cast<sal_uInt16>( nResId ) ) )
     220             :     , ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     221             : {
     222             : }
     223             : 
     224             : template<class TWindow, bool bBindRef>
     225             : template<class TBindings, class TChildWindow, class TParentWindow>
     226           0 : ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     227             :                  TParentWindow* pParent, const OString& rID, const OUString& rUIXMLDescription )
     228             :     : TWindow(pB, pCW, pParent, rID, rUIXMLDescription )
     229           0 :     , ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     230             : {
     231           0 : }
     232             : 
     233             : template<class TWindow, bool bBindRef >
     234             : template<class TParentWindow, class TResId, class TArg>
     235             : ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB )
     236             :     : TWindow( pParent, ScResId(static_cast<sal_uInt16>( nResIdP )), rArg ),
     237             :     ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     238             : {
     239             : }
     240             : 
     241             : template<class TWindow, bool bBindRef >
     242             : template<class TParentWindow, class TArg>
     243           0 : ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, const OString& rID, const OUString& rUIXMLDescription, const TArg &rArg, SfxBindings *pB )
     244             :     : TWindow( pParent, rID, rUIXMLDescription, rArg ),
     245           0 :     ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     246             : {
     247           0 : }
     248             : 
     249             : 
     250             : template<class TWindow, bool bBindRef >
     251           0 : ScRefHdlrImplBase<TWindow,bBindRef>::~ScRefHdlrImplBase(){}
     252             : 
     253             : template<class TWindow, bool bBindRef>
     254           0 : bool ScRefHdlrImplBase<TWindow, bBindRef>::PreNotify( NotifyEvent& rNEvt )
     255             : {
     256           0 :     ScRefHandler::preNotify( rNEvt, bBindRef );
     257           0 :     return TWindow::PreNotify( rNEvt );
     258             : }
     259             : 
     260             : template<class TWindow, bool bBindRef>
     261           0 : void ScRefHdlrImplBase<TWindow, bBindRef>::StateChanged( StateChangedType nStateChange )
     262             : {
     263           0 :     TWindow::StateChanged( nStateChange );
     264           0 :     ScRefHandler::stateChanged( nStateChange, bBindRef );
     265           0 : }
     266             : 
     267           0 : class ScAnyRefModalDlg : public ScRefHdlModalImpl
     268             : {
     269             : public:
     270             :     ScAnyRefModalDlg(Window* pParent, const OString& rID,
     271             :         const OUString& rUIXMLDescription);
     272             : };
     273             : 
     274             : 
     275             : template<class TDerived, class TBase, bool bBindRef = true>
     276             : struct ScRefHdlrImpl: ScRefHdlrImplBase< TBase, bBindRef >
     277             : {
     278             :     enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
     279             : 
     280             :     template<class T1, class T2, class T3, class T4>
     281             :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 )
     282             :         : ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4)
     283             :     {
     284             :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     285             :     }
     286             : 
     287             :     template<class T1, class T2, class T3, class T4, class T5>
     288           0 :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 )
     289           0 :         : ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4, rt5)
     290             :     {
     291           0 :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     292           0 :     }
     293             : 
     294           0 :     ~ScRefHdlrImpl()
     295             :     {
     296           0 :         SC_MOD()->UnregisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     297           0 :     }
     298             : };
     299             : 
     300           0 : struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
     301             : {
     302             :     template<class T1, class T2, class T3, class T4>
     303             :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 )
     304             :         : ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4)
     305             :     {
     306             :     }
     307             : 
     308             :     template<class T1, class T2, class T3, class T4, class T5>
     309           0 :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 )
     310           0 :         : ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4, rt5)
     311             :     {
     312           0 :     }
     313             : };
     314             : 
     315             : 
     316           0 : inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit )
     317             : {
     318           0 :     return m_aHelper.CanInputStart( pEdit );
     319             : }
     320             : 
     321           0 : inline  bool ScRefHandler::CanInputDone( bool bForced )
     322             : {
     323           0 :     return m_aHelper.CanInputDone( bForced );
     324             : }
     325             : 
     326             : #endif // SC_ANYREFDG_HXX
     327             : 
     328             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10