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
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>
2015-05-09 21:15:13 +01:00
# include <vcl/builderfactory.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"
2013-10-22 15:58:57 +03:00
# include "sc.hrc"
2000-09-18 16:07:07 +00:00
2012-08-04 10:33:53 +01:00
# include "stringutil.hxx"
2000-09-18 16:07:07 +00:00
# include "validat.hxx"
# include "validate.hxx"
2003-08-19 10:39:33 +00:00
# include "compiler.hxx"
2014-05-10 18:19:39 +02:00
# include <formula/opcode.hxx>
2010-09-30 12:31:16 +01:00
// 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
2014-04-08 16:56:03 +01:00
/* Position indexes for "Allow" list box.
They do not map directly to ScValidationMode and can safely be modified to
change the order of the list box entries . */
# define SC_VALIDDLG_ALLOW_ANY 0
# define SC_VALIDDLG_ALLOW_WHOLE 1
# define SC_VALIDDLG_ALLOW_DECIMAL 2
# define SC_VALIDDLG_ALLOW_DATE 3
# define SC_VALIDDLG_ALLOW_TIME 4
# define SC_VALIDDLG_ALLOW_RANGE 5
# define SC_VALIDDLG_ALLOW_LIST 6
# define SC_VALIDDLG_ALLOW_TEXTLEN 7
/* Position indexes for "Data" list box.
They do not map directly to ScConditionMode and can safely be modified to
change the order of the list box entries . */
# define SC_VALIDDLG_DATA_EQUAL 0
# define SC_VALIDDLG_DATA_LESS 1
# define SC_VALIDDLG_DATA_GREATER 2
# define SC_VALIDDLG_DATA_EQLESS 3
# define SC_VALIDDLG_DATA_EQGREATER 4
# define SC_VALIDDLG_DATA_NOTEQUAL 5
# define SC_VALIDDLG_DATA_VALIDRANGE 6
# define SC_VALIDDLG_DATA_INVALIDRANGE 7
2014-09-05 15:34:48 +00:00
namespace ValidListType = css : : sheet : : TableValidationVisibility ;
2015-03-19 15:27:30 +02:00
const sal_uInt16 ScTPValidationValue : : 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
} ;
2014-09-23 11:20:40 +02:00
ScValidationDlg : : ScValidationDlg ( vcl : : Window * pParent , const SfxItemSet * pArgSet ,
2013-12-23 17:33:24 +00:00
ScTabViewShell * pTabViewSh , SfxBindings * pB /*= NULL*/ )
2014-06-27 10:26:55 +02:00
: ScValidationDlgBase ( pParent ? pParent : SfxGetpApp ( ) - > GetTopWindow ( ) ,
2013-12-23 17:33:24 +00:00
" ValidationDialog " , " modules/scalc/ui/validationdialog.ui " , pArgSet , pB )
, m_pTabVwSh ( pTabViewSh )
, m_nValuePageId ( 0 )
, m_bOwnRefHdlr ( false )
, m_bRefInputting ( false )
2000-09-18 16:07:07 +00:00
{
2013-12-23 17:33:24 +00:00
m_nValuePageId = AddTabPage ( " criteria " , ScTPValidationValue : : Create , 0 ) ;
AddTabPage ( " inputhelp " , ScTPValidationHelp : : Create , 0 ) ;
AddTabPage ( " erroralert " , ScTPValidationError : : Create , 0 ) ;
get ( m_pHBox , " refinputbox " ) ;
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 )
{
2014-09-22 08:07:01 +02:00
OUString aStr ( rRange . Format ( SCR_ABS_3D , pDoc , pDoc - > GetAddressConvention ( ) ) ) ;
2009-11-16 13:48:33 +01:00
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
}
}
2014-04-08 16:56:03 +01:00
void ScTPValidationValue : : RefInputStartPreHdl ( formula : : RefEdit * pEdit , formula : : RefButton * pButton )
2009-11-16 13:48:33 +01:00
{
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
{
2014-09-23 11:20:40 +02:00
vcl : : Window * pNewParent = pValidationDlg - > get_refinput_shrink_parent ( ) ;
Related: fdo#61948 data->validity crashes calc
There are two scenarios with the cell range thing here,
data->validity->allow->cell range
scenario a), click the shrink icon, dialog shrinks, click the expand icon,
dialog expands again
scenario b), click inside the edit box, now you can select cells in
the spreadsheet, and the dialog autoshrinks, and autoexpands on mouse release
in scenario a there is an expand button in the shrunked dialog, in
scenario b the shrink/expand button is hidden
Change-Id: I8efe76536feeae10ac70fb7b7e95c70c69b057b5
2013-04-05 11:36:34 +01:00
if ( pEdit = = m_pRefEdit & & m_pRefEdit - > GetParent ( ) ! = pNewParent )
2009-11-16 13:48:33 +01:00
{
2013-03-08 09:23:53 +00:00
m_pRefEdit - > SetParent ( pNewParent ) ;
2009-11-16 13:48:33 +01:00
}
2014-04-08 16:56:03 +01:00
if ( pButton = = m_pBtnRef & & m_pBtnRef - > GetParent ( ) ! = pNewParent )
2013-03-08 09:23:53 +00:00
{
2014-04-08 16:56:03 +01:00
m_pBtnRef - > SetParent ( pNewParent ) ;
2013-03-08 09:23:53 +00:00
}
Related: fdo#61948 data->validity crashes calc
There are two scenarios with the cell range thing here,
data->validity->allow->cell range
scenario a), click the shrink icon, dialog shrinks, click the expand icon,
dialog expands again
scenario b), click inside the edit box, now you can select cells in
the spreadsheet, and the dialog autoshrinks, and autoexpands on mouse release
in scenario a there is an expand button in the shrunked dialog, in
scenario b the shrink/expand button is hidden
Change-Id: I8efe76536feeae10ac70fb7b7e95c70c69b057b5
2013-04-05 11:36:34 +01:00
2013-03-08 09:23:53 +00:00
pNewParent - > Show ( ) ;
2009-11-16 13:48:33 +01:00
}
}
2014-04-08 16:56:03 +01:00
void ScTPValidationValue : : RefInputDonePostHdl ( )
2009-11-16 13:48:33 +01:00
{
2014-04-08 16:56:03 +01:00
if ( m_pRefEdit & & m_pRefEdit - > GetParent ( ) ! = m_pRefGrid )
2009-11-16 13:48:33 +01:00
{
2014-04-08 16:56:03 +01:00
m_pRefEdit - > SetParent ( m_pRefGrid ) ;
2015-06-16 12:20:56 +02:00
m_pBtnRef - > SetParent ( m_pRefEdit ) ; //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to another window and restore parent later in order to restore the tab order
Related: fdo#61948 data->validity crashes calc
There are two scenarios with the cell range thing here,
data->validity->allow->cell range
scenario a), click the shrink icon, dialog shrinks, click the expand icon,
dialog expands again
scenario b), click inside the edit box, now you can select cells in
the spreadsheet, and the dialog autoshrinks, and autoexpands on mouse release
in scenario a there is an expand button in the shrunked dialog, in
scenario b the shrink/expand button is hidden
Change-Id: I8efe76536feeae10ac70fb7b7e95c70c69b057b5
2013-04-05 11:36:34 +01:00
}
2014-04-08 16:56:03 +01:00
if ( m_pBtnRef - > GetParent ( ) ! = m_pRefGrid )
m_pBtnRef - > SetParent ( m_pRefGrid ) ;
2009-11-16 13:48:33 +01:00
2013-03-08 09:23:53 +00:00
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
2014-09-27 07:59:04 +02:00
{
2013-03-08 09:23:53 +00:00
pValidationDlg - > get_refinput_shrink_parent ( ) - > Hide ( ) ;
2014-09-27 07:59:04 +02:00
ScViewData & rViewData = pValidationDlg - > GetTabViewShell ( ) - > GetViewData ( ) ;
SCTAB nCurTab = rViewData . GetTabNo ( ) ;
SCTAB nRefTab = rViewData . GetRefTabNo ( ) ;
// If RefInput switched to a different sheet from the data sheet,
// switch back: fdo#53920
if ( nCurTab ! = nRefTab )
{
rViewData . GetViewShell ( ) - > SetTabNo ( nRefTab ) ;
}
}
2009-11-16 13:48:33 +01:00
if ( m_pRefEdit & & ! m_pRefEdit - > HasFocus ( ) )
m_pRefEdit - > GrabFocus ( ) ;
}
2015-03-09 14:29:30 +02:00
ScTPValidationValue : : ScRefButtonEx : : ~ ScRefButtonEx ( )
{
2015-03-10 09:07:06 +02:00
disposeOnce ( ) ;
2015-03-09 14:29:30 +02:00
}
void ScTPValidationValue : : ScRefButtonEx : : dispose ( )
{
m_pPage . clear ( ) ;
: : formula : : RefButton : : dispose ( ) ;
}
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
{
2014-12-18 13:29:00 +01:00
rFmlaStr . clear ( ) ;
2013-08-06 00:48:55 +02:00
sal_Int32 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
2014-12-18 13:29:00 +01:00
rStringList . clear ( ) ;
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
2014-09-23 11:20:40 +02:00
ScTPValidationValue : : ScTPValidationValue ( vcl : : Window * pParent , const SfxItemSet & rArgSet )
2014-04-08 16:56:03 +01:00
: SfxTabPage ( pParent , " ValidationCriteriaPage " ,
2014-06-11 14:34:46 +02:00
" modules/scalc/ui/validationcriteriapage.ui " , & rArgSet )
2014-04-08 16:56:03 +01:00
, maStrMin ( ScResId ( SCSTR_VALID_MINIMUM ) )
, maStrMax ( ScResId ( SCSTR_VALID_MAXIMUM ) )
, maStrValue ( ScResId ( SCSTR_VALID_VALUE ) )
, maStrRange ( ScResId ( SCSTR_VALID_RANGE ) )
, maStrList ( ScResId ( SCSTR_VALID_LIST ) )
2014-04-29 11:00:20 +01:00
, m_pRefEdit ( NULL )
2014-04-08 16:56:03 +01:00
{
get ( m_pLbAllow , " allow " ) ;
get ( m_pCbAllow , " allowempty " ) ;
get ( m_pCbShow , " showlist " ) ;
get ( m_pCbSort , " sortascend " ) ;
get ( m_pFtValue , " valueft " ) ;
get ( m_pLbValue , " data " ) ;
get ( m_pFtMin , " minft " ) ;
get ( m_pMinGrid , " mingrid " ) ;
get ( m_pEdMin , " min " ) ;
m_pEdMin - > SetReferences ( NULL , m_pFtMin ) ;
get ( m_pEdList , " minlist " ) ;
Size aSize ( LogicToPixel ( Size ( 174 , 105 ) , MAP_APPFONT ) ) ;
m_pEdList - > set_width_request ( aSize . Width ( ) ) ;
m_pEdList - > set_height_request ( aSize . Height ( ) ) ;
get ( m_pFtMax , " maxft " ) ;
get ( m_pEdMax , " max " ) ;
m_pEdMax - > SetReferences ( NULL , m_pFtMax ) ;
get ( m_pFtHint , " hintft " ) ;
get ( m_pBtnRef , " validref " ) ;
m_pBtnRef - > SetParentPage ( this ) ;
get ( m_pRefGrid , " refgrid " ) ;
//lock in the max size initial config
aSize = get_preferred_size ( ) ;
set_width_request ( aSize . Width ( ) ) ;
set_height_request ( aSize . Height ( ) ) ;
2003-08-19 10:39:33 +00:00
Init ( ) ;
2000-09-18 16:07:07 +00:00
2003-08-19 10:39:33 +00:00
// list separator in formulas
2013-08-06 00:48:55 +02:00
OUString aListSep = : : ScCompiler : : GetNativeSymbol ( ocSep ) ;
OSL_ENSURE ( aListSep . getLength ( ) = = 1 , " ScTPValidationValue::ScTPValidationValue - list separator error " ) ;
mcFmlaSep = aListSep . getLength ( ) ? aListSep [ 0 ] : ' ; ' ;
2014-04-08 16:56:03 +01:00
m_pBtnRef - > Hide ( ) ; // cell range picker
2000-09-18 16:07:07 +00:00
}
2015-03-09 14:29:30 +02:00
ScTPValidationValue : : ~ ScTPValidationValue ( )
{
2015-03-10 09:07:06 +02:00
disposeOnce ( ) ;
2015-03-09 14:29:30 +02:00
}
void ScTPValidationValue : : dispose ( )
{
m_pLbAllow . clear ( ) ;
m_pCbAllow . clear ( ) ;
m_pCbShow . clear ( ) ;
m_pCbSort . clear ( ) ;
m_pFtValue . clear ( ) ;
m_pLbValue . clear ( ) ;
m_pFtMin . clear ( ) ;
m_pMinGrid . clear ( ) ;
m_pEdMin . clear ( ) ;
m_pEdList . clear ( ) ;
m_pFtMax . clear ( ) ;
m_pEdMax . clear ( ) ;
m_pFtHint . clear ( ) ;
m_pRefEdit . clear ( ) ;
m_pBtnRef . clear ( ) ;
m_pRefGrid . clear ( ) ;
SfxTabPage : : dispose ( ) ;
}
2003-08-19 10:39:33 +00:00
void ScTPValidationValue : : Init ( )
{
2014-04-08 16:56:03 +01:00
m_pLbAllow - > SetSelectHdl ( LINK ( this , ScTPValidationValue , SelectHdl ) ) ;
m_pLbValue - > SetSelectHdl ( LINK ( this , ScTPValidationValue , SelectHdl ) ) ;
m_pCbShow - > SetClickHdl ( LINK ( this , ScTPValidationValue , CheckHdl ) ) ;
2010-09-30 12:31:16 +01:00
// cell range picker
2014-04-08 16:56:03 +01:00
m_pEdMin - > SetGetFocusHdl ( LINK ( this , ScTPValidationValue , EditSetFocusHdl ) ) ;
m_pEdMin - > SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
m_pEdMax - > SetGetFocusHdl ( LINK ( this , ScTPValidationValue , EditSetFocusHdl ) ) ;
m_pBtnRef - > SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
m_pEdMax - > SetLoseFocusHdl ( LINK ( this , ScTPValidationValue , KillFocusHdl ) ) ;
2000-09-18 16:07:07 +00:00
2014-04-08 16:56:03 +01:00
m_pLbAllow - > SelectEntryPos ( SC_VALIDDLG_ALLOW_ANY ) ;
m_pLbValue - > SelectEntryPos ( SC_VALIDDLG_DATA_EQUAL ) ;
2003-08-19 10:39:33 +00:00
SelectHdl ( NULL ) ;
CheckHdl ( NULL ) ;
}
2015-04-17 13:51:33 +01:00
VclPtr < SfxTabPage > ScTPValidationValue : : Create ( vcl : : Window * pParent , const SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2015-06-03 12:02:36 +02:00
return VclPtr < ScTPValidationValue > : : Create ( pParent , * rArgSet ) ;
2000-09-18 16:07:07 +00:00
}
2014-06-11 10:35:24 +02: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 ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_MODE , true , & pItem ) = = SfxItemState : : SET )
2003-08-19 10:39:33 +00:00
nLbPos = lclGetPosFromValMode ( static_cast < ScValidationMode > (
static_cast < const SfxAllEnumItem * > ( pItem ) - > GetValue ( ) ) ) ;
2014-04-08 16:56:03 +01:00
m_pLbAllow - > SelectEntryPos ( nLbPos ) ;
2003-08-19 10:39:33 +00:00
nLbPos = SC_VALIDDLG_DATA_EQUAL ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_CONDMODE , true , & pItem ) = = SfxItemState : : SET )
2003-08-19 10:39:33 +00:00
nLbPos = lclGetPosFromCondMode ( static_cast < ScConditionMode > (
static_cast < const SfxAllEnumItem * > ( pItem ) - > GetValue ( ) ) ) ;
2014-04-08 16:56:03 +01:00
m_pLbValue - > SelectEntryPos ( nLbPos ) ;
2003-08-19 10:39:33 +00:00
// *** check boxes ***
2014-04-23 11:08:48 +02:00
bool bCheck = true ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_BLANK , true , & pItem ) = = SfxItemState : : SET )
2003-08-19 10:39:33 +00:00
bCheck = static_cast < const SfxBoolItem * > ( pItem ) - > GetValue ( ) ;
2014-04-08 16:56:03 +01:00
m_pCbAllow - > Check ( bCheck ) ;
2003-08-19 10:39:33 +00:00
sal_Int32 nListType = ValidListType : : UNSORTED ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_LISTTYPE , true , & pItem ) = = SfxItemState : : SET )
2003-08-19 10:39:33 +00:00
nListType = static_cast < const SfxInt16Item * > ( pItem ) - > GetValue ( ) ;
2014-04-08 16:56:03 +01:00
m_pCbShow - > Check ( nListType ! = ValidListType : : INVISIBLE ) ;
m_pCbSort - > Check ( nListType = = ValidListType : : SORTEDASCENDING ) ;
2003-08-19 10:39:33 +00:00
// *** formulas ***
2013-08-06 00:48:55 +02:00
OUString aFmlaStr ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_VALUE1 , true , & pItem ) = = SfxItemState : : 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
2014-12-18 13:29:00 +01:00
aFmlaStr . clear ( ) ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_VALUE2 , true , & pItem ) = = SfxItemState : : 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
}
2014-06-10 17:23:12 +02:00
bool ScTPValidationValue : : FillItemSet ( SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2014-04-08 16:56:03 +01:00
sal_Int16 nListType = m_pCbShow - > IsChecked ( ) ?
( m_pCbSort - > IsChecked ( ) ? ValidListType : : SORTEDASCENDING : ValidListType : : UNSORTED ) :
2003-08-19 10:39:33 +00:00
ValidListType : : INVISIBLE ;
2014-06-10 17:23:12 +02:00
rArgSet - > Put ( SfxAllEnumItem ( FID_VALID_MODE , sal : : static_int_cast < sal_uInt16 > (
2014-04-08 16:56:03 +01:00
lclGetValModeFromPos ( m_pLbAllow - > GetSelectEntryPos ( ) ) ) ) ) ;
2014-06-10 17:23:12 +02:00
rArgSet - > Put ( SfxAllEnumItem ( FID_VALID_CONDMODE , sal : : static_int_cast < sal_uInt16 > (
2014-04-08 16:56:03 +01:00
lclGetCondModeFromPos ( m_pLbValue - > GetSelectEntryPos ( ) ) ) ) ) ;
2014-06-10 17:23:12 +02:00
rArgSet - > Put ( SfxStringItem ( FID_VALID_VALUE1 , GetFirstFormula ( ) ) ) ;
rArgSet - > Put ( SfxStringItem ( FID_VALID_VALUE2 , GetSecondFormula ( ) ) ) ;
rArgSet - > Put ( SfxBoolItem ( FID_VALID_BLANK , m_pCbAllow - > IsChecked ( ) ) ) ;
rArgSet - > Put ( SfxInt16Item ( FID_VALID_LISTTYPE , nListType ) ) ;
2014-03-26 15:34:49 +02:00
return true ;
2000-09-18 16:07:07 +00:00
}
2013-08-06 00:48:55 +02:00
OUString ScTPValidationValue : : GetFirstFormula ( ) const
2003-08-19 10:39:33 +00:00
{
2013-03-14 13:57:57 +05:30
OUString aFmlaStr ;
2014-04-08 16:56:03 +01:00
if ( m_pLbAllow - > GetSelectEntryPos ( ) = = SC_VALIDDLG_ALLOW_LIST )
lclGetFormulaFromStringList ( aFmlaStr , m_pEdList - > GetText ( ) , mcFmlaSep ) ;
2003-08-19 10:39:33 +00:00
else
2014-04-08 16:56:03 +01:00
aFmlaStr = m_pEdMin - > GetText ( ) ;
2003-08-19 10:39:33 +00:00
return aFmlaStr ;
}
2000-09-18 16:07:07 +00:00
2013-08-06 00:48:55 +02:00
OUString ScTPValidationValue : : GetSecondFormula ( ) const
2000-09-18 16:07:07 +00:00
{
2014-04-08 16:56:03 +01:00
return m_pEdMax - > GetText ( ) ;
2003-08-19 10:39:33 +00:00
}
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 ;
2014-04-08 16:56:03 +01:00
if ( ( m_pLbAllow - > GetSelectEntryPos ( ) = = SC_VALIDDLG_ALLOW_RANGE ) & &
2003-08-19 10:39:33 +00:00
lclGetStringListFromFormula ( aStringList , rFmlaStr , mcFmlaSep ) )
{
2014-04-08 16:56:03 +01:00
m_pEdList - > SetText ( aStringList ) ;
m_pEdMin - > SetText ( EMPTY_OUSTRING ) ;
2003-08-19 10:39:33 +00:00
// change validation mode to string list
2014-04-08 16:56:03 +01:00
m_pLbAllow - > SelectEntryPos ( SC_VALIDDLG_ALLOW_LIST ) ;
2003-08-19 10:39:33 +00:00
}
else
{
2014-04-08 16:56:03 +01:00
m_pEdMin - > SetText ( rFmlaStr ) ;
m_pEdList - > SetText ( EMPTY_OUSTRING ) ;
2003-08-19 10:39:33 +00:00
}
}
2000-09-18 16:07:07 +00:00
2013-08-06 00:48:55 +02:00
void ScTPValidationValue : : SetSecondFormula ( const OUString & rFmlaStr )
2003-08-19 10:39:33 +00:00
{
2014-04-08 16:56:03 +01:00
m_pEdMax - > SetText ( rFmlaStr ) ;
2000-09-18 16:07:07 +00:00
}
2009-11-16 13:48:33 +01:00
ScValidationDlg * ScTPValidationValue : : GetValidationDlg ( )
{
2014-09-23 11:20:40 +02:00
if ( vcl : : Window * pParent = GetParent ( ) )
2009-11-16 13:48:33 +01:00
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 ) ;
2014-10-27 14:18:17 +02:00
pValidationDlg - > SetSetRefHdl ( static_cast < ScRefHandlerHelper : : PFUNCSETREFHDLTYPE > ( & ScTPValidationValue : : SetReferenceHdl ) ) ;
pValidationDlg - > SetSetActHdl ( static_cast < ScRefHandlerHelper : : PCOMMONHDLTYPE > ( & ScTPValidationValue : : SetActiveHdl ) ) ;
pValidationDlg - > SetRefInputStartPreHdl ( static_cast < ScRefHandlerHelper : : PINPUTSTARTDLTYPE > ( & ScTPValidationValue : : RefInputStartPreHdl ) ) ;
pValidationDlg - > SetRefInputDonePostHdl ( static_cast < ScRefHandlerHelper : : PCOMMONHDLTYPE > ( & ScTPValidationValue : : RefInputDonePostHdl ) ) ;
2009-11-16 13:48:33 +01:00
2014-09-23 11:20:40 +02:00
vcl : : Window * pLabel = NULL ;
2009-11-16 13:48:33 +01:00
2014-04-08 16:56:03 +01:00
if ( m_pEdMax - > IsVisible ( ) )
2013-03-08 13:41:51 +00:00
{
2014-04-08 16:56:03 +01:00
m_pRefEdit = m_pEdMax ;
pLabel = m_pFtMax ;
2013-03-08 13:41:51 +00:00
}
2014-04-08 16:56:03 +01:00
else if ( m_pEdMin - > IsVisible ( ) )
2013-03-08 13:41:51 +00:00
{
2014-04-08 16:56:03 +01:00
m_pRefEdit = m_pEdMin ;
pLabel = m_pFtMin ;
2013-03-08 13:41:51 +00:00
}
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 )
2013-04-16 20:41:34 +01:00
m_pRefEdit - > SetReferences ( pValidationDlg , pLabel ) ;
2013-03-08 13:41:51 +00:00
2014-04-08 16:56:03 +01:00
m_pBtnRef - > SetReferences ( pValidationDlg , m_pRefEdit ) ;
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 )
2013-04-16 20:41:34 +01:00
m_pRefEdit - > SetReferences ( NULL , NULL ) ;
2009-11-16 13:48:33 +01:00
m_pRefEdit = NULL ;
2014-04-08 16:56:03 +01:00
m_pBtnRef - > SetReferences ( NULL , NULL ) ;
2009-11-16 13:48:33 +01:00
}
}
}
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationValue , EditSetFocusHdl )
2009-11-16 13:48:33 +01:00
{
2014-04-08 16:56:03 +01:00
sal_uInt16 nPos = m_pLbAllow - > GetSelectEntryPos ( ) ;
2009-11-16 13:48:33 +01:00
if ( nPos = = SC_VALIDDLG_ALLOW_RANGE )
{
SetupRefDlg ( ) ;
}
return 0 ;
}
2014-09-23 11:20:40 +02:00
IMPL_LINK ( ScTPValidationValue , KillFocusHdl , vcl : : Window * , pWnd )
2009-11-16 13:48:33 +01:00
{
2014-04-08 16:56:03 +01:00
if ( pWnd = = m_pRefEdit | | pWnd = = m_pBtnRef )
2009-11-16 13:48:33 +01:00
if ( ScValidationDlg * pValidationDlg = GetValidationDlg ( ) )
if ( ( pValidationDlg - > IsActive ( ) | | pValidationDlg - > IsChildFocus ( ) ) & & ! pValidationDlg - > IsRefInputting ( ) )
2014-04-08 16:56:03 +01:00
if ( ( ! m_pRefEdit | | ! m_pRefEdit - > HasFocus ( ) ) & & ! m_pBtnRef - > HasFocus ( ) )
2009-11-16 13:48:33 +01:00
{
RemoveRefDlg ( ) ;
}
return 0 ;
}
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
{
2014-04-08 16:56:03 +01:00
sal_uInt16 nLbPos = m_pLbAllow - > 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 ) ;
2014-04-08 16:56:03 +01:00
m_pCbAllow - > Enable ( bEnable ) ; // Empty cell
m_pFtValue - > Enable ( bEnable ) ;
m_pLbValue - > Enable ( bEnable ) ;
m_pFtMin - > Enable ( bEnable ) ;
m_pEdMin - > Enable ( bEnable ) ;
m_pEdList - > Enable ( bEnable ) ;
m_pFtMax - > Enable ( bEnable ) ;
m_pEdMax - > Enable ( bEnable ) ;
2003-08-19 10:39:33 +00:00
bool bShowMax = false ;
if ( bRange )
2014-04-08 16:56:03 +01:00
m_pFtMin - > SetText ( maStrRange ) ;
2003-08-19 10:39:33 +00:00
else if ( bList )
2014-04-08 16:56:03 +01:00
m_pFtMin - > SetText ( maStrList ) ;
2003-08-19 10:39:33 +00:00
else
2000-09-18 16:07:07 +00:00
{
2014-04-08 16:56:03 +01:00
switch ( m_pLbValue - > GetSelectEntryPos ( ) )
2003-08-19 10:39:33 +00:00
{
case SC_VALIDDLG_DATA_EQUAL :
2014-04-08 16:56:03 +01:00
case SC_VALIDDLG_DATA_NOTEQUAL : m_pFtMin - > SetText ( maStrValue ) ; break ;
2003-08-19 10:39:33 +00:00
case SC_VALIDDLG_DATA_LESS :
2014-04-08 16:56:03 +01:00
case SC_VALIDDLG_DATA_EQLESS : m_pFtMin - > SetText ( maStrMax ) ; break ;
2003-08-19 10:39:33 +00:00
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 :
2014-04-08 16:56:03 +01:00
case SC_VALIDDLG_DATA_EQGREATER : m_pFtMin - > SetText ( maStrMin ) ; break ;
2003-08-19 10:39:33 +00:00
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
}
2014-04-08 16:56:03 +01:00
m_pCbShow - > Show ( bRange | | bList ) ;
m_pCbSort - > Show ( bRange | | bList ) ;
m_pFtValue - > Show ( ! bRange & & ! bList ) ;
m_pLbValue - > Show ( ! bRange & & ! bList ) ;
m_pEdMin - > Show ( ! bList ) ;
m_pEdList - > Show ( bList ) ;
m_pMinGrid - > set_vexpand ( bList ) ;
WinBits nBits = m_pFtMin - > GetStyle ( ) ;
nBits & = ~ ( WB_TOP | WB_VCENTER | WB_BOTTOM ) ;
if ( bList )
nBits | = WB_TOP ;
else
nBits | = WB_VCENTER ;
m_pFtMin - > SetStyle ( nBits ) ;
m_pFtMax - > Show ( bShowMax ) ;
m_pEdMax - > Show ( bShowMax ) ;
m_pFtHint - > Show ( bRange ) ;
m_pBtnRef - > 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
{
2014-04-08 16:56:03 +01:00
m_pCbSort - > Enable ( m_pCbShow - > IsChecked ( ) ) ;
2003-08-19 10:39:33 +00:00
return 0 ;
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
2014-09-23 11:20:40 +02:00
ScTPValidationHelp : : ScTPValidationHelp ( vcl : : Window * pParent ,
2000-09-18 16:07:07 +00:00
const SfxItemSet & rArgSet )
: SfxTabPage ( pParent ,
2013-08-02 18:27:04 +02:00
" ValidationHelpTabPage " , " modules/scalc/ui/validationhelptabpage.ui " ,
2014-06-11 14:34:46 +02:00
& rArgSet )
2000-09-18 16:07:07 +00:00
{
2013-08-02 18:27:04 +02:00
get ( pTsbHelp , " tsbhelp " ) ;
get ( pEdtTitle , " title " ) ;
get ( pEdInputHelp , " inputhelp " ) ;
2013-08-19 12:21:19 +01:00
pEdInputHelp - > set_height_request ( pEdInputHelp - > GetTextHeight ( ) * 12 ) ;
pEdInputHelp - > set_width_request ( pEdInputHelp - > approximate_char_width ( ) * 50 ) ;
2000-09-18 16:07:07 +00:00
Init ( ) ;
}
2010-12-11 23:25:30 +01:00
ScTPValidationHelp : : ~ ScTPValidationHelp ( )
2000-09-18 16:07:07 +00:00
{
2015-03-10 09:07:06 +02:00
disposeOnce ( ) ;
2015-03-09 14:29:30 +02:00
}
void ScTPValidationHelp : : dispose ( )
{
pTsbHelp . clear ( ) ;
pEdtTitle . clear ( ) ;
pEdInputHelp . clear ( ) ;
SfxTabPage : : dispose ( ) ;
2000-09-18 16:07:07 +00:00
}
void ScTPValidationHelp : : Init ( )
{
2013-08-02 18:27:04 +02:00
pTsbHelp - > EnableTriState ( false ) ;
2000-09-18 16:07:07 +00:00
}
2015-04-17 13:51:33 +01:00
VclPtr < SfxTabPage > ScTPValidationHelp : : Create ( vcl : : Window * pParent ,
const SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2015-04-17 13:51:33 +01:00
return VclPtr < ScTPValidationHelp > : : Create ( pParent , * rArgSet ) ;
2000-09-18 16:07:07 +00:00
}
2014-06-11 10:35:24 +02:00
void ScTPValidationHelp : : Reset ( const SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem * pItem ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_SHOWHELP , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
pTsbHelp - > SetState ( static_cast < const SfxBoolItem * > ( pItem ) - > GetValue ( ) ? TRISTATE_TRUE : TRISTATE_FALSE ) ;
2001-01-17 18:28:42 +00:00
else
2014-02-24 12:25:02 +01:00
pTsbHelp - > SetState ( TRISTATE_FALSE ) ;
2001-01-17 18:28:42 +00:00
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_HELPTITLE , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
pEdtTitle - > SetText ( static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
2013-10-16 14:27:58 +02:00
pEdtTitle - > SetText ( EMPTY_OUSTRING ) ;
2001-01-17 18:28:42 +00:00
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_HELPTEXT , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
pEdInputHelp - > SetText ( static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
2013-10-16 14:27:58 +02:00
pEdInputHelp - > SetText ( EMPTY_OUSTRING ) ;
2000-09-18 16:07:07 +00:00
}
2014-06-10 17:23:12 +02:00
bool ScTPValidationHelp : : FillItemSet ( SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2014-06-10 17:23:12 +02:00
rArgSet - > Put ( SfxBoolItem ( FID_VALID_SHOWHELP , pTsbHelp - > GetState ( ) = = TRISTATE_TRUE ) ) ;
rArgSet - > Put ( SfxStringItem ( FID_VALID_HELPTITLE , pEdtTitle - > GetText ( ) ) ) ;
rArgSet - > Put ( SfxStringItem ( FID_VALID_HELPTEXT , pEdInputHelp - > GetText ( ) ) ) ;
2000-09-18 16:07:07 +00:00
2014-03-26 15:34:49 +02:00
return 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
2014-09-23 11:20:40 +02:00
ScTPValidationError : : ScTPValidationError ( vcl : : Window * pParent ,
2000-09-18 16:07:07 +00:00
const SfxItemSet & rArgSet )
: SfxTabPage ( pParent ,
2013-08-19 10:01:25 +03:00
" ErrorAlertTabPage " , " modules/scalc/ui/erroralerttabpage.ui " ,
2014-06-11 14:34:46 +02:00
& rArgSet )
2000-09-18 16:07:07 +00:00
{
2013-08-19 10:01:25 +03:00
get ( m_pTsbShow , " tsbshow " ) ;
get ( m_pLbAction , " actionCB " ) ;
get ( m_pBtnSearch , " browseBtn " ) ;
get ( m_pEdtTitle , " title " ) ;
get ( m_pFtError , " errormsg_label " ) ;
get ( m_pEdError , " errorMsg " ) ;
2013-08-19 12:21:19 +01:00
m_pEdError - > set_height_request ( m_pEdError - > GetTextHeight ( ) * 12 ) ;
m_pEdError - > set_width_request ( m_pEdError - > approximate_char_width ( ) * 50 ) ;
2000-09-18 16:07:07 +00:00
Init ( ) ;
}
2010-12-11 23:25:30 +01:00
ScTPValidationError : : ~ ScTPValidationError ( )
2000-09-18 16:07:07 +00:00
{
2015-03-10 09:07:06 +02:00
disposeOnce ( ) ;
2015-03-09 14:29:30 +02:00
}
void ScTPValidationError : : dispose ( )
{
m_pTsbShow . clear ( ) ;
m_pLbAction . clear ( ) ;
m_pBtnSearch . clear ( ) ;
m_pEdtTitle . clear ( ) ;
m_pFtError . clear ( ) ;
m_pEdError . clear ( ) ;
SfxTabPage : : dispose ( ) ;
2000-09-18 16:07:07 +00:00
}
void ScTPValidationError : : Init ( )
{
2013-08-19 10:01:25 +03:00
m_pLbAction - > SetSelectHdl ( LINK ( this , ScTPValidationError , SelectActionHdl ) ) ;
m_pBtnSearch - > SetClickHdl ( LINK ( this , ScTPValidationError , ClickSearchHdl ) ) ;
2000-09-18 16:07:07 +00:00
2013-08-19 10:01:25 +03:00
m_pLbAction - > SelectEntryPos ( 0 ) ;
m_pTsbShow - > EnableTriState ( false ) ;
2000-09-18 16:07:07 +00:00
SelectActionHdl ( NULL ) ;
}
2015-04-17 13:51:33 +01:00
VclPtr < SfxTabPage > ScTPValidationError : : Create ( vcl : : Window * pParent ,
const SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2015-04-17 13:51:33 +01:00
return VclPtr < ScTPValidationError > : : Create ( pParent , * rArgSet ) ;
2000-09-18 16:07:07 +00:00
}
2014-06-11 10:35:24 +02:00
void ScTPValidationError : : Reset ( const SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem * pItem ;
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_SHOWERR , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
m_pTsbShow - > SetState ( static_cast < const SfxBoolItem * > ( pItem ) - > GetValue ( ) ? TRISTATE_TRUE : TRISTATE_FALSE ) ;
2001-01-17 18:28:42 +00:00
else
2014-02-24 12:25:02 +01:00
m_pTsbShow - > SetState ( TRISTATE_TRUE ) ; // check by default
2001-01-17 18:28:42 +00:00
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_ERRSTYLE , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
m_pLbAction - > SelectEntryPos ( static_cast < const SfxAllEnumItem * > ( pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
2013-08-19 10:01:25 +03:00
m_pLbAction - > SelectEntryPos ( 0 ) ;
2001-01-17 18:28:42 +00:00
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_ERRTITLE , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
m_pEdtTitle - > SetText ( static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
2013-10-16 14:27:58 +02:00
m_pEdtTitle - > SetText ( EMPTY_OUSTRING ) ;
2001-01-17 18:28:42 +00:00
2014-09-10 17:53:41 +02:00
if ( rArgSet - > GetItemState ( FID_VALID_ERRTEXT , true , & pItem ) = = SfxItemState : : SET )
2014-10-27 14:18:17 +02:00
m_pEdError - > SetText ( static_cast < const SfxStringItem * > ( pItem ) - > GetValue ( ) ) ;
2001-01-17 18:28:42 +00:00
else
2013-10-16 14:27:58 +02:00
m_pEdError - > SetText ( EMPTY_OUSTRING ) ;
2000-09-18 16:07:07 +00:00
SelectActionHdl ( NULL ) ;
}
2014-06-10 17:23:12 +02:00
bool ScTPValidationError : : FillItemSet ( SfxItemSet * rArgSet )
2000-09-18 16:07:07 +00:00
{
2014-06-10 17:23:12 +02:00
rArgSet - > Put ( SfxBoolItem ( FID_VALID_SHOWERR , m_pTsbShow - > GetState ( ) = = TRISTATE_TRUE ) ) ;
rArgSet - > Put ( SfxAllEnumItem ( FID_VALID_ERRSTYLE , m_pLbAction - > GetSelectEntryPos ( ) ) ) ;
rArgSet - > Put ( SfxStringItem ( FID_VALID_ERRTITLE , m_pEdtTitle - > GetText ( ) ) ) ;
rArgSet - > Put ( SfxStringItem ( FID_VALID_ERRTEXT , m_pEdError - > GetText ( ) ) ) ;
2000-09-18 16:07:07 +00:00
2014-03-26 15:34:49 +02:00
return 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
{
2013-08-19 10:01:25 +03:00
ScValidErrorStyle eStyle = ( ScValidErrorStyle ) m_pLbAction - > GetSelectEntryPos ( ) ;
2014-04-23 11:08:48 +02:00
bool bMacro = ( eStyle = = SC_VALERR_MACRO ) ;
2000-09-18 16:07:07 +00:00
2013-08-19 10:01:25 +03:00
m_pBtnSearch - > Enable ( bMacro ) ;
m_pFtError - > Enable ( ! bMacro ) ;
m_pEdError - > Enable ( ! bMacro ) ;
2000-09-18 16:07:07 +00:00
2015-02-11 13:20:49 +02:00
return 0L ;
2000-09-18 16:07:07 +00:00
}
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( ScTPValidationError , ClickSearchHdl )
2000-09-18 16:07:07 +00:00
{
2014-09-23 11:20:40 +02:00
vcl : : Window * pOld = Application : : GetDefDialogParent ( ) ;
2000-09-18 16:07:07 +00:00
Application : : SetDefDialogParent ( this ) ;
2004-05-19 06:59:30 +00:00
// Use static SfxApplication method to bring up selector dialog for
// choosing a script
2013-04-07 12:06:47 +02:00
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
{
2013-08-19 10:01:25 +03:00
m_pEdtTitle - > SetText ( aScriptURL ) ;
2000-09-18 16:07:07 +00:00
}
2015-02-11 13:20:49 +02:00
return 0L ;
2000-09-18 16:07:07 +00:00
}
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 ;
2015-04-24 12:33:01 +02:00
SC_MOD ( ) - > SetRefDialog ( nId , pWnd = = nullptr ) ;
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 ;
}
2014-02-19 12:07:42 +02:00
bool ScValidationDlg : : RemoveRefDlg ( bool bRestoreModal /* = 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 )
2014-02-19 12:07:42 +02:00
SetModal ( 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 ;
}
2015-05-09 21:15:13 +01:00
VCL_BUILDER_DECL_FACTORY ( ScRefButtonEx )
2014-04-08 16:56:03 +01:00
{
2015-05-09 21:15:13 +01:00
( void ) rMap ;
2015-05-11 14:02:42 +01:00
rRet = VclPtr < ScTPValidationValue : : ScRefButtonEx > : : Create ( pParent , 0 ) ;
2014-04-08 16:56:03 +01:00
}
2009-11-16 13:48:33 +01:00
void ScTPValidationValue : : ScRefButtonEx : : Click ( )
{
2014-04-08 16:56:03 +01:00
if ( ScTPValidationValue * pParent = GetParentPage ( ) )
2009-11-16 13:48:33 +01:00
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 )
{
2014-04-08 16:56:03 +01:00
if ( pBtn = = m_pBtnRef )
2009-11-16 13:48:33 +01:00
SetupRefDlg ( ) ;
}
2014-02-19 12:07:42 +02:00
bool ScValidationDlg : : IsChildFocus ( )
2009-11-16 13:48:33 +01:00
{
2014-09-23 11:20:40 +02:00
if ( const vcl : : Window * pWin = Application : : GetFocusWindow ( ) )
2009-11-16 13:48:33 +01:00
while ( NULL ! = ( pWin = pWin - > GetParent ( ) ) )
if ( pWin = = this )
2014-02-19 12:07:42 +02:00
return 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
}
2010-10-12 15:59:00 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */