LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - validate.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 480 0.0 %
Date: 2014-11-03 Functions: 0 60 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             : #ifdef SC_DLLIMPLEMENTATION
      21             : #undef SC_DLLIMPLEMENTATION
      22             : #endif
      23             : 
      24             : #include <comphelper/string.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <svl/aeitem.hxx>
      27             : #include <svl/stritem.hxx>
      28             : #include <svl/eitem.hxx>
      29             : #include <svl/intitem.hxx>
      30             : #include <basic/sbmeth.hxx>
      31             : #include <basic/sbstar.hxx>
      32             : #include <basic/sbmod.hxx>
      33             : #include <sfx2/app.hxx>
      34             : 
      35             : #include "scresid.hxx"
      36             : #include "sc.hrc"
      37             : 
      38             : #include "stringutil.hxx"
      39             : #include "validat.hxx"
      40             : #include "validate.hxx"
      41             : #include "compiler.hxx"
      42             : #include <formula/opcode.hxx>
      43             : 
      44             : // cell range picker
      45             : #include "tabvwsh.hxx"
      46             : #include <sfx2/viewfrm.hxx>
      47             : #include <sfx2/childwin.hxx>
      48             : #include "reffact.hxx"
      49             : 
      50             : /*  Position indexes for "Allow" list box.
      51             :     They do not map directly to ScValidationMode and can safely be modified to
      52             :     change the order of the list box entries. */
      53             : #define SC_VALIDDLG_ALLOW_ANY       0
      54             : #define SC_VALIDDLG_ALLOW_WHOLE     1
      55             : #define SC_VALIDDLG_ALLOW_DECIMAL   2
      56             : #define SC_VALIDDLG_ALLOW_DATE      3
      57             : #define SC_VALIDDLG_ALLOW_TIME      4
      58             : #define SC_VALIDDLG_ALLOW_RANGE     5
      59             : #define SC_VALIDDLG_ALLOW_LIST      6
      60             : #define SC_VALIDDLG_ALLOW_TEXTLEN   7
      61             : 
      62             : /*  Position indexes for "Data" list box.
      63             :     They do not map directly to ScConditionMode and can safely be modified to
      64             :     change the order of the list box entries. */
      65             : #define SC_VALIDDLG_DATA_EQUAL        0
      66             : #define SC_VALIDDLG_DATA_LESS         1
      67             : #define SC_VALIDDLG_DATA_GREATER      2
      68             : #define SC_VALIDDLG_DATA_EQLESS       3
      69             : #define SC_VALIDDLG_DATA_EQGREATER    4
      70             : #define SC_VALIDDLG_DATA_NOTEQUAL     5
      71             : #define SC_VALIDDLG_DATA_VALIDRANGE   6
      72             : #define SC_VALIDDLG_DATA_INVALIDRANGE 7
      73             : 
      74             : namespace ValidListType = css::sheet::TableValidationVisibility;
      75             : 
      76             : static const sal_uInt16 pValueRanges[] =
      77             : {
      78             :     FID_VALID_MODE, FID_VALID_ERRTEXT,
      79             :     FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
      80             :     0
      81             : };
      82             : 
      83           0 : ScValidationDlg::ScValidationDlg(vcl::Window* pParent, const SfxItemSet* pArgSet,
      84             :     ScTabViewShell *pTabViewSh, SfxBindings *pB /*= NULL*/)
      85           0 :     : ScValidationDlgBase(pParent ? pParent : SfxGetpApp()->GetTopWindow(),
      86             :         "ValidationDialog", "modules/scalc/ui/validationdialog.ui", pArgSet, pB)
      87             :     , m_pTabVwSh(pTabViewSh)
      88             :     , m_nValuePageId(0)
      89             :     , m_bOwnRefHdlr(false)
      90           0 :     , m_bRefInputting(false)
      91             : {
      92           0 :     m_nValuePageId = AddTabPage("criteria", ScTPValidationValue::Create, 0);
      93           0 :     AddTabPage("inputhelp", ScTPValidationHelp::Create, 0);
      94           0 :     AddTabPage("erroralert", ScTPValidationError::Create, 0);
      95           0 :     get(m_pHBox, "refinputbox");
      96           0 : }
      97             : 
      98           0 : void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
      99             : {
     100           0 :     if ( rRange.aStart != rRange.aEnd )
     101           0 :         if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     102           0 :             if( m_pRefEdit )
     103           0 :                 pValidationDlg->RefInputStart( m_pRefEdit );
     104             : 
     105           0 :     if ( m_pRefEdit )
     106             :     {
     107           0 :         OUString aStr(rRange.Format(SCR_ABS_3D, pDoc, pDoc->GetAddressConvention()));
     108           0 :         m_pRefEdit->SetRefString( aStr );
     109             :     }
     110           0 : }
     111             : 
     112           0 : void ScTPValidationValue:: SetActiveHdl()
     113             : {
     114           0 :     if ( m_pRefEdit ) m_pRefEdit->GrabFocus();
     115             : 
     116           0 :     if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     117           0 :         if( m_pRefEdit )
     118             :         {
     119           0 :             pValidationDlg->RefInputDone();
     120             :         }
     121           0 : }
     122             : 
     123           0 : void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton )
     124             : {
     125           0 :     if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     126             :     {
     127           0 :         vcl::Window *pNewParent = pValidationDlg->get_refinput_shrink_parent();
     128           0 :         if( pEdit == m_pRefEdit && m_pRefEdit->GetParent() != pNewParent )
     129             :         {
     130           0 :             m_pRefEdit->SetParent(pNewParent);
     131             :         }
     132             : 
     133           0 :         if( pButton == m_pBtnRef && m_pBtnRef->GetParent() != pNewParent )
     134             :         {
     135           0 :             m_pBtnRef->SetParent(pNewParent);
     136             :         }
     137             : 
     138           0 :         pNewParent->Show();
     139             :     }
     140           0 : }
     141             : 
     142           0 : void ScTPValidationValue::RefInputDonePostHdl()
     143             : {
     144           0 :     if( m_pRefEdit && m_pRefEdit->GetParent() != m_pRefGrid )
     145             :     {
     146           0 :         m_pRefEdit->SetParent( m_pRefGrid );
     147           0 :         m_pBtnRef->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
     148             :     }
     149             : 
     150           0 :     if( m_pBtnRef->GetParent() != m_pRefGrid )
     151           0 :         m_pBtnRef->SetParent( m_pRefGrid );
     152             : 
     153           0 :     if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     154             :     {
     155           0 :         pValidationDlg->get_refinput_shrink_parent()->Hide();
     156           0 :         ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData();
     157           0 :         SCTAB nCurTab = rViewData.GetTabNo();
     158           0 :         SCTAB nRefTab = rViewData.GetRefTabNo();
     159             :         // If RefInput switched to a different sheet from the data sheet,
     160             :         // switch back: fdo#53920
     161           0 :         if ( nCurTab != nRefTab )
     162             :         {
     163           0 :              rViewData.GetViewShell()->SetTabNo( nRefTab );
     164             :         }
     165             :     }
     166             : 
     167           0 :     if( m_pRefEdit && !m_pRefEdit->HasFocus() )
     168           0 :         m_pRefEdit->GrabFocus();
     169           0 : }
     170             : 
     171             : namespace {
     172             : 
     173             : /** Converts the passed ScValidationMode to the position in the list box. */
     174           0 : sal_uInt16 lclGetPosFromValMode( ScValidationMode eValMode )
     175             : {
     176           0 :     sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
     177           0 :     switch( eValMode )
     178             :     {
     179           0 :         case SC_VALID_ANY:      nLbPos = SC_VALIDDLG_ALLOW_ANY;     break;
     180           0 :         case SC_VALID_WHOLE:    nLbPos = SC_VALIDDLG_ALLOW_WHOLE;   break;
     181           0 :         case SC_VALID_DECIMAL:  nLbPos = SC_VALIDDLG_ALLOW_DECIMAL; break;
     182           0 :         case SC_VALID_DATE:     nLbPos = SC_VALIDDLG_ALLOW_DATE;    break;
     183           0 :         case SC_VALID_TIME:     nLbPos = SC_VALIDDLG_ALLOW_TIME;    break;
     184           0 :         case SC_VALID_TEXTLEN:  nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN; break;
     185           0 :         case SC_VALID_LIST:     nLbPos = SC_VALIDDLG_ALLOW_RANGE;   break;
     186           0 :         case SC_VALID_CUSTOM:   nLbPos = SC_VALIDDLG_ALLOW_ANY;     break;  // not supported
     187             :         default:    OSL_FAIL( "lclGetPosFromValMode - unknown validity mode" );
     188             :     }
     189           0 :     return nLbPos;
     190             : }
     191             : 
     192             : /** Converts the passed list box position to an ScValidationMode. */
     193           0 : ScValidationMode lclGetValModeFromPos( sal_uInt16 nLbPos )
     194             : {
     195           0 :     ScValidationMode eValMode = SC_VALID_ANY;
     196           0 :     switch( nLbPos )
     197             :     {
     198           0 :         case SC_VALIDDLG_ALLOW_ANY:     eValMode = SC_VALID_ANY;        break;
     199           0 :         case SC_VALIDDLG_ALLOW_WHOLE:   eValMode = SC_VALID_WHOLE;      break;
     200           0 :         case SC_VALIDDLG_ALLOW_DECIMAL: eValMode = SC_VALID_DECIMAL;    break;
     201           0 :         case SC_VALIDDLG_ALLOW_DATE:    eValMode = SC_VALID_DATE;       break;
     202           0 :         case SC_VALIDDLG_ALLOW_TIME:    eValMode = SC_VALID_TIME;       break;
     203           0 :         case SC_VALIDDLG_ALLOW_RANGE:   eValMode = SC_VALID_LIST;       break;
     204           0 :         case SC_VALIDDLG_ALLOW_LIST:    eValMode = SC_VALID_LIST;       break;
     205           0 :         case SC_VALIDDLG_ALLOW_TEXTLEN: eValMode = SC_VALID_TEXTLEN;    break;
     206             :         default:    OSL_FAIL( "lclGetValModeFromPos - invalid list box position" );
     207             :     }
     208           0 :     return eValMode;
     209             : }
     210             : 
     211             : /** Converts the passed ScConditionMode to the position in the list box. */
     212           0 : sal_uInt16 lclGetPosFromCondMode( ScConditionMode eCondMode )
     213             : {
     214           0 :     sal_uInt16 nLbPos = SC_VALIDDLG_DATA_EQUAL;
     215           0 :     switch( eCondMode )
     216             :     {
     217             :         case SC_COND_NONE:          // may occur in old XML files after Excel import
     218           0 :         case SC_COND_EQUAL:         nLbPos = SC_VALIDDLG_DATA_EQUAL;        break;
     219           0 :         case SC_COND_LESS:          nLbPos = SC_VALIDDLG_DATA_LESS;         break;
     220           0 :         case SC_COND_GREATER:       nLbPos = SC_VALIDDLG_DATA_GREATER;      break;
     221           0 :         case SC_COND_EQLESS:        nLbPos = SC_VALIDDLG_DATA_EQLESS;       break;
     222           0 :         case SC_COND_EQGREATER:     nLbPos = SC_VALIDDLG_DATA_EQGREATER;    break;
     223           0 :         case SC_COND_NOTEQUAL:      nLbPos = SC_VALIDDLG_DATA_NOTEQUAL;     break;
     224           0 :         case SC_COND_BETWEEN:       nLbPos = SC_VALIDDLG_DATA_VALIDRANGE;      break;
     225           0 :         case SC_COND_NOTBETWEEN:    nLbPos = SC_VALIDDLG_DATA_INVALIDRANGE;   break;
     226             :         default:    OSL_FAIL( "lclGetPosFromCondMode - unknown condition mode" );
     227             :     }
     228           0 :     return nLbPos;
     229             : }
     230             : 
     231             : /** Converts the passed list box position to an ScConditionMode. */
     232           0 : ScConditionMode lclGetCondModeFromPos( sal_uInt16 nLbPos )
     233             : {
     234           0 :     ScConditionMode eCondMode = SC_COND_EQUAL;
     235           0 :     switch( nLbPos )
     236             :     {
     237           0 :         case SC_VALIDDLG_DATA_EQUAL:        eCondMode = SC_COND_EQUAL;      break;
     238           0 :         case SC_VALIDDLG_DATA_LESS:         eCondMode = SC_COND_LESS;       break;
     239           0 :         case SC_VALIDDLG_DATA_GREATER:      eCondMode = SC_COND_GREATER;    break;
     240           0 :         case SC_VALIDDLG_DATA_EQLESS:       eCondMode = SC_COND_EQLESS;     break;
     241           0 :         case SC_VALIDDLG_DATA_EQGREATER:    eCondMode = SC_COND_EQGREATER;  break;
     242           0 :         case SC_VALIDDLG_DATA_NOTEQUAL:     eCondMode = SC_COND_NOTEQUAL;   break;
     243           0 :         case SC_VALIDDLG_DATA_VALIDRANGE:      eCondMode = SC_COND_BETWEEN;    break;
     244           0 :         case SC_VALIDDLG_DATA_INVALIDRANGE:   eCondMode = SC_COND_NOTBETWEEN; break;
     245             :         default:    OSL_FAIL( "lclGetCondModeFromPos - invalid list box position" );
     246             :     }
     247           0 :     return eCondMode;
     248             : }
     249             : 
     250             : /** Converts line feed separated string to a formula with strings separated by semicolons.
     251             :     @descr  Keeps all empty strings.
     252             :     Example: abc\ndef\n\nghi -> "abc";"def";"";"ghi".
     253             :     @param rFmlaStr  (out-param) The converted formula string. */
     254           0 : void lclGetFormulaFromStringList( OUString& rFmlaStr, const OUString& rStringList, sal_Unicode cFmlaSep )
     255             : {
     256           0 :     rFmlaStr = "";
     257           0 :     sal_Int32 nTokenCnt = comphelper::string::getTokenCount(rStringList, '\n');
     258           0 :     for( sal_Int32 nToken = 0, nStringIx = 0; nToken < (sal_Int32) nTokenCnt; ++nToken )
     259             :     {
     260           0 :         OUString aToken( rStringList.getToken( 0, '\n', nStringIx ) );
     261           0 :         ScGlobal::AddQuotes( aToken, '"' );
     262           0 :         rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep);
     263           0 :     }
     264           0 :     if( rFmlaStr.isEmpty() )
     265           0 :         rFmlaStr = "\"\"";
     266           0 : }
     267             : 
     268             : /** Converts formula with strings separated by semicolons to line feed separated string.
     269             :     @descr  Keeps all empty strings. Ignores all empty tokens (multiple semicolons).
     270             :     Example: "abc";;;"def";"";"ghi" -> abc\ndef\n\nghi.
     271             :     @param rStringList  (out-param) The converted line feed separated string list.
     272             :     @return  true = Conversion successful. */
     273           0 : bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaStr, sal_Unicode cFmlaSep )
     274             : {
     275           0 :     OUString aQuotes( "\"\"" );
     276           0 :     sal_Int32 nTokenCnt = ScStringUtil::GetQuotedTokenCount(rFmlaStr, aQuotes, cFmlaSep );
     277             : 
     278           0 :     rStringList="";
     279           0 :     bool bIsStringList = (nTokenCnt > 0);
     280           0 :     bool bTokenAdded = false;
     281             : 
     282           0 :     for( sal_Int32 nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
     283             :     {
     284           0 :         OUString aToken( ScStringUtil::GetQuotedToken(rFmlaStr, 0, aQuotes, cFmlaSep, nStringIx ) );
     285           0 :         aToken = comphelper::string::strip(aToken, ' ');
     286           0 :         if( !aToken.isEmpty() )      // ignore empty tokens, i.e. "a";;"b"
     287             :         {
     288           0 :             bIsStringList = ScGlobal::IsQuoted( aToken, '"' );
     289           0 :             if( bIsStringList )
     290             :             {
     291           0 :                 ScGlobal::EraseQuotes( aToken, '"' );
     292           0 :                 rStringList = ScGlobal::addToken(rStringList, aToken, '\n', 1, bTokenAdded);
     293           0 :                 bTokenAdded = true;
     294             :             }
     295             :         }
     296           0 :     }
     297             : 
     298           0 :     return bIsStringList;
     299             : }
     300             : 
     301             : } // namespace
     302             : 
     303           0 : ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet )
     304             :     : SfxTabPage( pParent, "ValidationCriteriaPage",
     305             :         "modules/scalc/ui/validationcriteriapage.ui", &rArgSet)
     306             :     , maStrMin(ScResId(SCSTR_VALID_MINIMUM))
     307             :     , maStrMax(ScResId(SCSTR_VALID_MAXIMUM))
     308             :     , maStrValue(ScResId(SCSTR_VALID_VALUE))
     309             :     , maStrRange(ScResId(SCSTR_VALID_RANGE))
     310             :     , maStrList(ScResId(SCSTR_VALID_LIST))
     311           0 :     , m_pRefEdit(NULL)
     312             : {
     313           0 :     get(m_pLbAllow, "allow");
     314           0 :     get(m_pCbAllow, "allowempty");
     315           0 :     get(m_pCbShow, "showlist");
     316           0 :     get(m_pCbSort, "sortascend");
     317           0 :     get(m_pFtValue, "valueft");
     318           0 :     get(m_pLbValue, "data");
     319           0 :     get(m_pFtMin, "minft");
     320           0 :     get(m_pMinGrid, "mingrid");
     321           0 :     get(m_pEdMin, "min");
     322           0 :     m_pEdMin->SetReferences(NULL, m_pFtMin);
     323           0 :     get(m_pEdList, "minlist");
     324           0 :     Size aSize(LogicToPixel(Size(174, 105), MAP_APPFONT));
     325           0 :     m_pEdList->set_width_request(aSize.Width());
     326           0 :     m_pEdList->set_height_request(aSize.Height());
     327           0 :     get(m_pFtMax, "maxft");
     328           0 :     get(m_pEdMax, "max");
     329           0 :     m_pEdMax->SetReferences(NULL, m_pFtMax);
     330           0 :     get(m_pFtHint, "hintft");
     331           0 :     get(m_pBtnRef, "validref");
     332           0 :     m_pBtnRef->SetParentPage(this);
     333           0 :     get(m_pRefGrid, "refgrid");
     334             : 
     335             :     //lock in the max size initial config
     336           0 :     aSize = get_preferred_size();
     337           0 :     set_width_request(aSize.Width());
     338           0 :     set_height_request(aSize.Height());
     339             : 
     340           0 :     Init();
     341             : 
     342             :     // list separator in formulas
     343           0 :     OUString aListSep = ::ScCompiler::GetNativeSymbol( ocSep );
     344             :     OSL_ENSURE( aListSep.getLength() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" );
     345           0 :     mcFmlaSep = aListSep.getLength() ? aListSep[0] : ';';
     346           0 :     m_pBtnRef->Hide(); // cell range picker
     347           0 : }
     348             : 
     349           0 : void ScTPValidationValue::Init()
     350             : {
     351           0 :     m_pLbAllow->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
     352           0 :     m_pLbValue->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
     353           0 :     m_pCbShow->SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) );
     354             : 
     355             :     // cell range picker
     356           0 :     m_pEdMin->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
     357           0 :     m_pEdMin->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
     358           0 :     m_pEdMax->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
     359           0 :     m_pBtnRef->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
     360           0 :     m_pEdMax->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
     361             : 
     362           0 :     m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_ANY );
     363           0 :     m_pLbValue->SelectEntryPos( SC_VALIDDLG_DATA_EQUAL );
     364             : 
     365           0 :     SelectHdl( NULL );
     366           0 :     CheckHdl( NULL );
     367           0 : }
     368             : 
     369           0 : SfxTabPage* ScTPValidationValue::Create( vcl::Window* pParent, const SfxItemSet* rArgSet )
     370             : {
     371           0 :     return( new ScTPValidationValue( pParent, *rArgSet ) );
     372             : }
     373             : 
     374           0 : const sal_uInt16* ScTPValidationValue::GetRanges()
     375             : {
     376           0 :     return pValueRanges;
     377             : }
     378             : 
     379           0 : void ScTPValidationValue::Reset( const SfxItemSet* rArgSet )
     380             : {
     381             :     const SfxPoolItem* pItem;
     382             : 
     383           0 :     sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
     384           0 :     if( rArgSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET )
     385             :         nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
     386           0 :             static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
     387           0 :     m_pLbAllow->SelectEntryPos( nLbPos );
     388             : 
     389           0 :     nLbPos = SC_VALIDDLG_DATA_EQUAL;
     390           0 :     if( rArgSet->GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SfxItemState::SET )
     391             :         nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
     392           0 :             static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
     393           0 :     m_pLbValue->SelectEntryPos( nLbPos );
     394             : 
     395             :     // *** check boxes ***
     396           0 :     bool bCheck = true;
     397           0 :     if( rArgSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET )
     398           0 :         bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
     399           0 :     m_pCbAllow->Check( bCheck );
     400             : 
     401           0 :     sal_Int32 nListType = ValidListType::UNSORTED;
     402           0 :     if( rArgSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET )
     403           0 :         nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
     404           0 :     m_pCbShow->Check( nListType != ValidListType::INVISIBLE );
     405           0 :     m_pCbSort->Check( nListType == ValidListType::SORTEDASCENDING );
     406             : 
     407             :     // *** formulas ***
     408           0 :     OUString aFmlaStr;
     409           0 :     if ( rArgSet->GetItemState( FID_VALID_VALUE1, true, &pItem ) == SfxItemState::SET )
     410           0 :         aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
     411           0 :     SetFirstFormula( aFmlaStr );
     412             : 
     413           0 :     aFmlaStr= "";
     414           0 :     if ( rArgSet->GetItemState( FID_VALID_VALUE2, true, &pItem ) == SfxItemState::SET )
     415           0 :         aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
     416           0 :     SetSecondFormula( aFmlaStr );
     417             : 
     418           0 :     SelectHdl( NULL );
     419           0 :     CheckHdl( NULL );
     420           0 : }
     421             : 
     422           0 : bool ScTPValidationValue::FillItemSet( SfxItemSet* rArgSet )
     423             : {
     424           0 :     sal_Int16 nListType = m_pCbShow->IsChecked() ?
     425           0 :         (m_pCbSort->IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
     426           0 :         ValidListType::INVISIBLE;
     427             : 
     428             :     rArgSet->Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(
     429           0 :                     lclGetValModeFromPos( m_pLbAllow->GetSelectEntryPos() ) ) ) );
     430             :     rArgSet->Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(
     431           0 :                     lclGetCondModeFromPos( m_pLbValue->GetSelectEntryPos() ) ) ) );
     432           0 :     rArgSet->Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) );
     433           0 :     rArgSet->Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) );
     434           0 :     rArgSet->Put( SfxBoolItem( FID_VALID_BLANK, m_pCbAllow->IsChecked() ) );
     435           0 :     rArgSet->Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
     436           0 :     return true;
     437             : }
     438             : 
     439           0 : OUString ScTPValidationValue::GetFirstFormula() const
     440             : {
     441           0 :     OUString aFmlaStr;
     442           0 :     if( m_pLbAllow->GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST )
     443           0 :         lclGetFormulaFromStringList( aFmlaStr, m_pEdList->GetText(), mcFmlaSep );
     444             :     else
     445           0 :         aFmlaStr = m_pEdMin->GetText();
     446           0 :     return aFmlaStr;
     447             : }
     448             : 
     449           0 : OUString ScTPValidationValue::GetSecondFormula() const
     450             : {
     451           0 :     return m_pEdMax->GetText();
     452             : }
     453             : 
     454           0 : void ScTPValidationValue::SetFirstFormula( const OUString& rFmlaStr )
     455             : {
     456             :     // try if formula is a string list, validation mode must already be set
     457           0 :     OUString aStringList;
     458           0 :     if( (m_pLbAllow->GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) &&
     459           0 :         lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) )
     460             :     {
     461           0 :         m_pEdList->SetText( aStringList );
     462           0 :         m_pEdMin->SetText( EMPTY_OUSTRING );
     463             :         // change validation mode to string list
     464           0 :         m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_LIST );
     465             :     }
     466             :     else
     467             :     {
     468           0 :         m_pEdMin->SetText( rFmlaStr );
     469           0 :         m_pEdList->SetText( EMPTY_OUSTRING );
     470           0 :     }
     471           0 : }
     472             : 
     473           0 : void ScTPValidationValue::SetSecondFormula( const OUString& rFmlaStr )
     474             : {
     475           0 :     m_pEdMax->SetText( rFmlaStr );
     476           0 : }
     477             : 
     478           0 : ScValidationDlg * ScTPValidationValue::GetValidationDlg()
     479             : {
     480           0 :     if( vcl::Window *pParent = GetParent() )
     481           0 :         do{
     482           0 :             if ( dynamic_cast<ScValidationDlg*>( pParent ) )
     483           0 :                 return static_cast< ScValidationDlg * >( pParent );
     484             :         }while ( NULL != ( pParent = pParent->GetParent() ) );
     485           0 :     return NULL;
     486             : }
     487             : 
     488           0 : void ScTPValidationValue::SetupRefDlg()
     489             : {
     490           0 :     if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     491             :     {
     492           0 :         if( pValidationDlg->SetupRefDlg() )
     493             :         {
     494           0 :             pValidationDlg->SetHandler( this );
     495           0 :             pValidationDlg->SetSetRefHdl( static_cast<ScRefHandlerHelper::PFUNCSETREFHDLTYPE>( &ScTPValidationValue::SetReferenceHdl ) );
     496           0 :             pValidationDlg->SetSetActHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::SetActiveHdl ) );
     497           0 :             pValidationDlg->SetRefInputStartPreHdl( static_cast<ScRefHandlerHelper::PINPUTSTARTDLTYPE>( &ScTPValidationValue::RefInputStartPreHdl ) );
     498           0 :             pValidationDlg->SetRefInputDonePostHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::RefInputDonePostHdl ) );
     499             : 
     500           0 :             vcl::Window *pLabel = NULL;
     501             : 
     502           0 :             if ( m_pEdMax->IsVisible() )
     503             :             {
     504           0 :                 m_pRefEdit = m_pEdMax;
     505           0 :                 pLabel = m_pFtMax;
     506             :             }
     507           0 :             else if ( m_pEdMin->IsVisible() )
     508             :             {
     509           0 :                 m_pRefEdit = m_pEdMin;
     510           0 :                 pLabel = m_pFtMin;
     511             :             }
     512             : 
     513           0 :             if( m_pRefEdit && !m_pRefEdit->HasFocus() )
     514           0 :                 m_pRefEdit->GrabFocus();
     515             : 
     516           0 :             if( m_pRefEdit )
     517           0 :                 m_pRefEdit->SetReferences( pValidationDlg, pLabel );
     518             : 
     519           0 :             m_pBtnRef->SetReferences( pValidationDlg, m_pRefEdit );
     520             :         }
     521             :     }
     522           0 : }
     523             : 
     524           0 : void ScTPValidationValue::RemoveRefDlg()
     525             : {
     526           0 :     if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     527             :     {
     528           0 :         if( pValidationDlg->RemoveRefDlg() )
     529             :         {
     530           0 :             pValidationDlg->SetHandler( NULL );
     531           0 :             pValidationDlg->SetSetRefHdl( NULL );
     532           0 :             pValidationDlg->SetSetActHdl( NULL );
     533           0 :             pValidationDlg->SetRefInputStartPreHdl( NULL );
     534           0 :             pValidationDlg->SetRefInputDonePostHdl( NULL );
     535             : 
     536           0 :             if( m_pRefEdit )
     537           0 :                 m_pRefEdit->SetReferences( NULL, NULL );
     538           0 :             m_pRefEdit = NULL;
     539             : 
     540           0 :             m_pBtnRef->SetReferences( NULL, NULL );
     541             :         }
     542             :     }
     543           0 : }
     544             : 
     545           0 : IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl)
     546             : {
     547           0 :     sal_uInt16  nPos=m_pLbAllow->GetSelectEntryPos();
     548             : 
     549           0 :     if ( nPos == SC_VALIDDLG_ALLOW_RANGE )
     550             :     {
     551           0 :         SetupRefDlg();
     552             :     }
     553             : 
     554           0 :     return 0;
     555             : }
     556             : 
     557           0 : IMPL_LINK( ScTPValidationValue, KillFocusHdl, vcl::Window *, pWnd )
     558             : {
     559           0 :     if( pWnd == m_pRefEdit || pWnd == m_pBtnRef )
     560           0 :         if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
     561           0 :             if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() )
     562           0 :                 if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_pBtnRef->HasFocus() )
     563             :                 {
     564           0 :                     RemoveRefDlg();
     565             :                 }
     566             : 
     567           0 :     return 0;
     568             : }
     569             : 
     570           0 : IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl)
     571             : {
     572           0 :     sal_uInt16 nLbPos = m_pLbAllow->GetSelectEntryPos();
     573           0 :     bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY);
     574           0 :     bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE);
     575           0 :     bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST);
     576             : 
     577           0 :     m_pCbAllow->Enable( bEnable );   // Empty cell
     578           0 :     m_pFtValue->Enable( bEnable );
     579           0 :     m_pLbValue->Enable( bEnable );
     580           0 :     m_pFtMin->Enable( bEnable );
     581           0 :     m_pEdMin->Enable( bEnable );
     582           0 :     m_pEdList->Enable( bEnable );
     583           0 :     m_pFtMax->Enable( bEnable );
     584           0 :     m_pEdMax->Enable( bEnable );
     585             : 
     586           0 :     bool bShowMax = false;
     587           0 :     if( bRange )
     588           0 :         m_pFtMin->SetText( maStrRange );
     589           0 :     else if( bList )
     590           0 :         m_pFtMin->SetText( maStrList );
     591             :     else
     592             :     {
     593           0 :         switch( m_pLbValue->GetSelectEntryPos() )
     594             :         {
     595             :             case SC_VALIDDLG_DATA_EQUAL:
     596           0 :             case SC_VALIDDLG_DATA_NOTEQUAL:     m_pFtMin->SetText( maStrValue );  break;
     597             : 
     598             :             case SC_VALIDDLG_DATA_LESS:
     599           0 :             case SC_VALIDDLG_DATA_EQLESS:       m_pFtMin->SetText( maStrMax );    break;
     600             : 
     601             :             case SC_VALIDDLG_DATA_VALIDRANGE:
     602           0 :             case SC_VALIDDLG_DATA_INVALIDRANGE:   bShowMax = true;    // fall through
     603             :             case SC_VALIDDLG_DATA_GREATER:
     604           0 :             case SC_VALIDDLG_DATA_EQGREATER:    m_pFtMin->SetText( maStrMin );    break;
     605             : 
     606             :             default:
     607             :                 OSL_FAIL( "ScTPValidationValue::SelectHdl - unknown condition mode" );
     608             :         }
     609             :     }
     610             : 
     611           0 :     m_pCbShow->Show( bRange || bList );
     612           0 :     m_pCbSort->Show( bRange || bList );
     613           0 :     m_pFtValue->Show( !bRange && !bList );
     614           0 :     m_pLbValue->Show( !bRange && !bList );
     615           0 :     m_pEdMin->Show( !bList );
     616           0 :     m_pEdList->Show( bList );
     617           0 :     m_pMinGrid->set_vexpand( bList );
     618           0 :     WinBits nBits = m_pFtMin->GetStyle();
     619           0 :     nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM);
     620           0 :     if (bList)
     621           0 :         nBits |= WB_TOP;
     622             :     else
     623           0 :         nBits |= WB_VCENTER;
     624           0 :     m_pFtMin->SetStyle( nBits );
     625           0 :     m_pFtMax->Show( bShowMax );
     626           0 :     m_pEdMax->Show( bShowMax );
     627           0 :     m_pFtHint->Show( bRange );
     628           0 :     m_pBtnRef->Show( bRange );  // cell range picker
     629           0 :     return 0;
     630             : }
     631             : 
     632           0 : IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl)
     633             : {
     634           0 :     m_pCbSort->Enable( m_pCbShow->IsChecked() );
     635           0 :     return 0;
     636             : }
     637             : 
     638             : // Input Help Page
     639             : 
     640           0 : ScTPValidationHelp::ScTPValidationHelp( vcl::Window*         pParent,
     641             :                                           const SfxItemSet& rArgSet )
     642             : 
     643             :     :   SfxTabPage      ( pParent,
     644             :                           "ValidationHelpTabPage" , "modules/scalc/ui/validationhelptabpage.ui" ,
     645           0 :                           &rArgSet )
     646             : {
     647           0 :     get(pTsbHelp,"tsbhelp");
     648           0 :     get(pEdtTitle,"title");
     649           0 :     get(pEdInputHelp,"inputhelp");
     650           0 :     pEdInputHelp->set_height_request(pEdInputHelp->GetTextHeight() * 12);
     651           0 :     pEdInputHelp->set_width_request(pEdInputHelp->approximate_char_width() * 50);
     652           0 :     Init();
     653           0 : }
     654             : 
     655           0 : ScTPValidationHelp::~ScTPValidationHelp()
     656             : {
     657           0 : }
     658             : 
     659           0 : void ScTPValidationHelp::Init()
     660             : {
     661           0 :     pTsbHelp->EnableTriState( false );
     662           0 : }
     663             : 
     664           0 : SfxTabPage* ScTPValidationHelp::Create( vcl::Window* pParent,
     665             :                                          const SfxItemSet*  rArgSet )
     666             : {
     667           0 :     return ( new ScTPValidationHelp( pParent, *rArgSet ) );
     668             : }
     669             : 
     670           0 : void ScTPValidationHelp::Reset( const SfxItemSet* rArgSet )
     671             : {
     672             :     const SfxPoolItem* pItem;
     673             : 
     674           0 :     if ( rArgSet->GetItemState( FID_VALID_SHOWHELP, true, &pItem ) == SfxItemState::SET )
     675           0 :         pTsbHelp->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
     676             :     else
     677           0 :         pTsbHelp->SetState( TRISTATE_FALSE );
     678             : 
     679           0 :     if ( rArgSet->GetItemState( FID_VALID_HELPTITLE, true, &pItem ) == SfxItemState::SET )
     680           0 :         pEdtTitle->SetText( static_cast<const SfxStringItem*>(pItem)->GetValue() );
     681             :     else
     682           0 :         pEdtTitle->SetText( EMPTY_OUSTRING );
     683             : 
     684           0 :     if ( rArgSet->GetItemState( FID_VALID_HELPTEXT, true, &pItem ) == SfxItemState::SET )
     685           0 :         pEdInputHelp->SetText( static_cast<const SfxStringItem*>(pItem)->GetValue() );
     686             :     else
     687           0 :         pEdInputHelp->SetText( EMPTY_OUSTRING );
     688           0 : }
     689             : 
     690           0 : bool ScTPValidationHelp::FillItemSet( SfxItemSet* rArgSet )
     691             : {
     692           0 :     rArgSet->Put( SfxBoolItem( FID_VALID_SHOWHELP, pTsbHelp->GetState() == TRISTATE_TRUE ) );
     693           0 :     rArgSet->Put( SfxStringItem( FID_VALID_HELPTITLE, pEdtTitle->GetText() ) );
     694           0 :     rArgSet->Put( SfxStringItem( FID_VALID_HELPTEXT, pEdInputHelp->GetText() ) );
     695             : 
     696           0 :     return true;
     697             : }
     698             : 
     699             : // Error Alert Page
     700             : 
     701           0 : ScTPValidationError::ScTPValidationError( vcl::Window*           pParent,
     702             :                                           const SfxItemSet& rArgSet )
     703             : 
     704             :     :   SfxTabPage      ( pParent,
     705             :                           "ErrorAlertTabPage" , "modules/scalc/ui/erroralerttabpage.ui" ,
     706           0 :                           &rArgSet )
     707             : {
     708           0 :     get(m_pTsbShow,"tsbshow");
     709           0 :     get(m_pLbAction,"actionCB");
     710           0 :     get(m_pBtnSearch,"browseBtn");
     711           0 :     get(m_pEdtTitle,"title");
     712           0 :     get(m_pFtError,"errormsg_label");
     713           0 :     get(m_pEdError,"errorMsg");
     714           0 :     m_pEdError->set_height_request(m_pEdError->GetTextHeight() * 12);
     715           0 :     m_pEdError->set_width_request(m_pEdError->approximate_char_width() * 50);
     716           0 :     Init();
     717           0 : }
     718             : 
     719           0 : ScTPValidationError::~ScTPValidationError()
     720             : {
     721           0 : }
     722             : 
     723           0 : void ScTPValidationError::Init()
     724             : {
     725           0 :     m_pLbAction->SetSelectHdl( LINK( this, ScTPValidationError, SelectActionHdl ) );
     726           0 :     m_pBtnSearch->SetClickHdl( LINK( this, ScTPValidationError, ClickSearchHdl ) );
     727             : 
     728           0 :     m_pLbAction->SelectEntryPos( 0 );
     729           0 :     m_pTsbShow->EnableTriState( false );
     730             : 
     731           0 :     SelectActionHdl( NULL );
     732           0 : }
     733             : 
     734           0 : SfxTabPage* ScTPValidationError::Create( vcl::Window*    pParent,
     735             :                                          const SfxItemSet*  rArgSet )
     736             : {
     737           0 :     return ( new ScTPValidationError( pParent, *rArgSet ) );
     738             : }
     739             : 
     740           0 : void ScTPValidationError::Reset( const SfxItemSet* rArgSet )
     741             : {
     742             :     const SfxPoolItem* pItem;
     743             : 
     744           0 :     if ( rArgSet->GetItemState( FID_VALID_SHOWERR, true, &pItem ) == SfxItemState::SET )
     745           0 :         m_pTsbShow->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
     746             :     else
     747           0 :         m_pTsbShow->SetState( TRISTATE_TRUE );   // check by default
     748             : 
     749           0 :     if ( rArgSet->GetItemState( FID_VALID_ERRSTYLE, true, &pItem ) == SfxItemState::SET )
     750           0 :         m_pLbAction->SelectEntryPos( static_cast<const SfxAllEnumItem*>(pItem)->GetValue() );
     751             :     else
     752           0 :         m_pLbAction->SelectEntryPos( 0 );
     753             : 
     754           0 :     if ( rArgSet->GetItemState( FID_VALID_ERRTITLE, true, &pItem ) == SfxItemState::SET )
     755           0 :         m_pEdtTitle->SetText( static_cast<const SfxStringItem*>(pItem)->GetValue() );
     756             :     else
     757           0 :         m_pEdtTitle->SetText( EMPTY_OUSTRING );
     758             : 
     759           0 :     if ( rArgSet->GetItemState( FID_VALID_ERRTEXT, true, &pItem ) == SfxItemState::SET )
     760           0 :         m_pEdError->SetText( static_cast<const SfxStringItem*>(pItem)->GetValue() );
     761             :     else
     762           0 :         m_pEdError->SetText( EMPTY_OUSTRING );
     763             : 
     764           0 :     SelectActionHdl( NULL );
     765           0 : }
     766             : 
     767           0 : bool ScTPValidationError::FillItemSet( SfxItemSet* rArgSet )
     768             : {
     769           0 :     rArgSet->Put( SfxBoolItem( FID_VALID_SHOWERR, m_pTsbShow->GetState() == TRISTATE_TRUE ) );
     770           0 :     rArgSet->Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, m_pLbAction->GetSelectEntryPos() ) );
     771           0 :     rArgSet->Put( SfxStringItem( FID_VALID_ERRTITLE, m_pEdtTitle->GetText() ) );
     772           0 :     rArgSet->Put( SfxStringItem( FID_VALID_ERRTEXT, m_pEdError->GetText() ) );
     773             : 
     774           0 :     return true;
     775             : }
     776             : 
     777           0 : IMPL_LINK_NOARG(ScTPValidationError, SelectActionHdl)
     778             : {
     779           0 :     ScValidErrorStyle eStyle = (ScValidErrorStyle) m_pLbAction->GetSelectEntryPos();
     780           0 :     bool bMacro = ( eStyle == SC_VALERR_MACRO );
     781             : 
     782           0 :     m_pBtnSearch->Enable( bMacro );
     783           0 :     m_pFtError->Enable( !bMacro );
     784           0 :     m_pEdError->Enable( !bMacro );
     785             : 
     786           0 :     return( 0L );
     787             : }
     788             : 
     789           0 : IMPL_LINK_NOARG(ScTPValidationError, ClickSearchHdl)
     790             : {
     791           0 :     vcl::Window* pOld = Application::GetDefDialogParent();
     792           0 :     Application::SetDefDialogParent( this );
     793             : 
     794             :     // Use static SfxApplication method to bring up selector dialog for
     795             :     // choosing a script
     796           0 :     OUString aScriptURL = SfxApplication::ChooseScript();
     797             : 
     798           0 :     Application::SetDefDialogParent( pOld );
     799             : 
     800           0 :     if ( aScriptURL != NULL && !aScriptURL.isEmpty() )
     801             :     {
     802           0 :         m_pEdtTitle->SetText( aScriptURL );
     803             :     }
     804             : 
     805           0 :     return( 0L );
     806             : }
     807             : 
     808           0 : bool ScValidationDlg::EnterRefStatus()
     809             : {
     810           0 :     ScTabViewShell *pTabViewShell = GetTabViewShell();
     811             : 
     812           0 :     if( !pTabViewShell ) return false;
     813             : 
     814           0 :     sal_uInt16 nId  = SLOTID;
     815           0 :     SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     816           0 :     SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     817             : 
     818           0 :     if ( pWnd && pWnd->GetWindow()!= this ) pWnd = NULL;
     819             : 
     820           0 :     SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
     821             : 
     822           0 :     return true;
     823             : }
     824             : 
     825           0 : bool ScValidationDlg::LeaveRefStatus()
     826             : {
     827           0 :     ScTabViewShell *pTabViewShell = GetTabViewShell();
     828             : 
     829           0 :     if( !pTabViewShell ) return false;
     830             : 
     831           0 :     sal_uInt16 nId  = SLOTID;
     832           0 :     SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     833           0 :     if ( pViewFrm->GetChildWindow( nId ) )
     834             :     {
     835           0 :         DoClose( nId );
     836             :     }
     837           0 :     return true;
     838             : }
     839             : 
     840           0 : bool ScValidationDlg::SetupRefDlg()
     841             : {
     842           0 :     if ( m_bOwnRefHdlr ) return false;
     843           0 :     if( EnterRefMode() )
     844             :     {
     845           0 :         SetModal( false );
     846           0 :         return  m_bOwnRefHdlr = true && EnterRefStatus();
     847             :     }
     848             : 
     849           0 :     return false;
     850             : }
     851             : 
     852           0 : bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ )
     853             : {
     854           0 :     bool bVisLock = false;
     855           0 :     bool bFreeWindowLock = false;
     856             : 
     857           0 :     ScTabViewShell *pTabVwSh = GetTabViewShell();
     858             : 
     859           0 :     if( !pTabVwSh ) return false;
     860             : 
     861           0 :     if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
     862             :     {
     863           0 :         bVisLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( true );
     864           0 :         bFreeWindowLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( true );
     865             :     }
     866             : 
     867           0 :     if ( !m_bOwnRefHdlr ) return false;
     868           0 :     if( LeaveRefStatus() && LeaveRefMode() )
     869             :     {
     870           0 :         m_bOwnRefHdlr = false;
     871             : 
     872           0 :         if( bRestoreModal )
     873           0 :             SetModal( true );
     874             :     }
     875             : 
     876           0 :     if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
     877             :     {
     878           0 :         static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( bVisLock );
     879           0 :         static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( bFreeWindowLock );
     880             :     }
     881             : 
     882           0 :     return true;
     883             : }
     884             : 
     885           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeScRefButtonEx(vcl::Window *pParent, VclBuilder::stringmap &)
     886             : {
     887           0 :     return new ScTPValidationValue::ScRefButtonEx(pParent, 0);
     888             : }
     889             : 
     890           0 : void ScTPValidationValue::ScRefButtonEx::Click()
     891             : {
     892           0 :     if( ScTPValidationValue *pParent = GetParentPage() )
     893           0 :         pParent->OnClick( this );
     894             : 
     895           0 :     formula::RefButton::Click();
     896           0 : }
     897             : 
     898           0 : void ScTPValidationValue::OnClick( Button *pBtn )
     899             : {
     900           0 :     if( pBtn == m_pBtnRef )
     901           0 :         SetupRefDlg();
     902           0 : }
     903             : 
     904           0 : bool ScValidationDlg::IsChildFocus()
     905             : {
     906           0 :     if ( const vcl::Window *pWin = Application::GetFocusWindow() )
     907           0 :         while( NULL != ( pWin = pWin->GetParent() ) )
     908           0 :             if( pWin == this )
     909           0 :                 return true;
     910             : 
     911           0 :     return false;
     912           0 : }
     913             : 
     914             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10