138d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 338d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 438d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 538d50f7bSAndrew Rist * distributed with this work for additional information 638d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 738d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 838d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 938d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1138d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1338d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 1438d50f7bSAndrew Rist * software distributed under the License is distributed on an 1538d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1638d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 1738d50f7bSAndrew Rist * specific language governing permissions and limitations 1838d50f7bSAndrew Rist * under the License. 19cdf0e10cSrcweir * 2038d50f7bSAndrew Rist *************************************************************/ 2138d50f7bSAndrew Rist 2238d50f7bSAndrew 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 DECL_LINK( OkHdl, Button * ); 97*0deba7fbSSteve Yin 98cdf0e10cSrcweir bool m_bOwnRefHdlr:1; 99cdf0e10cSrcweir 100cdf0e10cSrcweir ScTabViewShell *m_pTabVwSh; 101cdf0e10cSrcweir bool m_bRefInputting:1; 102cdf0e10cSrcweir bool EnterRefStatus(); 103cdf0e10cSrcweir bool LeaveRefStatus(); 104cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 105cdf0e10cSrcweir public: 106cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 107cdf0e10cSrcweir //explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet ); 108cdf0e10cSrcweir explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh, SfxBindings *pB = NULL ); 109cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 110cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 111cdf0e10cSrcweir virtual ~ScValidationDlg(); 112cdf0e10cSrcweir inline static ScValidationDlg * Find1AliveObject( Window *pAncestor ); 113cdf0e10cSrcweir bool IsAlive(); 114cdf0e10cSrcweir inline ScTabViewShell * GetTabViewShell(); 115cdf0e10cSrcweir 116cdf0e10cSrcweir bool SetupRefDlg(); 117cdf0e10cSrcweir bool RemoveRefDlg( sal_Bool bRestoreModal = sal_True ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir virtual void SetModal( sal_Bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); } 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir if ( m_pHandler && m_pSetReferenceHdl ) 124cdf0e10cSrcweir (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc ); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir virtual void SetActive() 128cdf0e10cSrcweir { 129cdf0e10cSrcweir if ( m_pHandler && m_pSetActiveHdl ) 130cdf0e10cSrcweir (m_pHandler->*m_pSetActiveHdl)(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir void CloseRefDialog() 134cdf0e10cSrcweir { 135cdf0e10cSrcweir DBG_ASSERT( false, "should not execute here!!!when the edit kill focus, should remove refhandler.\r\n" ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir if ( IsInExecute() ) 138cdf0e10cSrcweir EndDialog( sal_False ); 139cdf0e10cSrcweir else if ( GetStyle() & WB_CLOSEABLE ) 140cdf0e10cSrcweir Close(); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir bool IsRefInputting(){ return m_bRefInputting; } 144cdf0e10cSrcweir 145cdf0e10cSrcweir virtual void RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton = NULL ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir if( !CanInputStart( pEdit ) ) 148cdf0e10cSrcweir return; 149cdf0e10cSrcweir 150cdf0e10cSrcweir if ( m_pHandler && m_pRefInputStartPreHdl ) 151cdf0e10cSrcweir (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton ); 152cdf0e10cSrcweir m_bRefInputting = true; 153cdf0e10cSrcweir ScValidationDlgBase::RefInputStart( pEdit, pButton ); 154cdf0e10cSrcweir if ( m_pHandler && m_pRefInputStartPostHdl ) 155cdf0e10cSrcweir (m_pHandler->*m_pRefInputStartPostHdl)( pEdit, pButton ); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir virtual void RefInputDone( sal_Bool bForced = sal_False ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir if( !CanInputDone( bForced ) ) 161cdf0e10cSrcweir return; 162cdf0e10cSrcweir 163cdf0e10cSrcweir if ( m_pHandler && m_pRefInputDonePreHdl ) 164cdf0e10cSrcweir (m_pHandler->*m_pRefInputDonePreHdl)(); 165cdf0e10cSrcweir 166cdf0e10cSrcweir ScValidationDlgBase::RefInputDone( bForced ); 167cdf0e10cSrcweir m_bRefInputting = false; 168cdf0e10cSrcweir 169cdf0e10cSrcweir if ( m_pHandler && m_pRefInputDonePostHdl ) 170cdf0e10cSrcweir (m_pHandler->*m_pRefInputDonePostHdl)(); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir sal_Bool IsChildFocus(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir enum { SLOTID = SID_VALIDITY_REFERENCE }; 176cdf0e10cSrcweir 177cdf0e10cSrcweir sal_Bool Close(); 178cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 179cdf0e10cSrcweir }; 180cdf0e10cSrcweir 181cdf0e10cSrcweir 182cdf0e10cSrcweir // ============================================================================ 183cdf0e10cSrcweir 184cdf0e10cSrcweir /** The tab page "Criteria" from the Validation dialog. */ 185cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 186cdf0e10cSrcweir //class ScTPValidationValue : public SfxTabPage 187cdf0e10cSrcweir class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage 188cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 189cdf0e10cSrcweir { 190cdf0e10cSrcweir public: 191cdf0e10cSrcweir explicit ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ); 192cdf0e10cSrcweir virtual ~ScTPValidationValue(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir static SfxTabPage* Create( Window* pParent, const SfxItemSet& rArgSet ); 195cdf0e10cSrcweir static sal_uInt16* GetRanges(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir virtual sal_Bool FillItemSet( SfxItemSet& rArgSet ); 198cdf0e10cSrcweir virtual void Reset( const SfxItemSet& rArgSet ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir private: 201cdf0e10cSrcweir void Init(); 202cdf0e10cSrcweir 203cdf0e10cSrcweir String GetFirstFormula() const; 204cdf0e10cSrcweir String GetSecondFormula() const; 205cdf0e10cSrcweir 206cdf0e10cSrcweir void SetFirstFormula( const String& rFmlaStr ); 207cdf0e10cSrcweir void SetSecondFormula( const String& rFmlaStr ); 208cdf0e10cSrcweir 209cdf0e10cSrcweir DECL_LINK( SelectHdl, ListBox* ); 210cdf0e10cSrcweir DECL_LINK( CheckHdl, CheckBox* ); 211cdf0e10cSrcweir 212cdf0e10cSrcweir FixedText maFtAllow; 213cdf0e10cSrcweir ListBox maLbAllow; 214cdf0e10cSrcweir CheckBox maCbAllow; /// Allow blank cells. 215cdf0e10cSrcweir CheckBox maCbShow; /// Show selection list in cell. 216cdf0e10cSrcweir CheckBox maCbSort; /// Sort selection list in cell. 217cdf0e10cSrcweir FixedText maFtValue; 218cdf0e10cSrcweir ListBox maLbValue; 219cdf0e10cSrcweir FixedText maFtMin; 220cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 221cdf0e10cSrcweir //Edit maEdMin; 222cdf0e10cSrcweir ScRefEdit maEdMin; 223cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 224cdf0e10cSrcweir MultiLineEdit maEdList; /// Entries for explicit list 225cdf0e10cSrcweir FixedText maFtMax; 226cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 227cdf0e10cSrcweir //Edit maEdMax; 228cdf0e10cSrcweir ScRefEdit maEdMax; 229cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 230cdf0e10cSrcweir FixedText maFtHint; /// Hint text for cell range validity. 231cdf0e10cSrcweir 232cdf0e10cSrcweir String maStrMin; 233cdf0e10cSrcweir String maStrMax; 234cdf0e10cSrcweir String maStrValue; 235cdf0e10cSrcweir String maStrRange; 236cdf0e10cSrcweir String maStrList; 237cdf0e10cSrcweir sal_Unicode mcFmlaSep; /// List separator in formulas. 238cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 239cdf0e10cSrcweir DECL_LINK( EditSetFocusHdl, Edit *); 240cdf0e10cSrcweir DECL_LINK( KillFocusHdl, Window *); 241cdf0e10cSrcweir void OnClick( Button *pBtn ); 242cdf0e10cSrcweir ScRefEdit *m_pRefEdit; 243cdf0e10cSrcweir class ScRefButtonEx:public ::ScRefButton 244cdf0e10cSrcweir { 245cdf0e10cSrcweir void Click(); 246cdf0e10cSrcweir public: 247cdf0e10cSrcweir ScRefButtonEx( Window* pParent, const ResId& rResId, ScRefEdit* pEdit = NULL, ScRefHandler *pRefHdlr = NULL ): ::ScRefButton( pParent, rResId, pEdit, pRefHdlr ){} 248cdf0e10cSrcweir }m_btnRef; 249cdf0e10cSrcweir friend class ScRefButtonEx; 250cdf0e10cSrcweir void SetReferenceHdl( const ScRange& , ScDocument* ); 251cdf0e10cSrcweir void SetActiveHdl(); 252cdf0e10cSrcweir void RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton ); 253cdf0e10cSrcweir void RefInputDonePreHdl(); 254cdf0e10cSrcweir void RefInputDonePostHdl(); 255cdf0e10cSrcweir ScValidationDlg * GetValidationDlg(); 256cdf0e10cSrcweir 257cdf0e10cSrcweir //TYPEINFO(); 258cdf0e10cSrcweir void TidyListBoxes(); 259cdf0e10cSrcweir public: 260cdf0e10cSrcweir sal_uInt16 GetAllowEntryPos(); 261cdf0e10cSrcweir String GetMinText(); 262cdf0e10cSrcweir void SetupRefDlg(); 263cdf0e10cSrcweir void RemoveRefDlg(); 264cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 265cdf0e10cSrcweir }; 266cdf0e10cSrcweir 267cdf0e10cSrcweir 268cdf0e10cSrcweir //================================================================== 269cdf0e10cSrcweir 270cdf0e10cSrcweir class ScTPValidationHelp : public SfxTabPage 271cdf0e10cSrcweir { 272cdf0e10cSrcweir private: 273cdf0e10cSrcweir TriStateBox aTsbHelp; 274cdf0e10cSrcweir FixedLine aFlContent; 275cdf0e10cSrcweir FixedText aFtTitle; 276cdf0e10cSrcweir Edit aEdtTitle; 277cdf0e10cSrcweir FixedText aFtInputHelp; 278cdf0e10cSrcweir MultiLineEdit aEdInputHelp; 279cdf0e10cSrcweir 280cdf0e10cSrcweir const SfxItemSet& mrArgSet; 281cdf0e10cSrcweir 282cdf0e10cSrcweir void Init(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir // Handler ------------------------ 285cdf0e10cSrcweir // DECL_LINK( SelectHdl, ListBox * ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir public: 288cdf0e10cSrcweir ScTPValidationHelp( Window* pParent, const SfxItemSet& rArgSet ); 289cdf0e10cSrcweir ~ScTPValidationHelp(); 290cdf0e10cSrcweir 291cdf0e10cSrcweir static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet ); 292cdf0e10cSrcweir static sal_uInt16* GetRanges (); 293cdf0e10cSrcweir virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet ); 294cdf0e10cSrcweir virtual void Reset ( const SfxItemSet& rArgSet ); 295cdf0e10cSrcweir }; 296cdf0e10cSrcweir 297cdf0e10cSrcweir //================================================================== 298cdf0e10cSrcweir 299cdf0e10cSrcweir class ScTPValidationError : public SfxTabPage 300cdf0e10cSrcweir { 301cdf0e10cSrcweir private: 302cdf0e10cSrcweir TriStateBox aTsbShow; 303cdf0e10cSrcweir FixedLine aFlContent; 304cdf0e10cSrcweir FixedText aFtAction; 305cdf0e10cSrcweir ListBox aLbAction; 306cdf0e10cSrcweir PushButton aBtnSearch; 307cdf0e10cSrcweir FixedText aFtTitle; 308cdf0e10cSrcweir Edit aEdtTitle; 309cdf0e10cSrcweir FixedText aFtError; 310cdf0e10cSrcweir MultiLineEdit aEdError; 311cdf0e10cSrcweir 312cdf0e10cSrcweir const SfxItemSet& mrArgSet; 313cdf0e10cSrcweir 314cdf0e10cSrcweir void Init(); 315cdf0e10cSrcweir 316cdf0e10cSrcweir // Handler ------------------------ 317cdf0e10cSrcweir DECL_LINK( SelectActionHdl, ListBox * ); 318cdf0e10cSrcweir DECL_LINK( ClickSearchHdl, PushButton * ); 319cdf0e10cSrcweir 320cdf0e10cSrcweir public: 321cdf0e10cSrcweir ScTPValidationError( Window* pParent, const SfxItemSet& rArgSet ); 322cdf0e10cSrcweir ~ScTPValidationError(); 323cdf0e10cSrcweir 324cdf0e10cSrcweir static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet ); 325cdf0e10cSrcweir static sal_uInt16* GetRanges (); 326cdf0e10cSrcweir virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet ); 327cdf0e10cSrcweir virtual void Reset ( const SfxItemSet& rArgSet ); 328cdf0e10cSrcweir }; 329cdf0e10cSrcweir 330cdf0e10cSrcweir //<!--Added by PengYunQuan for Validity Cell Range Picker 331cdf0e10cSrcweir inline ScTabViewShell *ScValidationDlg::GetTabViewShell() 332cdf0e10cSrcweir { 333cdf0e10cSrcweir return m_pTabVwSh; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir inline ScValidationDlg * ScValidationDlg::Find1AliveObject( Window *pAncestor ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) ); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir //-->Added by PengYunQuan for Validity Cell Range Picker 341cdf0e10cSrcweir #endif // SC_VALIDATE_HXX 342cdf0e10cSrcweir 343