2010-10-12 15:59:00 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-30 12:23:25 +00:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
2006-07-21 12:31:51 +00:00
2004-08-23 08:32:25 +00:00
# ifdef SC_DLLIMPLEMENTATION
# undef SC_DLLIMPLEMENTATION
# endif
2011-11-23 22:17:24 +00:00
# include <comphelper/string.hxx>
2003-08-19 10:39:33 +00:00
# include <vcl/svapp.hxx>
2009-10-16 00:05:16 +02:00
# include <svl/aeitem.hxx>
# include <svl/stritem.hxx>
# include <svl/eitem.hxx>
# include <svl/intitem.hxx>
2000-09-18 16:07:07 +00:00
# include <basic/sbmeth.hxx>
# include <basic/sbstar.hxx>
# include <basic/sbmod.hxx>
2004-02-03 19:28:54 +00:00
# include <sfx2/app.hxx>
2000-09-18 16:07:07 +00:00
# include "scresid.hxx"
# include "sc.hrc" // -> Slot IDs
2012-08-04 10:33:53 +01:00
# include "stringutil.hxx"
2000-09-18 16:07:07 +00:00
# include "validat.hxx"
# include "validate.hrc"
# include "validate.hxx"
2003-08-19 10:39:33 +00:00
# include "compiler.hxx"
2010-09-30 12:31:16 +01:00
# include "formula/opcode.hxx"
// cell range picker
2009-11-16 13:48:33 +01:00
# include "tabvwsh.hxx"
# include <sfx2/viewfrm.hxx>
# include <sfx2/childwin.hxx>
# include "reffact.hxx"
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
// ============================================================================
2000-09-18 16:07:07 +00:00
2011-01-17 13:20:22 +01:00
static sal_uInt16 pValueRanges [ ] =
2000-09-18 16:07:07 +00:00
{
FID_VALID_MODE , FID_VALID_ERRTEXT ,
2003-08-19 10:39:33 +00:00
FID_VALID_LISTTYPE , FID_VALID_LISTTYPE ,
2000-09-18 16:07:07 +00:00
0
} ;
2003-08-19 10:39:33 +00:00
// ============================================================================
2009-11-16 13:48:33 +01:00
ScValidationDlg : : ScValidationDlg ( Window * pParent ,
const SfxItemSet * pArgSet ,
ScTabViewShell * pTabViewSh ,
SfxBindings * pB /*= NULL*/
) :
ScValidationDlgBase ( pParent ? pParent : SFX_APP ( ) - > GetTopWindow ( ) , TAB_DLG_VALIDATION , pArgSet , pB ) ,
m_bOwnRefHdlr ( false ) ,
m_pTabVwSh ( pTabViewSh ) ,
m_bRefInputting ( false )
2000-09-18 16:07:07 +00:00
{
2003-08-19 10:39:33 +00:00
AddTabPage ( TP_VALIDATION_VALUES , ScTPValidationValue : : Create , 0 ) ;
2000-09-18 16:07:07 +00:00
AddTabPage ( TP_VALIDATION_INPUTHELP , ScTPValidationHelp : : Create , 0 ) ;
2003-08-19 10:39:33 +00:00
AddTabPage ( TP_VALIDATION_ERROR , ScTPValidationError : : Create , 0 ) ;
2000-09-18 16:07:07 +00:00
FreeResource ( ) ;
2013-03-08 09:23:53 +00:00
//temp hack until converted to .ui
mpHBox = new VclHBox ( get_content_area ( ) ) ;
2000-09-18 16:07:07 +00:00
}
2009-11-16 13:48:33 +01:00
void ScTPValidationValue : : SetReferenceHdl ( const ScRange & rRange , ScDocument * pDoc )
{
if ( rRange . aStart ! = rRange . aEnd )
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
if ( m_pRefEdit )
2010-09-30 12:31:16 +01:00
pValidationDlg - > RefInputStart ( m_pRefEdit ) ;
2009-11-16 13:48:33 +01:00
if ( m_pRefEdit )
{
2013-03-14 13:57:57 +05:30
OUString aStr ;
2009-11-16 13:48:33 +01:00
rRange . Format ( aStr , SCR_ABS_3D , pDoc ) ;
m_pRefEdit - > SetRefString ( aStr ) ;
}
}
void ScTPValidationValue : : SetActiveHdl ( )
{
if ( m_pRefEdit ) m_pRefEdit - > GrabFocus ( ) ;
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
if ( m_pRefEdit )
{
2010-09-30 12:31:16 +01:00
pValidationDlg - > RefInputDone ( ) ;
2009-11-16 13:48:33 +01:00
}
}
2011-01-12 13:29:17 -05:00
void ScTPValidationValue : : RefInputStartPreHdl ( formula : : RefEdit * pEdit , formula : : RefButton * pButton )
2009-11-16 13:48:33 +01:00
{
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
{
2013-03-08 09:23:53 +00:00
Window * pNewParent = pValidationDlg - > get_refinput_shrink_parent ( ) ;
2009-11-16 13:48:33 +01:00
if ( pEdit = = m_pRefEdit )
{
2013-03-08 09:23:53 +00:00
maRefEditPos = m_pRefEdit - > GetPosPixel ( ) ;
maRefEditSize = m_pRefEdit - > GetSizePixel ( ) ;
m_pRefEdit - > SetParent ( pNewParent ) ;
2009-11-16 13:48:33 +01:00
}
2013-03-08 09:23:53 +00:00
if ( pButton = = & m_btnRef )
{
maBtnRefPos = m_btnRef . GetPosPixel ( ) ;
maBtnRefSize = m_btnRef . GetSizePixel ( ) ;
m_btnRef . SetParent ( pNewParent ) ;
}
pNewParent - > Show ( ) ;
2009-11-16 13:48:33 +01:00
}
}
2013-03-08 09:23:53 +00:00
void ScTPValidationValue : : RefInputDonePostHdl ( )
2009-11-16 13:48:33 +01:00
{
if ( m_pRefEdit & & m_pRefEdit - > GetParent ( ) ! = this )
{
m_pRefEdit - > SetParent ( this ) ;
2013-03-08 09:23:53 +00:00
m_pRefEdit - > SetPosSizePixel ( maRefEditPos , maRefEditSize ) ;
2009-11-16 13:48:33 +01:00
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
2013-03-08 09:23:53 +00:00
m_btnRef . SetPosSizePixel ( maBtnRefPos , maBtnRefSize ) ;
2009-11-16 13:48:33 +01:00
}
if ( m_btnRef . GetParent ( ) ! = this ) m_btnRef . SetParent ( this ) ;
2013-03-08 09:23:53 +00:00
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
pValidationDlg - > get_refinput_shrink_parent ( ) - > Hide ( ) ;
2009-11-16 13:48:33 +01:00
if ( m_pRefEdit & & ! m_pRefEdit - > HasFocus ( ) )
m_pRefEdit - > GrabFocus ( ) ;
}
2011-01-17 13:20:22 +01:00
sal_Bool ScValidationDlg : : Close ( )
2009-11-16 13:48:33 +01:00
{
if ( m_bOwnRefHdlr )
if ( SfxTabPage * pPage = GetTabPage ( TP_VALIDATION_VALUES ) )
static_cast < ScTPValidationValue * > ( pPage ) - > RemoveRefDlg ( ) ;
return ScValidationDlgBase : : Close ( ) ;
}
2003-08-19 10:39:33 +00:00
ScValidationDlg : : ~ ScValidationDlg ( )
2000-09-18 16:07:07 +00:00
{
2009-11-16 13:48:33 +01:00
if ( m_bOwnRefHdlr )
2011-03-10 16:55:21 -05:00
RemoveRefDlg ( false ) ;
2013-03-08 09:23:53 +00:00
delete mpHBox ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
// ============================================================================
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
namespace {
/** Converts the passed ScValidationMode to the position in the list box. */
2011-01-17 13:20:22 +01:00
sal_uInt16 lclGetPosFromValMode ( ScValidationMode eValMode )
2000-09-18 16:07:07 +00:00
{
2011-01-17 13:20:22 +01:00
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY ;
2003-08-19 10:39:33 +00:00
switch ( eValMode )
{
case SC_VALID_ANY : nLbPos = SC_VALIDDLG_ALLOW_ANY ; break ;
case SC_VALID_WHOLE : nLbPos = SC_VALIDDLG_ALLOW_WHOLE ; break ;
case SC_VALID_DECIMAL : nLbPos = SC_VALIDDLG_ALLOW_DECIMAL ; break ;
case SC_VALID_DATE : nLbPos = SC_VALIDDLG_ALLOW_DATE ; break ;
case SC_VALID_TIME : nLbPos = SC_VALIDDLG_ALLOW_TIME ; break ;
case SC_VALID_TEXTLEN : nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN ; break ;
case SC_VALID_LIST : nLbPos = SC_VALIDDLG_ALLOW_RANGE ; break ;
case SC_VALID_CUSTOM : nLbPos = SC_VALIDDLG_ALLOW_ANY ; break ; // not supported
2011-05-21 15:04:26 +02:00
default : OSL_FAIL ( " lclGetPosFromValMode - unknown validity mode " ) ;
2003-08-19 10:39:33 +00:00
}
return nLbPos ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
/** Converts the passed list box position to an ScValidationMode. */
2011-01-17 13:20:22 +01:00
ScValidationMode lclGetValModeFromPos ( sal_uInt16 nLbPos )
2003-08-19 10:39:33 +00:00
{
ScValidationMode eValMode = SC_VALID_ANY ;
switch ( nLbPos )
{
case SC_VALIDDLG_ALLOW_ANY : eValMode = SC_VALID_ANY ; break ;
case SC_VALIDDLG_ALLOW_WHOLE : eValMode = SC_VALID_WHOLE ; break ;
case SC_VALIDDLG_ALLOW_DECIMAL : eValMode = SC_VALID_DECIMAL ; break ;
case SC_VALIDDLG_ALLOW_DATE : eValMode = SC_VALID_DATE ; break ;
case SC_VALIDDLG_ALLOW_TIME : eValMode = SC_VALID_TIME ; break ;
case SC_VALIDDLG_ALLOW_RANGE : eValMode = SC_VALID_LIST ; break ;
case SC_VALIDDLG_ALLOW_LIST : eValMode = SC_VALID_LIST ; break ;
case SC_VALIDDLG_ALLOW_TEXTLEN : eValMode = SC_VALID_TEXTLEN ; break ;
2011-05-21 15:04:26 +02:00
default : OSL_FAIL ( " lclGetValModeFromPos - invalid list box position " ) ;
2003-08-19 10:39:33 +00:00
}
return eValMode ;
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
/** Converts the passed ScConditionMode to the position in the list box. */
2011-01-17 13:20:22 +01:00
sal_uInt16 lclGetPosFromCondMode ( ScConditionMode eCondMode )
2000-09-18 16:07:07 +00:00
{
2011-01-17 13:20:22 +01:00
sal_uInt16 nLbPos = SC_VALIDDLG_DATA_EQUAL ;
2003-08-19 10:39:33 +00:00
switch ( eCondMode )
{
2011-03-01 14:29:24 +01:00
case SC_COND_NONE : // may occur in old XML files after Excel import
2003-08-19 10:39:33 +00:00
case SC_COND_EQUAL : nLbPos = SC_VALIDDLG_DATA_EQUAL ; break ;
case SC_COND_LESS : nLbPos = SC_VALIDDLG_DATA_LESS ; break ;
case SC_COND_GREATER : nLbPos = SC_VALIDDLG_DATA_GREATER ; break ;
case SC_COND_EQLESS : nLbPos = SC_VALIDDLG_DATA_EQLESS ; break ;
case SC_COND_EQGREATER : nLbPos = SC_VALIDDLG_DATA_EQGREATER ; break ;
case SC_COND_NOTEQUAL : nLbPos = SC_VALIDDLG_DATA_NOTEQUAL ; break ;
2012-06-14 22:49:11 -07:00
case SC_COND_BETWEEN : nLbPos = SC_VALIDDLG_DATA_VALIDRANGE ; break ;
case SC_COND_NOTBETWEEN : nLbPos = SC_VALIDDLG_DATA_INVALIDRANGE ; break ;
2011-05-21 15:04:26 +02:00
default : OSL_FAIL ( " lclGetPosFromCondMode - unknown condition mode " ) ;
2003-08-19 10:39:33 +00:00
}
return nLbPos ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
/** Converts the passed list box position to an ScConditionMode. */
2011-01-17 13:20:22 +01:00
ScConditionMode lclGetCondModeFromPos ( sal_uInt16 nLbPos )
2003-08-19 10:39:33 +00:00
{
ScConditionMode eCondMode = SC_COND_EQUAL ;
switch ( nLbPos )
{
case SC_VALIDDLG_DATA_EQUAL : eCondMode = SC_COND_EQUAL ; break ;
case SC_VALIDDLG_DATA_LESS : eCondMode = SC_COND_LESS ; break ;
case SC_VALIDDLG_DATA_GREATER : eCondMode = SC_COND_GREATER ; break ;
case SC_VALIDDLG_DATA_EQLESS : eCondMode = SC_COND_EQLESS ; break ;
case SC_VALIDDLG_DATA_EQGREATER : eCondMode = SC_COND_EQGREATER ; break ;
case SC_VALIDDLG_DATA_NOTEQUAL : eCondMode = SC_COND_NOTEQUAL ; break ;
2012-06-14 22:49:11 -07:00
case SC_VALIDDLG_DATA_VALIDRANGE : eCondMode = SC_COND_BETWEEN ; break ;
case SC_VALIDDLG_DATA_INVALIDRANGE : eCondMode = SC_COND_NOTBETWEEN ; break ;
2011-05-21 15:04:26 +02:00
default : OSL_FAIL ( " lclGetCondModeFromPos - invalid list box position " ) ;
2003-08-19 10:39:33 +00:00
}
return eCondMode ;
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
/** Converts line feed separated string to a formula with strings separated by semicolons.
@ descr Keeps all empty strings .
Example : abc \ ndef \ n \ nghi - > " abc " ; " def " ; " " ; " ghi " .
@ param rFmlaStr ( out - param ) The converted formula string . */
2013-03-14 13:57:57 +05:30
void lclGetFormulaFromStringList ( OUString & rFmlaStr , const OUString & rStringList , sal_Unicode cFmlaSep )
2003-08-19 10:39:33 +00:00
{
2013-03-14 13:57:57 +05:30
rFmlaStr = " " ;
2012-01-02 10:55:27 +00:00
xub_StrLen nTokenCnt = comphelper : : string : : getTokenCount ( rStringList , ' \n ' ) ;
2013-03-07 19:35:49 +05:30
for ( sal_Int32 nToken = 0 , nStringIx = 0 ; nToken < ( sal_Int32 ) nTokenCnt ; + + nToken )
2003-08-19 10:39:33 +00:00
{
2013-03-14 13:57:57 +05:30
OUString aToken ( rStringList . getToken ( 0 , ' \n ' , nStringIx ) ) ;
2008-12-12 09:38:47 +00:00
ScGlobal : : AddQuotes ( aToken , ' " ' ) ;
2012-10-28 20:31:11 +00:00
rFmlaStr = ScGlobal : : addToken ( rFmlaStr , aToken , cFmlaSep ) ;
2003-08-19 10:39:33 +00:00
}
2013-03-14 13:57:57 +05:30
if ( rFmlaStr . isEmpty ( ) )
rFmlaStr = " \" \" " ;
2003-08-19 10:39:33 +00:00
}
/** Converts formula with strings separated by semicolons to line feed separated string.
@ descr Keeps all empty strings . Ignores all empty tokens ( multiple semicolons ) .
Example : " abc " ; ; ; " def " ; " " ; " ghi " - > abc \ ndef \ n \ nghi .
@ param rStringList ( out - param ) The converted line feed separated string list .
@ return true = Conversion successful . */
2013-03-14 13:57:57 +05:30
bool lclGetStringListFromFormula ( OUString & rStringList , const OUString & rFmlaStr , sal_Unicode cFmlaSep )
2000-09-18 16:07:07 +00:00
{
2013-03-14 13:57:57 +05:30
OUString aQuotes ( " \" \" " ) ;
sal_Int32 nTokenCnt = ScStringUtil : : GetQuotedTokenCount ( rFmlaStr , aQuotes , cFmlaSep ) ;
2000-09-18 16:07:07 +00:00
2013-03-14 13:57:57 +05:30
rStringList = " " ;
2003-08-19 10:39:33 +00:00
bool bIsStringList = ( nTokenCnt > 0 ) ;
bool bTokenAdded = false ;
2000-09-18 16:07:07 +00:00
2013-03-14 13:57:57 +05:30
for ( sal_Int32 nToken = 0 , nStringIx = 0 ; bIsStringList & & ( nToken < nTokenCnt ) ; + + nToken )
2003-08-19 10:39:33 +00:00
{
2013-03-14 13:57:57 +05:30
OUString aToken ( ScStringUtil : : GetQuotedToken ( rFmlaStr , 0 , aQuotes , cFmlaSep , nStringIx ) ) ;
2011-11-23 22:17:24 +00:00
aToken = comphelper : : string : : strip ( aToken , ' ' ) ;
2013-03-15 01:20:05 +01:00
if ( ! aToken . isEmpty ( ) ) // ignore empty tokens, i.e. "a";;"b"
2003-08-19 10:39:33 +00:00
{
2008-12-12 09:38:47 +00:00
bIsStringList = ScGlobal : : IsQuoted ( aToken , ' " ' ) ;
2003-08-19 10:39:33 +00:00
if ( bIsStringList )
{
2008-12-12 09:38:47 +00:00
ScGlobal : : EraseQuotes ( aToken , ' " ' ) ;
2012-10-28 20:31:11 +00:00
rStringList = ScGlobal : : addToken ( rStringList , aToken , ' \n ' , 1 , bTokenAdded ) ;
2003-08-19 10:39:33 +00:00
bTokenAdded = true ;
}
}
}
return bIsStringList ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
} // namespace
// ----------------------------------------------------------------------------
ScTPValidationValue : : ScTPValidationValue ( Window * pParent , const SfxItemSet & rArgSet ) :
SfxTabPage ( pParent , ScResId ( TP_VALIDATION_VALUES ) , rArgSet ) ,
maFtAllow ( this , ScResId ( FT_ALLOW ) ) ,
maLbAllow ( this , ScResId ( LB_ALLOW ) ) ,
maCbAllow ( this , ScResId ( TSB_ALLOW_BLANKS ) ) ,
maCbShow ( this , ScResId ( CB_SHOWLIST ) ) ,
maCbSort ( this , ScResId ( CB_SORTLIST ) ) ,
maFtValue ( this , ScResId ( FT_VALUE ) ) ,
maLbValue ( this , ScResId ( LB_VALUE ) ) ,
maFtMin ( this , ScResId ( FT_MIN ) ) ,
2012-10-11 06:29:26 +02:00
maEdMin ( this , NULL , ScResId ( EDT_MIN ) ) ,
2003-08-19 10:39:33 +00:00
maEdList ( this , ScResId ( EDT_LIST ) ) ,
maFtMax ( this , ScResId ( FT_MAX ) ) ,
2012-10-11 06:29:26 +02:00
maEdMax ( this , NULL , ScResId ( EDT_MAX ) ) ,
2003-08-19 10:39:33 +00:00
maFtHint ( this , ScResId ( FT_SOURCEHINT ) ) ,
maStrMin ( ScResId ( SCSTR_VALID_MINIMUM ) ) ,
maStrMax ( ScResId ( SCSTR_VALID_MAXIMUM ) ) ,
maStrValue ( ScResId ( SCSTR_VALID_VALUE ) ) ,
maStrRange ( ScResId ( SCSTR_VALID_RANGE ) ) ,
2009-11-16 13:48:33 +01:00
maStrList ( ScResId ( SCSTR_VALID_LIST ) ) ,
2010-09-30 12:31:16 +01:00
m_btnRef ( this , ScResId ( RB_VALIDITY_REF ) )
2003-08-19 10:39:33 +00:00
{
Init ( ) ;
FreeResource ( ) ;
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
// list separator in formulas
2010-11-06 11:25:04 -04:00
String aListSep = : : ScCompiler : : GetNativeSymbol ( ocSep ) ;
2011-05-21 15:04:26 +02:00
OSL_ENSURE ( aListSep . Len ( ) = = 1 , " ScTPValidationValue::ScTPValidationValue - list separator error " ) ;
2008-01-10 12:15:13 +00:00
mcFmlaSep = aListSep . Len ( ) ? aListSep . GetChar ( 0 ) : ' ; ' ;
2010-09-30 12:31:16 +01:00
m_btnRef . Hide ( ) ; // cell range picker
2003-08-19 10:39:33 +00:00
}
ScTPValidationValue : : ~ ScTPValidationValue ( )
2000-09-18 16:07:07 +00:00
{
}
2003-08-19 10:39:33 +00:00
void ScTPValidationValue : : Init ( )
{
maLbAllow . SetSelectHdl ( LINK ( this , ScTPValidationValue , SelectHdl ) ) ;
maLbValue . SetSelectHdl ( LINK ( this , ScTPValidationValue , SelectHdl ) ) ;
maCbShow . SetClickHdl ( LINK ( this , ScTPValidationValue , CheckHdl ) ) ;
2010-09-30 12:31:16 +01:00
// cell range picker
2009-11-16 13:48:33 +01:00
maEdMin . SetGetFocusHdl ( LINK ( this , ScTPValidationValue , EditSetFocusHdl ) ) ;
maEdMin . SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
maEdMax . SetGetFocusHdl ( LINK ( this , ScTPValidationValue , EditSetFocusHdl ) ) ;
m_btnRef . SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
maEdMax . SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
maLbAllow . SelectEntryPos ( SC_VALIDDLG_ALLOW_ANY ) ;
maLbValue . SelectEntryPos ( SC_VALIDDLG_DATA_EQUAL ) ;
SelectHdl ( NULL ) ;
CheckHdl ( NULL ) ;
}
SfxTabPage * ScTPValidationValue : : Create ( Window * pParent , const SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
2003-08-19 10:39:33 +00:00
return ( new ScTPValidationValue ( pParent , rArgSet ) ) ;
2000-09-18 16:07:07 +00:00
}
2011-01-17 13:20:22 +01:00
sal_uInt16 * ScTPValidationValue : : GetRanges ( )
2003-08-19 10:39:33 +00:00
{
return pValueRanges ;
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
void ScTPValidationValue : : Reset ( const SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem * pItem ;
2011-01-17 13:20:22 +01:00
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY ;
if ( rArgSet . GetItemState ( FID_VALID_MODE , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
nLbPos = lclGetPosFromValMode ( static_cast < ScValidationMode > (
static_cast < const SfxAllEnumItem * > ( pItem ) - > GetValue ( ) ) ) ;
maLbAllow . SelectEntryPos ( nLbPos ) ;
nLbPos = SC_VALIDDLG_DATA_EQUAL ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_CONDMODE , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
nLbPos = lclGetPosFromCondMode ( static_cast < ScConditionMode > (
static_cast < const SfxAllEnumItem * > ( pItem ) - > GetValue ( ) ) ) ;
maLbValue . SelectEntryPos ( nLbPos ) ;
// *** check boxes ***
2011-01-17 13:20:22 +01:00
sal_Bool bCheck = sal_True ;
if ( rArgSet . GetItemState ( FID_VALID_BLANK , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
bCheck = static_cast < const SfxBoolItem * > ( pItem ) - > GetValue ( ) ;
maCbAllow . Check ( bCheck ) ;
sal_Int32 nListType = ValidListType : : UNSORTED ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_LISTTYPE , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
nListType = static_cast < const SfxInt16Item * > ( pItem ) - > GetValue ( ) ;
maCbShow . Check ( nListType ! = ValidListType : : INVISIBLE ) ;
maCbSort . Check ( nListType = = ValidListType : : SORTEDASCENDING ) ;
// *** formulas ***
String aFmlaStr ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_VALUE1 , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
aFmlaStr = static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ;
SetFirstFormula ( aFmlaStr ) ;
2001-01-17 18:28:42 +00:00
2003-08-19 10:39:33 +00:00
aFmlaStr . Erase ( ) ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_VALUE2 , sal_True , & pItem ) = = SFX_ITEM_SET )
2003-08-19 10:39:33 +00:00
aFmlaStr = static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ;
SetSecondFormula ( aFmlaStr ) ;
2001-01-17 18:28:42 +00:00
2003-08-19 10:39:33 +00:00
SelectHdl ( NULL ) ;
CheckHdl ( NULL ) ;
2000-09-18 16:07:07 +00:00
}
2011-01-17 13:20:22 +01:00
sal_Bool ScTPValidationValue : : FillItemSet ( SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
2003-08-19 10:39:33 +00:00
sal_Int16 nListType = maCbShow . IsChecked ( ) ?
( maCbSort . IsChecked ( ) ? ValidListType : : SORTEDASCENDING : ValidListType : : UNSORTED ) :
ValidListType : : INVISIBLE ;
2011-01-17 13:20:22 +01:00
rArgSet . Put ( SfxAllEnumItem ( FID_VALID_MODE , sal : : static_int_cast < sal_uInt16 > (
2007-02-27 12:05:45 +00:00
lclGetValModeFromPos ( maLbAllow . GetSelectEntryPos ( ) ) ) ) ) ;
2011-01-17 13:20:22 +01:00
rArgSet . Put ( SfxAllEnumItem ( FID_VALID_CONDMODE , sal : : static_int_cast < sal_uInt16 > (
2007-02-27 12:05:45 +00:00
lclGetCondModeFromPos ( maLbValue . GetSelectEntryPos ( ) ) ) ) ) ;
2003-08-19 10:39:33 +00:00
rArgSet . Put ( SfxStringItem ( FID_VALID_VALUE1 , GetFirstFormula ( ) ) ) ;
rArgSet . Put ( SfxStringItem ( FID_VALID_VALUE2 , GetSecondFormula ( ) ) ) ;
rArgSet . Put ( SfxBoolItem ( FID_VALID_BLANK , maCbAllow . IsChecked ( ) ) ) ;
rArgSet . Put ( SfxInt16Item ( FID_VALID_LISTTYPE , nListType ) ) ;
2011-01-17 13:20:22 +01:00
return sal_True ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
String ScTPValidationValue : : GetFirstFormula ( ) const
{
2013-03-14 13:57:57 +05:30
OUString aFmlaStr ;
2003-08-19 10:39:33 +00:00
if ( maLbAllow . GetSelectEntryPos ( ) = = SC_VALIDDLG_ALLOW_LIST )
lclGetFormulaFromStringList ( aFmlaStr , maEdList . GetText ( ) , mcFmlaSep ) ;
else
aFmlaStr = maEdMin . GetText ( ) ;
return aFmlaStr ;
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
String ScTPValidationValue : : GetSecondFormula ( ) const
2000-09-18 16:07:07 +00:00
{
2003-08-19 10:39:33 +00:00
return maEdMax . GetText ( ) ;
}
2000-09-18 16:07:07 +00:00
2013-03-14 13:57:57 +05:30
void ScTPValidationValue : : SetFirstFormula ( const OUString & rFmlaStr )
2003-08-19 10:39:33 +00:00
{
// try if formula is a string list, validation mode must already be set
2013-03-14 13:57:57 +05:30
OUString aStringList ;
2003-08-19 10:39:33 +00:00
if ( ( maLbAllow . GetSelectEntryPos ( ) = = SC_VALIDDLG_ALLOW_RANGE ) & &
lclGetStringListFromFormula ( aStringList , rFmlaStr , mcFmlaSep ) )
{
maEdList . SetText ( aStringList ) ;
maEdMin . SetText ( EMPTY_STRING ) ;
// change validation mode to string list
maLbAllow . SelectEntryPos ( SC_VALIDDLG_ALLOW_LIST ) ;
}
else
{
maEdMin . SetText ( rFmlaStr ) ;
maEdList . SetText ( EMPTY_STRING ) ;
}
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
void ScTPValidationValue : : SetSecondFormula ( const String & rFmlaStr )
{
maEdMax . SetText ( rFmlaStr ) ;
2000-09-18 16:07:07 +00:00
}
2009-11-16 13:48:33 +01:00
ScValidationDlg * ScTPValidationValue : : GetValidationDlg ( )
{
if ( Window * pParent = GetParent ( ) )
do {
if ( dynamic_cast < ScValidationDlg * > ( pParent ) )
return static_cast < ScValidationDlg * > ( pParent ) ;
} while ( NULL ! = ( pParent = pParent - > GetParent ( ) ) ) ;
return NULL ;
}
2010-09-30 12:31:16 +01:00
2009-11-16 13:48:33 +01:00
void ScTPValidationValue : : SetupRefDlg ( )
{
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
2013-03-08 13:41:51 +00:00
{
2009-11-16 13:48:33 +01:00
if ( pValidationDlg - > SetupRefDlg ( ) )
{
pValidationDlg - > SetHandler ( this ) ;
pValidationDlg - > SetSetRefHdl ( ( ScRefHandlerHelper : : PFUNCSETREFHDLTYPE ) ( & ScTPValidationValue : : SetReferenceHdl ) ) ;
pValidationDlg - > SetSetActHdl ( ( ScRefHandlerHelper : : PCOMMONHDLTYPE ) ( & ScTPValidationValue : : SetActiveHdl ) ) ;
pValidationDlg - > SetRefInputStartPreHdl ( ( ScRefHandlerHelper : : PINPUTSTARTDLTYPE ) ( & ScTPValidationValue : : RefInputStartPreHdl ) ) ;
pValidationDlg - > SetRefInputDonePostHdl ( ( ScRefHandlerHelper : : PCOMMONHDLTYPE ) ( & ScTPValidationValue : : RefInputDonePostHdl ) ) ;
2013-03-08 13:41:51 +00:00
Window * pLabel = NULL ;
2009-11-16 13:48:33 +01:00
2013-03-08 13:41:51 +00:00
if ( maEdMax . IsVisible ( ) )
{
m_pRefEdit = & maEdMax ;
pLabel = & maFtMax ;
}
else if ( maEdMin . IsVisible ( ) )
{
m_pRefEdit = & maEdMin ;
pLabel = & maFtMin ;
}
2009-11-16 13:48:33 +01:00
2013-03-08 13:41:51 +00:00
if ( m_pRefEdit & & ! m_pRefEdit - > HasFocus ( ) )
m_pRefEdit - > GrabFocus ( ) ;
if ( m_pRefEdit )
m_pRefEdit - > SetRefDialog ( pValidationDlg ) ;
m_btnRef . SetReferences ( pValidationDlg , m_pRefEdit , pLabel ) ;
2009-11-16 13:48:33 +01:00
}
2013-03-08 13:41:51 +00:00
}
2009-11-16 13:48:33 +01:00
}
void ScTPValidationValue : : RemoveRefDlg ( )
{
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
2013-03-08 13:41:51 +00:00
{
2009-11-16 13:48:33 +01:00
if ( pValidationDlg - > RemoveRefDlg ( ) )
{
pValidationDlg - > SetHandler ( NULL ) ;
pValidationDlg - > SetSetRefHdl ( NULL ) ;
pValidationDlg - > SetSetActHdl ( NULL ) ;
pValidationDlg - > SetRefInputStartPreHdl ( NULL ) ;
pValidationDlg - > SetRefInputDonePostHdl ( NULL ) ;
2013-03-08 13:41:51 +00:00
if ( m_pRefEdit )
m_pRefEdit - > SetRefDialog ( NULL ) ;
2009-11-16 13:48:33 +01:00
m_pRefEdit = NULL ;
2013-03-08 13:41:51 +00:00
m_btnRef . SetReferences ( NULL , NULL , NULL ) ;
2009-11-16 13:48:33 +01:00
# if ! defined( WNT ) && !defined( _MSC_VER )
TidyListBoxes ( ) ;
# endif
}
2013-03-08 13:41:51 +00:00
}
2009-11-16 13:48:33 +01:00
}
void ScTPValidationValue : : TidyListBoxes ( )
{
if ( Window * pWnd = GetChild ( 0 ) )
{
bool bFindLst = false ;
std : : list < Window * > alstOrder ;
do {
if ( pWnd - > GetParent ( ) = = this )
{
if ( ! bFindLst )
{
try {
if ( dynamic_cast < ListBox * > ( pWnd ) | | dynamic_cast < ListBox * > ( pWnd - > GetWindow ( WINDOW_CLIENT ) ) )
bFindLst = true ;
}
catch ( . . . )
{
if ( * ( void * * ) pWnd = = * ( void * * ) & maLbValue )
bFindLst = true ;
else if ( Window * pClient = pWnd - > GetWindow ( WINDOW_CLIENT ) )
if ( * ( void * * ) pClient = = * ( void * * ) & maLbValue )
bFindLst = true ;
}
}
if ( bFindLst )
alstOrder . push_back ( pWnd - > GetWindow ( WINDOW_CLIENT ) ) ;
}
} while ( NULL ! = ( pWnd = pWnd - > GetWindow ( WINDOW_NEXT ) ) ) ;
pWnd = GetChild ( 0 ) ;
2010-03-04 23:07:14 +00:00
while ( std : : find ( alstOrder . begin ( ) , alstOrder . end ( ) , pWnd ) ! = alstOrder . end ( ) & & NULL ! = ( pWnd = pWnd - > GetWindow ( WINDOW_NEXT ) ) ) ;
2009-11-16 13:48:33 +01:00
if ( pWnd )
{
2010-12-21 01:22:29 -05:00
for ( std : : list < Window * > : : iterator i = alstOrder . begin ( ) ; i ! = alstOrder . end ( ) ; + + i )
2009-11-16 13:48:33 +01:00
{
Window * pParent = ( * i ) - > GetParent ( ) ;
( * i ) - > SetParent ( pWnd ) ;
( * i ) - > SetParent ( pParent ) ;
}
}
}
}
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationValue , EditSetFocusHdl )
2009-11-16 13:48:33 +01:00
{
2011-01-17 13:20:22 +01:00
sal_uInt16 nPos = maLbAllow . GetSelectEntryPos ( ) ;
2009-11-16 13:48:33 +01:00
if ( nPos = = SC_VALIDDLG_ALLOW_RANGE )
{
SetupRefDlg ( ) ;
}
return 0 ;
}
IMPL_LINK ( ScTPValidationValue , KillFocusHdl , Window * , pWnd )
{
if ( pWnd = = m_pRefEdit | | pWnd = = & m_btnRef )
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
if ( ( pValidationDlg - > IsActive ( ) | | pValidationDlg - > IsChildFocus ( ) ) & & ! pValidationDlg - > IsRefInputting ( ) )
if ( ( ! m_pRefEdit | | ! m_pRefEdit - > HasFocus ( ) ) & & ! m_btnRef . HasFocus ( ) )
{
RemoveRefDlg ( ) ;
}
return 0 ;
}
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
// ----------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationValue , SelectHdl )
2003-08-19 10:39:33 +00:00
{
2011-01-17 13:20:22 +01:00
sal_uInt16 nLbPos = maLbAllow . GetSelectEntryPos ( ) ;
2003-08-19 10:39:33 +00:00
bool bEnable = ( nLbPos ! = SC_VALIDDLG_ALLOW_ANY ) ;
bool bRange = ( nLbPos = = SC_VALIDDLG_ALLOW_RANGE ) ;
bool bList = ( nLbPos = = SC_VALIDDLG_ALLOW_LIST ) ;
2010-09-30 12:31:16 +01:00
maCbAllow . Enable ( bEnable ) ; // Empty cell
2003-08-19 10:39:33 +00:00
maFtValue . Enable ( bEnable ) ;
maLbValue . Enable ( bEnable ) ;
maFtMin . Enable ( bEnable ) ;
maEdMin . Enable ( bEnable ) ;
maEdList . Enable ( bEnable ) ;
maFtMax . Enable ( bEnable ) ;
maEdMax . Enable ( bEnable ) ;
bool bShowMax = false ;
if ( bRange )
maFtMin . SetText ( maStrRange ) ;
else if ( bList )
maFtMin . SetText ( maStrList ) ;
else
2000-09-18 16:07:07 +00:00
{
2003-08-19 10:39:33 +00:00
switch ( maLbValue . GetSelectEntryPos ( ) )
{
case SC_VALIDDLG_DATA_EQUAL :
case SC_VALIDDLG_DATA_NOTEQUAL : maFtMin . SetText ( maStrValue ) ; break ;
case SC_VALIDDLG_DATA_LESS :
case SC_VALIDDLG_DATA_EQLESS : maFtMin . SetText ( maStrMax ) ; break ;
2012-06-14 22:49:11 -07:00
case SC_VALIDDLG_DATA_VALIDRANGE :
case SC_VALIDDLG_DATA_INVALIDRANGE : bShowMax = true ; // fall through
2003-08-19 10:39:33 +00:00
case SC_VALIDDLG_DATA_GREATER :
case SC_VALIDDLG_DATA_EQGREATER : maFtMin . SetText ( maStrMin ) ; break ;
default :
2011-05-21 15:04:26 +02:00
OSL_FAIL ( " ScTPValidationValue::SelectHdl - unknown condition mode " ) ;
2003-08-19 10:39:33 +00:00
}
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
maCbShow . Show ( bRange | | bList ) ;
maCbSort . Show ( bRange | | bList ) ;
maFtValue . Show ( ! bRange & & ! bList ) ;
maLbValue . Show ( ! bRange & & ! bList ) ;
maEdMin . Show ( ! bList ) ;
maEdList . Show ( bList ) ;
maFtMax . Show ( bShowMax ) ;
maEdMax . Show ( bShowMax ) ;
maFtHint . Show ( bRange ) ;
2010-09-30 12:31:16 +01:00
m_btnRef . Show ( bRange ) ; // cell range picker
2003-08-19 10:39:33 +00:00
return 0 ;
}
2000-09-18 16:07:07 +00:00
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationValue , CheckHdl )
2003-08-19 10:39:33 +00:00
{
maCbSort . Enable ( maCbShow . IsChecked ( ) ) ;
return 0 ;
2000-09-18 16:07:07 +00:00
}
2003-08-19 10:39:33 +00:00
2000-09-18 16:07:07 +00:00
//========================================================================
//========================================================================
2001-01-17 18:28:42 +00:00
// Input Help Page
2000-09-18 16:07:07 +00:00
ScTPValidationHelp : : ScTPValidationHelp ( Window * pParent ,
const SfxItemSet & rArgSet )
: SfxTabPage ( pParent ,
ScResId ( TP_VALIDATION_INPUTHELP ) ,
rArgSet ) ,
aTsbHelp ( this , ScResId ( TSB_HELP ) ) ,
2007-02-27 12:05:45 +00:00
aFlContent ( this , ScResId ( FL_CONTENT ) ) ,
2000-09-18 16:07:07 +00:00
aFtTitle ( this , ScResId ( FT_TITLE ) ) ,
aEdtTitle ( this , ScResId ( EDT_TITLE ) ) ,
aFtInputHelp ( this , ScResId ( FT_INPUTHELP ) ) ,
2012-09-11 11:18:45 +02:00
aEdInputHelp ( this , ScResId ( EDT_INPUTHELP ) )
2000-09-18 16:07:07 +00:00
{
Init ( ) ;
FreeResource ( ) ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
ScTPValidationHelp : : ~ ScTPValidationHelp ( )
2000-09-18 16:07:07 +00:00
{
}
// -----------------------------------------------------------------------
void ScTPValidationHelp : : Init ( )
{
2011-03-10 16:55:21 -05:00
aTsbHelp . EnableTriState ( false ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------
2011-03-10 16:55:21 -05:00
sal_uInt16 * ScTPValidationHelp : : GetRanges ( )
2000-09-18 16:07:07 +00:00
{
return pValueRanges ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
SfxTabPage * ScTPValidationHelp : : Create ( Window * pParent ,
2000-09-18 16:07:07 +00:00
const SfxItemSet & rArgSet )
{
return ( new ScTPValidationHelp ( pParent , rArgSet ) ) ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
void ScTPValidationHelp : : Reset ( const SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem * pItem ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_SHOWHELP , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aTsbHelp . SetState ( ( ( const SfxBoolItem * ) pItem ) - > GetValue ( ) ? STATE_CHECK : STATE_NOCHECK ) ;
2001-01-17 18:28:42 +00:00
else
aTsbHelp . SetState ( STATE_NOCHECK ) ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_HELPTITLE , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aEdtTitle . SetText ( ( ( const SfxStringItem * ) pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
aEdtTitle . SetText ( EMPTY_STRING ) ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_HELPTEXT , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aEdInputHelp . SetText ( ( ( const SfxStringItem * ) pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
aEdInputHelp . SetText ( EMPTY_STRING ) ;
2000-09-18 16:07:07 +00:00
}
// -----------------------------------------------------------------------
2011-03-10 16:55:21 -05:00
sal_Bool ScTPValidationHelp : : FillItemSet ( SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
rArgSet . Put ( SfxBoolItem ( FID_VALID_SHOWHELP , aTsbHelp . GetState ( ) = = STATE_CHECK ) ) ;
rArgSet . Put ( SfxStringItem ( FID_VALID_HELPTITLE , aEdtTitle . GetText ( ) ) ) ;
rArgSet . Put ( SfxStringItem ( FID_VALID_HELPTEXT , aEdInputHelp . GetText ( ) ) ) ;
2011-01-17 13:20:22 +01:00
return sal_True ;
2000-09-18 16:07:07 +00:00
}
//========================================================================
//========================================================================
2001-01-17 18:28:42 +00:00
// Error Alert Page
2000-09-18 16:07:07 +00:00
ScTPValidationError : : ScTPValidationError ( Window * pParent ,
const SfxItemSet & rArgSet )
: SfxTabPage ( pParent ,
ScResId ( TP_VALIDATION_ERROR ) ,
rArgSet ) ,
aTsbShow ( this , ScResId ( TSB_SHOW ) ) ,
2007-02-27 12:05:45 +00:00
aFlContent ( this , ScResId ( FL_CONTENT ) ) ,
2000-09-18 16:07:07 +00:00
aFtAction ( this , ScResId ( FT_ACTION ) ) ,
aLbAction ( this , ScResId ( LB_ACTION ) ) ,
aBtnSearch ( this , ScResId ( BTN_SEARCH ) ) ,
aFtTitle ( this , ScResId ( FT_TITLE ) ) ,
aEdtTitle ( this , ScResId ( EDT_TITLE ) ) ,
aFtError ( this , ScResId ( FT_ERROR ) ) ,
2012-09-11 11:18:45 +02:00
aEdError ( this , ScResId ( EDT_ERROR ) )
2000-09-18 16:07:07 +00:00
{
Init ( ) ;
FreeResource ( ) ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
ScTPValidationError : : ~ ScTPValidationError ( )
2000-09-18 16:07:07 +00:00
{
}
// -----------------------------------------------------------------------
void ScTPValidationError : : Init ( )
{
aLbAction . SetSelectHdl ( LINK ( this , ScTPValidationError , SelectActionHdl ) ) ;
aBtnSearch . SetClickHdl ( LINK ( this , ScTPValidationError , ClickSearchHdl ) ) ;
aLbAction . SelectEntryPos ( 0 ) ;
2011-03-10 16:55:21 -05:00
aTsbShow . EnableTriState ( false ) ;
2000-09-18 16:07:07 +00:00
SelectActionHdl ( NULL ) ;
}
//------------------------------------------------------------------------
2011-03-10 16:55:21 -05:00
sal_uInt16 * ScTPValidationError : : GetRanges ( )
2000-09-18 16:07:07 +00:00
{
return pValueRanges ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
SfxTabPage * ScTPValidationError : : Create ( Window * pParent ,
2000-09-18 16:07:07 +00:00
const SfxItemSet & rArgSet )
{
return ( new ScTPValidationError ( pParent , rArgSet ) ) ;
}
// -----------------------------------------------------------------------
2010-12-11 23:25:30 +01:00
void ScTPValidationError : : Reset ( const SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem * pItem ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_SHOWERR , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aTsbShow . SetState ( ( ( const SfxBoolItem * ) pItem ) - > GetValue ( ) ? STATE_CHECK : STATE_NOCHECK ) ;
2001-01-17 18:28:42 +00:00
else
2011-03-01 14:29:24 +01:00
aTsbShow . SetState ( STATE_CHECK ) ; // check by default
2001-01-17 18:28:42 +00:00
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_ERRSTYLE , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aLbAction . SelectEntryPos ( ( ( const SfxAllEnumItem * ) pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
aLbAction . SelectEntryPos ( 0 ) ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_ERRTITLE , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aEdtTitle . SetText ( ( ( const SfxStringItem * ) pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
aEdtTitle . SetText ( EMPTY_STRING ) ;
2011-01-17 13:20:22 +01:00
if ( rArgSet . GetItemState ( FID_VALID_ERRTEXT , sal_True , & pItem ) = = SFX_ITEM_SET )
2000-09-18 16:07:07 +00:00
aEdError . SetText ( ( ( const SfxStringItem * ) pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
aEdError . SetText ( EMPTY_STRING ) ;
2000-09-18 16:07:07 +00:00
SelectActionHdl ( NULL ) ;
}
// -----------------------------------------------------------------------
2011-03-10 16:55:21 -05:00
sal_Bool ScTPValidationError : : FillItemSet ( SfxItemSet & rArgSet )
2000-09-18 16:07:07 +00:00
{
rArgSet . Put ( SfxBoolItem ( FID_VALID_SHOWERR , aTsbShow . GetState ( ) = = STATE_CHECK ) ) ;
rArgSet . Put ( SfxAllEnumItem ( FID_VALID_ERRSTYLE , aLbAction . GetSelectEntryPos ( ) ) ) ;
rArgSet . Put ( SfxStringItem ( FID_VALID_ERRTITLE , aEdtTitle . GetText ( ) ) ) ;
rArgSet . Put ( SfxStringItem ( FID_VALID_ERRTEXT , aEdError . GetText ( ) ) ) ;
2011-01-17 13:20:22 +01:00
return sal_True ;
2000-09-18 16:07:07 +00:00
}
// -----------------------------------------------------------------------
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationError , SelectActionHdl )
2000-09-18 16:07:07 +00:00
{
ScValidErrorStyle eStyle = ( ScValidErrorStyle ) aLbAction . GetSelectEntryPos ( ) ;
2011-01-17 13:20:22 +01:00
sal_Bool bMacro = ( eStyle = = SC_VALERR_MACRO ) ;
2000-09-18 16:07:07 +00:00
aBtnSearch . Enable ( bMacro ) ;
aFtError . Enable ( ! bMacro ) ;
aEdError . Enable ( ! bMacro ) ;
return ( 0L ) ;
}
// -----------------------------------------------------------------------
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationError , ClickSearchHdl )
2000-09-18 16:07:07 +00:00
{
Window * pOld = Application : : GetDefDialogParent ( ) ;
Application : : SetDefDialogParent ( this ) ;
2004-05-19 06:59:30 +00:00
// Use static SfxApplication method to bring up selector dialog for
// choosing a script
: : rtl : : OUString aScriptURL = SfxApplication : : ChooseScript ( ) ;
2001-08-03 14:28:32 +00:00
Application : : SetDefDialogParent ( pOld ) ;
2001-07-17 07:54:01 +00:00
2012-01-06 14:22:10 -02:00
if ( aScriptURL ! = NULL & & ! aScriptURL . isEmpty ( ) )
2000-09-18 16:07:07 +00:00
{
2004-05-19 06:59:30 +00:00
aEdtTitle . SetText ( aScriptURL ) ;
2000-09-18 16:07:07 +00:00
}
return ( 0L ) ;
}
2009-11-16 13:48:33 +01:00
bool ScValidationDlg : : EnterRefStatus ( )
{
ScTabViewShell * pTabViewShell = GetTabViewShell ( ) ;
if ( ! pTabViewShell ) return false ;
2011-01-17 13:20:22 +01:00
sal_uInt16 nId = SLOTID ;
2009-11-16 13:48:33 +01:00
SfxViewFrame * pViewFrm = pTabViewShell - > GetViewFrame ( ) ;
SfxChildWindow * pWnd = pViewFrm - > GetChildWindow ( nId ) ;
if ( pWnd & & pWnd - > GetWindow ( ) ! = this ) pWnd = NULL ;
2011-03-10 16:55:21 -05:00
SC_MOD ( ) - > SetRefDialog ( nId , pWnd ? false : sal_True ) ;
2009-11-16 13:48:33 +01:00
return true ;
}
bool ScValidationDlg : : LeaveRefStatus ( )
{
ScTabViewShell * pTabViewShell = GetTabViewShell ( ) ;
if ( ! pTabViewShell ) return false ;
2011-01-17 13:20:22 +01:00
sal_uInt16 nId = SLOTID ;
2009-11-16 13:48:33 +01:00
SfxViewFrame * pViewFrm = pTabViewShell - > GetViewFrame ( ) ;
if ( pViewFrm - > GetChildWindow ( nId ) )
{
DoClose ( nId ) ;
}
return true ;
}
bool ScValidationDlg : : SetupRefDlg ( )
{
if ( m_bOwnRefHdlr ) return false ;
if ( EnterRefMode ( ) )
{
2011-03-10 16:55:21 -05:00
SetModal ( false ) ;
2010-09-30 12:31:16 +01:00
return m_bOwnRefHdlr = true & & EnterRefStatus ( ) ;
2009-11-16 13:48:33 +01:00
}
return false ;
}
2011-01-17 13:20:22 +01:00
bool ScValidationDlg : : RemoveRefDlg ( sal_Bool bRestoreModal /* = sal_True */ )
2009-11-16 13:48:33 +01:00
{
bool bVisLock = false ;
bool bFreeWindowLock = false ;
ScTabViewShell * pTabVwSh = GetTabViewShell ( ) ;
if ( ! pTabVwSh ) return false ;
if ( SfxChildWindow * pWnd = pTabVwSh - > GetViewFrame ( ) - > GetChildWindow ( SID_VALIDITY_REFERENCE ) )
{
bVisLock = static_cast < ScValidityRefChildWin * > ( pWnd ) - > LockVisible ( true ) ;
bFreeWindowLock = static_cast < ScValidityRefChildWin * > ( pWnd ) - > LockFreeWindow ( true ) ;
}
if ( ! m_bOwnRefHdlr ) return false ;
if ( LeaveRefStatus ( ) & & LeaveRefMode ( ) )
{
m_bOwnRefHdlr = false ;
if ( bRestoreModal )
2011-01-17 13:20:22 +01:00
SetModal ( sal_True ) ;
2009-11-16 13:48:33 +01:00
}
if ( SfxChildWindow * pWnd = pTabVwSh - > GetViewFrame ( ) - > GetChildWindow ( SID_VALIDITY_REFERENCE ) )
{
static_cast < ScValidityRefChildWin * > ( pWnd ) - > LockVisible ( bVisLock ) ;
static_cast < ScValidityRefChildWin * > ( pWnd ) - > LockFreeWindow ( bFreeWindowLock ) ;
}
return true ;
}
void ScTPValidationValue : : ScRefButtonEx : : Click ( )
{
if ( ScTPValidationValue * pParent = dynamic_cast < ScTPValidationValue * > ( GetParent ( ) ) )
pParent - > OnClick ( this ) ;
2011-01-12 13:29:17 -05:00
formula : : RefButton : : Click ( ) ;
2009-11-16 13:48:33 +01:00
}
void ScTPValidationValue : : OnClick ( Button * pBtn )
{
if ( pBtn = = & m_btnRef )
SetupRefDlg ( ) ;
}
2011-01-17 13:20:22 +01:00
sal_Bool ScValidationDlg : : IsChildFocus ( )
2009-11-16 13:48:33 +01:00
{
if ( const Window * pWin = Application : : GetFocusWindow ( ) )
while ( NULL ! = ( pWin = pWin - > GetParent ( ) ) )
if ( pWin = = this )
2011-01-17 13:20:22 +01:00
return sal_True ;
2009-11-16 13:48:33 +01:00
2011-03-10 16:55:21 -05:00
return false ;
2009-11-16 13:48:33 +01:00
}
bool ScValidationDlg : : IsAlive ( )
{
return SC_MOD ( ) - > IsAliveRefDlg ( SLOTID , this ) ;
}
2010-10-12 15:59:00 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */