Files
libreoffice/sc/source/ui/dbgui/validate.cxx

1000 lines
34 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
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
#ifdef SC_DLLIMPLEMENTATION
#undef SC_DLLIMPLEMENTATION
#endif
#include <comphelper/string.hxx>
#include <vcl/svapp.hxx>
#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>
#include <sfx2/app.hxx>
2000-09-18 16:07:07 +00:00
#include "scresid.hxx"
#include "sc.hrc" // -> Slot IDs
#include "stringutil.hxx"
2000-09-18 16:07:07 +00:00
#include "validat.hxx"
#include "validate.hrc"
#include "validate.hxx"
#include "compiler.hxx"
#include "formula/opcode.hxx"
// cell range picker
#include "tabvwsh.hxx"
#include <sfx2/viewfrm.hxx>
#include <sfx2/childwin.hxx>
#include "reffact.hxx"
2000-09-18 16:07:07 +00:00
// ============================================================================
2000-09-18 16:07:07 +00:00
static sal_uInt16 pValueRanges[] =
2000-09-18 16:07:07 +00:00
{
FID_VALID_MODE, FID_VALID_ERRTEXT,
FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
2000-09-18 16:07:07 +00:00
0
};
// ============================================================================
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
{
AddTabPage( TP_VALIDATION_VALUES, ScTPValidationValue::Create, 0 );
2000-09-18 16:07:07 +00:00
AddTabPage( TP_VALIDATION_INPUTHELP, ScTPValidationHelp::Create, 0 );
AddTabPage( TP_VALIDATION_ERROR, ScTPValidationError::Create, 0 );
2000-09-18 16:07:07 +00:00
FreeResource();
//temp hack until converted to .ui
mpHBox = new VclHBox(get_content_area());
2000-09-18 16:07:07 +00:00
}
void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
{
if ( rRange.aStart != rRange.aEnd )
if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
if( m_pRefEdit )
pValidationDlg->RefInputStart( m_pRefEdit );
if ( m_pRefEdit )
{
OUString aStr;
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 )
{
pValidationDlg->RefInputDone();
}
}
void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton )
{
if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
{
Window *pNewParent = pValidationDlg->get_refinput_shrink_parent();
if( pEdit == m_pRefEdit )
{
maRefEditPos = m_pRefEdit->GetPosPixel();
maRefEditSize = m_pRefEdit->GetSizePixel();
m_pRefEdit->SetParent(pNewParent);
}
if( pButton == &m_btnRef )
{
maBtnRefPos = m_btnRef.GetPosPixel();
maBtnRefSize = m_btnRef.GetSizePixel();
m_btnRef.SetParent(pNewParent);
}
pNewParent->Show();
}
}
void ScTPValidationValue::RefInputDonePostHdl()
{
if( m_pRefEdit && m_pRefEdit->GetParent()!= this )
{
m_pRefEdit->SetParent( this );
m_pRefEdit->SetPosSizePixel( maRefEditPos, maRefEditSize );
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
m_btnRef.SetPosSizePixel( maBtnRefPos, maBtnRefSize );
}
if( m_btnRef.GetParent()!=this ) m_btnRef.SetParent( this );
if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
pValidationDlg->get_refinput_shrink_parent()->Hide();
if( m_pRefEdit && !m_pRefEdit->HasFocus() )
m_pRefEdit->GrabFocus();
}
sal_Bool ScValidationDlg::Close()
{
if( m_bOwnRefHdlr )
if( SfxTabPage* pPage = GetTabPage( TP_VALIDATION_VALUES ) )
static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg();
return ScValidationDlgBase::Close();
}
ScValidationDlg::~ScValidationDlg()
2000-09-18 16:07:07 +00:00
{
if( m_bOwnRefHdlr )
RemoveRefDlg( false );
delete mpHBox;
2000-09-18 16:07:07 +00:00
}
// ============================================================================
2000-09-18 16:07:07 +00:00
namespace {
/** Converts the passed ScValidationMode to the position in the list box. */
sal_uInt16 lclGetPosFromValMode( ScValidationMode eValMode )
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
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
default: OSL_FAIL( "lclGetPosFromValMode - unknown validity mode" );
}
return nLbPos;
2000-09-18 16:07:07 +00:00
}
/** Converts the passed list box position to an ScValidationMode. */
ScValidationMode lclGetValModeFromPos( sal_uInt16 nLbPos )
{
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;
default: OSL_FAIL( "lclGetValModeFromPos - invalid list box position" );
}
return eValMode;
}
2000-09-18 16:07:07 +00:00
/** Converts the passed ScConditionMode to the position in the list box. */
sal_uInt16 lclGetPosFromCondMode( ScConditionMode eCondMode )
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nLbPos = SC_VALIDDLG_DATA_EQUAL;
switch( eCondMode )
{
2011-03-01 14:29:24 +01:00
case SC_COND_NONE: // may occur in old XML files after Excel import
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;
case SC_COND_BETWEEN: nLbPos = SC_VALIDDLG_DATA_VALIDRANGE; break;
case SC_COND_NOTBETWEEN: nLbPos = SC_VALIDDLG_DATA_INVALIDRANGE; break;
default: OSL_FAIL( "lclGetPosFromCondMode - unknown condition mode" );
}
return nLbPos;
2000-09-18 16:07:07 +00:00
}
/** Converts the passed list box position to an ScConditionMode. */
ScConditionMode lclGetCondModeFromPos( sal_uInt16 nLbPos )
{
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;
case SC_VALIDDLG_DATA_VALIDRANGE: eCondMode = SC_COND_BETWEEN; break;
case SC_VALIDDLG_DATA_INVALIDRANGE: eCondMode = SC_COND_NOTBETWEEN; break;
default: OSL_FAIL( "lclGetCondModeFromPos - invalid list box position" );
}
return eCondMode;
}
2000-09-18 16:07:07 +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. */
void lclGetFormulaFromStringList( OUString& rFmlaStr, const OUString& rStringList, sal_Unicode cFmlaSep )
{
rFmlaStr = "";
xub_StrLen nTokenCnt = comphelper::string::getTokenCount(rStringList, '\n');
for( sal_Int32 nToken = 0, nStringIx = 0; nToken < (sal_Int32) nTokenCnt; ++nToken )
{
OUString aToken( rStringList.getToken( 0, '\n', nStringIx ) );
CWS-TOOLING: integrate CWS mooxlsc 2008-12-12 09:32:19 +0100 dr r265390 : #i10000# warning 2008-12-11 14:54:26 +0100 dr r265301 : add strings from dr66 to meet ui freeze 2008-12-11 14:53:20 +0100 dr r265300 : add strings from dr66 to meet ui freeze 2008-12-08 14:43:25 +0100 er r264997 : DBG_... need semicolon 2008-12-04 19:16:50 +0100 er r264872 : DBG_... needs semicolon 2008-12-04 11:09:27 +0100 er r264824 : DBG_ERROR needs semicolon 2008-12-03 13:29:46 +0100 er r264770 : CWS-TOOLING: rebase CWS mooxlsc to trunk@264325 (milestone: DEV300:m36) 2008-12-02 16:49:09 +0100 er r264722 : disable code for named references #i4385# import as long as #i3740# isn't fully implemented 2008-12-02 16:45:04 +0100 er r264721 : some compilers attempt to be too smart; persuade them it's really meant what was written 2008-12-02 16:04:56 +0100 er r264715 : #i3740# no storage in ODF for external name references 2008-11-29 02:20:50 +0100 er r264575 : some huge performance improvement when reading repeated empty rows for the external references cache from ODF, as they often occur in the sparse matrix 2008-11-29 01:14:55 +0100 er r264574 : WriteExternalRefCaches: for table:number-columns-repeated write used columns instead of MAXCOLCOUNT 2008-11-28 18:30:04 +0100 er r264570 : #i3740# write/read external name references as bracketed references, as proposed on the ODFF list 2008-11-27 20:36:54 +0100 er r264521 : merge i95068 from cws calc46 for code correctness 2008-11-21 20:39:34 +0100 kohei r264174 : fixed a crash when importing a BIFF8 document with per-sheet external names. For now, we don't support per-sheet external names. Let's throw in NoName error until they are supported. 2008-11-21 18:47:27 +0100 kohei r264168 : I forgot to process cached range references in the EXTERNNAME record, which prevented cached external names with range references from being imported correctly. P.S. I swear I thought I had covered this.... 2008-11-20 23:07:22 +0100 er r264104 : #i4385# parse external defined names in MOOXML import 2008-11-14 23:18:54 +0100 er r263700 : #i92797# parse external sheet references under aspects of MOOXML import and new ScExternalRefManager 2008-11-14 18:49:48 +0100 er r263696 : remove infinity assertion, leftover from binary file format; coded double error may occur via filter import 2008-11-12 13:29:44 +0100 er r263593 : make references to entire rows/columns, such as A:A or 3:3, actually work in MOOXML import 2008-11-03 12:35:11 +0100 er r263282 : a struct is a struct is a ... 2008-10-31 00:30:59 +0100 er r262843 : aTableRowCellAttrTokenMap needed 2008-10-31 00:26:07 +0100 er r262842 : GetTableRowCellAttrTokenMap() is not unused 2008-10-31 00:13:53 +0100 er r262841 : merge error 2008-10-31 00:05:39 +0100 er r262840 : merge error 2008-10-30 23:17:48 +0100 er r262839 : unresolved merge conflict!?! 2008-10-30 22:59:11 +0100 er r262838 : merge error 2008-10-30 16:31:04 +0100 hr r262833 : CWS-TOOLING: rebase CWS mooxlsc to trunk@262620 (milestone: DEV300:m34) 2008-10-16 21:57:51 +0200 er r262272 : migrate CWS mooxlsc to SVN
2008-12-12 09:38:47 +00:00
ScGlobal::AddQuotes( aToken, '"' );
rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep);
}
if( rFmlaStr.isEmpty() )
rFmlaStr = "\"\"";
}
/** 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. */
bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaStr, sal_Unicode cFmlaSep )
2000-09-18 16:07:07 +00:00
{
OUString aQuotes( "\"\"" );
sal_Int32 nTokenCnt = ScStringUtil::GetQuotedTokenCount(rFmlaStr, aQuotes, cFmlaSep );
2000-09-18 16:07:07 +00:00
rStringList="";
bool bIsStringList = (nTokenCnt > 0);
bool bTokenAdded = false;
2000-09-18 16:07:07 +00:00
for( sal_Int32 nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
{
OUString aToken( ScStringUtil::GetQuotedToken(rFmlaStr, 0, aQuotes, cFmlaSep, nStringIx ) );
aToken = comphelper::string::strip(aToken, ' ');
if( !aToken.isEmpty() ) // ignore empty tokens, i.e. "a";;"b"
{
CWS-TOOLING: integrate CWS mooxlsc 2008-12-12 09:32:19 +0100 dr r265390 : #i10000# warning 2008-12-11 14:54:26 +0100 dr r265301 : add strings from dr66 to meet ui freeze 2008-12-11 14:53:20 +0100 dr r265300 : add strings from dr66 to meet ui freeze 2008-12-08 14:43:25 +0100 er r264997 : DBG_... need semicolon 2008-12-04 19:16:50 +0100 er r264872 : DBG_... needs semicolon 2008-12-04 11:09:27 +0100 er r264824 : DBG_ERROR needs semicolon 2008-12-03 13:29:46 +0100 er r264770 : CWS-TOOLING: rebase CWS mooxlsc to trunk@264325 (milestone: DEV300:m36) 2008-12-02 16:49:09 +0100 er r264722 : disable code for named references #i4385# import as long as #i3740# isn't fully implemented 2008-12-02 16:45:04 +0100 er r264721 : some compilers attempt to be too smart; persuade them it's really meant what was written 2008-12-02 16:04:56 +0100 er r264715 : #i3740# no storage in ODF for external name references 2008-11-29 02:20:50 +0100 er r264575 : some huge performance improvement when reading repeated empty rows for the external references cache from ODF, as they often occur in the sparse matrix 2008-11-29 01:14:55 +0100 er r264574 : WriteExternalRefCaches: for table:number-columns-repeated write used columns instead of MAXCOLCOUNT 2008-11-28 18:30:04 +0100 er r264570 : #i3740# write/read external name references as bracketed references, as proposed on the ODFF list 2008-11-27 20:36:54 +0100 er r264521 : merge i95068 from cws calc46 for code correctness 2008-11-21 20:39:34 +0100 kohei r264174 : fixed a crash when importing a BIFF8 document with per-sheet external names. For now, we don't support per-sheet external names. Let's throw in NoName error until they are supported. 2008-11-21 18:47:27 +0100 kohei r264168 : I forgot to process cached range references in the EXTERNNAME record, which prevented cached external names with range references from being imported correctly. P.S. I swear I thought I had covered this.... 2008-11-20 23:07:22 +0100 er r264104 : #i4385# parse external defined names in MOOXML import 2008-11-14 23:18:54 +0100 er r263700 : #i92797# parse external sheet references under aspects of MOOXML import and new ScExternalRefManager 2008-11-14 18:49:48 +0100 er r263696 : remove infinity assertion, leftover from binary file format; coded double error may occur via filter import 2008-11-12 13:29:44 +0100 er r263593 : make references to entire rows/columns, such as A:A or 3:3, actually work in MOOXML import 2008-11-03 12:35:11 +0100 er r263282 : a struct is a struct is a ... 2008-10-31 00:30:59 +0100 er r262843 : aTableRowCellAttrTokenMap needed 2008-10-31 00:26:07 +0100 er r262842 : GetTableRowCellAttrTokenMap() is not unused 2008-10-31 00:13:53 +0100 er r262841 : merge error 2008-10-31 00:05:39 +0100 er r262840 : merge error 2008-10-30 23:17:48 +0100 er r262839 : unresolved merge conflict!?! 2008-10-30 22:59:11 +0100 er r262838 : merge error 2008-10-30 16:31:04 +0100 hr r262833 : CWS-TOOLING: rebase CWS mooxlsc to trunk@262620 (milestone: DEV300:m34) 2008-10-16 21:57:51 +0200 er r262272 : migrate CWS mooxlsc to SVN
2008-12-12 09:38:47 +00:00
bIsStringList = ScGlobal::IsQuoted( aToken, '"' );
if( bIsStringList )
{
CWS-TOOLING: integrate CWS mooxlsc 2008-12-12 09:32:19 +0100 dr r265390 : #i10000# warning 2008-12-11 14:54:26 +0100 dr r265301 : add strings from dr66 to meet ui freeze 2008-12-11 14:53:20 +0100 dr r265300 : add strings from dr66 to meet ui freeze 2008-12-08 14:43:25 +0100 er r264997 : DBG_... need semicolon 2008-12-04 19:16:50 +0100 er r264872 : DBG_... needs semicolon 2008-12-04 11:09:27 +0100 er r264824 : DBG_ERROR needs semicolon 2008-12-03 13:29:46 +0100 er r264770 : CWS-TOOLING: rebase CWS mooxlsc to trunk@264325 (milestone: DEV300:m36) 2008-12-02 16:49:09 +0100 er r264722 : disable code for named references #i4385# import as long as #i3740# isn't fully implemented 2008-12-02 16:45:04 +0100 er r264721 : some compilers attempt to be too smart; persuade them it's really meant what was written 2008-12-02 16:04:56 +0100 er r264715 : #i3740# no storage in ODF for external name references 2008-11-29 02:20:50 +0100 er r264575 : some huge performance improvement when reading repeated empty rows for the external references cache from ODF, as they often occur in the sparse matrix 2008-11-29 01:14:55 +0100 er r264574 : WriteExternalRefCaches: for table:number-columns-repeated write used columns instead of MAXCOLCOUNT 2008-11-28 18:30:04 +0100 er r264570 : #i3740# write/read external name references as bracketed references, as proposed on the ODFF list 2008-11-27 20:36:54 +0100 er r264521 : merge i95068 from cws calc46 for code correctness 2008-11-21 20:39:34 +0100 kohei r264174 : fixed a crash when importing a BIFF8 document with per-sheet external names. For now, we don't support per-sheet external names. Let's throw in NoName error until they are supported. 2008-11-21 18:47:27 +0100 kohei r264168 : I forgot to process cached range references in the EXTERNNAME record, which prevented cached external names with range references from being imported correctly. P.S. I swear I thought I had covered this.... 2008-11-20 23:07:22 +0100 er r264104 : #i4385# parse external defined names in MOOXML import 2008-11-14 23:18:54 +0100 er r263700 : #i92797# parse external sheet references under aspects of MOOXML import and new ScExternalRefManager 2008-11-14 18:49:48 +0100 er r263696 : remove infinity assertion, leftover from binary file format; coded double error may occur via filter import 2008-11-12 13:29:44 +0100 er r263593 : make references to entire rows/columns, such as A:A or 3:3, actually work in MOOXML import 2008-11-03 12:35:11 +0100 er r263282 : a struct is a struct is a ... 2008-10-31 00:30:59 +0100 er r262843 : aTableRowCellAttrTokenMap needed 2008-10-31 00:26:07 +0100 er r262842 : GetTableRowCellAttrTokenMap() is not unused 2008-10-31 00:13:53 +0100 er r262841 : merge error 2008-10-31 00:05:39 +0100 er r262840 : merge error 2008-10-30 23:17:48 +0100 er r262839 : unresolved merge conflict!?! 2008-10-30 22:59:11 +0100 er r262838 : merge error 2008-10-30 16:31:04 +0100 hr r262833 : CWS-TOOLING: rebase CWS mooxlsc to trunk@262620 (milestone: DEV300:m34) 2008-10-16 21:57:51 +0200 er r262272 : migrate CWS mooxlsc to SVN
2008-12-12 09:38:47 +00:00
ScGlobal::EraseQuotes( aToken, '"' );
rStringList = ScGlobal::addToken(rStringList, aToken, '\n', 1, bTokenAdded);
bTokenAdded = true;
}
}
}
return bIsStringList;
2000-09-18 16:07:07 +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 ) ),
maEdMin ( this, NULL, ScResId( EDT_MIN ) ),
maEdList ( this, ScResId( EDT_LIST ) ),
maFtMax ( this, ScResId( FT_MAX ) ),
maEdMax ( this, NULL, ScResId( EDT_MAX ) ),
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 ) ),
maStrList ( ScResId( SCSTR_VALID_LIST ) ),
m_btnRef( this, ScResId( RB_VALIDITY_REF ) )
{
Init();
FreeResource();
2000-09-18 16:07:07 +00:00
// list separator in formulas
2010-11-06 11:25:04 -04:00
String aListSep = ::ScCompiler::GetNativeSymbol( ocSep );
OSL_ENSURE( aListSep.Len() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" );
mcFmlaSep = aListSep.Len() ? aListSep.GetChar( 0 ) : ';';
m_btnRef.Hide(); // cell range picker
}
ScTPValidationValue::~ScTPValidationValue()
2000-09-18 16:07:07 +00:00
{
}
void ScTPValidationValue::Init()
{
maLbAllow.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
maLbValue.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
maCbShow.SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) );
// cell range picker
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
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
{
return( new ScTPValidationValue( pParent, rArgSet ) );
2000-09-18 16:07:07 +00:00
}
sal_uInt16* ScTPValidationValue::GetRanges()
{
return pValueRanges;
}
2000-09-18 16:07:07 +00:00
void ScTPValidationValue::Reset( const SfxItemSet& rArgSet )
2000-09-18 16:07:07 +00:00
{
const SfxPoolItem* pItem;
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
if( rArgSet.GetItemState( FID_VALID_MODE, sal_True, &pItem ) == SFX_ITEM_SET )
nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
maLbAllow.SelectEntryPos( nLbPos );
nLbPos = SC_VALIDDLG_DATA_EQUAL;
if( rArgSet.GetItemState( FID_VALID_CONDMODE, sal_True, &pItem ) == SFX_ITEM_SET )
nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
maLbValue.SelectEntryPos( nLbPos );
// *** check boxes ***
sal_Bool bCheck = sal_True;
if( rArgSet.GetItemState( FID_VALID_BLANK, sal_True, &pItem ) == SFX_ITEM_SET )
bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
maCbAllow.Check( bCheck );
sal_Int32 nListType = ValidListType::UNSORTED;
if( rArgSet.GetItemState( FID_VALID_LISTTYPE, sal_True, &pItem ) == SFX_ITEM_SET )
nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
maCbShow.Check( nListType != ValidListType::INVISIBLE );
maCbSort.Check( nListType == ValidListType::SORTEDASCENDING );
// *** formulas ***
String aFmlaStr;
if ( rArgSet.GetItemState( FID_VALID_VALUE1, sal_True, &pItem ) == SFX_ITEM_SET )
aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
SetFirstFormula( aFmlaStr );
2001-01-17 18:28:42 +00:00
aFmlaStr.Erase();
if ( rArgSet.GetItemState( FID_VALID_VALUE2, sal_True, &pItem ) == SFX_ITEM_SET )
aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
SetSecondFormula( aFmlaStr );
2001-01-17 18:28:42 +00:00
SelectHdl( NULL );
CheckHdl( NULL );
2000-09-18 16:07:07 +00:00
}
sal_Bool ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet )
2000-09-18 16:07:07 +00:00
{
sal_Int16 nListType = maCbShow.IsChecked() ?
(maCbSort.IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
ValidListType::INVISIBLE;
rArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(
lclGetValModeFromPos( maLbAllow.GetSelectEntryPos() ) ) ) );
rArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(
lclGetCondModeFromPos( maLbValue.GetSelectEntryPos() ) ) ) );
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 ) );
return sal_True;
2000-09-18 16:07:07 +00:00
}
String ScTPValidationValue::GetFirstFormula() const
{
OUString aFmlaStr;
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
String ScTPValidationValue::GetSecondFormula() const
2000-09-18 16:07:07 +00:00
{
return maEdMax.GetText();
}
2000-09-18 16:07:07 +00:00
void ScTPValidationValue::SetFirstFormula( const OUString& rFmlaStr )
{
// try if formula is a string list, validation mode must already be set
OUString aStringList;
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
void ScTPValidationValue::SetSecondFormula( const String& rFmlaStr )
{
maEdMax.SetText( rFmlaStr );
2000-09-18 16:07:07 +00: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;
}
void ScTPValidationValue::SetupRefDlg()
{
if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
{
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 ) );
Window *pLabel = NULL;
if ( maEdMax.IsVisible() )
{
m_pRefEdit = &maEdMax;
pLabel = &maFtMax;
}
else if ( maEdMin.IsVisible() )
{
m_pRefEdit = &maEdMin;
pLabel = &maFtMin;
}
if( m_pRefEdit && !m_pRefEdit->HasFocus() )
m_pRefEdit->GrabFocus();
if( m_pRefEdit )
m_pRefEdit->SetRefDialog( pValidationDlg );
m_btnRef.SetReferences( pValidationDlg, m_pRefEdit, pLabel );
}
}
}
void ScTPValidationValue::RemoveRefDlg()
{
if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
{
if( pValidationDlg->RemoveRefDlg() )
{
pValidationDlg->SetHandler( NULL );
pValidationDlg->SetSetRefHdl( NULL );
pValidationDlg->SetSetActHdl( NULL );
pValidationDlg->SetRefInputStartPreHdl( NULL );
pValidationDlg->SetRefInputDonePostHdl( NULL );
if( m_pRefEdit )
m_pRefEdit->SetRefDialog( NULL );
m_pRefEdit = NULL;
m_btnRef.SetReferences( NULL, NULL, NULL );
#if ! defined( WNT ) && !defined( _MSC_VER )
TidyListBoxes();
#endif
}
}
}
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) ) ) ;
if ( pWnd )
{
for ( std::list<Window*>::iterator i = alstOrder.begin(); i!=alstOrder.end(); ++i )
{
Window *pParent = (*i)->GetParent();
(*i)->SetParent( pWnd );
(*i)->SetParent( pParent );
}
}
}
}
IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl)
{
sal_uInt16 nPos=maLbAllow.GetSelectEntryPos();
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
// ----------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl)
{
sal_uInt16 nLbPos = maLbAllow.GetSelectEntryPos();
bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY);
bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE);
bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST);
maCbAllow.Enable( bEnable ); // Empty cell
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
{
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;
case SC_VALIDDLG_DATA_VALIDRANGE:
case SC_VALIDDLG_DATA_INVALIDRANGE: bShowMax = true; // fall through
case SC_VALIDDLG_DATA_GREATER:
case SC_VALIDDLG_DATA_EQGREATER: maFtMin.SetText( maStrMin ); break;
default:
OSL_FAIL( "ScTPValidationValue::SelectHdl - unknown condition mode" );
}
2000-09-18 16:07:07 +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 );
m_btnRef.Show( bRange ); // cell range picker
return 0;
}
2000-09-18 16:07:07 +00:00
IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl)
{
maCbSort.Enable( maCbShow.IsChecked() );
return 0;
2000-09-18 16:07:07 +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 ) ),
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 ) ),
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()
{
aTsbHelp.EnableTriState( false );
2000-09-18 16:07:07 +00: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;
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 );
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 );
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
}
// -----------------------------------------------------------------------
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() ) );
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 ) ),
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 ) ),
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 );
aTsbShow.EnableTriState( false );
2000-09-18 16:07:07 +00:00
SelectActionHdl( NULL );
}
//------------------------------------------------------------------------
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;
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
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 );
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 );
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 );
}
// -----------------------------------------------------------------------
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() ) );
return sal_True;
2000-09-18 16:07:07 +00:00
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(ScTPValidationError, SelectActionHdl)
2000-09-18 16:07:07 +00:00
{
ScValidErrorStyle eStyle = (ScValidErrorStyle) aLbAction.GetSelectEntryPos();
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 );
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(ScTPValidationError, ClickSearchHdl)
2000-09-18 16:07:07 +00:00
{
Window* pOld = Application::GetDefDialogParent();
Application::SetDefDialogParent( this );
// 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 );
if ( aScriptURL != NULL && !aScriptURL.isEmpty() )
2000-09-18 16:07:07 +00:00
{
aEdtTitle.SetText( aScriptURL );
2000-09-18 16:07:07 +00:00
}
return( 0L );
}
bool ScValidationDlg::EnterRefStatus()
{
ScTabViewShell *pTabViewShell = GetTabViewShell();
if( !pTabViewShell ) return false;
sal_uInt16 nId = SLOTID;
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
if ( pWnd && pWnd->GetWindow()!= this ) pWnd = NULL;
SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
return true;
}
bool ScValidationDlg::LeaveRefStatus()
{
ScTabViewShell *pTabViewShell = GetTabViewShell();
if( !pTabViewShell ) return false;
sal_uInt16 nId = SLOTID;
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
if ( pViewFrm->GetChildWindow( nId ) )
{
DoClose( nId );
}
return true;
}
bool ScValidationDlg::SetupRefDlg()
{
if ( m_bOwnRefHdlr ) return false;
if( EnterRefMode() )
{
SetModal( false );
return m_bOwnRefHdlr = true && EnterRefStatus();
}
return false;
}
bool ScValidationDlg::RemoveRefDlg( sal_Bool bRestoreModal /* = sal_True */ )
{
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 )
SetModal( sal_True );
}
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 );
formula::RefButton::Click();
}
void ScTPValidationValue::OnClick( Button *pBtn )
{
if( pBtn == &m_btnRef )
SetupRefDlg();
}
sal_Bool ScValidationDlg::IsChildFocus()
{
if ( const Window *pWin = Application::GetFocusWindow() )
while( NULL != ( pWin = pWin->GetParent() ) )
if( pWin == this )
return sal_True;
return false;
}
bool ScValidationDlg::IsAlive()
{
return SC_MOD()->IsAliveRefDlg( SLOTID, this );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */