xref: /trunk/main/sc/source/ui/dbgui/validate.cxx (revision a479921a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scui.hxx"
26 
27 
28 #include <vcl/svapp.hxx>
29 #include <svl/aeitem.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/eitem.hxx>
32 #include <svl/intitem.hxx>
33 #include <basic/sbmeth.hxx>
34 #include <basic/sbstar.hxx>
35 #include <basic/sbmod.hxx>
36 #include <sfx2/app.hxx>
37 
38 #include "scresid.hxx"
39 #include "sc.hrc"       // -> Slot IDs
40 
41 #include "validat.hxx"
42 #include "validate.hrc"
43 #include "validate.hxx"
44 #include "compiler.hxx"
45 #include "formula/opcode.hxx" //CHINA001
46 //<!--Added by PengYunQuan for Validity Cell Range Picker
47 #include "tabvwsh.hxx"
48 #include <sfx2/viewfrm.hxx>
49 #include <sfx2/childwin.hxx>
50 #include "reffact.hxx"
51 //-->Added by PengYunQuan for Validity Cell Range Picker
52 
53 // ============================================================================
54 
55 static sal_uInt16 pValueRanges[] =
56 {
57 	FID_VALID_MODE,	FID_VALID_ERRTEXT,
58     FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
59 	0
60 };
61 
62 
63 // ============================================================================
64 
65 //<!--Modified by PengYunQuan for Validity Cell Range Picker
66 //ScValidationDlg::ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet ) :
67 //    SfxTabDialog( pParent, ScResId( TAB_DLG_VALIDATION ), pArgSet )
ScValidationDlg(Window * pParent,const SfxItemSet * pArgSet,ScTabViewShell * pTabViewSh,SfxBindings * pB)68 ScValidationDlg::ScValidationDlg( Window*			pParent,
69 								 const SfxItemSet* pArgSet,
70 								 ScTabViewShell *pTabViewSh,
71 								 SfxBindings *pB /*= NULL*/
72 					  ) :
73 		ScValidationDlgBase( pParent ? pParent : SFX_APP()->GetTopWindow(), TAB_DLG_VALIDATION, pArgSet, pB ),
74 			m_bOwnRefHdlr( false ),
75 			m_pTabVwSh( pTabViewSh ),
76 			m_bRefInputting( false )
77 //-->Modified by PengYunQuan for Validity Cell Range Picker
78 {
79     AddTabPage( TP_VALIDATION_VALUES,    ScTPValidationValue::Create, 0 );
80 	AddTabPage( TP_VALIDATION_INPUTHELP, ScTPValidationHelp::Create,  0 );
81     AddTabPage( TP_VALIDATION_ERROR,     ScTPValidationError::Create, 0 );
82 	FreeResource();
83 }
84 
85 //<!--Added by PengYunQuan for Validity Cell Range Picker
SetReferenceHdl(const ScRange & rRange,ScDocument * pDoc)86 void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
87 {
88 	if ( rRange.aStart != rRange.aEnd )
89 		if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
90 			if( m_pRefEdit )
91 				pValidationDlg/*->GetRefHandler()*/->RefInputStart( m_pRefEdit );
92 
93 	if ( m_pRefEdit )
94 	{
95 		String	aStr;
96 		rRange.Format( aStr, SCR_ABS_3D, pDoc );
97 		m_pRefEdit->SetRefString( aStr );
98 		//m_pRefEdit->SetRefString( rRange.aStart != rRange.aEnd ? aStr : String::CreateFromAscii("=").Append( aStr ) );
99 	}
100 }
101 
SetActiveHdl()102 void ScTPValidationValue:: SetActiveHdl()
103 {
104 	if ( m_pRefEdit ) m_pRefEdit->GrabFocus();
105 
106 	if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
107 		if( m_pRefEdit )
108 		{
109 			pValidationDlg/*->GetRefHandler()*/->RefInputDone();
110 		}
111 }
112 
RefInputStartPreHdl(ScRefEdit * pEdit,ScRefButton * pButton)113 void			ScTPValidationValue::RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton )
114 {
115 	if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
116 	{
117 		if( pEdit == m_pRefEdit )
118 		{
119 			if( Window *pPreWnd = pEdit==&maEdMax?&maFtMax:(pEdit==&maEdMin?&maFtMin:NULL) )
120 			{
121 				pPreWnd->SetParent( pValidationDlg );
122 				pPreWnd->Hide();
123 			}
124 
125 			m_pRefEdit->SetParent( pValidationDlg );
126 		}
127 
128 		if( pButton == &m_btnRef )m_btnRef.SetParent( pValidationDlg );
129 	}
130 }
131 
RefInputDonePreHdl()132 void			ScTPValidationValue::RefInputDonePreHdl()
133 {
134 
135 	if( m_pRefEdit && m_pRefEdit->GetParent()!= this )
136 	{
137 		if( Window *pPreWnd = m_pRefEdit==&maEdMax?&maFtMax:(m_pRefEdit==&maEdMin?&maFtMin:NULL) )
138 		{
139 			pPreWnd->SetParent( this );
140 			pPreWnd->Show();
141 		}
142 
143 		m_pRefEdit->SetParent( this );
144 
145 		m_btnRef.SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to anthor window and restore parent later in order to restore the tab order
146 //		aExample1.SetParent( m_pRefEdit ); // the aExample1's child order will affect acc key
147 	}
148 
149 	if( m_btnRef.GetParent()!=this ) m_btnRef.SetParent( this );
150 //	if( aExample1.GetParent()!=this ) aExample1.SetParent( this );
151 }
152 
RefInputDonePostHdl()153 void			ScTPValidationValue::RefInputDonePostHdl()
154 {
155 
156 
157 	if( m_pRefEdit && !m_pRefEdit->HasFocus() )
158 		m_pRefEdit->GrabFocus();
159 
160 }
161 
162 
Close()163 sal_Bool ScValidationDlg::Close()
164 {
165 	if( m_bOwnRefHdlr )
166 		if( SfxTabPage* pPage = GetTabPage( TP_VALIDATION_VALUES ) )
167 			static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg();
168 
169 	return ScValidationDlgBase::Close();
170 }
171 //-->Added by PengYunQuan for Validity Cell Range Picker
172 
~ScValidationDlg()173 ScValidationDlg::~ScValidationDlg()
174 {
175 	//<!--Added by PengYunQuan for Validity Cell Range Picker
176 	if( m_bOwnRefHdlr )
177 		RemoveRefDlg( sal_False );
178 	//-->Added by PengYunQuan for Validity Cell Range Picker
179 }
180 
181 
182 // ============================================================================
183 
184 namespace {
185 
186 /** Converts the passed ScValidationMode to the position in the list box. */
lclGetPosFromValMode(ScValidationMode eValMode)187 sal_uInt16 lclGetPosFromValMode( ScValidationMode eValMode )
188 {
189     sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
190     switch( eValMode )
191     {
192         case SC_VALID_ANY:      nLbPos = SC_VALIDDLG_ALLOW_ANY;     break;
193         case SC_VALID_WHOLE:    nLbPos = SC_VALIDDLG_ALLOW_WHOLE;   break;
194         case SC_VALID_DECIMAL:  nLbPos = SC_VALIDDLG_ALLOW_DECIMAL; break;
195         case SC_VALID_DATE:     nLbPos = SC_VALIDDLG_ALLOW_DATE;    break;
196         case SC_VALID_TIME:     nLbPos = SC_VALIDDLG_ALLOW_TIME;    break;
197         case SC_VALID_TEXTLEN:  nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN; break;
198         case SC_VALID_LIST:     nLbPos = SC_VALIDDLG_ALLOW_RANGE;   break;
199         case SC_VALID_CUSTOM:   nLbPos = SC_VALIDDLG_ALLOW_ANY;     break;  // not supported
200         default:    DBG_ERRORFILE( "lclGetPosFromValMode - unknown validity mode" );
201     }
202     return nLbPos;
203 }
204 
205 /** Converts the passed list box position to an ScValidationMode. */
lclGetValModeFromPos(sal_uInt16 nLbPos)206 ScValidationMode lclGetValModeFromPos( sal_uInt16 nLbPos )
207 {
208     ScValidationMode eValMode = SC_VALID_ANY;
209     switch( nLbPos )
210     {
211         case SC_VALIDDLG_ALLOW_ANY:     eValMode = SC_VALID_ANY;        break;
212         case SC_VALIDDLG_ALLOW_WHOLE:   eValMode = SC_VALID_WHOLE;      break;
213         case SC_VALIDDLG_ALLOW_DECIMAL: eValMode = SC_VALID_DECIMAL;    break;
214         case SC_VALIDDLG_ALLOW_DATE:    eValMode = SC_VALID_DATE;       break;
215         case SC_VALIDDLG_ALLOW_TIME:    eValMode = SC_VALID_TIME;       break;
216         case SC_VALIDDLG_ALLOW_RANGE:   eValMode = SC_VALID_LIST;       break;
217         case SC_VALIDDLG_ALLOW_LIST:    eValMode = SC_VALID_LIST;       break;
218         case SC_VALIDDLG_ALLOW_TEXTLEN: eValMode = SC_VALID_TEXTLEN;    break;
219         default:    DBG_ERRORFILE( "lclGetValModeFromPos - invalid list box position" );
220     }
221     return eValMode;
222 }
223 
224 /** Converts the passed ScConditionMode to the position in the list box. */
lclGetPosFromCondMode(ScConditionMode eCondMode)225 sal_uInt16 lclGetPosFromCondMode( ScConditionMode eCondMode )
226 {
227     sal_uInt16 nLbPos = SC_VALIDDLG_DATA_EQUAL;
228     switch( eCondMode )
229     {
230         case SC_COND_NONE:          // #111771# may occur in old XML files after Excel import
231         case SC_COND_EQUAL:         nLbPos = SC_VALIDDLG_DATA_EQUAL;        break;
232         case SC_COND_LESS:          nLbPos = SC_VALIDDLG_DATA_LESS;         break;
233         case SC_COND_GREATER:       nLbPos = SC_VALIDDLG_DATA_GREATER;      break;
234         case SC_COND_EQLESS:        nLbPos = SC_VALIDDLG_DATA_EQLESS;       break;
235         case SC_COND_EQGREATER:     nLbPos = SC_VALIDDLG_DATA_EQGREATER;    break;
236         case SC_COND_NOTEQUAL:      nLbPos = SC_VALIDDLG_DATA_NOTEQUAL;     break;
237         case SC_COND_BETWEEN:       nLbPos = SC_VALIDDLG_DATA_BETWEEN;      break;
238         case SC_COND_NOTBETWEEN:    nLbPos = SC_VALIDDLG_DATA_NOTBETWEEN;   break;
239         default:    DBG_ERRORFILE( "lclGetPosFromCondMode - unknown condition mode" );
240     }
241     return nLbPos;
242 }
243 
244 /** Converts the passed list box position to an ScConditionMode. */
lclGetCondModeFromPos(sal_uInt16 nLbPos)245 ScConditionMode lclGetCondModeFromPos( sal_uInt16 nLbPos )
246 {
247     ScConditionMode eCondMode = SC_COND_EQUAL;
248     switch( nLbPos )
249     {
250         case SC_VALIDDLG_DATA_EQUAL:        eCondMode = SC_COND_EQUAL;      break;
251         case SC_VALIDDLG_DATA_LESS:         eCondMode = SC_COND_LESS;       break;
252         case SC_VALIDDLG_DATA_GREATER:      eCondMode = SC_COND_GREATER;    break;
253         case SC_VALIDDLG_DATA_EQLESS:       eCondMode = SC_COND_EQLESS;     break;
254         case SC_VALIDDLG_DATA_EQGREATER:    eCondMode = SC_COND_EQGREATER;  break;
255         case SC_VALIDDLG_DATA_NOTEQUAL:     eCondMode = SC_COND_NOTEQUAL;   break;
256         case SC_VALIDDLG_DATA_BETWEEN:      eCondMode = SC_COND_BETWEEN;    break;
257         case SC_VALIDDLG_DATA_NOTBETWEEN:   eCondMode = SC_COND_NOTBETWEEN; break;
258         default:    DBG_ERRORFILE( "lclGetCondModeFromPos - invalid list box position" );
259     }
260     return eCondMode;
261 }
262 
263 /** Converts line feed separated string to a formula with strings separated by semicolons.
264     @descr  Keeps all empty strings.
265     Example: abc\ndef\n\nghi -> "abc";"def";"";"ghi".
266     @param rFmlaStr  (out-param) The converted formula string. */
lclGetFormulaFromStringList(String & rFmlaStr,const String & rStringList,sal_Unicode cFmlaSep)267 void lclGetFormulaFromStringList( String& rFmlaStr, const String& rStringList, sal_Unicode cFmlaSep )
268 {
269     rFmlaStr.Erase();
270     xub_StrLen nTokenCnt = rStringList.GetTokenCount( '\n' );
271     for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
272     {
273         String aToken( rStringList.GetToken( 0, '\n', nStringIx ) );
274         ScGlobal::AddQuotes( aToken, '"' );
275         ScGlobal::AddToken( rFmlaStr, aToken, cFmlaSep );
276     }
277     if( !rFmlaStr.Len() )
278         rFmlaStr.AssignAscii( "\"\"" );
279 }
280 
281 
282 /** Converts formula with strings separated by semicolons to line feed separated string.
283     @descr  Keeps all empty strings. Ignores all empty tokens (multiple semicolons).
284     Example: "abc";;;"def";"";"ghi" -> abc\ndef\n\nghi.
285     @param rStringList  (out-param) The converted line feed separated string list.
286     @return  true = Conversion successful. */
lclGetStringListFromFormula(String & rStringList,const String & rFmlaStr,sal_Unicode cFmlaSep)287 bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, sal_Unicode cFmlaSep )
288 {
289     String aQuotes( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) );
290     xub_StrLen nTokenCnt = rFmlaStr.GetQuotedTokenCount( aQuotes, cFmlaSep );
291 
292     rStringList.Erase();
293     bool bIsStringList = (nTokenCnt > 0);
294     bool bTokenAdded = false;
295 
296     for( xub_StrLen nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
297     {
298         String aToken( rFmlaStr.GetQuotedToken( 0, aQuotes, cFmlaSep, nStringIx ) );
299         aToken.EraseLeadingAndTrailingChars();
300         if( aToken.Len() )      // ignore empty tokens, i.e. "a";;"b"
301         {
302             bIsStringList = ScGlobal::IsQuoted( aToken, '"' );
303             if( bIsStringList )
304             {
305                 ScGlobal::EraseQuotes( aToken, '"' );
306                 ScGlobal::AddToken( rStringList, aToken, '\n', 1, bTokenAdded );
307                 bTokenAdded = true;
308             }
309         }
310     }
311 
312     return bIsStringList;
313 }
314 
315 } // namespace
316 
317 // ----------------------------------------------------------------------------
318 
ScTPValidationValue(Window * pParent,const SfxItemSet & rArgSet)319 ScTPValidationValue::ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ) :
320     SfxTabPage( pParent, ScResId( TP_VALIDATION_VALUES ), rArgSet ),
321     maFtAllow ( this, ScResId( FT_ALLOW ) ),
322     maLbAllow ( this, ScResId( LB_ALLOW ) ),
323     maCbAllow ( this, ScResId( TSB_ALLOW_BLANKS ) ),
324     maCbShow  ( this, ScResId( CB_SHOWLIST ) ),
325     maCbSort  ( this, ScResId( CB_SORTLIST ) ),
326     maFtValue ( this, ScResId( FT_VALUE ) ),
327     maLbValue ( this, ScResId( LB_VALUE ) ),
328     maFtMin   ( this, ScResId( FT_MIN ) ),
329     maEdMin   ( this, ScResId( EDT_MIN ) ),
330     maEdList  ( this, ScResId( EDT_LIST ) ),
331     maFtMax   ( this, ScResId( FT_MAX ) ),
332     maEdMax   ( this, ScResId( EDT_MAX ) ),
333     maFtHint  ( this, ScResId( FT_SOURCEHINT ) ),
334     maStrMin  ( ScResId( SCSTR_VALID_MINIMUM ) ),
335     maStrMax  ( ScResId( SCSTR_VALID_MAXIMUM ) ),
336     maStrValue( ScResId( SCSTR_VALID_VALUE ) ),
337     maStrRange( ScResId( SCSTR_VALID_RANGE ) ),
338     maStrList ( ScResId( SCSTR_VALID_LIST ) ),
339 //<!--Added by PengYunQuan for Validity Cell Range Picker
340 		m_btnRef( this, ScResId( RB_VALIDITY_REF ) )
341 //-->Added by PengYunQuan for Validity Cell Range Picker
342 {
343 	Init();
344 	FreeResource();
345 
346     // list separator in formulas
347     //CHINA001 const String& rListSep = ScCompiler::pSymbolTableNative[ ocSep ];
348 	String aListSep = ::GetScCompilerNativeSymbol( ocSep ); //CHINA001
349     DBG_ASSERT( aListSep.Len() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" );
350     mcFmlaSep = aListSep.Len() ? aListSep.GetChar( 0 ) : ';';
351 	//<!--Added by PengYunQuan for Validity Cell Range Picker
352 	m_btnRef.Hide();
353 	//-->Added by PengYunQuan for Validity Cell Range Picker
354 }
355 
~ScTPValidationValue()356 ScTPValidationValue::~ScTPValidationValue()
357 {
358 }
359 
Init()360 void ScTPValidationValue::Init()
361 {
362     maLbAllow.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
363     maLbValue.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
364     maCbShow.SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) );
365 	//<!--Added by PengYunQuan for Validity Cell Range Picker
366 	maEdMin.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
367 	maEdMin.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
368 	maEdMax.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
369 	m_btnRef.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
370 	maEdMax.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
371 	//-->Added by PengYunQuan for Validity Cell Range Picker
372 
373     maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_ANY );
374     maLbValue.SelectEntryPos( SC_VALIDDLG_DATA_EQUAL );
375 
376     SelectHdl( NULL );
377     CheckHdl( NULL );
378 }
379 
Create(Window * pParent,const SfxItemSet & rArgSet)380 SfxTabPage* ScTPValidationValue::Create( Window* pParent, const SfxItemSet& rArgSet )
381 {
382     return( new ScTPValidationValue( pParent, rArgSet ) );
383 }
384 
GetRanges()385 sal_uInt16* ScTPValidationValue::GetRanges()
386 {
387     return pValueRanges;
388 }
389 
Reset(const SfxItemSet & rArgSet)390 void ScTPValidationValue::Reset( const SfxItemSet& rArgSet )
391 {
392 	const SfxPoolItem* pItem;
393 
394     sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
395     if( rArgSet.GetItemState( FID_VALID_MODE, sal_True, &pItem ) == SFX_ITEM_SET )
396         nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
397             static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
398     maLbAllow.SelectEntryPos( nLbPos );
399 
400     nLbPos = SC_VALIDDLG_DATA_EQUAL;
401     if( rArgSet.GetItemState( FID_VALID_CONDMODE, sal_True, &pItem ) == SFX_ITEM_SET )
402         nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
403             static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
404     maLbValue.SelectEntryPos( nLbPos );
405 
406     // *** check boxes ***
407     sal_Bool bCheck = sal_True;
408     if( rArgSet.GetItemState( FID_VALID_BLANK, sal_True, &pItem ) == SFX_ITEM_SET )
409         bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
410     maCbAllow.Check( bCheck );
411 
412     sal_Int32 nListType = ValidListType::UNSORTED;
413     if( rArgSet.GetItemState( FID_VALID_LISTTYPE, sal_True, &pItem ) == SFX_ITEM_SET )
414         nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
415     maCbShow.Check( nListType != ValidListType::INVISIBLE );
416     maCbSort.Check( nListType == ValidListType::SORTEDASCENDING );
417 
418     // *** formulas ***
419     String aFmlaStr;
420 	if ( rArgSet.GetItemState( FID_VALID_VALUE1, sal_True, &pItem ) == SFX_ITEM_SET )
421         aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
422     SetFirstFormula( aFmlaStr );
423 
424     aFmlaStr.Erase();
425 	if ( rArgSet.GetItemState( FID_VALID_VALUE2, sal_True, &pItem ) == SFX_ITEM_SET )
426         aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
427     SetSecondFormula( aFmlaStr );
428 
429     SelectHdl( NULL );
430     CheckHdl( NULL );
431 }
432 
FillItemSet(SfxItemSet & rArgSet)433 sal_Bool ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet )
434 {
435     sal_Int16 nListType = maCbShow.IsChecked() ?
436         (maCbSort.IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
437         ValidListType::INVISIBLE;
438 
439     rArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(
440                     lclGetValModeFromPos( maLbAllow.GetSelectEntryPos() ) ) ) );
441     rArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(
442                     lclGetCondModeFromPos( maLbValue.GetSelectEntryPos() ) ) ) );
443     rArgSet.Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) );
444     rArgSet.Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) );
445     rArgSet.Put( SfxBoolItem( FID_VALID_BLANK, maCbAllow.IsChecked() ) );
446     rArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
447 	return sal_True;
448 }
449 
GetFirstFormula() const450 String ScTPValidationValue::GetFirstFormula() const
451 {
452     String aFmlaStr;
453     if( maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST )
454         lclGetFormulaFromStringList( aFmlaStr, maEdList.GetText(), mcFmlaSep );
455     else
456         aFmlaStr = maEdMin.GetText();
457     return aFmlaStr;
458 }
459 
GetSecondFormula() const460 String ScTPValidationValue::GetSecondFormula() const
461 {
462     return maEdMax.GetText();
463 }
464 
SetFirstFormula(const String & rFmlaStr)465 void ScTPValidationValue::SetFirstFormula( const String& rFmlaStr )
466 {
467     // try if formula is a string list, validation mode must already be set
468     String aStringList;
469     if( (maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) &&
470         lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) )
471     {
472         maEdList.SetText( aStringList );
473         maEdMin.SetText( EMPTY_STRING );
474         // change validation mode to string list
475         maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_LIST );
476     }
477     else
478     {
479         maEdMin.SetText( rFmlaStr );
480         maEdList.SetText( EMPTY_STRING );
481     }
482 }
483 
SetSecondFormula(const String & rFmlaStr)484 void ScTPValidationValue::SetSecondFormula( const String& rFmlaStr )
485 {
486     maEdMax.SetText( rFmlaStr );
487 }
488 
489 //<!--Added by PengYunQuan for Validity Cell Range Picker
GetValidationDlg()490 ScValidationDlg * ScTPValidationValue::GetValidationDlg()
491 {
492 	if( Window *pParent = GetParent() )
493 		do{
494 			if ( dynamic_cast<ScValidationDlg*>( pParent ) )
495 				return static_cast<	ScValidationDlg * >( pParent );
496 		}while ( NULL != ( pParent = pParent->GetParent() ) );
497 	return NULL;
498 }
SetupRefDlg()499 void ScTPValidationValue::SetupRefDlg()
500 {
501 	if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
502 		if( pValidationDlg->SetupRefDlg() )
503 		{
504 			pValidationDlg->SetHandler( this );
505 			pValidationDlg->SetSetRefHdl( (ScRefHandlerHelper::PFUNCSETREFHDLTYPE)( &ScTPValidationValue::SetReferenceHdl ) );
506 			pValidationDlg->SetSetActHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::SetActiveHdl ) );
507 			pValidationDlg->SetRefInputStartPreHdl( (ScRefHandlerHelper::PINPUTSTARTDLTYPE)( &ScTPValidationValue::RefInputStartPreHdl ) );
508 			pValidationDlg->SetRefInputDonePreHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePreHdl ) );
509 			pValidationDlg->SetRefInputDonePostHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePostHdl ) );
510 
511 			if ( maEdMax.IsVisible() ) { m_pRefEdit = &maEdMax; }
512 			else if ( maEdMin.IsVisible() ) {  m_pRefEdit = &maEdMin; }
513 
514 			if( m_pRefEdit && !m_pRefEdit->HasFocus() ) m_pRefEdit->GrabFocus();
515 
516 			if( m_pRefEdit ) m_pRefEdit->SetRefDialog( pValidationDlg );
517 			m_btnRef.SetReferences( pValidationDlg, m_pRefEdit );
518 		}
519 }
520 
RemoveRefDlg()521 void ScTPValidationValue::RemoveRefDlg()
522 {
523 	if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
524 		if( pValidationDlg->RemoveRefDlg() )
525 		{
526 			pValidationDlg->SetHandler( NULL );
527 			pValidationDlg->SetSetRefHdl( NULL );
528 			pValidationDlg->SetSetActHdl( NULL );
529 			pValidationDlg->SetRefInputStartPreHdl( NULL );
530 			pValidationDlg->SetRefInputDonePreHdl( NULL );
531 			pValidationDlg->SetRefInputDonePostHdl( NULL );
532 
533 			if( m_pRefEdit ) m_pRefEdit->SetRefDialog( NULL );
534 			m_pRefEdit = NULL;
535 
536 			m_btnRef.SetReferences( NULL, NULL );
537 
538 #if ! defined( WNT ) && !defined( _MSC_VER )
539 			TidyListBoxes();
540 #endif
541 		}
542 }
543 
TidyListBoxes()544 void ScTPValidationValue::TidyListBoxes()
545 {
546 	if ( Window *pWnd = GetChild( 0 ) )
547 	{
548 		bool bFindLst = false;
549 		std::list<Window*> alstOrder;
550 
551 		do{
552 			if( pWnd->GetParent() == this )
553 			{
554 				if ( !bFindLst )
555 				{
556 					try{
557 						if( dynamic_cast<ListBox*>(pWnd)||dynamic_cast<ListBox*>(pWnd->GetWindow(WINDOW_CLIENT) ) )
558 							bFindLst = true;
559 					}
560 					catch( ... )
561 					{
562 						if ( *(void**)pWnd == *(void**)&maLbValue )
563 							bFindLst = true;
564 						else if ( Window *pClient = pWnd->GetWindow( WINDOW_CLIENT ) )
565 							if ( *(void**)pClient == *(void**)&maLbValue )
566 								bFindLst = true;
567 					}
568 				}
569 
570 				if ( bFindLst )
571 					alstOrder.push_back( pWnd->GetWindow( WINDOW_CLIENT ) );
572 			}
573 		}while( NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT  ) ) );
574 
575 		pWnd = GetChild(0);
576 
577 		while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ) ;
578 
579 		if ( pWnd )
580 		{
581 			for ( std::list<Window*>::iterator i = alstOrder.begin(); i!=alstOrder.end(); i++ )
582 			{
583 				Window *pParent = (*i)->GetParent();
584 				(*i)->SetParent( pWnd );
585 				(*i)->SetParent( pParent );
586 			}
587 		}
588 	}
589 }
590 
591 IMPL_LINK( ScTPValidationValue, EditSetFocusHdl, Edit *, /*pEdit*/ )
592 {
593 	sal_uInt16  nPos=maLbAllow.GetSelectEntryPos();
594 
595 	if ( nPos == SC_VALIDDLG_ALLOW_RANGE )
596 	{
597 		SetupRefDlg();
598 	}
599 
600 	return 0;
601 }
602 
IMPL_LINK(ScTPValidationValue,KillFocusHdl,Window *,pWnd)603 IMPL_LINK( ScTPValidationValue, KillFocusHdl, Window *, pWnd )
604 {
605 	if(	pWnd == m_pRefEdit || pWnd == &m_btnRef )
606 		if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
607 			if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() )
608 				if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_btnRef.HasFocus() )
609 				{
610 					RemoveRefDlg();
611 				}
612 
613 	return 0;
614 }
615 //-->Added by PengYunQuan for Validity Cell Range Picker
616 
617 // ----------------------------------------------------------------------------
618 
IMPL_LINK(ScTPValidationValue,SelectHdl,ListBox *,EMPTYARG)619 IMPL_LINK( ScTPValidationValue, SelectHdl, ListBox*, EMPTYARG )
620 {
621     sal_uInt16 nLbPos = maLbAllow.GetSelectEntryPos();
622     bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY);
623     bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE);
624     bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST);
625 
626     maCbAllow.Enable( bEnable );   // Leerzellen
627     maFtValue.Enable( bEnable );
628     maLbValue.Enable( bEnable );
629     maFtMin.Enable( bEnable );
630     maEdMin.Enable( bEnable );
631     maEdList.Enable( bEnable );
632     maFtMax.Enable( bEnable );
633     maEdMax.Enable( bEnable );
634 
635     bool bShowMax = false;
636     if( bRange )
637         maFtMin.SetText( maStrRange );
638     else if( bList )
639         maFtMin.SetText( maStrList );
640     else
641     {
642         switch( maLbValue.GetSelectEntryPos() )
643         {
644             case SC_VALIDDLG_DATA_EQUAL:
645             case SC_VALIDDLG_DATA_NOTEQUAL:     maFtMin.SetText( maStrValue );  break;
646 
647             case SC_VALIDDLG_DATA_LESS:
648             case SC_VALIDDLG_DATA_EQLESS:       maFtMin.SetText( maStrMax );    break;
649 
650             case SC_VALIDDLG_DATA_BETWEEN:
651             case SC_VALIDDLG_DATA_NOTBETWEEN:   bShowMax = true;    // fall through
652             case SC_VALIDDLG_DATA_GREATER:
653             case SC_VALIDDLG_DATA_EQGREATER:    maFtMin.SetText( maStrMin );    break;
654 
655             default:
656                 DBG_ERRORFILE( "ScTPValidationValue::SelectHdl - unknown condition mode" );
657         }
658     }
659 
660     maCbShow.Show( bRange || bList );
661     maCbSort.Show( bRange || bList );
662     maFtValue.Show( !bRange && !bList );
663     maLbValue.Show( !bRange && !bList );
664     maEdMin.Show( !bList );
665     maEdList.Show( bList );
666     maFtMax.Show( bShowMax );
667     maEdMax.Show( bShowMax );
668     maFtHint.Show( bRange );
669 	//<!--Added by PengYunQuan for Validity Cell Range Picker
670 	m_btnRef.Show( bRange );
671 	//-->Added by PengYunQuan for Validity Cell Range Picker
672     return 0;
673 }
674 
IMPL_LINK(ScTPValidationValue,CheckHdl,CheckBox *,EMPTYARG)675 IMPL_LINK( ScTPValidationValue, CheckHdl, CheckBox*, EMPTYARG )
676 {
677     maCbSort.Enable( maCbShow.IsChecked() );
678     return 0;
679 }
680 
681 
682 //========================================================================
683 //========================================================================
684 // Input Help Page
685 
ScTPValidationHelp(Window * pParent,const SfxItemSet & rArgSet)686 ScTPValidationHelp::ScTPValidationHelp( Window*			pParent,
687 										  const SfxItemSet& rArgSet )
688 
689 	:	SfxTabPage		( pParent,
690 						  ScResId( TP_VALIDATION_INPUTHELP ),
691 						  rArgSet ),
692 		aTsbHelp		( this, ScResId( TSB_HELP ) ),
693         aFlContent      ( this, ScResId( FL_CONTENT ) ),
694 		aFtTitle		( this, ScResId( FT_TITLE ) ),
695 		aEdtTitle		( this, ScResId( EDT_TITLE ) ),
696 		aFtInputHelp	( this, ScResId( FT_INPUTHELP ) ),
697 		aEdInputHelp	( this, ScResId( EDT_INPUTHELP ) ),
698 
699         mrArgSet            ( rArgSet )
700 {
701 	Init();
702 	FreeResource();
703 }
704 
705 // -----------------------------------------------------------------------
706 
~ScTPValidationHelp()707 __EXPORT ScTPValidationHelp::~ScTPValidationHelp()
708 {
709 }
710 
711 // -----------------------------------------------------------------------
712 
Init()713 void ScTPValidationHelp::Init()
714 {
715 	//aLb.SetSelectHdl( LINK( this, ScTPValidationHelp, SelectHdl ) );
716 
717 	aTsbHelp.EnableTriState( sal_False );
718 }
719 
720 //------------------------------------------------------------------------
721 
GetRanges()722 sal_uInt16* __EXPORT ScTPValidationHelp::GetRanges()
723 {
724 	return pValueRanges;
725 }
726 
727 // -----------------------------------------------------------------------
728 
Create(Window * pParent,const SfxItemSet & rArgSet)729 SfxTabPage* __EXPORT ScTPValidationHelp::Create( Window*	pParent,
730 										 const SfxItemSet&	rArgSet )
731 {
732 	return ( new ScTPValidationHelp( pParent, rArgSet ) );
733 }
734 
735 // -----------------------------------------------------------------------
736 
Reset(const SfxItemSet & rArgSet)737 void __EXPORT ScTPValidationHelp::Reset( const SfxItemSet& rArgSet )
738 {
739 	const SfxPoolItem* pItem;
740 
741 	if ( rArgSet.GetItemState( FID_VALID_SHOWHELP, sal_True, &pItem ) == SFX_ITEM_SET )
742 		aTsbHelp.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
743 	else
744 		aTsbHelp.SetState( STATE_NOCHECK );
745 
746 	if ( rArgSet.GetItemState( FID_VALID_HELPTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
747 		aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
748 	else
749 		aEdtTitle.SetText( EMPTY_STRING );
750 
751 	if ( rArgSet.GetItemState( FID_VALID_HELPTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
752 		aEdInputHelp.SetText( ((const SfxStringItem*)pItem)->GetValue() );
753 	else
754 		aEdInputHelp.SetText( EMPTY_STRING );
755 }
756 
757 // -----------------------------------------------------------------------
758 
FillItemSet(SfxItemSet & rArgSet)759 sal_Bool __EXPORT ScTPValidationHelp::FillItemSet( SfxItemSet& rArgSet )
760 {
761 	rArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, aTsbHelp.GetState() == STATE_CHECK ) );
762 	rArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aEdtTitle.GetText() ) );
763 	rArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aEdInputHelp.GetText() ) );
764 
765 	return sal_True;
766 }
767 
768 //========================================================================
769 //========================================================================
770 // Error Alert Page
771 
ScTPValidationError(Window * pParent,const SfxItemSet & rArgSet)772 ScTPValidationError::ScTPValidationError( Window*			pParent,
773 										  const SfxItemSet& rArgSet )
774 
775 	:	SfxTabPage		( pParent,
776 						  ScResId( TP_VALIDATION_ERROR ),
777 						  rArgSet ),
778 		aTsbShow		( this, ScResId( TSB_SHOW ) ),
779         aFlContent      ( this, ScResId( FL_CONTENT ) ),
780 		aFtAction		( this, ScResId( FT_ACTION ) ),
781 		aLbAction		( this, ScResId( LB_ACTION ) ),
782 		aBtnSearch		( this, ScResId( BTN_SEARCH ) ),
783 		aFtTitle		( this, ScResId( FT_TITLE ) ),
784 		aEdtTitle		( this, ScResId( EDT_TITLE ) ),
785 		aFtError		( this, ScResId( FT_ERROR ) ),
786 		aEdError		( this, ScResId( EDT_ERROR ) ),
787 
788         mrArgSet            ( rArgSet )
789 {
790 	Init();
791 	FreeResource();
792 }
793 
794 // -----------------------------------------------------------------------
795 
~ScTPValidationError()796 __EXPORT ScTPValidationError::~ScTPValidationError()
797 {
798 }
799 
800 // -----------------------------------------------------------------------
801 
Init()802 void ScTPValidationError::Init()
803 {
804 	aLbAction.SetSelectHdl( LINK( this, ScTPValidationError, SelectActionHdl ) );
805 	aBtnSearch.SetClickHdl( LINK( this, ScTPValidationError, ClickSearchHdl ) );
806 
807 	aLbAction.SelectEntryPos( 0 );
808 	aTsbShow.EnableTriState( sal_False );
809 
810 	SelectActionHdl( NULL );
811 }
812 
813 //------------------------------------------------------------------------
814 
GetRanges()815 sal_uInt16* __EXPORT ScTPValidationError::GetRanges()
816 {
817 	return pValueRanges;
818 }
819 
820 // -----------------------------------------------------------------------
821 
Create(Window * pParent,const SfxItemSet & rArgSet)822 SfxTabPage* __EXPORT ScTPValidationError::Create( Window*	pParent,
823 										 const SfxItemSet&	rArgSet )
824 {
825 	return ( new ScTPValidationError( pParent, rArgSet ) );
826 }
827 
828 // -----------------------------------------------------------------------
829 
Reset(const SfxItemSet & rArgSet)830 void __EXPORT ScTPValidationError::Reset( const SfxItemSet& rArgSet )
831 {
832 	const SfxPoolItem* pItem;
833 
834 	if ( rArgSet.GetItemState( FID_VALID_SHOWERR, sal_True, &pItem ) == SFX_ITEM_SET )
835 		aTsbShow.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
836 	else
837         aTsbShow.SetState( STATE_CHECK );   // #111720# check by default
838 
839 	if ( rArgSet.GetItemState( FID_VALID_ERRSTYLE, sal_True, &pItem ) == SFX_ITEM_SET )
840 		aLbAction.SelectEntryPos( ((const SfxAllEnumItem*)pItem)->GetValue() );
841 	else
842 		aLbAction.SelectEntryPos( 0 );
843 
844 	if ( rArgSet.GetItemState( FID_VALID_ERRTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
845 		aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
846 	else
847 		aEdtTitle.SetText( EMPTY_STRING );
848 
849 	if ( rArgSet.GetItemState( FID_VALID_ERRTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
850 		aEdError.SetText( ((const SfxStringItem*)pItem)->GetValue() );
851 	else
852 		aEdError.SetText( EMPTY_STRING );
853 
854 	SelectActionHdl( NULL );
855 }
856 
857 // -----------------------------------------------------------------------
858 
FillItemSet(SfxItemSet & rArgSet)859 sal_Bool __EXPORT ScTPValidationError::FillItemSet( SfxItemSet& rArgSet )
860 {
861 	rArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, aTsbShow.GetState() == STATE_CHECK ) );
862 	rArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, aLbAction.GetSelectEntryPos() ) );
863 	rArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aEdtTitle.GetText() ) );
864 	rArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aEdError.GetText() ) );
865 
866 	return sal_True;
867 }
868 
869 // -----------------------------------------------------------------------
870 
IMPL_LINK(ScTPValidationError,SelectActionHdl,ListBox *,EMPTYARG)871 IMPL_LINK( ScTPValidationError, SelectActionHdl, ListBox*, EMPTYARG )
872 {
873 	ScValidErrorStyle eStyle = (ScValidErrorStyle) aLbAction.GetSelectEntryPos();
874 	sal_Bool bMacro = ( eStyle == SC_VALERR_MACRO );
875 
876 	aBtnSearch.Enable( bMacro );
877 	aFtError.Enable( !bMacro );
878 	aEdError.Enable( !bMacro );
879 
880 	return( 0L );
881 }
882 
883 // -----------------------------------------------------------------------
884 
IMPL_LINK(ScTPValidationError,ClickSearchHdl,PushButton *,EMPTYARG)885 IMPL_LINK( ScTPValidationError, ClickSearchHdl, PushButton*, EMPTYARG )
886 {
887 	Window* pOld = Application::GetDefDialogParent();
888 	Application::SetDefDialogParent( this );
889 
890 	// Use static SfxApplication method to bring up selector dialog for
891 	// choosing a script
892 	::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
893 
894 	Application::SetDefDialogParent( pOld );
895 
896 	if ( aScriptURL != NULL && aScriptURL.getLength() != 0 )
897 	{
898 		aEdtTitle.SetText( aScriptURL );
899 	}
900 
901 	return( 0L );
902 }
903 
904 //<!--Added by PengYunQuan for Validity Cell Range Picker
EnterRefStatus()905 bool ScValidationDlg::EnterRefStatus()
906 {
907 	ScTabViewShell *pTabViewShell = GetTabViewShell();
908 
909 	if( !pTabViewShell ) return false;
910 
911 	sal_uInt16 nId  = SLOTID;
912 	SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
913 	SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
914 
915 	if ( pWnd && pWnd->GetWindow()!= this ) pWnd = NULL;
916 
917 	SC_MOD()->SetRefDialog( nId, pWnd ? sal_False : sal_True );
918 
919 	return true;
920 }
921 
LeaveRefStatus()922 bool ScValidationDlg::LeaveRefStatus()
923 {
924 	ScTabViewShell *pTabViewShell = GetTabViewShell();
925 
926 	if( !pTabViewShell ) return false;
927 
928 	sal_uInt16 nId  = SLOTID;
929 	SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
930 	//SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
931     if ( pViewFrm->GetChildWindow( nId ) )
932 	{
933 		DoClose( nId );
934 	}
935 	return true;
936 }
937 
SetupRefDlg()938 bool ScValidationDlg::SetupRefDlg()
939 {
940 	if ( m_bOwnRefHdlr ) return false;
941 	if( EnterRefMode() )
942 	{
943 		SetModal( sal_False );
944 		return  /*SetChkShell( GetDocShell() ),*/ m_bOwnRefHdlr = true && EnterRefStatus();
945 	}
946 
947 	return false;
948 }
949 
RemoveRefDlg(sal_Bool bRestoreModal)950 bool ScValidationDlg::RemoveRefDlg( sal_Bool bRestoreModal /* = sal_True */ )
951 {
952 	bool bVisLock = false;
953 	bool bFreeWindowLock = false;
954 
955 	ScTabViewShell *pTabVwSh = GetTabViewShell();
956 
957 	if( !pTabVwSh ) return false;
958 
959 	if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
960 	{
961 		bVisLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( true );
962 		bFreeWindowLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( true );
963 	}
964 
965 	if ( !m_bOwnRefHdlr ) return false;
966 	if( LeaveRefStatus() && LeaveRefMode() )
967 	{
968 		m_bOwnRefHdlr = false;
969 
970 		if( bRestoreModal )
971 			SetModal( sal_True );
972 	}
973 
974 	if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
975 	{
976 		static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( bVisLock );
977 		static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( bFreeWindowLock );
978 	}
979 
980 	return true;
981 }
982 
983 //TYPEINIT1( ScTPValidationValue, SfxTabPage )
984 
Click()985 void ScTPValidationValue::ScRefButtonEx::Click()
986 {
987 	if( ScTPValidationValue *pParent = dynamic_cast< ScTPValidationValue*>( GetParent() ) )
988 		pParent->OnClick( this );
989 
990 	ScRefButton::Click();
991 }
992 
OnClick(Button * pBtn)993 void ScTPValidationValue::OnClick( Button *pBtn )
994 {
995 	if( pBtn == &m_btnRef )
996 		SetupRefDlg();
997 }
998 
IsChildFocus()999 sal_Bool ScValidationDlg::IsChildFocus()
1000 {
1001 	if ( const Window *pWin = Application::GetFocusWindow() )
1002 		while( NULL != ( pWin = pWin->GetParent() ) )
1003 			if( pWin == this )
1004 				return sal_True;
1005 
1006 	return sal_False;
1007 }
1008 
1009 
IsAlive()1010 bool	ScValidationDlg::IsAlive()
1011 {
1012 	return SC_MOD()->IsAliveRefDlg( SLOTID, this );
1013 }
1014 //-->Added by PengYunQuan for Validity Cell Range Picker
1015