LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/inc - validate.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 54 0.0 %
Date: 2013-07-09 Functions: 0 21 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_VALIDATE_HXX
      21             : #define SC_VALIDATE_HXX
      22             : 
      23             : #include <sfx2/tabdlg.hxx>
      24             : #include <vcl/edit.hxx>
      25             : #include <vcl/fixed.hxx>
      26             : #include <vcl/layout.hxx>
      27             : #include <vcl/lstbox.hxx>
      28             : #include <svtools/svmedit.hxx>
      29             : 
      30             : #include "anyrefdg.hxx"
      31             : 
      32             : // ============================================================================
      33             : 
      34           0 : struct  ScRefHandlerCaller{
      35           0 :     virtual ~ScRefHandlerCaller(){}
      36             : };
      37             : class ScRefHandlerHelper
      38             : {
      39             : protected:
      40             :     ScRefHandlerCaller  *m_pHandler;
      41             :     void            (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , ScDocument* );
      42             :     void            (ScRefHandlerCaller::*m_pSetActiveHdl)();
      43             :     void            (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, formula::RefButton* pButton );
      44             :     void            (ScRefHandlerCaller::*m_pRefInputStartPostHdl)( formula::RefEdit* pEdit, formula::RefButton* pButton );
      45             :     void            (ScRefHandlerCaller::*m_pRefInputDonePreHdl)();
      46             :     void            (ScRefHandlerCaller::*m_pRefInputDonePostHdl)();
      47             : 
      48             : public:
      49             :     typedef void            (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , ScDocument* );
      50             :     typedef void            (ScRefHandlerCaller::*PCOMMONHDLTYPE)();
      51             :     typedef void            (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)(  formula::RefEdit* pEdit, formula::RefButton* pButton );
      52             : 
      53           0 :     PFUNCSETREFHDLTYPE  SetSetRefHdl(  PFUNCSETREFHDLTYPE pNewHdl )
      54             :     {
      55           0 :         PFUNCSETREFHDLTYPE pOldHdl = m_pSetReferenceHdl;
      56           0 :         m_pSetReferenceHdl = pNewHdl;
      57           0 :         return pOldHdl;
      58             :     }
      59             : 
      60           0 :     PCOMMONHDLTYPE  SetSetActHdl(  PCOMMONHDLTYPE pNewHdl )
      61             :     {
      62           0 :         PCOMMONHDLTYPE pOldHdl = m_pSetActiveHdl;
      63           0 :         m_pSetActiveHdl = pNewHdl;
      64           0 :         return pOldHdl;
      65             :     }
      66             : 
      67           0 :     ScRefHandlerCaller  *SetHandler( ScRefHandlerCaller *pNewHandler )
      68             :     {
      69           0 :         ScRefHandlerCaller  *pOldHandler = m_pHandler;
      70           0 :         m_pHandler = pNewHandler;
      71           0 :         return pOldHandler;
      72             :     }
      73           0 :     void    SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl   ){  m_pRefInputStartPreHdl = pNewHdl;   }
      74           0 :     void    SetRefInputDonePostHdl( void            (ScRefHandlerCaller::*pNewHdl)()    ){  m_pRefInputDonePostHdl = pNewHdl;   }
      75             :     void    SetRefInputStartPostHdl(    PINPUTSTARTDLTYPE pNewHdl   ){  m_pRefInputStartPostHdl = pNewHdl;  }
      76             :     void    SetRefInputDonePreHdl( void            (ScRefHandlerCaller::*pNewHdl)() ){  m_pRefInputDonePreHdl = pNewHdl;    }
      77             : 
      78           0 :     ScRefHandlerHelper():m_pHandler(NULL), m_pSetReferenceHdl( NULL ), m_pSetActiveHdl(NULL),  m_pRefInputStartPreHdl( NULL ), m_pRefInputStartPostHdl( NULL ), m_pRefInputDonePreHdl( NULL ),  m_pRefInputDonePostHdl( NULL ){}
      79             : };
      80             : 
      81             : /** The "Validity" tab dialog. */
      82             : class ScValidationDlg :public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>, public ScRefHandlerHelper
      83             : {
      84             :     typedef ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> ScValidationDlgBase;
      85             : 
      86             :     DECL_LINK( OkHdl, Button * );
      87             : 
      88             :     bool    m_bOwnRefHdlr:1;
      89             : 
      90             :     ScTabViewShell *m_pTabVwSh;
      91             :     VclHBox* mpHBox;
      92             :     bool    m_bRefInputting:1;
      93             :     bool    EnterRefStatus();
      94             :     bool    LeaveRefStatus();
      95             : 
      96             : public:
      97             :     explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh, SfxBindings *pB = NULL );
      98             :     virtual                     ~ScValidationDlg();
      99             :     inline static ScValidationDlg * Find1AliveObject( Window *pAncestor );
     100             :     bool    IsAlive();
     101             :     inline  ScTabViewShell * GetTabViewShell();
     102             : 
     103             :     bool    SetupRefDlg();
     104             :     bool    RemoveRefDlg( sal_Bool bRestoreModal = sal_True );
     105             : 
     106           0 :     virtual void            SetModal( sal_Bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); }
     107             : 
     108           0 :     virtual void            SetReference( const ScRange& rRef, ScDocument* pDoc )
     109             :     {
     110           0 :         if ( m_pHandler && m_pSetReferenceHdl )
     111           0 :             (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc );
     112           0 :     }
     113             : 
     114           0 :     virtual void            SetActive()
     115             :     {
     116           0 :         if ( m_pHandler && m_pSetActiveHdl )
     117           0 :             (m_pHandler->*m_pSetActiveHdl)();
     118           0 :     }
     119             : 
     120             :     void        CloseRefDialog()
     121             :     {
     122             :         OSL_FAIL( "should not execute here!!!when the edit kill focus, should remove refhandler.\r\n" );
     123             : 
     124             :         if ( IsInExecute() )
     125             :             EndDialog( false );
     126             :         else if ( GetStyle() & WB_CLOSEABLE )
     127             :             Close();
     128             :     }
     129             : 
     130           0 :     bool IsRefInputting(){  return m_bRefInputting; }
     131           0 :     Window*             get_refinput_shrink_parent() { return mpHBox; }
     132             : 
     133           0 :     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL )
     134             :     {
     135           0 :         if( !CanInputStart( pEdit ) )
     136           0 :             return;
     137             : 
     138           0 :         if ( m_pHandler && m_pRefInputStartPreHdl )
     139           0 :             (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
     140           0 :         m_bRefInputting = true;
     141           0 :         ScValidationDlgBase::RefInputStart( pEdit, pButton );
     142           0 :         if ( m_pHandler && m_pRefInputStartPostHdl )
     143           0 :             (m_pHandler->*m_pRefInputStartPostHdl)( pEdit, pButton );
     144             :     }
     145             : 
     146           0 :     virtual void        RefInputDone( sal_Bool bForced = false )
     147             :     {
     148           0 :         if( !CanInputDone( bForced ) )
     149           0 :             return;
     150             : 
     151           0 :         if ( m_pHandler && m_pRefInputDonePreHdl )
     152           0 :             (m_pHandler->*m_pRefInputDonePreHdl)();
     153             : 
     154           0 :         ScValidationDlgBase::RefInputDone( bForced );
     155           0 :         m_bRefInputting = false;
     156             : 
     157           0 :         if ( m_pHandler && m_pRefInputDonePostHdl )
     158           0 :             (m_pHandler->*m_pRefInputDonePostHdl)();
     159             :     }
     160             : 
     161             :     sal_Bool IsChildFocus();
     162             : 
     163             :     enum { SLOTID = SID_VALIDITY_REFERENCE };
     164             : 
     165             :     sal_Bool Close();
     166             : };
     167             : 
     168             : 
     169             : // ============================================================================
     170             : 
     171             : /** The tab page "Criteria" from the Validation dialog. */
     172             : class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage
     173             : {
     174             : public:
     175             :     explicit                    ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet );
     176             :     virtual                     ~ScTPValidationValue();
     177             : 
     178             :     static SfxTabPage*          Create( Window* pParent, const SfxItemSet& rArgSet );
     179             :     static sal_uInt16*              GetRanges();
     180             : 
     181             :     virtual sal_Bool                FillItemSet( SfxItemSet& rArgSet );
     182             :     virtual void                Reset( const SfxItemSet& rArgSet );
     183             : 
     184             : private:
     185             :     void                        Init();
     186             : 
     187             :     String                      GetFirstFormula() const;
     188             :     String                      GetSecondFormula() const;
     189             : 
     190             :     void                        SetFirstFormula( const OUString& rFmlaStr );
     191             :     void                        SetSecondFormula( const String& rFmlaStr );
     192             : 
     193             :                                 DECL_LINK(SelectHdl, void *);
     194             :                                 DECL_LINK(CheckHdl, void *);
     195             : 
     196             :     FixedText                   maFtAllow;
     197             :     ListBox                     maLbAllow;
     198             :     CheckBox                    maCbAllow;      /// Allow blank cells.
     199             :     CheckBox                    maCbShow;       /// Show selection list in cell.
     200             :     CheckBox                    maCbSort;       /// Sort selection list in cell.
     201             :     FixedText                   maFtValue;
     202             :     ListBox                     maLbValue;
     203             :     FixedText                   maFtMin;
     204             :     formula::RefEdit            maEdMin;
     205             :     MultiLineEdit               maEdList;       /// Entries for explicit list
     206             :     FixedText                   maFtMax;
     207             :     formula::RefEdit            maEdMax;
     208             :     FixedText                   maFtHint;       /// Hint text for cell range validity.
     209             : 
     210             :     String                      maStrMin;
     211             :     String                      maStrMax;
     212             :     String                      maStrValue;
     213             :     String                      maStrRange;
     214             :     String                      maStrList;
     215             :     sal_Unicode                 mcFmlaSep;      /// List separator in formulas.
     216             : 
     217             :     Point                       maRefEditPos;
     218             :     Point                       maBtnRefPos;
     219             :     Size                        maRefEditSize;
     220             :     Size                        maBtnRefSize;
     221             : 
     222             :     DECL_LINK(EditSetFocusHdl, void *);
     223             :     DECL_LINK( KillFocusHdl, Window *);
     224             :     void    OnClick( Button *pBtn );
     225             :     formula::RefEdit*           m_pRefEdit;
     226           0 :     class ScRefButtonEx:public ::formula::RefButton
     227             :     {
     228             :         void Click();
     229             :     public:
     230           0 :         ScRefButtonEx( Window* pParent, const ResId& rResId, formula::RefEdit* pEdit = NULL,
     231             :             ScRefHandler *pRefHdlr = NULL )
     232           0 :             : ::formula::RefButton( pParent, rResId, pEdit, pRefHdlr )
     233             :         {
     234           0 :         }
     235             :     }m_btnRef;
     236             :     friend class ScRefButtonEx;
     237             :     void            SetReferenceHdl( const ScRange& , ScDocument* );
     238             :     void            SetActiveHdl();
     239             :     void            RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton );
     240             :     void            RefInputDonePostHdl();
     241             :     ScValidationDlg * GetValidationDlg();
     242             : 
     243             :     void            TidyListBoxes();
     244             : public:
     245             :     sal_uInt16          GetAllowEntryPos();
     246             :     String          GetMinText();
     247             :     void    SetupRefDlg();
     248             :     void    RemoveRefDlg();
     249             : };
     250             : 
     251             : 
     252             : //==================================================================
     253             : 
     254             : class ScTPValidationHelp : public SfxTabPage
     255             : {
     256             : private:
     257             :     TriStateBox     aTsbHelp;
     258             :     FixedLine       aFlContent;
     259             :     FixedText       aFtTitle;
     260             :     Edit            aEdtTitle;
     261             :     FixedText       aFtInputHelp;
     262             :     MultiLineEdit   aEdInputHelp;
     263             : 
     264             :     void    Init();
     265             : 
     266             :     // Handler ------------------------
     267             :     // DECL_LINK( SelectHdl, ListBox * );
     268             : 
     269             : public:
     270             :             ScTPValidationHelp( Window* pParent, const SfxItemSet& rArgSet );
     271             :             ~ScTPValidationHelp();
     272             : 
     273             :     static  SfxTabPage* Create      ( Window* pParent, const SfxItemSet& rArgSet );
     274             :     static  sal_uInt16*     GetRanges   ();
     275             :     virtual sal_Bool        FillItemSet ( SfxItemSet& rArgSet );
     276             :     virtual void        Reset       ( const SfxItemSet& rArgSet );
     277             : };
     278             : 
     279             : //==================================================================
     280             : 
     281             : class ScTPValidationError : public SfxTabPage
     282             : {
     283             : private:
     284             :     TriStateBox     aTsbShow;
     285             :     FixedLine       aFlContent;
     286             :     FixedText       aFtAction;
     287             :     ListBox         aLbAction;
     288             :     PushButton      aBtnSearch;
     289             :     FixedText       aFtTitle;
     290             :     Edit            aEdtTitle;
     291             :     FixedText       aFtError;
     292             :     MultiLineEdit   aEdError;
     293             : 
     294             :     void    Init();
     295             : 
     296             :     // Handler ------------------------
     297             :     DECL_LINK(SelectActionHdl, void *);
     298             :     DECL_LINK(ClickSearchHdl, void *);
     299             : 
     300             : public:
     301             :             ScTPValidationError( Window* pParent, const SfxItemSet& rArgSet );
     302             :             ~ScTPValidationError();
     303             : 
     304             :     static  SfxTabPage* Create      ( Window* pParent, const SfxItemSet& rArgSet );
     305             :     static  sal_uInt16*     GetRanges   ();
     306             :     virtual sal_Bool        FillItemSet ( SfxItemSet& rArgSet );
     307             :     virtual void        Reset       ( const SfxItemSet& rArgSet );
     308             : };
     309             : 
     310           0 : inline ScTabViewShell *ScValidationDlg::GetTabViewShell()
     311             : {
     312           0 :     return m_pTabVwSh;
     313             : }
     314             : 
     315           0 : inline ScValidationDlg * ScValidationDlg::Find1AliveObject( Window *pAncestor )
     316             : {
     317           0 :     return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) );
     318             : }
     319             : 
     320             : #endif // SC_VALIDATE_HXX
     321             : 
     322             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10