diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-04-08 16:56:03 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-09 11:01:53 +0100 |
commit | e1bc666cda47eff1305253923ab16b9fd4eb3d42 (patch) | |
tree | c1db3d1b5fd5fde33af5c037055f874c37932e99 /sc/source/ui | |
parent | 92f2ea382446d1a8e16db198dc1e1baa48769800 (diff) |
convert data validation tab page to .ui
Change-Id: I1a4f1f4f06ec1ab0b28637380a8bfcb3bc64ee30
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/validate.cxx | 323 | ||||
-rw-r--r-- | sc/source/ui/dbgui/validate.src | 161 | ||||
-rw-r--r-- | sc/source/ui/inc/validate.hrc | 61 | ||||
-rw-r--r-- | sc/source/ui/inc/validate.hxx | 59 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 3 |
7 files changed, 190 insertions, 433 deletions
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 8afb4f7255ac..aa730924ad6c 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -56,7 +56,6 @@ #include "subtdlg.hxx" #include "textdlgs.hxx" #include "validate.hxx" -#include "validate.hrc" #include "sortdlg.hxx" #include "textimportoptions.hxx" #include "opredlin.hxx" @@ -1061,18 +1060,9 @@ CreateTabPage ScAbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nI return 0; } -GetTabPageRanges ScAbstractDialogFactory_Impl::GetTabPageRangesFunc( sal_uInt16 nId ) +GetTabPageRanges ScAbstractDialogFactory_Impl::GetTabPageRangesFunc() { - switch ( nId ) - { - case TP_VALIDATION_VALUES : - return ScTPValidationValue::GetRanges; - //break; - default: - break; - } - - return 0; + return ScTPValidationValue::GetRanges; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 9b5625bb6ee0..7dd1b48dd6b5 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -562,7 +562,7 @@ public: // For TabPage virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) SAL_OVERRIDE; - virtual GetTabPageRanges GetTabPageRangesFunc( sal_uInt16 nId ) SAL_OVERRIDE; + virtual GetTabPageRanges GetTabPageRangesFunc() SAL_OVERRIDE; }; diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index b53301e1d81d..83462faae305 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -38,7 +38,6 @@ #include "stringutil.hxx" #include "validat.hxx" -#include "validate.hrc" #include "validate.hxx" #include "compiler.hxx" #include "formula/opcode.hxx" @@ -49,6 +48,31 @@ #include <sfx2/childwin.hxx> #include "reffact.hxx" +/* Position indexes for "Allow" list box. + They do not map directly to ScValidationMode and can safely be modified to + change the order of the list box entries. */ +#define SC_VALIDDLG_ALLOW_ANY 0 +#define SC_VALIDDLG_ALLOW_WHOLE 1 +#define SC_VALIDDLG_ALLOW_DECIMAL 2 +#define SC_VALIDDLG_ALLOW_DATE 3 +#define SC_VALIDDLG_ALLOW_TIME 4 +#define SC_VALIDDLG_ALLOW_RANGE 5 +#define SC_VALIDDLG_ALLOW_LIST 6 +#define SC_VALIDDLG_ALLOW_TEXTLEN 7 + +/* Position indexes for "Data" list box. + They do not map directly to ScConditionMode and can safely be modified to + change the order of the list box entries. */ +#define SC_VALIDDLG_DATA_EQUAL 0 +#define SC_VALIDDLG_DATA_LESS 1 +#define SC_VALIDDLG_DATA_GREATER 2 +#define SC_VALIDDLG_DATA_EQLESS 3 +#define SC_VALIDDLG_DATA_EQGREATER 4 +#define SC_VALIDDLG_DATA_NOTEQUAL 5 +#define SC_VALIDDLG_DATA_VALIDRANGE 6 +#define SC_VALIDDLG_DATA_INVALIDRANGE 7 + + static sal_uInt16 pValueRanges[] = { FID_VALID_MODE, FID_VALID_ERRTEXT, @@ -97,44 +121,35 @@ void ScTPValidationValue:: SetActiveHdl() } } -void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton ) +void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton ) { if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) { Window *pNewParent = pValidationDlg->get_refinput_shrink_parent(); if( pEdit == m_pRefEdit && m_pRefEdit->GetParent() != pNewParent ) { - maRefEditPos = m_pRefEdit->GetPosPixel(); - maRefEditSize = m_pRefEdit->GetSizePixel(); m_pRefEdit->SetParent(pNewParent); } - if( pButton == &m_btnRef && m_btnRef.GetParent() != pNewParent ) + if( pButton == m_pBtnRef && m_pBtnRef->GetParent() != pNewParent ) { - maBtnRefPos = m_btnRef.GetPosPixel(); - maBtnRefSize = m_btnRef.GetSizePixel(); - m_btnRef.SetParent(pNewParent); + m_pBtnRef->SetParent(pNewParent); } pNewParent->Show(); } } -void ScTPValidationValue::RefInputDonePostHdl() +void ScTPValidationValue::RefInputDonePostHdl() { - if( m_pRefEdit && m_pRefEdit->GetParent()!= this ) + if( m_pRefEdit && m_pRefEdit->GetParent() != m_pRefGrid ) { - m_pRefEdit->SetParent( this ); - m_pRefEdit->SetPosSizePixel( maRefEditPos, maRefEditSize ); - - m_btnRef.SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to anthor window and restore parent later in order to restore the tab order + m_pRefEdit->SetParent( m_pRefGrid ); + 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 } - if( m_btnRef.GetParent()!=this ) - { - m_btnRef.SetParent( this ); - m_btnRef.SetPosSizePixel( maBtnRefPos, maBtnRefSize ); - } + if( m_pBtnRef->GetParent() != m_pRefGrid ) + m_pBtnRef->SetParent( m_pRefGrid ); if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) pValidationDlg->get_refinput_shrink_parent()->Hide(); @@ -144,7 +159,6 @@ void ScTPValidationValue::RefInputDonePostHdl() } - bool ScValidationDlg::Close() { if( m_bOwnRefHdlr ) @@ -295,57 +309,66 @@ bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaSt } // namespace -ScTPValidationValue::ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ) : - SfxTabPage( pParent, ScResId( TP_VALIDATION_VALUES ), rArgSet ), - maFtAllow ( this, ScResId( FT_ALLOW ) ), - maLbAllow ( this, ScResId( LB_ALLOW ) ), - maCbAllow ( this, ScResId( TSB_ALLOW_BLANKS ) ), - maCbShow ( this, ScResId( CB_SHOWLIST ) ), - maCbSort ( this, ScResId( CB_SORTLIST ) ), - maFtValue ( this, ScResId( FT_VALUE ) ), - maLbValue ( this, ScResId( LB_VALUE ) ), - maFtMin ( this, ScResId( FT_MIN ) ), - maEdMin ( this, NULL, &maFtMin, ScResId( EDT_MIN ) ), - maEdList ( this, ScResId( EDT_LIST ) ), - maFtMax ( this, ScResId( FT_MAX ) ), - maEdMax ( this, NULL, &maFtMax, ScResId( EDT_MAX ) ), - maFtHint ( this, ScResId( FT_SOURCEHINT ) ), - maStrMin ( ScResId( SCSTR_VALID_MINIMUM ) ), - maStrMax ( ScResId( SCSTR_VALID_MAXIMUM ) ), - maStrValue( ScResId( SCSTR_VALID_VALUE ) ), - maStrRange( ScResId( SCSTR_VALID_RANGE ) ), - maStrList ( ScResId( SCSTR_VALID_LIST ) ), - m_btnRef( this, ScResId( RB_VALIDITY_REF ) ) -{ +ScTPValidationValue::ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ) + : SfxTabPage( pParent, "ValidationCriteriaPage", + "modules/scalc/ui/validationcriteriapage.ui", rArgSet) + , maStrMin(ScResId(SCSTR_VALID_MINIMUM)) + , maStrMax(ScResId(SCSTR_VALID_MAXIMUM)) + , maStrValue(ScResId(SCSTR_VALID_VALUE)) + , maStrRange(ScResId(SCSTR_VALID_RANGE)) + , maStrList(ScResId(SCSTR_VALID_LIST)) +{ + get(m_pLbAllow, "allow"); + get(m_pCbAllow, "allowempty"); + get(m_pCbShow, "showlist"); + get(m_pCbSort, "sortascend"); + get(m_pFtValue, "valueft"); + get(m_pLbValue, "data"); + get(m_pFtMin, "minft"); + get(m_pMinGrid, "mingrid"); + get(m_pEdMin, "min"); + m_pEdMin->SetReferences(NULL, m_pFtMin); + get(m_pEdList, "minlist"); + Size aSize(LogicToPixel(Size(174, 105), MAP_APPFONT)); + m_pEdList->set_width_request(aSize.Width()); + m_pEdList->set_height_request(aSize.Height()); + get(m_pFtMax, "maxft"); + get(m_pEdMax, "max"); + m_pEdMax->SetReferences(NULL, m_pFtMax); + get(m_pFtHint, "hintft"); + get(m_pBtnRef, "validref"); + m_pBtnRef->SetParentPage(this); + get(m_pRefGrid, "refgrid"); + + //lock in the max size initial config + aSize = get_preferred_size(); + set_width_request(aSize.Width()); + set_height_request(aSize.Height()); + Init(); - FreeResource(); // list separator in formulas OUString aListSep = ::ScCompiler::GetNativeSymbol( ocSep ); OSL_ENSURE( aListSep.getLength() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" ); mcFmlaSep = aListSep.getLength() ? aListSep[0] : ';'; - m_btnRef.Hide(); // cell range picker -} - -ScTPValidationValue::~ScTPValidationValue() -{ + m_pBtnRef->Hide(); // cell range picker } void ScTPValidationValue::Init() { - maLbAllow.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - maLbValue.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - maCbShow.SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) ); + m_pLbAllow->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_pLbValue->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_pCbShow->SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) ); // cell range picker - maEdMin.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); - maEdMin.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); - maEdMax.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); - m_btnRef.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); - maEdMax.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); + m_pEdMin->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_pEdMin->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); + m_pEdMax->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_pBtnRef->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); + m_pEdMax->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) ); - maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_ANY ); - maLbValue.SelectEntryPos( SC_VALIDDLG_DATA_EQUAL ); + m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_ANY ); + m_pLbValue->SelectEntryPos( SC_VALIDDLG_DATA_EQUAL ); SelectHdl( NULL ); CheckHdl( NULL ); @@ -369,25 +392,25 @@ void ScTPValidationValue::Reset( const SfxItemSet& rArgSet ) if( rArgSet.GetItemState( FID_VALID_MODE, true, &pItem ) == SFX_ITEM_SET ) nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - maLbAllow.SelectEntryPos( nLbPos ); + m_pLbAllow->SelectEntryPos( nLbPos ); nLbPos = SC_VALIDDLG_DATA_EQUAL; if( rArgSet.GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SFX_ITEM_SET ) nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - maLbValue.SelectEntryPos( nLbPos ); + m_pLbValue->SelectEntryPos( nLbPos ); // *** check boxes *** sal_Bool bCheck = sal_True; if( rArgSet.GetItemState( FID_VALID_BLANK, true, &pItem ) == SFX_ITEM_SET ) bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue(); - maCbAllow.Check( bCheck ); + m_pCbAllow->Check( bCheck ); sal_Int32 nListType = ValidListType::UNSORTED; if( rArgSet.GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SFX_ITEM_SET ) nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue(); - maCbShow.Check( nListType != ValidListType::INVISIBLE ); - maCbSort.Check( nListType == ValidListType::SORTEDASCENDING ); + m_pCbShow->Check( nListType != ValidListType::INVISIBLE ); + m_pCbSort->Check( nListType == ValidListType::SORTEDASCENDING ); // *** formulas *** OUString aFmlaStr; @@ -406,17 +429,17 @@ void ScTPValidationValue::Reset( const SfxItemSet& rArgSet ) bool ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet ) { - sal_Int16 nListType = maCbShow.IsChecked() ? - (maCbSort.IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : + sal_Int16 nListType = m_pCbShow->IsChecked() ? + (m_pCbSort->IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : ValidListType::INVISIBLE; rArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>( - lclGetValModeFromPos( maLbAllow.GetSelectEntryPos() ) ) ) ); + lclGetValModeFromPos( m_pLbAllow->GetSelectEntryPos() ) ) ) ); rArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>( - lclGetCondModeFromPos( maLbValue.GetSelectEntryPos() ) ) ) ); + lclGetCondModeFromPos( m_pLbValue->GetSelectEntryPos() ) ) ) ); rArgSet.Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) ); rArgSet.Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) ); - rArgSet.Put( SfxBoolItem( FID_VALID_BLANK, maCbAllow.IsChecked() ) ); + rArgSet.Put( SfxBoolItem( FID_VALID_BLANK, m_pCbAllow->IsChecked() ) ); rArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) ); return true; } @@ -424,40 +447,40 @@ bool ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet ) OUString ScTPValidationValue::GetFirstFormula() const { OUString aFmlaStr; - if( maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST ) - lclGetFormulaFromStringList( aFmlaStr, maEdList.GetText(), mcFmlaSep ); + if( m_pLbAllow->GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST ) + lclGetFormulaFromStringList( aFmlaStr, m_pEdList->GetText(), mcFmlaSep ); else - aFmlaStr = maEdMin.GetText(); + aFmlaStr = m_pEdMin->GetText(); return aFmlaStr; } OUString ScTPValidationValue::GetSecondFormula() const { - return maEdMax.GetText(); + return m_pEdMax->GetText(); } void ScTPValidationValue::SetFirstFormula( const OUString& rFmlaStr ) { // try if formula is a string list, validation mode must already be set OUString aStringList; - if( (maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) && + if( (m_pLbAllow->GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) && lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) ) { - maEdList.SetText( aStringList ); - maEdMin.SetText( EMPTY_OUSTRING ); + m_pEdList->SetText( aStringList ); + m_pEdMin->SetText( EMPTY_OUSTRING ); // change validation mode to string list - maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_LIST ); + m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_LIST ); } else { - maEdMin.SetText( rFmlaStr ); - maEdList.SetText( EMPTY_OUSTRING ); + m_pEdMin->SetText( rFmlaStr ); + m_pEdList->SetText( EMPTY_OUSTRING ); } } void ScTPValidationValue::SetSecondFormula( const OUString& rFmlaStr ) { - maEdMax.SetText( rFmlaStr ); + m_pEdMax->SetText( rFmlaStr ); } ScValidationDlg * ScTPValidationValue::GetValidationDlg() @@ -484,15 +507,15 @@ void ScTPValidationValue::SetupRefDlg() Window *pLabel = NULL; - if ( maEdMax.IsVisible() ) + if ( m_pEdMax->IsVisible() ) { - m_pRefEdit = &maEdMax; - pLabel = &maFtMax; + m_pRefEdit = m_pEdMax; + pLabel = m_pFtMax; } - else if ( maEdMin.IsVisible() ) + else if ( m_pEdMin->IsVisible() ) { - m_pRefEdit = &maEdMin; - pLabel = &maFtMin; + m_pRefEdit = m_pEdMin; + pLabel = m_pFtMin; } if( m_pRefEdit && !m_pRefEdit->HasFocus() ) @@ -501,7 +524,7 @@ void ScTPValidationValue::SetupRefDlg() if( m_pRefEdit ) m_pRefEdit->SetReferences( pValidationDlg, pLabel ); - m_btnRef.SetReferences( pValidationDlg, m_pRefEdit ); + m_pBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); } } } @@ -522,65 +545,14 @@ void ScTPValidationValue::RemoveRefDlg() m_pRefEdit->SetReferences( NULL, NULL ); m_pRefEdit = NULL; - m_btnRef.SetReferences( NULL, NULL ); - -#if ! defined( WNT ) && !defined( _MSC_VER ) - TidyListBoxes(); -#endif - } - } -} - -void ScTPValidationValue::TidyListBoxes() -{ - if ( Window *pWnd = GetChild( 0 ) ) - { - bool bFindLst = false; - std::list<Window*> alstOrder; - - do{ - if( pWnd->GetParent() == this ) - { - if ( !bFindLst ) - { - try{ - if( dynamic_cast<ListBox*>(pWnd)||dynamic_cast<ListBox*>(pWnd->GetWindow(WINDOW_CLIENT) ) ) - bFindLst = true; - } - catch( ... ) - { - if ( *(void**)pWnd == *(void**)&maLbValue ) - bFindLst = true; - else if ( Window *pClient = pWnd->GetWindow( WINDOW_CLIENT ) ) - if ( *(void**)pClient == *(void**)&maLbValue ) - bFindLst = true; - } - } - - if ( bFindLst ) - alstOrder.push_back( pWnd->GetWindow( WINDOW_CLIENT ) ); - } - }while( NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT ) ) ); - - pWnd = GetChild(0); - - while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ) ; - - if ( pWnd ) - { - for ( std::list<Window*>::iterator i = alstOrder.begin(); i!=alstOrder.end(); ++i ) - { - Window *pParent = (*i)->GetParent(); - (*i)->SetParent( pWnd ); - (*i)->SetParent( pParent ); - } + m_pBtnRef->SetReferences( NULL, NULL ); } } } IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl) { - sal_uInt16 nPos=maLbAllow.GetSelectEntryPos(); + sal_uInt16 nPos=m_pLbAllow->GetSelectEntryPos(); if ( nPos == SC_VALIDDLG_ALLOW_RANGE ) { @@ -592,10 +564,10 @@ IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl) IMPL_LINK( ScTPValidationValue, KillFocusHdl, Window *, pWnd ) { - if( pWnd == m_pRefEdit || pWnd == &m_btnRef ) + if( pWnd == m_pRefEdit || pWnd == m_pBtnRef ) if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() ) - if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_btnRef.HasFocus() ) + if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_pBtnRef->HasFocus() ) { RemoveRefDlg(); } @@ -605,61 +577,69 @@ IMPL_LINK( ScTPValidationValue, KillFocusHdl, Window *, pWnd ) IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl) { - sal_uInt16 nLbPos = maLbAllow.GetSelectEntryPos(); + sal_uInt16 nLbPos = m_pLbAllow->GetSelectEntryPos(); bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY); bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE); bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST); - maCbAllow.Enable( bEnable ); // Empty cell - maFtValue.Enable( bEnable ); - maLbValue.Enable( bEnable ); - maFtMin.Enable( bEnable ); - maEdMin.Enable( bEnable ); - maEdList.Enable( bEnable ); - maFtMax.Enable( bEnable ); - maEdMax.Enable( bEnable ); + m_pCbAllow->Enable( bEnable ); // Empty cell + m_pFtValue->Enable( bEnable ); + m_pLbValue->Enable( bEnable ); + m_pFtMin->Enable( bEnable ); + m_pEdMin->Enable( bEnable ); + m_pEdList->Enable( bEnable ); + m_pFtMax->Enable( bEnable ); + m_pEdMax->Enable( bEnable ); bool bShowMax = false; if( bRange ) - maFtMin.SetText( maStrRange ); + m_pFtMin->SetText( maStrRange ); else if( bList ) - maFtMin.SetText( maStrList ); + m_pFtMin->SetText( maStrList ); else { - switch( maLbValue.GetSelectEntryPos() ) + switch( m_pLbValue->GetSelectEntryPos() ) { case SC_VALIDDLG_DATA_EQUAL: - case SC_VALIDDLG_DATA_NOTEQUAL: maFtMin.SetText( maStrValue ); break; + case SC_VALIDDLG_DATA_NOTEQUAL: m_pFtMin->SetText( maStrValue ); break; case SC_VALIDDLG_DATA_LESS: - case SC_VALIDDLG_DATA_EQLESS: maFtMin.SetText( maStrMax ); break; + case SC_VALIDDLG_DATA_EQLESS: m_pFtMin->SetText( maStrMax ); break; case SC_VALIDDLG_DATA_VALIDRANGE: case SC_VALIDDLG_DATA_INVALIDRANGE: bShowMax = true; // fall through case SC_VALIDDLG_DATA_GREATER: - case SC_VALIDDLG_DATA_EQGREATER: maFtMin.SetText( maStrMin ); break; + case SC_VALIDDLG_DATA_EQGREATER: m_pFtMin->SetText( maStrMin ); break; default: OSL_FAIL( "ScTPValidationValue::SelectHdl - unknown condition mode" ); } } - maCbShow.Show( bRange || bList ); - maCbSort.Show( bRange || bList ); - maFtValue.Show( !bRange && !bList ); - maLbValue.Show( !bRange && !bList ); - maEdMin.Show( !bList ); - maEdList.Show( bList ); - maFtMax.Show( bShowMax ); - maEdMax.Show( bShowMax ); - maFtHint.Show( bRange ); - m_btnRef.Show( bRange ); // cell range picker + m_pCbShow->Show( bRange || bList ); + m_pCbSort->Show( bRange || bList ); + m_pFtValue->Show( !bRange && !bList ); + m_pLbValue->Show( !bRange && !bList ); + m_pEdMin->Show( !bList ); + m_pEdList->Show( bList ); + m_pMinGrid->set_vexpand( bList ); + WinBits nBits = m_pFtMin->GetStyle(); + nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM); + if (bList) + nBits |= WB_TOP; + else + nBits |= WB_VCENTER; + m_pFtMin->SetStyle( nBits ); + m_pFtMax->Show( bShowMax ); + m_pEdMax->Show( bShowMax ); + m_pFtHint->Show( bRange ); + m_pBtnRef->Show( bRange ); // cell range picker return 0; } IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl) { - maCbSort.Enable( maCbShow.IsChecked() ); + m_pCbSort->Enable( m_pCbShow->IsChecked() ); return 0; } @@ -921,9 +901,14 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ ) return true; } +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScRefButtonEx(Window *pParent, VclBuilder::stringmap &) +{ + return new ScTPValidationValue::ScRefButtonEx(pParent, 0); +} + void ScTPValidationValue::ScRefButtonEx::Click() { - if( ScTPValidationValue *pParent = dynamic_cast< ScTPValidationValue*>( GetParent() ) ) + if( ScTPValidationValue *pParent = GetParentPage() ) pParent->OnClick( this ); formula::RefButton::Click(); @@ -931,7 +916,7 @@ void ScTPValidationValue::ScRefButtonEx::Click() void ScTPValidationValue::OnClick( Button *pBtn ) { - if( pBtn == &m_btnRef ) + if( pBtn == m_pBtnRef ) SetupRefDlg(); } diff --git a/sc/source/ui/dbgui/validate.src b/sc/source/ui/dbgui/validate.src deleted file mode 100644 index aa24552ff639..000000000000 --- a/sc/source/ui/dbgui/validate.src +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sfx2/tabpage.hrc> - -#include "validate.hrc" - -#define OFFSET_X 30 - -TabPage TP_VALIDATION_VALUES -{ - HelpID = "sc:TabPage:TP_VALIDATION_VALUES"; - Hide = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( TP_WIDTH , TP_HEIGHT ) ; - Text [ en-US ] = "Values" ; - FixedText FT_ALLOW - { - Pos = MAP_APPFONT ( 6 , 16 ) ; - Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ; - Text [ en-US ] = "~Allow" ; - }; - ListBox LB_ALLOW - { - HelpID = "sc:ListBox:TP_VALIDATION_VALUES:LB_ALLOW"; - Border = TRUE ; - Pos = MAP_APPFONT ( 80 - OFFSET_X , 14 ) ; - Size = MAP_APPFONT ( 90 , 80 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - StringList [ en-US ] = - { - < "All values" ; SC_VALIDDLG_ALLOW_ANY ; > ; - < "Whole Numbers" ; SC_VALIDDLG_ALLOW_WHOLE ; > ; - < "Decimal" ; SC_VALIDDLG_ALLOW_DECIMAL ; > ; - < "Date" ; SC_VALIDDLG_ALLOW_DATE ; > ; - < "Time" ; SC_VALIDDLG_ALLOW_TIME ; > ; - < "Cell range" ; SC_VALIDDLG_ALLOW_RANGE ; > ; - < "List" ; SC_VALIDDLG_ALLOW_LIST ; > ; - < "Text length" ; SC_VALIDDLG_ALLOW_TEXTLEN ; > ; - }; - }; - FixedText FT_VALUE - { - Pos = MAP_APPFONT ( 6 , 58 ) ; - Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ; - Text [ en-US ] = "~Data" ; - }; - ListBox LB_VALUE - { - HelpID = "sc:ListBox:TP_VALIDATION_VALUES:LB_VALUE"; - Border = TRUE ; - Pos = MAP_APPFONT ( 80 - OFFSET_X , 56 ) ; - Size = MAP_APPFONT ( 90 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - // Reihenfolge entspricht enum ScConditionMode - StringList [ en-US ] = - { - < "equal" ; SC_VALIDDLG_DATA_EQUAL ; > ; - < "less than" ; SC_VALIDDLG_DATA_LESS ; > ; - < "greater than" ; SC_VALIDDLG_DATA_GREATER ; > ; - < "less than or equal" ; SC_VALIDDLG_DATA_EQLESS ; > ; - < "greater than or equal to" ; SC_VALIDDLG_DATA_EQGREATER ; > ; - < "not equal" ; SC_VALIDDLG_DATA_NOTEQUAL ; > ; - < "valid range" ; SC_VALIDDLG_DATA_VALIDRANGE ; > ; - < "invalid range" ; SC_VALIDDLG_DATA_INVALIDRANGE ; > ; - }; - }; - FixedText FT_MIN - { - Pos = MAP_APPFONT ( 6 , 76 ) ; - Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ; - Text [ en-US ] = "~Minimum" ; - }; - Edit EDT_MIN - { - HelpID = "sc:Edit:TP_VALIDATION_VALUES:EDT_MIN"; - Border = TRUE ; - Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ; - Size = MAP_APPFONT ( 90 , 12 ) ; - TabStop = TRUE ; - }; - MultiLineEdit EDT_LIST - { - HelpID = "sc:MultiLineEdit:TP_VALIDATION_VALUES:EDT_LIST"; - Border = TRUE ; - Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ; - Size = MAP_APPFONT ( 174 + OFFSET_X , 105 ) ; - VScroll = TRUE ; - IgnoreTab = TRUE ; - }; - FixedText FT_MAX - { - Pos = MAP_APPFONT ( 6 , 92 ) ; - Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ; - Text [ en-US ] = "Ma~ximum" ; - }; - Edit EDT_MAX - { - HelpID = "sc:Edit:TP_VALIDATION_VALUES:EDT_MAX"; - Border = TRUE ; - Pos = MAP_APPFONT ( 80 - OFFSET_X , 90 ) ; - Size = MAP_APPFONT ( 90 , 12 ) ; - TabStop = TRUE ; - }; - CheckBox TSB_ALLOW_BLANKS - { - Pos = MAP_APPFONT ( 80 - OFFSET_X , 30 ) ; - Size = MAP_APPFONT ( 174 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Allow ~empty cells" ; - }; - CheckBox CB_SHOWLIST - { - Pos = MAP_APPFONT ( 80 - OFFSET_X , 44 ) ; - Size = MAP_APPFONT ( 174 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Show selection ~list" ; - }; - CheckBox CB_SORTLIST - { - Pos = MAP_APPFONT ( 90 - OFFSET_X , 58 ) ; - Size = MAP_APPFONT ( 164 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Sor~t entries ascending" ; - }; - FixedText FT_SOURCEHINT - { - Pos = MAP_APPFONT ( 80 , 90 ) ; - Size = MAP_APPFONT ( 174 , 64 ) ; - WordBreak = TRUE ; - Text [ en-US ] = "A valid source can only consist of a contiguous selection of rows and columns, or a formula that results in an area or array."; - }; - ImageButton RB_VALIDITY_REF - { - HelpID = "sc:ImageButton:TP_VALIDATION_VALUES:RB_VALIDITY_REF"; - Pos = MAP_APPFONT ( 142 , 73 ) ; - Size = MAP_APPFONT ( 13 , 14 ) ; - TabStop = TRUE ; - QuickHelpText [ en-US ] = "Shrink" ; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/validate.hrc b/sc/source/ui/inc/validate.hrc deleted file mode 100644 index 38362d1577a1..000000000000 --- a/sc/source/ui/inc/validate.hrc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#define TP_VALIDATION_VALUES 696 - -#define FT_ALLOW 1 -#define LB_ALLOW 2 -#define TSB_ALLOW_BLANKS 3 -#define FT_VALUE 4 -#define LB_VALUE 5 -#define FT_MIN 6 -#define EDT_MIN 7 -#define FT_MAX 8 -#define EDT_MAX 9 - -#define CB_SHOWLIST 27 -#define CB_SORTLIST 28 -#define EDT_LIST 29 -#define FT_SOURCEHINT 30 -#define RB_VALIDITY_REF 88 - -/* Position indexes for "Allow" list box. - They do not map directly to ScValidationMode and can safely be modified to - change the order of the list box entries. */ -#define SC_VALIDDLG_ALLOW_ANY 0 -#define SC_VALIDDLG_ALLOW_WHOLE 1 -#define SC_VALIDDLG_ALLOW_DECIMAL 2 -#define SC_VALIDDLG_ALLOW_DATE 3 -#define SC_VALIDDLG_ALLOW_TIME 4 -#define SC_VALIDDLG_ALLOW_RANGE 5 -#define SC_VALIDDLG_ALLOW_LIST 6 -#define SC_VALIDDLG_ALLOW_TEXTLEN 7 - -/* Position indexes for "Data" list box. - They do not map directly to ScConditionMode and can safely be modified to - change the order of the list box entries. */ -#define SC_VALIDDLG_DATA_EQUAL 0 -#define SC_VALIDDLG_DATA_LESS 1 -#define SC_VALIDDLG_DATA_GREATER 2 -#define SC_VALIDDLG_DATA_EQLESS 3 -#define SC_VALIDDLG_DATA_EQGREATER 4 -#define SC_VALIDDLG_DATA_NOTEQUAL 5 -#define SC_VALIDDLG_DATA_VALIDRANGE 6 -#define SC_VALIDDLG_DATA_INVALIDRANGE 7 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx index c33a890a13f5..c27a52fffdb4 100644 --- a/sc/source/ui/inc/validate.hxx +++ b/sc/source/ui/inc/validate.hxx @@ -179,7 +179,6 @@ class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage { public: explicit ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ); - virtual ~ScTPValidationValue(); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rArgSet ); static sal_uInt16* GetRanges(); @@ -199,19 +198,19 @@ private: DECL_LINK(SelectHdl, void *); DECL_LINK(CheckHdl, void *); - FixedText maFtAllow; - ListBox maLbAllow; - CheckBox maCbAllow; /// Allow blank cells. - CheckBox maCbShow; /// Show selection list in cell. - CheckBox maCbSort; /// Sort selection list in cell. - FixedText maFtValue; - ListBox maLbValue; - FixedText maFtMin; - formula::RefEdit maEdMin; - VclMultiLineEdit maEdList; /// Entries for explicit list - FixedText maFtMax; - formula::RefEdit maEdMax; - FixedText maFtHint; /// Hint text for cell range validity. + ListBox* m_pLbAllow; + CheckBox* m_pCbAllow; /// Allow blank cells. + CheckBox* m_pCbShow; /// Show selection list in cell. + CheckBox* m_pCbSort; /// Sort selection list in cell. + FixedText* m_pFtValue; + ListBox* m_pLbValue; + FixedText* m_pFtMin; + VclContainer* m_pMinGrid; + formula::RefEdit* m_pEdMin; + VclMultiLineEdit* m_pEdList; /// Entries for explicit list + FixedText* m_pFtMax; + formula::RefEdit* m_pEdMax; + FixedText* m_pFtHint; /// Hint text for cell range validity. OUString maStrMin; OUString maStrMax; @@ -220,33 +219,39 @@ private: OUString maStrList; sal_Unicode mcFmlaSep; /// List separator in formulas. - Point maRefEditPos; - Point maBtnRefPos; - Size maRefEditSize; - Size maBtnRefSize; - DECL_LINK(EditSetFocusHdl, void *); DECL_LINK( KillFocusHdl, Window *); void OnClick( Button *pBtn ); formula::RefEdit* m_pRefEdit; - class ScRefButtonEx:public ::formula::RefButton +public: + class ScRefButtonEx : public ::formula::RefButton { - void Click() SAL_OVERRIDE; + ScTPValidationValue* m_pPage; + virtual void Click() SAL_OVERRIDE; public: - ScRefButtonEx( Window* pParent, const ResId& rResId, formula::RefEdit* pEdit = NULL, - ScRefHandler *pRefHdlr = NULL ) - : ::formula::RefButton( pParent, rResId, pEdit, pRefHdlr ) + ScRefButtonEx(Window* pParent, WinBits nStyle) + : ::formula::RefButton(pParent, nStyle) + , m_pPage(NULL) + { + } + void SetParentPage(ScTPValidationValue *pPage) { + m_pPage = pPage; } - }m_btnRef; + ScTPValidationValue* GetParentPage() + { + return m_pPage; + } + }; +private: + ScRefButtonEx* m_pBtnRef; + VclContainer* m_pRefGrid; friend class ScRefButtonEx; void SetReferenceHdl( const ScRange& , ScDocument* ); void SetActiveHdl(); void RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton ); void RefInputDonePostHdl(); ScValidationDlg * GetValidationDlg(); - - void TidyListBoxes(); public: sal_uInt16 GetAllowEntryPos(); OUString GetMinText(); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index b3e1de0781a0..44fdbed9e6fb 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -52,7 +52,6 @@ #include "validat.hxx" #include "scresid.hxx" -#include "validate.hrc" #include "scui_def.hxx" #include "scabstdlg.hxx" #include "impex.hxx" @@ -787,7 +786,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) { ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); - ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(TP_VALIDATION_VALUES); + ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(); OSL_ENSURE(ScTPValidationValueGetRanges, "TabPage create fail!"); SfxItemSet aArgSet( GetPool(), (*ScTPValidationValueGetRanges)() ); ScValidationMode eMode = SC_VALID_ANY; |