LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/inc - anyrefdg.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 30 0.0 %
Date: 2012-12-27 Functions: 0 29 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 "cell.hxx"
      30             : #include "compiler.hxx"
      31             : #include "formula/funcutl.hxx"
      32             : #include "IAnyRefDialog.hxx"
      33             : #include "scresid.hxx"
      34             : #include "scmod.hxx"
      35             : 
      36             : #include <memory>
      37             : 
      38             : class SfxObjectShell;
      39             : class ScRange;
      40             : class ScDocument;
      41             : class ScTabViewShell;
      42             : class ScRefHandler;
      43             : class ScRangeList;
      44             : 
      45             : class ScFormulaReferenceHelper
      46             : {
      47             :     IAnyRefDialog*      m_pDlg;
      48             :     ::std::auto_ptr<ScFormulaCell>      pRefCell;
      49             :     ::std::auto_ptr<ScCompiler>         pRefComp;
      50             :     formula::RefEdit*    pRefEdit;               // active input field
      51             :     formula::RefButton*  pRefBtn;                // associated button
      52             :     Window*             m_pWindow;
      53             :     SfxBindings*        m_pBindings;
      54             :     ::std::auto_ptr<Accelerator>
      55             :                         pAccel;                 // for Enter/Escape
      56             :     bool*               pHiddenMarks;           // Mark field for hidden Controls
      57             :     SCTAB               nRefTab;                // used for ShowReference
      58             : 
      59             :     String              sOldDialogText;         // Original title of the dialog window
      60             :     Size                aOldDialogSize;         // Original size of the dialog window
      61             :     Point               aOldEditPos;            // Original position of the input field
      62             :     Size                aOldEditSize;           // Original size of the input field
      63             :     Point               aOldButtonPos;          // Original position of the button
      64             :     Window*             mpOldEditParent;        // Original parent of the edit field and the button
      65             : 
      66             :     bool                bEnableColorRef;
      67             :     bool                bHighLightRef;
      68             :     bool                bAccInserted;
      69             : 
      70             :     DECL_LINK( AccelSelectHdl, Accelerator* );
      71             : 
      72             : public:
      73             :     ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings);
      74             :     ~ScFormulaReferenceHelper();
      75             : 
      76             :     void                ShowSimpleReference( const XubString& rStr );
      77             :     void                ShowFormulaReference( const XubString& rStr );
      78             :     bool                ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
      79             :     void                Init();
      80             : 
      81             :     void                ShowReference( const XubString& rStr );
      82             :     void                ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      83             :     void                HideReference( bool bDoneRefMode = true );
      84             :     void                RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      85             :     void                RefInputDone( bool bForced = false );
      86             :     void                ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
      87             : 
      88           0 :     inline void         SetWindow(Window* _pWindow) { m_pWindow = _pWindow; }
      89             :     bool                DoClose( sal_uInt16 nId );
      90             :     void                SetDispatcherLock( bool bLock );
      91             :     void                EnableSpreadsheets( bool bFlag = true, bool bChildren = true );
      92             :     void                ViewShellChanged();
      93             : 
      94             :     static              void enableInput(bool _bInput);
      95             : 
      96             : protected:
      97             :     Window      *       GetWindow(){ return m_pWindow; }
      98             : 
      99             : public:
     100           0 :     bool                CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; }
     101           0 :     bool                CanInputDone( bool bForced ){   return pRefEdit && (bForced || !pRefBtn);   }
     102             : };
     103             : 
     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             :     String              aDocName;               // document on which the dialog was opened
     126             : 
     127             :     DECL_LINK( UpdateFocusHdl, void* );
     128             : 
     129             : 
     130             : protected:
     131             :     virtual sal_Bool        DoClose( sal_uInt16 nId );
     132             : 
     133             :     void                SetDispatcherLock( bool bLock );
     134             : 
     135             :     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     136             :     virtual void        RefInputDone( sal_Bool bForced = false );
     137             :     void                ShowSimpleReference( const XubString& rStr );
     138             :     void                ShowFormulaReference( const XubString& rStr );
     139             : 
     140             :     bool                ParseWithNames( ScRangeList& rRanges, const String& 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 ) = 0;
     150             :     virtual void        AddRefEntry();
     151             : 
     152             :     virtual sal_Bool        IsRefInputMode() const;
     153             :     virtual sal_Bool        IsTableLocked() const;
     154             :     virtual sal_Bool        IsDocAllowed( SfxObjectShell* pDocSh ) const;
     155             : 
     156             :     virtual void        ShowReference( const XubString& rStr );
     157             :     virtual void        HideReference( sal_Bool bDoneRefMode = sal_True );
     158             : 
     159             :     virtual void        ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     160             :     virtual void        ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     161             : 
     162             :     virtual void        ViewShellChanged();
     163             :     void                SwitchToDocument();
     164             : 
     165             :     virtual void        SetActive() = 0;
     166             : 
     167             : public:
     168             :     bool                EnterRefMode();
     169             :     bool                LeaveRefMode();
     170             :     inline  bool        CanInputStart( const formula::RefEdit *pEdit );
     171             :     inline  bool        CanInputDone( sal_Bool bForced );
     172             : };
     173             : 
     174             : //============================================================================
     175             : 
     176             : 
     177           0 : class ScRefHdlModalImpl : public ModalDialog, public ScRefHandler
     178             : {
     179             : public:
     180             : 
     181             :     virtual long        PreNotify( NotifyEvent& rNEvt );
     182             :     virtual void        StateChanged( StateChangedType nStateChange );
     183             : protected:
     184             :     ScRefHdlModalImpl( Window* pParent, ResId& rResId );
     185             : 
     186             : private:
     187             : };
     188             : 
     189             : template<  class TWindow, bool bBindRef = true >
     190             : class ScRefHdlrImplBase: public TWindow, public ScRefHandler
     191             : {
     192             : public:
     193             :     virtual long        PreNotify( NotifyEvent& rNEvt );
     194             :     virtual void        StateChanged( StateChangedType nStateChange );
     195             : 
     196             : private:
     197             :     template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     198             :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     199             :         TParentWindow* pParent, TResId nResId);
     200             : 
     201             :     template<class TParentWindow, class TResId, class TArg>
     202             :     ScRefHdlrImplBase( TParentWindow* pParent, TResId nResId, const TArg &rArg, SfxBindings *pB = NULL );
     203             : 
     204             :     ~ScRefHdlrImplBase();
     205             : 
     206             :     template<class, class, bool> friend struct ScRefHdlrImpl;
     207             : };
     208             : 
     209             : template<class TWindow, bool bBindRef>
     210             : template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     211           0 : ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     212           0 :                  TParentWindow* pParent, TResId nResId):TWindow(pB, pCW, pParent, ScResId(static_cast<sal_uInt16>( nResId ) ) ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
     213             : 
     214             : template<class TWindow, bool bBindRef >
     215             : template<class TParentWindow, class TResId, class TArg>
     216           0 : ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB )
     217           0 : :TWindow( pParent, ScResId(static_cast<sal_uInt16>( nResIdP )), rArg ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
     218             : 
     219             : template<class TWindow, bool bBindRef >
     220           0 : ScRefHdlrImplBase<TWindow,bBindRef>::~ScRefHdlrImplBase(){}
     221             : 
     222             : template<class TWindow, bool bBindRef>
     223           0 : long ScRefHdlrImplBase<TWindow, bBindRef>::PreNotify( NotifyEvent& rNEvt )
     224             : {
     225           0 :     ScRefHandler::preNotify( rNEvt, bBindRef );
     226           0 :     return TWindow::PreNotify( rNEvt );
     227             : }
     228             : 
     229             : template<class TWindow, bool bBindRef>
     230           0 : void ScRefHdlrImplBase<TWindow, bBindRef>::StateChanged( StateChangedType nStateChange )
     231             : {
     232           0 :     TWindow::StateChanged( nStateChange );
     233           0 :     ScRefHandler::stateChanged( nStateChange, bBindRef );
     234           0 : }
     235             : 
     236           0 : class ScAnyRefModalDlg : public ScRefHdlModalImpl
     237             : {
     238             : public:
     239             :     ScAnyRefModalDlg(Window* pParent, ResId rResId);
     240             : };
     241             : 
     242             : //============================================================================
     243             : template<class TDerived, class TBase, bool bBindRef = true>
     244             : struct ScRefHdlrImpl: ScRefHdlrImplBase< TBase, bBindRef >
     245             : {
     246             :     enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
     247             : 
     248             :     template<class T1, class T2, class T3, class T4>
     249           0 :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ):ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4 )
     250             :     {
     251           0 :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     252           0 :     }
     253             : 
     254           0 :     ~ScRefHdlrImpl()
     255             :     {
     256           0 :         SC_MOD()->UnregisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     257           0 :     }
     258             : };
     259             : //============================================================================
     260           0 : struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
     261             : {
     262             :     template<class T1, class T2, class T3, class T4>
     263           0 :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ):ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4){}
     264             : };
     265             : //============================================================================
     266             : 
     267           0 : inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit )
     268             : {
     269           0 :     return m_aHelper.CanInputStart( pEdit );
     270             : }
     271             : 
     272           0 : inline  bool ScRefHandler::CanInputDone( sal_Bool bForced )
     273             : {
     274           0 :     return m_aHelper.CanInputDone( bForced );
     275             : }
     276             : 
     277             : #endif // SC_ANYREFDG_HXX
     278             : 
     279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10