LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/dbgui - validate.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 486 0.0 %
Date: 2013-07-09 Functions: 0 68 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10