include/formula/funcutl.hxx | 12 +++ sc/source/ui/inc/reffact.hxx | 5 + sc/source/ui/inc/simpref.hxx | 25 +++--- sc/source/ui/miscdlgs/simpref.cxx | 91 +++++++++--------------- sc/source/ui/view/reffact.cxx | 35 +++++---- sc/source/ui/view/tabvwshc.cxx | 19 ++--- sc/uiconfig/scalc/ui/simplerefdialog.ui | 113 ++++++++++++++++--------------- solenv/sanitizers/ui/modules/scalc.suppr | 1 8 files changed, 151 insertions(+), 150 deletions(-)
New commits: commit 8d19e03b17fdd6e6159843249fe0b4f41c526f17 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Apr 10 13:09:05 2019 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Apr 11 11:23:30 2019 +0200 weld ScSimpleRefDlg Change-Id: I36fe5a0790b2f7a43b9e4d8def9ef3a224d4d546 Reviewed-on: https://gerrit.libreoffice.org/70549 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/formula/funcutl.hxx b/include/formula/funcutl.hxx index 5a6c095db77e..d2aec01bf90a 100644 --- a/include/formula/funcutl.hxx +++ b/include/formula/funcutl.hxx @@ -142,6 +142,18 @@ public: xEntry->select_region(0, -1); } + void SetSelection(const Selection& rSelection) + { + xEntry->select_region(rSelection.Min(), rSelection.Max()); + } + + Selection GetSelection() const + { + int nStartPos, nEndPos; + xEntry->get_selection_bounds(nStartPos, nEndPos); + return Selection(nStartPos, nEndPos); + } + weld::Label* GetLabelWidgetForShrinkMode() { return pLabelWidget; diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index b7ab53612a0b..e6bf12c0feec 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -180,7 +180,10 @@ class ScSimpleRefDlgWrapper: public SfxChildWindow SfxBindings*, SfxChildWinInfo* ); - SFX_DECL_CHILDWINDOW_WITHID(Class); + static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, + SfxBindings *pBindings, SfxChildWinInfo* pInfo); + static void RegisterChildWindow(bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); + static sal_uInt16 GetChildWindowId(); static void SetDefaultPosSize(Point aPos, Size aSize); void SetRefString(const OUString& rStr); diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx index 492dac5910b2..c3a9184c1099 100644 --- a/sc/source/ui/inc/simpref.hxx +++ b/sc/source/ui/inc/simpref.hxx @@ -25,7 +25,7 @@ class ScDocument; -class ScSimpleRefDlg: public ScAnyRefDlg +class ScSimpleRefDlg: public ScAnyRefDlgController { private: Link<const OUString*,void> aCloseHdl; @@ -33,13 +33,6 @@ private: Link<const OUString&,void> aAbortedHdl; Link<const OUString&,void> aChangeHdl; - VclPtr<FixedText> m_pFtAssign; - VclPtr<formula::RefEdit> m_pEdAssign; - VclPtr<formula::RefButton> m_pRbAssign; - - VclPtr<OKButton> m_pBtnOk; - VclPtr<CancelButton> m_pBtnCancel; - ScRange theCurArea; bool bCloseFlag; bool bAutoReOpen; @@ -47,30 +40,34 @@ private: bool bSingleCell; bool bMultiSelection; + std::unique_ptr<weld::Label> m_xFtAssign; + std::unique_ptr<formula::WeldRefEdit> m_xEdAssign; + std::unique_ptr<formula::WeldRefButton> m_xRbAssign; + std::unique_ptr<weld::Button> m_xBtnOk; + std::unique_ptr<weld::Button> m_xBtnCancel; + void Init(); - DECL_LINK( CancelBtnHdl, Button*, void ); - DECL_LINK( OkBtnHdl, Button*, void ); + DECL_LINK( CancelBtnHdl, weld::Button&, void ); + DECL_LINK( OkBtnHdl, weld::Button&, void ); protected: virtual void RefInputDone( bool bForced = false ) override; public: - ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent); + ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent); virtual ~ScSimpleRefDlg() override; - virtual void dispose() override; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override; virtual bool IsRefInputMode() const override; virtual void SetActive() override; - virtual bool Close() override; + virtual void Close() override; void StartRefInput(); void SetRefString(const OUString &rStr); - virtual void FillInfo(SfxChildWinInfo&) const override; void SetCloseHdl( const Link<const OUString*,void>& rLink ); void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx index def1babab0f9..362c4e1382ae 100644 --- a/sc/source/ui/miscdlgs/simpref.cxx +++ b/sc/source/ui/miscdlgs/simpref.cxx @@ -21,23 +21,20 @@ #include <document.hxx> #include <simpref.hxx> -ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent) - : ScAnyRefDlg(pB, pCW, pParent, "SimpleRefDialog", "modules/scalc/ui/simplerefdialog.ui") -, - - bAutoReOpen ( true ), - bCloseOnButtonUp( false ), - bSingleCell ( false ), - bMultiSelection ( false ) -{ - get(m_pFtAssign, "area"); - get(m_pEdAssign, "assign"); - m_pEdAssign->SetReferences(this, m_pFtAssign); - get(m_pRbAssign, "assignref"); - m_pRbAssign->SetReferences(this, m_pEdAssign); - - get(m_pBtnOk, "ok"); - get(m_pBtnCancel, "cancel"); +ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent) + : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/simplerefdialog.ui", "SimpleRefDialog") + , bAutoReOpen(true) + , bCloseOnButtonUp(false) + , bSingleCell(false) + , bMultiSelection(false) + , m_xFtAssign(m_xBuilder->weld_label("area")) + , m_xEdAssign(new formula::WeldRefEdit(m_xBuilder->weld_entry("assign"))) + , m_xRbAssign(new formula::WeldRefButton(m_xBuilder->weld_button("assignref"))) + , m_xBtnOk(m_xBuilder->weld_button("ok")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) +{ + m_xEdAssign->SetReferences(this, m_xFtAssign.get()); + m_xRbAssign->SetReferences(this, m_xEdAssign.get()); // in order to keep the Strings with the FixedTexts in the resource: Init(); @@ -46,35 +43,18 @@ ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window ScSimpleRefDlg::~ScSimpleRefDlg() { - disposeOnce(); -} - -void ScSimpleRefDlg::dispose() -{ SetDispatcherLock( false ); // deactivate modal mode - m_pFtAssign.clear(); - m_pEdAssign.clear(); - m_pRbAssign.clear(); - m_pBtnOk.clear(); - m_pBtnCancel.clear(); - ScAnyRefDlg::dispose(); -} - -void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const -{ - ScAnyRefDlg::FillInfo(rWinInfo); - rWinInfo.bVisible=bAutoReOpen; } void ScSimpleRefDlg::SetRefString(const OUString &rStr) { - m_pEdAssign->SetText(rStr); + m_xEdAssign->SetText(rStr); } void ScSimpleRefDlg::Init() { - m_pBtnOk->SetClickHdl ( LINK( this, ScSimpleRefDlg, OkBtnHdl ) ); - m_pBtnCancel->SetClickHdl ( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) ); + m_xBtnOk->connect_clicked( LINK( this, ScSimpleRefDlg, OkBtnHdl ) ); + m_xBtnCancel->connect_clicked( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) ); bCloseFlag=false; } @@ -82,10 +62,10 @@ void ScSimpleRefDlg::Init() // shown as the new selection in the reference field. void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) { - if ( m_pEdAssign->IsEnabled() ) + if (m_xEdAssign->GetWidget()->get_sensitive()) { if ( rRef.aStart != rRef.aEnd ) - RefInputStart(m_pEdAssign); + RefInputStart(m_xEdAssign.get()); theCurArea = rRef; OUString aRefStr; @@ -99,30 +79,29 @@ void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) if ( bMultiSelection ) { - OUString aVal = m_pEdAssign->GetText(); - Selection aSel = m_pEdAssign->GetSelection(); + OUString aVal = m_xEdAssign->GetText(); + Selection aSel = m_xEdAssign->GetSelection(); aSel.Justify(); aVal = aVal.replaceAt( aSel.Min(), aSel.Len(), aRefStr ); Selection aNewSel( aSel.Min(), aSel.Min()+aRefStr.getLength() ); - m_pEdAssign->SetRefString( aVal ); - m_pEdAssign->SetSelection( aNewSel ); + m_xEdAssign->SetRefString( aVal ); + m_xEdAssign->SetSelection( aNewSel ); } else - m_pEdAssign->SetRefString( aRefStr ); + m_xEdAssign->SetRefString( aRefStr ); aChangeHdl.Call( aRefStr ); } } -bool ScSimpleRefDlg::Close() +void ScSimpleRefDlg::Close() { - CancelBtnHdl(m_pBtnCancel); - return true; + CancelBtnHdl(*m_xBtnCancel); } void ScSimpleRefDlg::SetActive() { - m_pEdAssign->GrabFocus(); + m_xEdAssign->GrabFocus(); // no NameModifyHdl. Otherwise ranges could not be altered // (after marking the reference, the old field content would be shown) @@ -162,36 +141,36 @@ void ScSimpleRefDlg::StartRefInput() if ( bMultiSelection ) { // initially select the whole string, so it gets replaced by default - m_pEdAssign->SetSelection( Selection( 0, m_pEdAssign->GetText().getLength() ) ); + m_xEdAssign->SelectAll(); } - m_pRbAssign->DoRef(); + m_xRbAssign->DoRef(); bCloseFlag = true; } void ScSimpleRefDlg::RefInputDone( bool bForced) { - ScAnyRefDlg::RefInputDone(bForced); + ScAnyRefDlgController::RefInputDone(bForced); if ( (bForced || bCloseOnButtonUp) && bCloseFlag ) - OkBtnHdl(m_pBtnOk); + OkBtnHdl(*m_xBtnOk); } // Handler: -IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, Button*, void) +IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, weld::Button&, void) { bAutoReOpen=false; - OUString aResult=m_pEdAssign->GetText(); + OUString aResult=m_xEdAssign->GetText(); aCloseHdl.Call(&aResult); Link<const OUString&,void> aUnoLink = aDoneHdl; // stack var because this is deleted in DoClose DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() ); aUnoLink.Call( aResult ); } -IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl, Button*, void) +IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl, weld::Button&, void) { bAutoReOpen=false; - OUString aResult=m_pEdAssign->GetText(); + OUString aResult=m_xEdAssign->GetText(); aCloseHdl.Call(nullptr); Link<const OUString&,void> aUnoLink = aAbortedHdl; // stack var because this is deleted in DoClose DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() ); diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index 483216905456..ae17dd5da8d1 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -48,7 +48,7 @@ SFX_IMPL_MODELESSDIALOG_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNA SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION ) SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT ) SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW ) -SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF ) +SFX_IMPL_CHILDWINDOW_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF ) SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF ) SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE) @@ -183,12 +183,12 @@ ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( vcl::Window* pParentP, pInfo->aSize.setHeight(nScSimpleRefHeight ); pInfo->aSize.setWidth(nScSimpleRefWidth ); } - SetWindow(nullptr); + SetController(nullptr); - if(bAutoReOpen && pViewShell) - SetWindow( pViewShell->CreateRefDialog( p, this, pInfo, pParentP, WID_SIMPLE_REF) ); + if (bAutoReOpen && pViewShell) + SetController(pViewShell->CreateRefDialogController(p, this, pInfo, pParentP->GetFrameWeld(), WID_SIMPLE_REF)); - if (!GetWindow()) + if (!GetController()) { SC_MOD()->SetRefDialog( nId, false ); } @@ -210,42 +210,47 @@ void ScSimpleRefDlgWrapper::SetAutoReOpen(bool bFlag) void ScSimpleRefDlgWrapper::SetRefString(const OUString& rStr) { - if(GetWindow()) + auto xDlgController = GetController(); + if (xDlgController) { - static_cast<ScSimpleRefDlg*>(GetWindow())->SetRefString(rStr); + static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetRefString(rStr); } } void ScSimpleRefDlgWrapper::SetCloseHdl( const Link<const OUString*,void>& rLink ) { - if(GetWindow()) + auto xDlgController = GetController(); + if (xDlgController) { - static_cast<ScSimpleRefDlg*>(GetWindow())->SetCloseHdl( rLink ); + static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetCloseHdl(rLink); } } void ScSimpleRefDlgWrapper::SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort, const Link<const OUString&,void>& rChange ) { - if(GetWindow()) + auto xDlgController = GetController(); + if (xDlgController) { - static_cast<ScSimpleRefDlg*>(GetWindow())->SetUnoLinks( rDone, rAbort, rChange ); + static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetUnoLinks( rDone, rAbort, rChange ); } } void ScSimpleRefDlgWrapper::SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ) { - if(GetWindow()) + auto xDlgController = GetController(); + if (xDlgController) { - static_cast<ScSimpleRefDlg*>(GetWindow())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); + static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); } } void ScSimpleRefDlgWrapper::StartRefInput() { - if(GetWindow()) + auto xDlgController = GetController(); + if (xDlgController) { - static_cast<ScSimpleRefDlg*>(GetWindow())->StartRefInput(); + static_cast<ScSimpleRefDlg*>(xDlgController.get())->StartRefInput(); } } diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 89d32bd4648f..dd9ea086f022 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -365,16 +365,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( } break; - case WID_SIMPLE_REF: - { - // dialog checks, what is in the cell - - ScViewData& rViewData = GetViewData(); - rViewData.SetRefTabNo( rViewData.GetTabNo() ); - pResult = VclPtr<ScSimpleRefDlg>::Create( pB, pCW, pParent ); - } - break; - case WID_CONDFRMT_REF: { bool bFound = false; @@ -484,6 +474,15 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont case SID_FOURIER_ANALYSIS_DIALOG: xResult.reset(new ScFourierAnalysisDialog(pB, pCW, pParent, &GetViewData())); break; + case WID_SIMPLE_REF: + { + // dialog checks, what is in the cell + + ScViewData& rViewData = GetViewData(); + rViewData.SetRefTabNo( rViewData.GetTabNo() ); + xResult.reset(new ScSimpleRefDlg(pB, pCW, pParent)); + break; + } case FID_DEFINE_NAME: { if (!mbInSwitch) diff --git a/sc/uiconfig/scalc/ui/simplerefdialog.ui b/sc/uiconfig/scalc/ui/simplerefdialog.ui index d16fffbd1e42..1513f139abd2 100644 --- a/sc/uiconfig/scalc/ui/simplerefdialog.ui +++ b/sc/uiconfig/scalc/ui/simplerefdialog.ui @@ -1,71 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="SimpleRefDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="simplerefdialog|SimpleRefDialog">Set range</property> <property name="resizable">False</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> - <child> - <object class="GtkGrid" id="grid3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <property name="row_homogeneous">True</property> - <child> - <object class="GtkLabel" id="area"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes" context="simplerefdialog|area">Area:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">assign</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="foruilo-RefEdit" id="assign"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="width_chars">50</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="foruilo-RefButton" id="assignref"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> <property name="can_focus">False</property> @@ -123,6 +75,59 @@ <property name="position">2</property> </packing> </child> + <child> + <object class="GtkGrid" id="grid3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <property name="row_homogeneous">True</property> + <child> + <object class="GtkLabel" id="area"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="simplerefdialog|area">Area:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">assign</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="assign"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> + <property name="width_chars">50</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="assignref"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> </object> </child> <action-widgets> diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr index 6b0b1ddaf1ef..df17d9b4110b 100644 --- a/solenv/sanitizers/ui/modules/scalc.suppr +++ b/solenv/sanitizers/ui/modules/scalc.suppr @@ -219,6 +219,7 @@ sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkSpinButton[@id='leftindent:0pt'] m sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkSpinButton[@id='leftindent:0pt'] labelled-by-and-mnemonic sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkLabel[@id='orientationlabel'] orphan-label sc/uiconfig/scalc/ui/sidebaralignment.ui://VclComboBoxNumeric[@id='orientationdegrees:0degrees'] missing-label-for +sc/uiconfig/scalc/ui/simplerefdialog.ui://GtkButton[@id='assignref'] button-no-label sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='targetlabel'] orphan-label sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='result'] orphan-label sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='changelabel'] orphan-label _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits