1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_VALIDATE_HXX 25cdf0e10cSrcweir #define SC_VALIDATE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sfx2/tabdlg.hxx> 28cdf0e10cSrcweir #include <vcl/edit.hxx> 29cdf0e10cSrcweir #include <vcl/fixed.hxx> 30cdf0e10cSrcweir #include <vcl/lstbox.hxx> 31cdf0e10cSrcweir #include <svtools/svmedit.hxx> 32cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 33cdf0e10cSrcweir #include "anyrefdg.hxx" 34cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 35cdf0e10cSrcweir 36cdf0e10cSrcweir // ============================================================================ 37cdf0e10cSrcweir 38cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 39cdf0e10cSrcweir struct ScRefHandlerCaller{ 40cdf0e10cSrcweir virtual ~ScRefHandlerCaller(){} 41cdf0e10cSrcweir }; 42cdf0e10cSrcweir class ScRefHandlerHelper 43cdf0e10cSrcweir { 44cdf0e10cSrcweir protected: 45cdf0e10cSrcweir ScRefHandlerCaller *m_pHandler; 46cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , ScDocument* ); 47cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pSetActiveHdl)(); 48cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( ScRefEdit* pEdit, ScRefButton* pButton ); 49cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pRefInputStartPostHdl)( ScRefEdit* pEdit, ScRefButton* pButton ); 50cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pRefInputDonePreHdl)(); 51cdf0e10cSrcweir void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)(); 52cdf0e10cSrcweir 53cdf0e10cSrcweir public: 54cdf0e10cSrcweir typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , ScDocument* ); 55cdf0e10cSrcweir typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)(); 56cdf0e10cSrcweir typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( ScRefEdit* pEdit, ScRefButton* pButton ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir PFUNCSETREFHDLTYPE SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl ) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir PFUNCSETREFHDLTYPE pOldHdl = m_pSetReferenceHdl; 61cdf0e10cSrcweir m_pSetReferenceHdl = pNewHdl; 62cdf0e10cSrcweir return pOldHdl; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir PCOMMONHDLTYPE SetSetActHdl( PCOMMONHDLTYPE pNewHdl ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir PCOMMONHDLTYPE pOldHdl = m_pSetActiveHdl; 68cdf0e10cSrcweir m_pSetActiveHdl = pNewHdl; 69cdf0e10cSrcweir return pOldHdl; 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir ScRefHandlerCaller *SetHandler( ScRefHandlerCaller *pNewHandler ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ScRefHandlerCaller *pOldHandler = m_pHandler; 75cdf0e10cSrcweir m_pHandler = pNewHandler; 76cdf0e10cSrcweir return pOldHandler; 77cdf0e10cSrcweir } 78cdf0e10cSrcweir void SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPreHdl = pNewHdl; } 79cdf0e10cSrcweir void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; } 80cdf0e10cSrcweir void SetRefInputStartPostHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPostHdl = pNewHdl; } 81cdf0e10cSrcweir void SetRefInputDonePreHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePreHdl = pNewHdl; } 82cdf0e10cSrcweir 83cdf0e10cSrcweir ScRefHandlerHelper():m_pHandler(NULL), m_pSetReferenceHdl( NULL ), m_pSetActiveHdl(NULL), m_pRefInputStartPreHdl( NULL ), m_pRefInputStartPostHdl( NULL ), m_pRefInputDonePreHdl( NULL ), m_pRefInputDonePostHdl( NULL ){} 84cdf0e10cSrcweir }; 85cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** The "Validity" tab dialog. */ 88cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 89cdf0e10cSrcweir //class ScValidationDlg : public SfxTabDialog 90cdf0e10cSrcweir class ScValidationDlg :public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>, public ScRefHandlerHelper 91cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 92cdf0e10cSrcweir { 93cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 94cdf0e10cSrcweir typedef ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> ScValidationDlgBase; 95cdf0e10cSrcweir 96cdf0e10cSrcweir //Start_Moddify by liliang 03/26/2008 SODC_13677_2 97cdf0e10cSrcweir DECL_LINK( OkHdl, Button * ); 98cdf0e10cSrcweir //End_Moddify by liliang 03/26/2008 SODC_13677_2 99cdf0e10cSrcweir bool m_bOwnRefHdlr:1; 100cdf0e10cSrcweir 101cdf0e10cSrcweir ScTabViewShell *m_pTabVwSh; 102cdf0e10cSrcweir bool m_bRefInputting:1; 103cdf0e10cSrcweir bool EnterRefStatus(); 104cdf0e10cSrcweir bool LeaveRefStatus(); 105cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 106cdf0e10cSrcweir public: 107cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 108cdf0e10cSrcweir //explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet ); 109cdf0e10cSrcweir explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh, SfxBindings *pB = NULL ); 110cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 111cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 112cdf0e10cSrcweir virtual ~ScValidationDlg(); 113cdf0e10cSrcweir inline static ScValidationDlg * Find1AliveObject( Window *pAncestor ); 114cdf0e10cSrcweir bool IsAlive(); 115cdf0e10cSrcweir inline ScTabViewShell * GetTabViewShell(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir bool SetupRefDlg(); 118cdf0e10cSrcweir bool RemoveRefDlg( sal_Bool bRestoreModal = sal_True ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void SetModal( sal_Bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); } 121cdf0e10cSrcweir 122cdf0e10cSrcweir virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir if ( m_pHandler && m_pSetReferenceHdl ) 125cdf0e10cSrcweir (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void SetActive() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir if ( m_pHandler && m_pSetActiveHdl ) 131cdf0e10cSrcweir (m_pHandler->*m_pSetActiveHdl)(); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir void CloseRefDialog() 135cdf0e10cSrcweir { 136cdf0e10cSrcweir DBG_ASSERT( false, "should not execute here!!!when the edit kill focus, should remove refhandler.\r\n" ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir if ( IsInExecute() ) 139cdf0e10cSrcweir EndDialog( sal_False ); 140cdf0e10cSrcweir else if ( GetStyle() & WB_CLOSEABLE ) 141cdf0e10cSrcweir Close(); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir bool IsRefInputting(){ return m_bRefInputting; } 145cdf0e10cSrcweir 146cdf0e10cSrcweir virtual void RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton = NULL ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir if( !CanInputStart( pEdit ) ) 149cdf0e10cSrcweir return; 150cdf0e10cSrcweir 151cdf0e10cSrcweir if ( m_pHandler && m_pRefInputStartPreHdl ) 152cdf0e10cSrcweir (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton ); 153cdf0e10cSrcweir m_bRefInputting = true; 154cdf0e10cSrcweir ScValidationDlgBase::RefInputStart( pEdit, pButton ); 155cdf0e10cSrcweir if ( m_pHandler && m_pRefInputStartPostHdl ) 156cdf0e10cSrcweir (m_pHandler->*m_pRefInputStartPostHdl)( pEdit, pButton ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir virtual void RefInputDone( sal_Bool bForced = sal_False ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir if( !CanInputDone( bForced ) ) 162cdf0e10cSrcweir return; 163cdf0e10cSrcweir 164cdf0e10cSrcweir if ( m_pHandler && m_pRefInputDonePreHdl ) 165cdf0e10cSrcweir (m_pHandler->*m_pRefInputDonePreHdl)(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir ScValidationDlgBase::RefInputDone( bForced ); 168cdf0e10cSrcweir m_bRefInputting = false; 169cdf0e10cSrcweir 170cdf0e10cSrcweir if ( m_pHandler && m_pRefInputDonePostHdl ) 171cdf0e10cSrcweir (m_pHandler->*m_pRefInputDonePostHdl)(); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir sal_Bool IsChildFocus(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir enum { SLOTID = SID_VALIDITY_REFERENCE }; 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Bool Close(); 179cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 180cdf0e10cSrcweir }; 181cdf0e10cSrcweir 182cdf0e10cSrcweir 183cdf0e10cSrcweir // ============================================================================ 184cdf0e10cSrcweir 185cdf0e10cSrcweir /** The tab page "Criteria" from the Validation dialog. */ 186cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 187cdf0e10cSrcweir //class ScTPValidationValue : public SfxTabPage 188cdf0e10cSrcweir class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage 189cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 190cdf0e10cSrcweir { 191cdf0e10cSrcweir public: 192cdf0e10cSrcweir explicit ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ); 193cdf0e10cSrcweir virtual ~ScTPValidationValue(); 194cdf0e10cSrcweir 195cdf0e10cSrcweir static SfxTabPage* Create( Window* pParent, const SfxItemSet& rArgSet ); 196cdf0e10cSrcweir static sal_uInt16* GetRanges(); 197cdf0e10cSrcweir 198cdf0e10cSrcweir virtual sal_Bool FillItemSet( SfxItemSet& rArgSet ); 199cdf0e10cSrcweir virtual void Reset( const SfxItemSet& rArgSet ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir private: 202cdf0e10cSrcweir void Init(); 203cdf0e10cSrcweir 204cdf0e10cSrcweir String GetFirstFormula() const; 205cdf0e10cSrcweir String GetSecondFormula() const; 206cdf0e10cSrcweir 207cdf0e10cSrcweir void SetFirstFormula( const String& rFmlaStr ); 208cdf0e10cSrcweir void SetSecondFormula( const String& rFmlaStr ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir DECL_LINK( SelectHdl, ListBox* ); 211cdf0e10cSrcweir DECL_LINK( CheckHdl, CheckBox* ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir FixedText maFtAllow; 214cdf0e10cSrcweir ListBox maLbAllow; 215cdf0e10cSrcweir CheckBox maCbAllow; /// Allow blank cells. 216cdf0e10cSrcweir CheckBox maCbShow; /// Show selection list in cell. 217cdf0e10cSrcweir CheckBox maCbSort; /// Sort selection list in cell. 218cdf0e10cSrcweir FixedText maFtValue; 219cdf0e10cSrcweir ListBox maLbValue; 220cdf0e10cSrcweir FixedText maFtMin; 221cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 222cdf0e10cSrcweir //Edit maEdMin; 223cdf0e10cSrcweir ScRefEdit maEdMin; 224cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 225cdf0e10cSrcweir MultiLineEdit maEdList; /// Entries for explicit list 226cdf0e10cSrcweir FixedText maFtMax; 227cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 228cdf0e10cSrcweir //Edit maEdMax; 229cdf0e10cSrcweir ScRefEdit maEdMax; 230cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 231cdf0e10cSrcweir FixedText maFtHint; /// Hint text for cell range validity. 232cdf0e10cSrcweir 233cdf0e10cSrcweir String maStrMin; 234cdf0e10cSrcweir String maStrMax; 235cdf0e10cSrcweir String maStrValue; 236cdf0e10cSrcweir String maStrRange; 237cdf0e10cSrcweir String maStrList; 238cdf0e10cSrcweir sal_Unicode mcFmlaSep; /// List separator in formulas. 239cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 240cdf0e10cSrcweir DECL_LINK( EditSetFocusHdl, Edit *); 241cdf0e10cSrcweir DECL_LINK( KillFocusHdl, Window *); 242cdf0e10cSrcweir void OnClick( Button *pBtn ); 243cdf0e10cSrcweir ScRefEdit *m_pRefEdit; 244cdf0e10cSrcweir class ScRefButtonEx:public ::ScRefButton 245cdf0e10cSrcweir { 246cdf0e10cSrcweir void Click(); 247cdf0e10cSrcweir public: 248cdf0e10cSrcweir ScRefButtonEx( Window* pParent, const ResId& rResId, ScRefEdit* pEdit = NULL, ScRefHandler *pRefHdlr = NULL ): ::ScRefButton( pParent, rResId, pEdit, pRefHdlr ){} 249cdf0e10cSrcweir }m_btnRef; 250cdf0e10cSrcweir friend class ScRefButtonEx; 251cdf0e10cSrcweir void SetReferenceHdl( const ScRange& , ScDocument* ); 252cdf0e10cSrcweir void SetActiveHdl(); 253cdf0e10cSrcweir void RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton ); 254cdf0e10cSrcweir void RefInputDonePreHdl(); 255cdf0e10cSrcweir void RefInputDonePostHdl(); 256cdf0e10cSrcweir ScValidationDlg * GetValidationDlg(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir //TYPEINFO(); 259cdf0e10cSrcweir void TidyListBoxes(); 260cdf0e10cSrcweir public: 261cdf0e10cSrcweir sal_uInt16 GetAllowEntryPos(); 262cdf0e10cSrcweir String GetMinText(); 263cdf0e10cSrcweir void SetupRefDlg(); 264cdf0e10cSrcweir void RemoveRefDlg(); 265cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 266cdf0e10cSrcweir }; 267cdf0e10cSrcweir 268cdf0e10cSrcweir 269cdf0e10cSrcweir //================================================================== 270cdf0e10cSrcweir 271cdf0e10cSrcweir class ScTPValidationHelp : public SfxTabPage 272cdf0e10cSrcweir { 273cdf0e10cSrcweir private: 274cdf0e10cSrcweir TriStateBox aTsbHelp; 275cdf0e10cSrcweir FixedLine aFlContent; 276cdf0e10cSrcweir FixedText aFtTitle; 277cdf0e10cSrcweir Edit aEdtTitle; 278cdf0e10cSrcweir FixedText aFtInputHelp; 279cdf0e10cSrcweir MultiLineEdit aEdInputHelp; 280cdf0e10cSrcweir 281cdf0e10cSrcweir const SfxItemSet& mrArgSet; 282cdf0e10cSrcweir 283cdf0e10cSrcweir void Init(); 284cdf0e10cSrcweir 285cdf0e10cSrcweir // Handler ------------------------ 286cdf0e10cSrcweir // DECL_LINK( SelectHdl, ListBox * ); 287cdf0e10cSrcweir 288cdf0e10cSrcweir public: 289cdf0e10cSrcweir ScTPValidationHelp( Window* pParent, const SfxItemSet& rArgSet ); 290cdf0e10cSrcweir ~ScTPValidationHelp(); 291cdf0e10cSrcweir 292cdf0e10cSrcweir static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet ); 293cdf0e10cSrcweir static sal_uInt16* GetRanges (); 294cdf0e10cSrcweir virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet ); 295cdf0e10cSrcweir virtual void Reset ( const SfxItemSet& rArgSet ); 296cdf0e10cSrcweir }; 297cdf0e10cSrcweir 298cdf0e10cSrcweir //================================================================== 299cdf0e10cSrcweir 300cdf0e10cSrcweir class ScTPValidationError : public SfxTabPage 301cdf0e10cSrcweir { 302cdf0e10cSrcweir private: 303cdf0e10cSrcweir TriStateBox aTsbShow; 304cdf0e10cSrcweir FixedLine aFlContent; 305cdf0e10cSrcweir FixedText aFtAction; 306cdf0e10cSrcweir ListBox aLbAction; 307cdf0e10cSrcweir PushButton aBtnSearch; 308cdf0e10cSrcweir FixedText aFtTitle; 309cdf0e10cSrcweir Edit aEdtTitle; 310cdf0e10cSrcweir FixedText aFtError; 311cdf0e10cSrcweir MultiLineEdit aEdError; 312cdf0e10cSrcweir 313cdf0e10cSrcweir const SfxItemSet& mrArgSet; 314cdf0e10cSrcweir 315cdf0e10cSrcweir void Init(); 316cdf0e10cSrcweir 317cdf0e10cSrcweir // Handler ------------------------ 318cdf0e10cSrcweir DECL_LINK( SelectActionHdl, ListBox * ); 319cdf0e10cSrcweir DECL_LINK( ClickSearchHdl, PushButton * ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir public: 322cdf0e10cSrcweir ScTPValidationError( Window* pParent, const SfxItemSet& rArgSet ); 323cdf0e10cSrcweir ~ScTPValidationError(); 324cdf0e10cSrcweir 325cdf0e10cSrcweir static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet ); 326cdf0e10cSrcweir static sal_uInt16* GetRanges (); 327cdf0e10cSrcweir virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet ); 328cdf0e10cSrcweir virtual void Reset ( const SfxItemSet& rArgSet ); 329cdf0e10cSrcweir }; 330cdf0e10cSrcweir 331cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 332cdf0e10cSrcweir inline ScTabViewShell *ScValidationDlg::GetTabViewShell() 333cdf0e10cSrcweir { 334cdf0e10cSrcweir return m_pTabVwSh; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir inline ScValidationDlg * ScValidationDlg::Find1AliveObject( Window *pAncestor ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 342cdf0e10cSrcweir #endif // SC_VALIDATE_HXX 343cdf0e10cSrcweir 344