From e54762baa8019d02cadd311e750f6ff0d276f67b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 16 Apr 2019 17:17:58 +0100 Subject: weld ScTPValidationValue and ScValidationDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I74b1569fe378f42c1cc78ca8d9b758c6e585c979 Reviewed-on: https://gerrit.libreoffice.org/70845 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/inc/scmod.hxx | 11 +- sc/source/ui/app/scmod.cxx | 36 ++- sc/source/ui/dbgui/validate.cxx | 397 ++++++++++++------------- sc/source/ui/inc/anyrefdg.hxx | 70 ++--- sc/source/ui/inc/reffact.hxx | 1 - sc/source/ui/inc/validate.hxx | 133 ++++----- sc/source/ui/miscdlgs/anyrefdg.cxx | 6 +- sc/source/ui/view/cellsh2.cxx | 29 +- sc/source/ui/view/reffact.cxx | 31 +- sc/uiconfig/scalc/ui/validationcriteriapage.ui | 140 +++------ sc/uiconfig/scalc/ui/validationdialog.ui | 104 ++++++- 11 files changed, 459 insertions(+), 499 deletions(-) (limited to 'sc') diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 2a3fbc04b748..5b4e519fd693 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -75,7 +75,7 @@ class ScSelectionTransferObj; class ScFormEditData; class ScMarkData; struct ScDragData; -class SfxModelessDialogController; +class SfxDialogController; class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationListener { @@ -109,7 +109,8 @@ class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationL bool m_bIsInSharedDocSaving:1; std::map > > m_mapRefWindow; - std::map> m_mapRefController; + // a way to find existing Dialogs for a given parent Window of the slot type + std::map, weld::Window*>>> m_mapRefController; css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller; @@ -250,10 +251,10 @@ public: SC_DLLPUBLIC void RegisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ); SC_DLLPUBLIC void UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ); - SC_DLLPUBLIC vcl::Window * Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor ); - SC_DLLPUBLIC void RegisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ); - SC_DLLPUBLIC void UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ); + SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr& rWnd, weld::Window* pWndAncestor); + SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, std::shared_ptr& rWnd); + SC_DLLPUBLIC std::shared_ptr Find1RefWindow(sal_uInt16 nSlotId, weld::Window *pWndAncestor); SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller); SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 381c27501d07..c701866a66d4 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2228,26 +2228,34 @@ void ScModule::UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd ) m_mapRefWindow.erase( nSlotId ); } -void ScModule::RegisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ) +void ScModule::RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr& rWnd, weld::Window* pWndAncestor) { - std::vector & rlRefWindow = m_mapRefController[nSlotId]; + std::vector, weld::Window*>> & rlRefWindow = m_mapRefController[nSlotId]; - if( std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ) == rlRefWindow.end() ) + if (std::find_if(rlRefWindow.begin(), rlRefWindow.end(), + [rWnd](const std::pair, weld::Window*>& rCandidate) + { + return rCandidate.first.get() == rWnd.get(); + }) == rlRefWindow.end()) { - rlRefWindow.emplace_back(pWnd ); + rlRefWindow.emplace_back(rWnd, pWndAncestor); } } -void ScModule::UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogController *pWnd ) +void ScModule::UnregisterRefController(sal_uInt16 nSlotId, std::shared_ptr& rWnd) { auto iSlot = m_mapRefController.find( nSlotId ); if( iSlot == m_mapRefController.end() ) return; - std::vector & rlRefWindow = iSlot->second; + std::vector, weld::Window*>> & rlRefWindow = iSlot->second; - auto i = std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ); + auto i = std::find_if(rlRefWindow.begin(), rlRefWindow.end(), + [rWnd](const std::pair, weld::Window*>& rCandidate) + { + return rCandidate.first.get() == rWnd.get(); + }); if( i == rlRefWindow.end() ) return; @@ -2258,23 +2266,21 @@ void ScModule::UnregisterRefController( sal_uInt16 nSlotId, SfxModelessDialogCo m_mapRefController.erase( nSlotId ); } -vcl::Window * ScModule::Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor ) +std::shared_ptr ScModule::Find1RefWindow(sal_uInt16 nSlotId, weld::Window *pWndAncestor) { if (!pWndAncestor) return nullptr; - auto iSlot = m_mapRefWindow.find( nSlotId ); + auto iSlot = m_mapRefController.find( nSlotId ); - if( iSlot == m_mapRefWindow.end() ) + if( iSlot == m_mapRefController.end() ) return nullptr; - std::vector > & rlRefWindow = iSlot->second; - - while( vcl::Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent; + std::vector, weld::Window*>> & rlRefWindow = iSlot->second; for (auto const& refWindow : rlRefWindow) - if ( pWndAncestor->IsWindowOrChild( refWindow, refWindow->IsSystemWindow() ) ) - return refWindow; + if ( refWindow.second == pWndAncestor ) + return refWindow.first; return nullptr; } diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 94a40ecf9d7e..c9c8bbc84be9 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -80,24 +80,25 @@ const sal_uInt16 ScTPValidationValue::pValueRanges[] = 0 }; -ScValidationDlg::ScValidationDlg(vcl::Window* pParent, const SfxItemSet* pArgSet, +ScValidationDlg::ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell *pTabViewSh) - : ScValidationDlgBase(pParent ? pParent : SfxGetpApp()->GetTopWindow(), - "ValidationDialog", "modules/scalc/ui/validationdialog.ui", pArgSet, nullptr) + : ScValidationDlgBase(pParent, + "modules/scalc/ui/validationdialog.ui", "ValidationDialog", pArgSet, nullptr) , m_pTabVwSh(pTabViewSh) - , m_nValuePageId(0) + , m_sValuePageId("criteria") , m_bOwnRefHdlr(false) , m_bRefInputting(false) + , m_xHBox(m_xBuilder->weld_container("refinputbox")) { - m_nValuePageId = AddTabPage("criteria", ScTPValidationValue::Create); - AddTabPage("inputhelp", ScTPValidationHelp::Create); - AddTabPage("erroralert", ScTPValidationError::Create); - get(m_pHBox, "refinputbox"); + AddTabPage(m_sValuePageId, ScTPValidationValue::Create, nullptr); + AddTabPage("inputhelp", ScTPValidationHelp::Create, nullptr); + AddTabPage("erroralert", ScTPValidationError::Create, nullptr); } ScValidationDlg::~ScValidationDlg() { - disposeOnce(); + if (m_bOwnRefHdlr) + RemoveRefDlg(false); } void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , const ScDocument* pDoc ) @@ -125,39 +126,52 @@ void ScTPValidationValue:: SetActiveHdl() } } -void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, const formula::RefButton* pButton ) +void ScTPValidationValue::RefInputStartPreHdl( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ) { - if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + if (ScValidationDlg *pValidationDlg = GetValidationDlg()) { - vcl::Window *pNewParent = pValidationDlg->get_refinput_shrink_parent(); - if( pEdit == m_pRefEdit && m_pRefEdit->GetParent() != pNewParent ) + weld::Container* pNewParent = pValidationDlg->get_refinput_shrink_parent(); + if (pEdit == m_pRefEdit && pNewParent != m_pRefEditParent) { - m_pRefEdit->SetParent(pNewParent); + m_xRefGrid->move(m_pRefEdit->GetWidget(), pNewParent); + m_pRefEditParent = pNewParent; } - if( pButton == m_pBtnRef && m_pBtnRef->GetParent() != pNewParent ) + if (pNewParent != m_pBtnRefParent) { - m_pBtnRef->SetParent(pNewParent); + // if Edit SetParent but button not, the tab order will be + // incorrect, so move button anyway, and restore + // parent later in order to restore the tab order. But + // hide it if its moved but unwanted + m_xRefGrid->move(m_xBtnRef->GetWidget(), pNewParent); + m_xBtnRef->GetWidget()->set_visible(pButton == m_xBtnRef.get()); + m_pBtnRefParent = pNewParent; } - pNewParent->Show(); + pNewParent->show(); } } void ScTPValidationValue::RefInputDonePostHdl() { - if( m_pRefEdit && m_pRefEdit->GetParent() != m_pRefGrid ) + if (ScValidationDlg *pValidationDlg = GetValidationDlg()) { - 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 another window and restore parent later in order to restore the tab order - } + weld::Container* pOldParent = pValidationDlg->get_refinput_shrink_parent(); - if( m_pBtnRef->GetParent() != m_pRefGrid ) - m_pBtnRef->SetParent( m_pRefGrid ); + if (m_pRefEdit && m_pRefEditParent != m_xRefGrid.get()) + { + pOldParent->move(m_pRefEdit->GetWidget(), m_xRefGrid.get()); + m_pRefEditParent = m_xRefGrid.get(); + } - if ( ScValidationDlg *pValidationDlg = GetValidationDlg() ) - { - pValidationDlg->get_refinput_shrink_parent()->Hide(); + if (m_pBtnRefParent != m_xRefGrid.get()) + { + pOldParent->move(m_xBtnRef->GetWidget(), m_xRefGrid.get()); + m_xBtnRef->GetWidget()->show(); + m_pBtnRefParent = m_xRefGrid.get(); + } + + pOldParent->hide(); ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData(); SCTAB nCurTab = rViewData.GetTabNo(); SCTAB nRefTab = rViewData.GetRefTabNo(); @@ -169,21 +183,10 @@ void ScTPValidationValue::RefInputDonePostHdl() } } - if( m_pRefEdit && !m_pRefEdit->HasFocus() ) + if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) m_pRefEdit->GrabFocus(); } -ScTPValidationValue::ScRefButtonEx::~ScRefButtonEx() -{ - disposeOnce(); -} - -void ScTPValidationValue::ScRefButtonEx::dispose() -{ - m_pPage.clear(); - ::formula::RefButton::dispose(); -} - namespace { /** Converts the passed ScValidationMode to the position in the list box. */ @@ -322,9 +325,9 @@ bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaSt } // namespace -ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet ) - : SfxTabPage( pParent, "ValidationCriteriaPage", - "modules/scalc/ui/validationcriteriapage.ui", &rArgSet) +ScTPValidationValue::ScTPValidationValue(TabPageParent pParent, const SfxItemSet& rArgSet) + : SfxTabPage(pParent, "modules/scalc/ui/validationcriteriapage.ui", + "ValidationCriteriaPage", &rArgSet) , maStrMin(ScResId(SCSTR_VALID_MINIMUM)) , maStrMax(ScResId(SCSTR_VALID_MAXIMUM)) , maStrValue(ScResId(SCSTR_VALID_VALUE)) @@ -332,33 +335,34 @@ ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet , maStrRange(ScResId(SCSTR_VALID_RANGE)) , maStrList(ScResId(SCSTR_VALID_LIST)) , m_pRefEdit(nullptr) -{ - 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(nullptr, m_pFtMin); - get(m_pEdList, "minlist"); + , m_xLbAllow(m_xBuilder->weld_combo_box("allow")) + , m_xCbAllow(m_xBuilder->weld_check_button("allowempty")) + , m_xCbShow(m_xBuilder->weld_check_button("showlist")) + , m_xCbSort(m_xBuilder->weld_check_button("sortascend")) + , m_xFtValue(m_xBuilder->weld_label("valueft")) + , m_xLbValue(m_xBuilder->weld_combo_box("data")) + , m_xFtMin(m_xBuilder->weld_label("minft")) + , m_xMinGrid(m_xBuilder->weld_widget("mingrid")) + , m_xEdMin(new formula::WeldRefEdit(m_xBuilder->weld_entry("min"))) + , m_xEdList(m_xBuilder->weld_text_view("minlist")) + , m_xFtMax(m_xBuilder->weld_label("maxft")) + , m_xEdMax(new formula::WeldRefEdit(m_xBuilder->weld_entry("max"))) + , m_xFtHint(m_xBuilder->weld_label("hintft")) + , m_xBtnRef(new formula::WeldRefButton(m_xBuilder->weld_button("validref"))) + , m_xRefGrid(m_xBuilder->weld_container("refgrid")) + , m_pRefEditParent(m_xRefGrid.get()) + , m_pBtnRefParent(m_xRefGrid.get()) +{ + m_xEdMin->SetReferences(nullptr, m_xFtMin.get()); Size aSize(LogicToPixel(Size(174, 105), MapMode(MapUnit::MapAppFont))); - 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(nullptr, m_pFtMax); - get(m_pFtHint, "hintft"); - get(m_pBtnRef, "validref"); - m_pBtnRef->SetParentPage(this); - get(m_pRefGrid, "refgrid"); + m_xEdList->set_size_request(aSize.Width(), aSize.Height()); + m_xEdMax->SetReferences(nullptr, m_xFtMax.get()); + + m_xBtnRef->SetClickHdl(LINK(this, ScTPValidationValue, ClickHdl)); //lock in the max size initial config - aSize = get_preferred_size(); - set_width_request(aSize.Width()); - set_height_request(aSize.Height()); + aSize = m_xContainer->get_preferred_size(); + m_xContainer->set_size_request(aSize.Width(), aSize.Height()); Init(); @@ -366,7 +370,7 @@ ScTPValidationValue::ScTPValidationValue( vcl::Window* pParent, const SfxItemSet OUString aListSep = ::ScCompiler::GetNativeSymbol( ocSep ); OSL_ENSURE( aListSep.getLength() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" ); mcFmlaSep = aListSep.getLength() ? aListSep[0] : ';'; - m_pBtnRef->Hide(); // cell range picker + m_xBtnRef->GetWidget()->hide(); // cell range picker } ScTPValidationValue::~ScTPValidationValue() @@ -376,49 +380,37 @@ ScTPValidationValue::~ScTPValidationValue() void ScTPValidationValue::dispose() { - m_pLbAllow.clear(); - m_pCbAllow.clear(); - m_pCbShow.clear(); - m_pCbSort.clear(); - m_pFtValue.clear(); - m_pLbValue.clear(); - m_pFtMin.clear(); - m_pMinGrid.clear(); - m_pEdMin.clear(); - m_pEdList.clear(); - m_pFtMax.clear(); - m_pEdMax.clear(); - m_pFtHint.clear(); - m_pRefEdit.clear(); - m_pBtnRef.clear(); - m_pRefGrid.clear(); + m_xEdMin.reset(); + m_xEdMin.reset(); + m_xEdMax.reset(); + m_xBtnRef.reset(); + m_xEdMax.reset(); SfxTabPage::dispose(); } - void ScTPValidationValue::Init() { - m_pLbAllow->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - m_pLbValue->SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) ); - m_pCbShow->SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) ); + m_xLbAllow->connect_changed( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_xLbValue->connect_changed( LINK( this, ScTPValidationValue, SelectHdl ) ); + m_xCbShow->connect_clicked( LINK( this, ScTPValidationValue, CheckHdl ) ); // cell range picker - 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 ) ); + m_xEdMin->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_xEdMin->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillEditFocusHdl ) ); + m_xEdMax->SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) ); + m_xBtnRef->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillButtonFocusHdl ) ); + m_xEdMax->SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillEditFocusHdl ) ); - m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_ANY ); - m_pLbValue->SelectEntryPos( SC_VALIDDLG_DATA_EQUAL ); + m_xLbAllow->set_active( SC_VALIDDLG_ALLOW_ANY ); + m_xLbValue->set_active( SC_VALIDDLG_DATA_EQUAL ); - SelectHdl( *m_pLbAllow.get() ); - CheckHdl( nullptr ); + SelectHdl( *m_xLbAllow.get() ); + CheckHdl( *m_xCbShow ); } -VclPtr ScTPValidationValue::Create( TabPageParent pParent, const SfxItemSet* rArgSet ) +VclPtr ScTPValidationValue::Create(TabPageParent pParent, const SfxItemSet* rArgSet) { - return VclPtr::Create( pParent.pParent, *rArgSet ); + return VclPtr::Create(pParent, *rArgSet); } void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) @@ -429,25 +421,25 @@ void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) if( rArgSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET ) nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - m_pLbAllow->SelectEntryPos( nLbPos ); + m_xLbAllow->set_active( nLbPos ); nLbPos = SC_VALIDDLG_DATA_EQUAL; if( rArgSet->GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SfxItemState::SET ) nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >( static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) ); - m_pLbValue->SelectEntryPos( nLbPos ); + m_xLbValue->set_active( nLbPos ); // *** check boxes *** bool bCheck = true; if( rArgSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET ) bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue(); - m_pCbAllow->Check( bCheck ); + m_xCbAllow->set_active( bCheck ); sal_Int32 nListType = ValidListType::UNSORTED; if( rArgSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET ) nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue(); - m_pCbShow->Check( nListType != ValidListType::INVISIBLE ); - m_pCbSort->Check( nListType == ValidListType::SORTEDASCENDING ); + m_xCbShow->set_active( nListType != ValidListType::INVISIBLE ); + m_xCbSort->set_active( nListType == ValidListType::SORTEDASCENDING ); // *** formulas *** OUString aFmlaStr; @@ -460,27 +452,27 @@ void ScTPValidationValue::Reset( const SfxItemSet* rArgSet ) aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue(); SetSecondFormula( aFmlaStr ); - SelectHdl( *m_pLbAllow.get() ); - CheckHdl( nullptr ); + SelectHdl( *m_xLbAllow.get() ); + CheckHdl( *m_xCbShow ); } bool ScTPValidationValue::FillItemSet( SfxItemSet* rArgSet ) { - sal_Int16 nListType = m_pCbShow->IsChecked() ? - (m_pCbSort->IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : + sal_Int16 nListType = m_xCbShow->get_active() ? + (m_xCbSort->get_active() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) : ValidListType::INVISIBLE; - const sal_Int32 nLbPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nLbPos = m_xLbAllow->get_active(); bool bCustom = (nLbPos == SC_VALIDDLG_ALLOW_CUSTOM); ScConditionMode eCondMode = bCustom ? - ScConditionMode::Direct : lclGetCondModeFromPos( m_pLbValue->GetSelectedEntryPos() ); + ScConditionMode::Direct : lclGetCondModeFromPos( m_xLbValue->get_active() ); rArgSet->Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast( lclGetValModeFromPos( nLbPos ) ) ) ); rArgSet->Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast( eCondMode ) ) ); rArgSet->Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) ); rArgSet->Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) ); - rArgSet->Put( SfxBoolItem( FID_VALID_BLANK, m_pCbAllow->IsChecked() ) ); + rArgSet->Put( SfxBoolItem( FID_VALID_BLANK, m_xCbAllow->get_active() ) ); rArgSet->Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) ); return true; } @@ -488,50 +480,45 @@ bool ScTPValidationValue::FillItemSet( SfxItemSet* rArgSet ) OUString ScTPValidationValue::GetFirstFormula() const { OUString aFmlaStr; - if( m_pLbAllow->GetSelectedEntryPos() == SC_VALIDDLG_ALLOW_LIST ) - lclGetFormulaFromStringList( aFmlaStr, m_pEdList->GetText(), mcFmlaSep ); + if( m_xLbAllow->get_active() == SC_VALIDDLG_ALLOW_LIST ) + lclGetFormulaFromStringList( aFmlaStr, m_xEdList->get_text(), mcFmlaSep ); else - aFmlaStr = m_pEdMin->GetText(); + aFmlaStr = m_xEdMin->GetText(); return aFmlaStr; } OUString ScTPValidationValue::GetSecondFormula() const { - return m_pEdMax->GetText(); + return m_xEdMax->GetText(); } void ScTPValidationValue::SetFirstFormula( const OUString& rFmlaStr ) { // try if formula is a string list, validation mode must already be set OUString aStringList; - if( (m_pLbAllow->GetSelectedEntryPos() == SC_VALIDDLG_ALLOW_RANGE) && + if( (m_xLbAllow->get_active() == SC_VALIDDLG_ALLOW_RANGE) && lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) ) { - m_pEdList->SetText( aStringList ); - m_pEdMin->SetText( EMPTY_OUSTRING ); + m_xEdList->set_text( aStringList ); + m_xEdMin->SetText( EMPTY_OUSTRING ); // change validation mode to string list - m_pLbAllow->SelectEntryPos( SC_VALIDDLG_ALLOW_LIST ); + m_xLbAllow->set_active( SC_VALIDDLG_ALLOW_LIST ); } else { - m_pEdMin->SetText( rFmlaStr ); - m_pEdList->SetText( EMPTY_OUSTRING ); + m_xEdMin->SetText( rFmlaStr ); + m_xEdList->set_text( EMPTY_OUSTRING ); } } void ScTPValidationValue::SetSecondFormula( const OUString& rFmlaStr ) { - m_pEdMax->SetText( rFmlaStr ); + m_xEdMax->SetText( rFmlaStr ); } ScValidationDlg * ScTPValidationValue::GetValidationDlg() { - if( vcl::Window *pParent = GetParent() ) - do{ - if ( auto pValidationDlg = dynamic_cast( pParent ) ) - return pValidationDlg; - }while ( nullptr != ( pParent = pParent->GetParent() ) ); - return nullptr; + return dynamic_cast(GetDialogController()); } void ScTPValidationValue::SetupRefDlg() @@ -546,35 +533,35 @@ void ScTPValidationValue::SetupRefDlg() pValidationDlg->SetRefInputStartPreHdl( static_cast( &ScTPValidationValue::RefInputStartPreHdl ) ); pValidationDlg->SetRefInputDonePostHdl( static_cast( &ScTPValidationValue::RefInputDonePostHdl ) ); - vcl::Window *pLabel = nullptr; + weld::Label* pLabel = nullptr; - if ( m_pEdMax->IsVisible() ) + if (m_xEdMax->GetWidget()->get_visible()) { - m_pRefEdit = m_pEdMax; - pLabel = m_pFtMax; + m_pRefEdit = m_xEdMax.get(); + pLabel = m_xFtMax.get(); } - else if ( m_pEdMin->IsVisible() ) + else if (m_xEdMin->GetWidget()->get_visible()) { - m_pRefEdit = m_pEdMin; - pLabel = m_pFtMin; + m_pRefEdit = m_xEdMin.get(); + pLabel = m_xFtMin.get(); } - if( m_pRefEdit && !m_pRefEdit->HasFocus() ) + if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) m_pRefEdit->GrabFocus(); if( m_pRefEdit ) m_pRefEdit->SetReferences( pValidationDlg, pLabel ); - m_pBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); + m_xBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); } } } -void ScTPValidationValue::RemoveRefDlg() +void ScTPValidationValue::RemoveRefDlg(bool bRestoreModal) { if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) { - if( pValidationDlg->RemoveRefDlg(true) ) + if( pValidationDlg->RemoveRefDlg(bRestoreModal) ) { pValidationDlg->SetHandler( nullptr ); pValidationDlg->SetSetRefHdl( nullptr ); @@ -586,14 +573,14 @@ void ScTPValidationValue::RemoveRefDlg() m_pRefEdit->SetReferences( nullptr, nullptr ); m_pRefEdit = nullptr; - m_pBtnRef->SetReferences( nullptr, nullptr ); + m_xBtnRef->SetReferences( nullptr, nullptr ); } } } -IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, Control&, void) +IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, formula::WeldRefEdit&, void) { - const sal_Int32 nPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nPos = m_xLbAllow->get_active(); if ( nPos == SC_VALIDDLG_ALLOW_RANGE ) { @@ -601,87 +588,96 @@ IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, Control&, void) } } -IMPL_LINK( ScTPValidationValue, KillFocusHdl, Control&, rControl, void ) +IMPL_LINK( ScTPValidationValue, KillEditFocusHdl, formula::WeldRefEdit&, rWnd, void ) +{ + if (&rWnd != m_pRefEdit) + return; + if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + { + if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting()) + { + if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() ) + { + RemoveRefDlg(true); + } + } + } +} + +IMPL_LINK( ScTPValidationValue, KillButtonFocusHdl, formula::WeldRefButton&, rWnd, void ) { - vcl::Window* pWnd = static_cast(&rControl); - 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_pBtnRef->HasFocus() ) - { - RemoveRefDlg(); - } + if( &rWnd != m_xBtnRef.get()) + return; + if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) + if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting()) + if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() ) + { + RemoveRefDlg(true); + } } -IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl, ListBox&, void) +IMPL_LINK_NOARG(ScTPValidationValue, SelectHdl, weld::ComboBox&, void) { - const sal_Int32 nLbPos = m_pLbAllow->GetSelectedEntryPos(); + const sal_Int32 nLbPos = m_xLbAllow->get_active(); bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY); bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE); bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST); bool bCustom = (nLbPos == SC_VALIDDLG_ALLOW_CUSTOM); - 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 ); + m_xCbAllow->set_sensitive( bEnable ); // Empty cell + m_xFtValue->set_sensitive( bEnable ); + m_xLbValue->set_sensitive( bEnable ); + m_xFtMin->set_sensitive( bEnable ); + m_xEdMin->GetWidget()->set_sensitive( bEnable ); + m_xEdList->set_sensitive( bEnable ); + m_xFtMax->set_sensitive( bEnable ); + m_xEdMax->GetWidget()->set_sensitive( bEnable ); bool bShowMax = false; if( bRange ) - m_pFtMin->SetText( maStrRange ); + m_xFtMin->set_label( maStrRange ); else if( bList ) - m_pFtMin->SetText( maStrList ); + m_xFtMin->set_label( maStrList ); else if( bCustom ) - m_pFtMin->SetText( maStrFormula ); + m_xFtMin->set_label( maStrFormula ); else { - switch( m_pLbValue->GetSelectedEntryPos() ) + switch( m_xLbValue->get_active() ) { case SC_VALIDDLG_DATA_EQUAL: - case SC_VALIDDLG_DATA_NOTEQUAL: m_pFtMin->SetText( maStrValue ); break; + case SC_VALIDDLG_DATA_NOTEQUAL: m_xFtMin->set_label( maStrValue ); break; case SC_VALIDDLG_DATA_LESS: - case SC_VALIDDLG_DATA_EQLESS: m_pFtMin->SetText( maStrMax ); break; + case SC_VALIDDLG_DATA_EQLESS: m_xFtMin->set_label( maStrMax ); break; case SC_VALIDDLG_DATA_VALIDRANGE: case SC_VALIDDLG_DATA_INVALIDRANGE: bShowMax = true; [[fallthrough]]; case SC_VALIDDLG_DATA_GREATER: - case SC_VALIDDLG_DATA_EQGREATER: m_pFtMin->SetText( maStrMin ); break; + case SC_VALIDDLG_DATA_EQGREATER: m_xFtMin->set_label( maStrMin ); break; default: OSL_FAIL( "ScTPValidationValue::SelectHdl - unknown condition mode" ); } } - m_pCbShow->Show( bRange || bList ); - m_pCbSort->Show( bRange || bList ); - m_pFtValue->Show( !bRange && !bList && !bCustom); - m_pLbValue->Show( !bRange && !bList && !bCustom ); - 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 + m_xCbShow->set_visible( bRange || bList ); + m_xCbSort->set_visible( bRange || bList ); + m_xFtValue->set_visible( !bRange && !bList && !bCustom); + m_xLbValue->set_visible( !bRange && !bList && !bCustom ); + m_xEdMin->GetWidget()->set_visible( !bList ); + m_xEdList->set_visible( bList ); + m_xMinGrid->set_vexpand( bList ); + m_xFtMax->set_visible( bShowMax ); + m_xEdMax->GetWidget()->set_visible( bShowMax ); + m_xFtHint->set_visible( bRange ); + m_xBtnRef->GetWidget()->set_visible( bRange ); // cell range picker } -IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl, Button*, void) +IMPL_LINK_NOARG(ScTPValidationValue, CheckHdl, weld::Button&, void) { - m_pCbSort->Enable( m_pCbShow->IsChecked() ); + m_xCbSort->set_sensitive( m_xCbShow->get_active() ); } // Input Help Page @@ -844,7 +840,7 @@ bool ScValidationDlg::EnterRefStatus() SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); - if ( pWnd && pWnd->GetWindow()!= this ) pWnd = nullptr; + if (pWnd && pWnd->GetController().get() != this) pWnd = nullptr; SC_MOD()->SetRefDialog( nId, pWnd == nullptr ); @@ -899,7 +895,9 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ ) m_bOwnRefHdlr = false; if( bRestoreModal ) + { SetModal( true ); + } } if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) ) @@ -911,33 +909,14 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ ) return true; } -extern "C" SAL_DLLPUBLIC_EXPORT void makeScRefButtonEx(VclPtr & rRet, VclPtr & pParent, VclBuilder::stringmap &) -{ - rRet = VclPtr::Create(pParent, 0); -} - -void ScTPValidationValue::ScRefButtonEx::Click() +IMPL_LINK_NOARG(ScTPValidationValue, ClickHdl, formula::WeldRefButton&, void) { - if( ScTPValidationValue *pParent = GetParentPage() ) - pParent->OnClick( this ); - - formula::RefButton::Click(); -} - -void ScTPValidationValue::OnClick( const Button *pBtn ) -{ - if( pBtn == m_pBtnRef ) - SetupRefDlg(); + SetupRefDlg(); } bool ScValidationDlg::IsChildFocus() { - if ( const vcl::Window *pWin = Application::GetFocusWindow() ) - while( nullptr != ( pWin = pWin->GetParent() ) ) - if( pWin == this ) - return true; - - return false; + return m_xDialog->has_toplevel_focus(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx index 3a5726123654..99c57edf5320 100644 --- a/sc/source/ui/inc/anyrefdg.hxx +++ b/sc/source/ui/inc/anyrefdg.hxx @@ -98,7 +98,7 @@ public: static void enableInput(bool _bInput); public: - static bool CanInputStart( const formula::RefEdit *pEdit ){ return !!pEdit; } + static bool CanInputStart( const formula::WeldRefEdit *pEdit ){ return !!pEdit; } bool CanInputDone( bool bForced ){ return (m_pRefEdit || m_pWeldRefEdit) && (bForced || !(m_pRefBtn || m_pWeldRefBtn)); } }; @@ -134,7 +134,7 @@ protected: public: ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef ); - ScRefHandler( SfxModelessDialogController &rController, SfxBindings* pB, bool bBindRef ); + ScRefHandler( SfxDialogController &rController, SfxBindings* pB, bool bBindRef ); virtual ~ScRefHandler() override; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override = 0; @@ -160,7 +160,7 @@ public: public: bool EnterRefMode(); bool LeaveRefMode(); - static inline bool CanInputStart( const formula::RefEdit *pEdit ); + static inline bool CanInputStart( const formula::WeldRefEdit *pEdit ); inline bool CanInputDone( bool bForced ); }; @@ -245,74 +245,50 @@ template< class TWindow, bool bBindRef = true > class ScRefHdlrControllerImplBase: public TWindow, public ScRefHandler { private: - template - ScRefHdlrControllerImplBase( TBindings* pB, TChildWindow* pCW, - TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID ); + ScRefHdlrControllerImplBase(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID) + : TWindow(pB, pCW, pParent, rUIXMLDescription, rID) + , ScRefHandler(*static_cast(this), pB, bBindRef) + { + } - template - ScRefHdlrControllerImplBase(TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID, const TArg &rArg, SfxBindings *pB); + ScRefHdlrControllerImplBase(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet* pArg, SfxBindings *pB) + : TWindow(pParent, rUIXMLDescription, rID, pArg) + , ScRefHandler(*static_cast(this), pB, bBindRef) + { + } - virtual ~ScRefHdlrControllerImplBase() override; + virtual ~ScRefHdlrControllerImplBase() override + { + } template friend struct ScRefHdlrControllerImpl; }; -template -ScRefHdlrControllerImplBase::~ScRefHdlrControllerImplBase(){} - -template -template -ScRefHdlrControllerImplBase::ScRefHdlrControllerImplBase(TBindings* pB, TChildWindow* pCW, - TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID) - : TWindow(pB, pCW, pParent, rUIXMLDescription, rID) - , ScRefHandler( *static_cast(this), pB, bBindRef ) -{ -} - -template -template -ScRefHdlrControllerImplBase::ScRefHdlrControllerImplBase(TParentWindow* pParent, const OUString& rUIXMLDescription, const OString& rID, - const TArg &rArg, SfxBindings *pB) - : TWindow(pParent, rUIXMLDescription, rID, rArg) - , ScRefHandler( *static_cast(this), pB, bBindRef ) -{ -} - template -struct ScRefHdlrControllerImpl: ScRefHdlrControllerImplBase< TBase, bBindRef > +struct ScRefHdlrControllerImpl : ScRefHdlrControllerImplBase { enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID }; - template - ScRefHdlrControllerImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ) - : ScRefHdlrControllerImplBase(rt1, rt2, rt3, rt4) - { - SC_MOD()->RegisterRefController( static_cast( TDerived::SLOTID ), this ); - } - - template - ScRefHdlrControllerImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 ) + ScRefHdlrControllerImpl(weld::Window* rt1, const OUString& rt2, const OString& rt3, const SfxItemSet* rt4, SfxBindings *rt5) : ScRefHdlrControllerImplBase(rt1, rt2, rt3, rt4, rt5) { - SC_MOD()->RegisterRefController( static_cast( TDerived::SLOTID ), this ); } - ~ScRefHdlrControllerImpl() + ScRefHdlrControllerImpl(SfxBindings* rt1, SfxChildWindow* rt2, weld::Window* rt3, const OUString& rt4, const OString& rt5) + : ScRefHdlrControllerImplBase(rt1, rt2, rt3, rt4, rt5) { - SC_MOD()->UnregisterRefController( static_cast( TDerived::SLOTID ), this ); } }; -struct ScAnyRefDlgController : ::ScRefHdlrControllerImpl +struct ScAnyRefDlgController : ScRefHdlrControllerImpl { - template - ScAnyRefDlgController( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4, const T5& rt5 ) + ScAnyRefDlgController(SfxBindings* rt1, SfxChildWindow* rt2, weld::Window* rt3, const OUString& rt4, const OString& rt5) : ScRefHdlrControllerImpl(rt1, rt2, rt3, rt4, rt5) { } }; -inline bool ScRefHandler::CanInputStart( const formula::RefEdit *pEdit ) +inline bool ScRefHandler::CanInputStart( const formula::WeldRefEdit *pEdit ) { return ScFormulaReferenceHelper::CanInputStart( pEdit ); } diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index 09c83aaf5632..45dd4f6a9db0 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -200,7 +200,6 @@ class SC_DLLPUBLIC ScValidityRefChildWin : public SfxChildWindow { bool m_bVisibleLock:1; bool m_bFreeWindowLock:1; - VclPtr m_pSavedWndParent; public: ScValidityRefChildWin( vcl::Window*, sal_uInt16, const SfxBindings*, SfxChildWinInfo* ); SFX_DECL_CHILDWINDOW_WITHID(ScValidityRefChildWin); diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx index c29d8b6c7335..d28ee58192cd 100644 --- a/sc/source/ui/inc/validate.hxx +++ b/sc/source/ui/inc/validate.hxx @@ -41,7 +41,7 @@ protected: #endif void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument* ); void (ScRefHandlerCaller::*m_pSetActiveHdl)(); - void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ); void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)(); #if defined( _WIN32) #pragma pack(pop) @@ -50,7 +50,7 @@ protected: public: typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument* ); typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)(); - typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton ); void SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl ) { @@ -79,10 +79,10 @@ class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage { static const sal_uInt16 pValueRanges[]; public: - explicit ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet ); - virtual ~ScTPValidationValue() override; + explicit ScTPValidationValue(TabPageParent pParent, const SfxItemSet& rArgSet); virtual void dispose() override; - static VclPtr Create( TabPageParent pParent, const SfxItemSet* rArgSet ); + virtual ~ScTPValidationValue() override; + static VclPtr Create( TabPageParent pParent, const SfxItemSet* rArgSet ); static const sal_uInt16* GetRanges() { return pValueRanges; } virtual bool FillItemSet( SfxItemSet* rArgSet ) override; @@ -97,22 +97,8 @@ private: void SetFirstFormula( const OUString& rFmlaStr ); void SetSecondFormula( const OUString& rFmlaStr ); - DECL_LINK(SelectHdl, ListBox&, void); - DECL_LINK(CheckHdl, Button*, void); - - VclPtr m_pLbAllow; - VclPtr m_pCbAllow; /// Allow blank cells. - VclPtr m_pCbShow; /// Show selection list in cell. - VclPtr m_pCbSort; /// Sort selection list in cell. - VclPtr m_pFtValue; - VclPtr m_pLbValue; - VclPtr m_pFtMin; - VclPtr m_pMinGrid; - VclPtr m_pEdMin; - VclPtr m_pEdList; /// Entries for explicit list - VclPtr m_pFtMax; - VclPtr m_pEdMax; - VclPtr m_pFtHint; /// Hint text for cell range validity. + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(CheckHdl, weld::Button&, void); OUString const maStrMin; OUString const maStrMax; @@ -122,75 +108,65 @@ private: OUString const maStrList; sal_Unicode mcFmlaSep; /// List separator in formulas. - DECL_LINK( EditSetFocusHdl, Control&, void ); - DECL_LINK( KillFocusHdl, Control&, void ); - void OnClick( const Button *pBtn ); - VclPtr m_pRefEdit; -public: - class ScRefButtonEx : public ::formula::RefButton - { - VclPtr m_pPage; - virtual void Click() override; - public: - ScRefButtonEx(vcl::Window* pParent, WinBits nStyle) - : ::formula::RefButton(pParent, nStyle) - , m_pPage(nullptr) - { - } - virtual ~ScRefButtonEx() override; - virtual void dispose() override; - void SetParentPage(ScTPValidationValue *pPage) - { - m_pPage = pPage; - } - ScTPValidationValue* GetParentPage() - { - return m_pPage; - } - }; -private: - VclPtr m_pBtnRef; - VclPtr m_pRefGrid; - friend class ScRefButtonEx; + DECL_LINK( EditSetFocusHdl, formula::WeldRefEdit&, void ); + DECL_LINK( KillEditFocusHdl, formula::WeldRefEdit&, void ); + DECL_LINK( KillButtonFocusHdl, formula::WeldRefButton&, void ); + DECL_LINK( ClickHdl, formula::WeldRefButton&, void ); + + formula::WeldRefEdit* m_pRefEdit; + + std::unique_ptr m_xLbAllow; + std::unique_ptr m_xCbAllow; /// Allow blank cells. + std::unique_ptr m_xCbShow; /// Show selection list in cell. + std::unique_ptr m_xCbSort; /// Sort selection list in cell. + std::unique_ptr m_xFtValue; + std::unique_ptr m_xLbValue; + std::unique_ptr m_xFtMin; + std::unique_ptr m_xMinGrid; + std::unique_ptr m_xEdMin; + std::unique_ptr m_xEdList; /// Entries for explicit list + std::unique_ptr m_xFtMax; + std::unique_ptr m_xEdMax; + std::unique_ptr m_xFtHint; /// Hint text for cell range validity. + std::unique_ptr m_xBtnRef; + std::unique_ptr m_xRefGrid; + + weld::Container* m_pRefEditParent; + weld::Container* m_pBtnRefParent; + void SetReferenceHdl( const ScRange& , const ScDocument* ); void SetActiveHdl(); - void RefInputStartPreHdl( formula::RefEdit* pEdit, const formula::RefButton* pButton ); + void RefInputStartPreHdl(formula::WeldRefEdit* pEdit, const formula::WeldRefButton* pButton); void RefInputDonePostHdl(); ScValidationDlg * GetValidationDlg(); public: void SetupRefDlg(); - void RemoveRefDlg(); + void RemoveRefDlg(bool bRestoreModal); }; /** The "Validity" tab dialog. */ class ScValidationDlg - : public ScRefHdlrImpl + : public ScRefHdlrControllerImpl , public ScRefHandlerHelper { - typedef ScRefHdlrImpl ScValidationDlgBase; + typedef ScRefHdlrControllerImpl ScValidationDlgBase; ScTabViewShell * const m_pTabVwSh; - VclPtr m_pHBox; - sal_uInt16 m_nValuePageId; + OString m_sValuePageId; bool m_bOwnRefHdlr:1; bool m_bRefInputting:1; + std::unique_ptr m_xHBox; + bool EnterRefStatus(); bool LeaveRefStatus(); public: - explicit ScValidationDlg( vcl::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh ); - virtual ~ScValidationDlg() override; - virtual void dispose() override - { - if( m_bOwnRefHdlr ) - RemoveRefDlg( false ); - m_pHBox.clear(); - ScRefHdlrImpl::dispose(); - } - static ScValidationDlg * Find1AliveObject( vcl::Window *pAncestor ) + explicit ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell* pTabViewSh); + virtual ~ScValidationDlg() override; + static std::shared_ptr Find1AliveObject(weld::Window *pAncestor) { - return static_cast( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) ); + return SC_MOD()->Find1RefWindow(SLOTID, pAncestor); } ScTabViewShell *GetTabViewShell() { @@ -198,9 +174,9 @@ public: } bool SetupRefDlg(); - bool RemoveRefDlg( bool bRestoreModal ); + bool RemoveRefDlg(bool bRestoreModal); - void SetModal( bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); } + void SetModal(bool bModal) { m_xDialog->set_modal(bModal); } virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override { @@ -215,9 +191,9 @@ public: } bool IsRefInputting(){ return m_bRefInputting; } - vcl::Window* get_refinput_shrink_parent() { return m_pHBox; } + weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); } - virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override + virtual void RefInputStart( formula::WeldRefEdit* pEdit, formula::WeldRefButton* pButton = nullptr ) override { if( !CanInputStart( pEdit ) ) return; @@ -228,7 +204,7 @@ public: ScValidationDlgBase::RefInputStart( pEdit, pButton ); } - virtual void RefInputStart( formula::WeldRefEdit* /*pEdit*/, formula::WeldRefButton* /*pButton*/ = nullptr ) override + virtual void RefInputStart( formula::RefEdit* /*pEdit*/, formula::RefButton* /*pButton*/ = nullptr ) override { assert(false); } @@ -249,15 +225,14 @@ public: enum { SLOTID = SID_VALIDITY_REFERENCE }; - bool Close() override + virtual void Close() override { - if( m_bOwnRefHdlr ) + if (m_bOwnRefHdlr) { - if (SfxTabPage* pPage = GetTabPage(m_nValuePageId)) - static_cast(pPage)->RemoveRefDlg(); + if (SfxTabPage* pPage = GetTabPage(m_sValuePageId)) + static_cast(pPage)->RemoveRefDlg(false); } - - return ScValidationDlgBase::Close(); + ScValidationDlgBase::Close(); } }; diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 29c05945b30c..44eec39037c8 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -879,7 +879,7 @@ ScRefHandler::ScRefHandler( vcl::Window &rWindow, SfxBindings* pB, bool bBindRef if( bBindRef ) EnterRefMode(); } -ScRefHandler::ScRefHandler(SfxModelessDialogController& rController, SfxBindings* pB, bool bBindRef) +ScRefHandler::ScRefHandler(SfxDialogController& rController, SfxBindings* pB, bool bBindRef) : m_pController(&rController) , m_bInRefMode(false) , m_aHelper(this, pB) @@ -959,10 +959,6 @@ bool ScRefHandler::LeaveRefMode() lcl_HideAllReferences(); - if( Dialog *pDlg = dynamic_cast( m_rWindow.get() ) ) - pDlg->SetModalInputMode(false); - if (m_pController) - m_pController->getDialog()->set_modal(false); SetDispatcherLock( false ); //! here and in DoClose ? ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index f827a032e1c2..9043bd3a4ba9 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -210,6 +210,26 @@ static bool lcl_GetSortParam( const ScViewData* pData, const ScSortParam& rSortP return bSort; } +namespace +{ + // this registers the dialog which Find1RefWindow search for + class ScValidationRegisteredDlg + { + std::shared_ptr m_xDlg; + public: + ScValidationRegisteredDlg(weld::Window* pParent, std::shared_ptr& rDlg) + : m_xDlg(rDlg) + { + SC_MOD()->RegisterRefController(static_cast(ScValidationDlg::SLOTID), m_xDlg, pParent); + } + ~ScValidationRegisteredDlg() + { + m_xDlg->Close(); + SC_MOD()->UnregisterRefController(static_cast(ScValidationDlg::SLOTID), m_xDlg); + } + }; +} + void ScCellShell::ExecuteDB( SfxRequest& rReq ) { ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); @@ -870,12 +890,15 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) } // cell range picker - ScopedVclPtrInstance pDlg(GetViewData()->GetActiveWin(), &aArgSet, pTabViewShell); + vcl::Window* pWin = GetViewData()->GetActiveWin(); + weld::Window* pParentWin = pWin ? pWin->GetFrameWeld() : nullptr; + std::shared_ptr xDlg(new ScValidationDlg(pParentWin, &aArgSet, pTabViewShell)); + ScValidationRegisteredDlg aRegisterThatDlgExists(pParentWin, xDlg); - short nResult = pDlg->Execute(); + short nResult = xDlg->run(); if ( nResult == RET_OK ) { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + const SfxItemSet* pOutSet = static_cast(xDlg.get())->GetOutputItemSet(); if ( pOutSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET ) eMode = static_cast(static_cast(pItem)->GetValue()); diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index 02c89d153321..4ccce3e9f575 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -306,38 +306,33 @@ namespace } } -ScValidityRefChildWin::ScValidityRefChildWin( vcl::Window* pParentP, - sal_uInt16 nId, - const SfxBindings* p, +ScValidityRefChildWin::ScValidityRefChildWin(vcl::Window* pParentP, + sal_uInt16 nId, + const SfxBindings* p, SAL_UNUSED_PARAMETER SfxChildWinInfo* /*pInfo*/ ) - : SfxChildWindow(pParentP, nId), - m_bVisibleLock( false ), - m_bFreeWindowLock( false ), - m_pSavedWndParent( nullptr ) + : SfxChildWindow(pParentP, nId) + , m_bVisibleLock(false) + , m_bFreeWindowLock(false) { SetWantsFocus( false ); - VclPtr pDlg = ScValidationDlg::Find1AliveObject( pParentP ); - SetWindow(pDlg); + std::shared_ptr xDlg(ScValidationDlg::Find1AliveObject(pParentP->GetFrameWeld())); + SetController(xDlg); ScTabViewShell* pViewShell; - if (pDlg) - pViewShell = static_cast(GetWindow())->GetTabViewShell(); + if (xDlg) + pViewShell = static_cast(xDlg.get())->GetTabViewShell(); else pViewShell = lcl_GetTabViewShell( p ); if (!pViewShell) pViewShell = dynamic_cast( SfxViewShell::Current() ); OSL_ENSURE( pViewShell, "missing view shell :-(" ); - if (pViewShell && !GetWindow()) + if (pViewShell && !xDlg) pViewShell->GetViewFrame()->SetChildWindow( nId, false ); - - if( GetWindow() ) m_pSavedWndParent = GetWindow()->GetParent(); } ScValidityRefChildWin::~ScValidityRefChildWin() { - if( GetWindow() ) GetWindow()->SetParent( m_pSavedWndParent ); - - if( m_bFreeWindowLock ) - SetWindow(nullptr); + if (m_bFreeWindowLock) + SetController(nullptr); } IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF ) diff --git a/sc/uiconfig/scalc/ui/validationcriteriapage.ui b/sc/uiconfig/scalc/ui/validationcriteriapage.ui index 2bf0bab17955..00897a20510e 100644 --- a/sc/uiconfig/scalc/ui/validationcriteriapage.ui +++ b/sc/uiconfig/scalc/ui/validationcriteriapage.ui @@ -1,96 +1,7 @@ - + - - - - - - - - - - - All values - 0 - - - Whole Numbers - 1 - - - Decimal - 2 - - - Date - 3 - - - Time - 4 - - - Cell range - 5 - - - List - 6 - - - Text length - 7 - - - Custom - 8 - - - - - - - - - - - - - equal - 0 - - - less than - 1 - - - greater than - 2 - - - less than or equal - 3 - - - greater than or equal to - 4 - - - not equal - 5 - - - valid range - 6 - - - invalid range - 7 - - - True False @@ -103,10 +14,10 @@ True False - 0 _Allow: True allow + 0 0 @@ -117,10 +28,10 @@ False True - 0 _Data: True data + 0 0 @@ -128,10 +39,20 @@ - + True False - liststore1 + + All values + Whole Numbers + Decimal + Date + Time + Cell range + List + Text length + Custom + 1 @@ -139,10 +60,19 @@ - + False True - liststore2 + + equal + less than + greater than + less than or equal + greater than or equal to + not equal + valid range + invalid range + 1 @@ -153,10 +83,10 @@ True False - 0 _Minimum: True mingrid + 0 0 @@ -175,10 +105,11 @@ True 12 - + True True True + True 0 @@ -186,7 +117,7 @@ - + True True True @@ -212,7 +143,7 @@ True in - + True True True @@ -235,10 +166,10 @@ False True - 0 Ma_ximum: True max + 0 0 @@ -296,11 +227,11 @@ False True - 0 - 0 A valid source can only consist of a contiguous selection of rows and columns, or a formula that results in an area or array. True 50 + 0 + 0 1 @@ -308,10 +239,11 @@ - + True True True + True 1 diff --git a/sc/uiconfig/scalc/ui/validationdialog.ui b/sc/uiconfig/scalc/ui/validationdialog.ui index f3a7b0ebefae..84441ca5b2c6 100644 --- a/sc/uiconfig/scalc/ui/validationdialog.ui +++ b/sc/uiconfig/scalc/ui/validationdialog.ui @@ -1,5 +1,5 @@ - + @@ -7,7 +7,13 @@ 6 Validity False + True + 0 + 0 dialog + + + False @@ -18,12 +24,10 @@ False end - - gtk-ok + + gtk-revert-to-saved True True - True - True True True @@ -34,10 +38,12 @@ - - gtk-cancel + + gtk-ok True True + True + True True True @@ -48,8 +54,8 @@ - - gtk-help + + gtk-cancel True True True @@ -59,12 +65,11 @@ False True 2 - True - - gtk-revert-to-saved + + gtk-help True True True @@ -74,6 +79,7 @@ False True 3 + True @@ -104,6 +110,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -123,6 +153,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1 @@ -146,6 +200,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + 2 @@ -193,10 +271,10 @@ + reset ok cancel help - reset -- cgit