LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/inc - anyrefdg.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 45 0.0 %
Date: 2013-07-09 Functions: 0 38 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             :     String              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 XubString& rStr );
      79             :     void                ShowFormulaReference( const XubString& rStr );
      80             :     bool                ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
      81             :     void                Init();
      82             : 
      83             :     void                ShowReference( const XubString& 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             : //============================================================================
     107             : 
     108             : class SC_DLLPUBLIC ScRefHandler :
     109             :                     public IAnyRefDialog
     110             : {
     111             :     Window &    m_rWindow;
     112             :     bool        m_bInRefMode;
     113             : 
     114             : public:
     115           0 :     operator Window *(){ return &m_rWindow; }
     116             :     Window  * operator ->() { return static_cast<Window *>(*this); }
     117             :     friend class        formula::RefButton;
     118             :     friend class        formula::RefEdit;
     119             : 
     120             : private:
     121             :     ScFormulaReferenceHelper
     122             :                         m_aHelper;
     123             :     SfxBindings*        pMyBindings;
     124             : 
     125             :     Window*             pActiveWin;
     126             :     Timer               aTimer;
     127             :     String              aDocName;               // document on which the dialog was opened
     128             : 
     129             :     DECL_LINK( UpdateFocusHdl, void* );
     130             : 
     131             : 
     132             : protected:
     133             :     virtual sal_Bool        DoClose( sal_uInt16 nId );
     134             : 
     135             :     void                SetDispatcherLock( bool bLock );
     136             : 
     137             :     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     138             :     virtual void        RefInputDone( sal_Bool bForced = false );
     139             :     void                ShowSimpleReference( const XubString& rStr );
     140             :     void                ShowFormulaReference( const XubString& rStr );
     141             : 
     142             :     bool                ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
     143             : 
     144             :     void preNotify(const NotifyEvent& rEvent, const bool bBindRef);
     145             :     void stateChanged(const StateChangedType nStateChange, const bool bBindRef);
     146             : 
     147             : public:
     148             :                         ScRefHandler( Window &rWindow, SfxBindings* pB, bool bBindRef );
     149             :     virtual             ~ScRefHandler();
     150             : 
     151             :     virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
     152             :     virtual void        AddRefEntry();
     153             : 
     154             :     virtual sal_Bool        IsRefInputMode() const;
     155             :     virtual sal_Bool        IsTableLocked() const;
     156             :     virtual sal_Bool        IsDocAllowed( SfxObjectShell* pDocSh ) const;
     157             : 
     158             :     virtual void        ShowReference( const XubString& rStr );
     159             :     virtual void        HideReference( sal_Bool bDoneRefMode = sal_True );
     160             : 
     161             :     virtual void        ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     162             :     virtual void        ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     163             : 
     164             :     virtual void        ViewShellChanged();
     165             :     void                SwitchToDocument();
     166             : 
     167             :     virtual void        SetActive() = 0;
     168             : 
     169             : public:
     170             :     bool                EnterRefMode();
     171             :     bool                LeaveRefMode();
     172             :     inline  bool        CanInputStart( const formula::RefEdit *pEdit );
     173             :     inline  bool        CanInputDone( sal_Bool bForced );
     174             : };
     175             : 
     176             : //============================================================================
     177             : 
     178             : 
     179           0 : class ScRefHdlModalImpl : public ModalDialog, public ScRefHandler
     180             : {
     181             : public:
     182             : 
     183             :     virtual long        PreNotify( NotifyEvent& rNEvt );
     184             :     virtual void        StateChanged( StateChangedType nStateChange );
     185             : protected:
     186             :     ScRefHdlModalImpl( Window* pParent, ResId& rResId );
     187             : 
     188             : private:
     189             : };
     190             : 
     191             : template<  class TWindow, bool bBindRef = true >
     192             : class ScRefHdlrImplBase: public TWindow, public ScRefHandler
     193             : {
     194             : public:
     195             :     virtual long        PreNotify( NotifyEvent& rNEvt );
     196             :     virtual void        StateChanged( StateChangedType nStateChange );
     197             : 
     198             : private:
     199             :     template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
     200             :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     201             :         TParentWindow* pParent, TResId nResId );
     202             : 
     203             :     template<class TBindings, class TChildWindow, class TParentWindow >
     204             :     ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
     205             :         TParentWindow* pParent, const OString& rID, const OUString& rUIXMLDescription );
     206             : 
     207             :     template<class TParentWindow, class TResId, class TArg>
     208             :     ScRefHdlrImplBase( TParentWindow* pParent, TResId nResId, const TArg &rArg, SfxBindings *pB = NULL );
     209             : 
     210             :     ~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           0 : 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           0 :     , ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     221             : {
     222           0 : }
     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           0 : ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB )
     236             :     : TWindow( pParent, ScResId(static_cast<sal_uInt16>( nResIdP )), rArg ),
     237           0 :     ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef )
     238             : {
     239           0 : }
     240             : 
     241             : template<class TWindow, bool bBindRef >
     242           0 : ScRefHdlrImplBase<TWindow,bBindRef>::~ScRefHdlrImplBase(){}
     243             : 
     244             : template<class TWindow, bool bBindRef>
     245           0 : long ScRefHdlrImplBase<TWindow, bBindRef>::PreNotify( NotifyEvent& rNEvt )
     246             : {
     247           0 :     ScRefHandler::preNotify( rNEvt, bBindRef );
     248           0 :     return TWindow::PreNotify( rNEvt );
     249             : }
     250             : 
     251             : template<class TWindow, bool bBindRef>
     252           0 : void ScRefHdlrImplBase<TWindow, bBindRef>::StateChanged( StateChangedType nStateChange )
     253             : {
     254           0 :     TWindow::StateChanged( nStateChange );
     255           0 :     ScRefHandler::stateChanged( nStateChange, bBindRef );
     256           0 : }
     257             : 
     258           0 : class ScAnyRefModalDlg : public ScRefHdlModalImpl
     259             : {
     260             : public:
     261             :     ScAnyRefModalDlg(Window* pParent, ResId rResId);
     262             : };
     263             : 
     264             : //============================================================================
     265             : template<class TDerived, class TBase, bool bBindRef = true>
     266             : struct ScRefHdlrImpl: ScRefHdlrImplBase< TBase, bBindRef >
     267             : {
     268             :     enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
     269             : 
     270             :     template<class T1, class T2, class T3, class T4>
     271           0 :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 )
     272           0 :         : ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4)
     273             :     {
     274           0 :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     275           0 :     }
     276             : 
     277             :     template<class T1, class T2, class T3, class T4, class T5>
     278           0 :     ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 )
     279           0 :         : ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4, rt5)
     280             :     {
     281           0 :         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     282           0 :     }
     283             : 
     284           0 :     ~ScRefHdlrImpl()
     285             :     {
     286           0 :         SC_MOD()->UnregisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     287           0 :     }
     288             : };
     289             : //============================================================================
     290           0 : struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
     291             : {
     292             :     template<class T1, class T2, class T3, class T4>
     293           0 :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 )
     294           0 :         : ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4)
     295             :     {
     296           0 :     }
     297             : 
     298             :     template<class T1, class T2, class T3, class T4, class T5>
     299           0 :     ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 )
     300           0 :         : ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4, rt5)
     301             :     {
     302           0 :     }
     303             : };
     304             : //============================================================================
     305             : 
     306           0 : inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit )
     307             : {
     308           0 :     return m_aHelper.CanInputStart( pEdit );
     309             : }
     310             : 
     311           0 : inline  bool ScRefHandler::CanInputDone( sal_Bool bForced )
     312             : {
     313           0 :     return m_aHelper.CanInputDone( bForced );
     314             : }
     315             : 
     316             : #endif // SC_ANYREFDG_HXX
     317             : 
     318             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10