From 168034416c9477ee5ae1d3c6f899451e28d42851 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 18 May 2018 10:01:00 +0100 Subject: weld DataStreamDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8da7228de5a1a9b7637c8c43ffd79f5f044bc788 Reviewed-on: https://gerrit.libreoffice.org/54521 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svtools/inettbc.hxx | 1 + sc/source/ui/inc/datastreamdlg.hxx | 54 ++++++------ sc/source/ui/miscdlgs/datastreamdlg.cxx | 142 ++++++++++++++------------------ sc/source/ui/view/cellsh2.cxx | 8 +- sc/uiconfig/scalc/ui/datastreams.ui | 134 +++++++++++++++--------------- 5 files changed, 161 insertions(+), 178 deletions(-) diff --git a/include/svtools/inettbc.hxx b/include/svtools/inettbc.hxx index e7f67bed8a03..18764ec42ce8 100644 --- a/include/svtools/inettbc.hxx +++ b/include/svtools/inettbc.hxx @@ -118,6 +118,7 @@ public: void SetText(const OUString& rStr) { m_xWidget->set_entry_text(rStr); } void Clear() { m_xWidget->clear(); } void connect_entry_activate(const Link& rLink) { m_xWidget->connect_entry_activate(rLink); } + void connect_changed(const Link& rLink) { m_xWidget->connect_changed(rLink); } void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); } OUString get_active_text() const { return m_xWidget->get_active_text(); } void EnableAutocomplete() { m_xWidget->set_entry_completion(true); } diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx index c728f87402cf..b6b2dd2cbaba 100644 --- a/sc/source/ui/inc/datastreamdlg.hxx +++ b/sc/source/ui/inc/datastreamdlg.hxx @@ -13,50 +13,48 @@ #include #include -#include -#include +#include #include "datastream.hxx" class ScDocShell; -class SvtURLBox; +class URLBox; class ScRange; class ComboBox; namespace sc { -class DataStreamDlg : public ModalDialog +class DataStreamDlg : public weld::GenericDialogController { - ScDocShell *mpDocShell; - - VclPtr m_pCbUrl; - VclPtr m_pBtnBrowse; - VclPtr m_pRBValuesInLine; - VclPtr m_pRBAddressValue; - VclPtr m_pCBRefreshOnEmpty; - VclPtr m_pRBDataDown; - VclPtr m_pRBRangeDown; - VclPtr m_pRBNoMove; - VclPtr m_pRBMaxLimit; - VclPtr m_pRBUnlimited; - VclPtr m_pEdRange; - VclPtr m_pEdLimit; - VclPtr m_pBtnOk; - VclPtr m_pVclFrameLimit; - VclPtr m_pVclFrameMove; - - DECL_LINK(UpdateClickHdl, Button*, void); - DECL_LINK(UpdateHdl, Edit&, void); - DECL_LINK(UpdateComboBoxHdl, ComboBox&, void); - DECL_LINK(BrowseHdl, Button*, void); + ScDocShell *m_pDocShell; + + std::unique_ptr m_xCbUrl; + std::unique_ptr m_xBtnBrowse; + std::unique_ptr m_xRBValuesInLine; + std::unique_ptr m_xRBAddressValue; + std::unique_ptr m_xCBRefreshOnEmpty; + std::unique_ptr m_xRBDataDown; + std::unique_ptr m_xRBRangeDown; + std::unique_ptr m_xRBNoMove; + std::unique_ptr m_xRBMaxLimit; + std::unique_ptr m_xRBUnlimited; + std::unique_ptr m_xEdRange; + std::unique_ptr m_xEdLimit; + std::unique_ptr m_xBtnOk; + std::unique_ptr m_xVclFrameLimit; + std::unique_ptr m_xVclFrameMove; + + DECL_LINK(UpdateClickHdl, weld::ToggleButton&, void); + DECL_LINK(UpdateHdl, weld::Entry&, void); + DECL_LINK(UpdateComboBoxHdl, weld::ComboBoxText&, void); + DECL_LINK(BrowseHdl, weld::Button&, void); void UpdateEnable(); ScRange GetStartRange(); public: - DataStreamDlg(ScDocShell *pDocShell, vcl::Window* pParent); + DataStreamDlg(ScDocShell *pDocShell, weld::Window* pParent); virtual ~DataStreamDlg() override; - virtual void dispose() override; void Init( const DataStream& rStrm ); diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx index 6164037b1c34..01c76e994173 100644 --- a/sc/source/ui/miscdlgs/datastreamdlg.cxx +++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx @@ -17,98 +17,78 @@ namespace sc { -DataStreamDlg::DataStreamDlg(ScDocShell *pDocShell, vcl::Window* pParent) - : ModalDialog(pParent, "DataStreamDialog", "modules/scalc/ui/datastreams.ui") - , mpDocShell(pDocShell) +DataStreamDlg::DataStreamDlg(ScDocShell *pDocShell, weld::Window* pParent) + : GenericDialogController(pParent, "modules/scalc/ui/datastreams.ui", "DataStreamDialog") + , m_pDocShell(pDocShell) + , m_xCbUrl(new URLBox(m_xBuilder->weld_combo_box_text("url"))) + , m_xBtnBrowse(m_xBuilder->weld_button("browse")) + , m_xRBValuesInLine(m_xBuilder->weld_radio_button("valuesinline")) + , m_xRBAddressValue(m_xBuilder->weld_radio_button("addressvalue")) + , m_xCBRefreshOnEmpty(m_xBuilder->weld_check_button("refresh_ui")) + , m_xRBDataDown(m_xBuilder->weld_radio_button("datadown")) + , m_xRBRangeDown(m_xBuilder->weld_radio_button("rangedown")) + , m_xRBNoMove(m_xBuilder->weld_radio_button("nomove")) + , m_xRBMaxLimit(m_xBuilder->weld_radio_button("maxlimit")) + , m_xRBUnlimited(m_xBuilder->weld_radio_button("unlimited")) + , m_xEdRange(m_xBuilder->weld_entry("range")) + , m_xEdLimit(m_xBuilder->weld_entry("limit")) + , m_xBtnOk(m_xBuilder->weld_button("ok")) + , m_xVclFrameLimit(m_xBuilder->weld_frame("framelimit")) + , m_xVclFrameMove(m_xBuilder->weld_frame("framemove")) { - get(m_pCbUrl, "url"); - get(m_pBtnBrowse, "browse"); - get(m_pRBValuesInLine, "valuesinline"); - get(m_pRBAddressValue, "addressvalue"); - get(m_pCBRefreshOnEmpty, "refresh_ui"); - get(m_pRBDataDown, "datadown"); - get(m_pRBRangeDown, "rangedown"); - get(m_pRBNoMove, "nomove"); - get(m_pRBMaxLimit, "maxlimit"); - get(m_pRBUnlimited, "unlimited"); - get(m_pEdRange, "range"); - get(m_pEdLimit, "limit"); - get(m_pBtnOk, "ok"); - get(m_pVclFrameLimit, "framelimit"); - get(m_pVclFrameMove, "framemove"); - - m_pCbUrl->SetSelectHdl( LINK( this, DataStreamDlg, UpdateComboBoxHdl ) ); - m_pRBAddressValue->SetClickHdl( LINK( this, DataStreamDlg, UpdateClickHdl ) ); - m_pRBAddressValue->Enable(false); - m_pRBNoMove->Hide(); - m_pRBValuesInLine->SetClickHdl( LINK( this, DataStreamDlg, UpdateClickHdl ) ); - m_pEdRange->SetModifyHdl( LINK( this, DataStreamDlg, UpdateHdl ) ); - m_pBtnBrowse->SetClickHdl( LINK( this, DataStreamDlg, BrowseHdl ) ); + m_xCbUrl->connect_changed( LINK( this, DataStreamDlg, UpdateComboBoxHdl ) ); + m_xRBAddressValue->connect_toggled( LINK( this, DataStreamDlg, UpdateClickHdl ) ); + m_xRBAddressValue->set_sensitive(false); + m_xRBNoMove->hide(); + m_xRBValuesInLine->connect_toggled( LINK( this, DataStreamDlg, UpdateClickHdl ) ); + m_xEdRange->connect_changed( LINK( this, DataStreamDlg, UpdateHdl ) ); + m_xBtnBrowse->connect_clicked( LINK( this, DataStreamDlg, BrowseHdl ) ); UpdateEnable(); } DataStreamDlg::~DataStreamDlg() { - disposeOnce(); } -void DataStreamDlg::dispose() +IMPL_LINK_NOARG(DataStreamDlg, BrowseHdl, weld::Button&, void) { - m_pCbUrl.clear(); - m_pBtnBrowse.clear(); - m_pRBValuesInLine.clear(); - m_pRBAddressValue.clear(); - m_pCBRefreshOnEmpty.clear(); - m_pRBDataDown.clear(); - m_pRBRangeDown.clear(); - m_pRBNoMove.clear(); - m_pRBMaxLimit.clear(); - m_pRBUnlimited.clear(); - m_pEdRange.clear(); - m_pEdLimit.clear(); - m_pBtnOk.clear(); - m_pVclFrameLimit.clear(); - m_pVclFrameMove.clear(); - ModalDialog::dispose(); -} - -IMPL_LINK_NOARG(DataStreamDlg, BrowseHdl, Button*, void) -{ - sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld()); + sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, m_xDialog.get()); if ( aFileDialog.Execute() != ERRCODE_NONE ) return; - m_pCbUrl->SetText( aFileDialog.GetPath() ); + m_xCbUrl->SetText( aFileDialog.GetPath() ); UpdateEnable(); } -IMPL_LINK_NOARG(DataStreamDlg, UpdateClickHdl, Button*, void) +IMPL_LINK_NOARG(DataStreamDlg, UpdateClickHdl, weld::ToggleButton&, void) { UpdateEnable(); } -IMPL_LINK_NOARG(DataStreamDlg, UpdateComboBoxHdl, ComboBox&, void) + +IMPL_LINK_NOARG(DataStreamDlg, UpdateComboBoxHdl, weld::ComboBoxText&, void) { UpdateEnable(); } -IMPL_LINK_NOARG(DataStreamDlg, UpdateHdl, Edit&, void) + +IMPL_LINK_NOARG(DataStreamDlg, UpdateHdl, weld::Entry&, void) { UpdateEnable(); } void DataStreamDlg::UpdateEnable() { - bool bOk = !m_pCbUrl->GetURL().isEmpty(); - if (m_pRBAddressValue->IsChecked()) + bool bOk = !m_xCbUrl->GetURL().isEmpty(); + if (m_xRBAddressValue->get_active()) { - m_pVclFrameLimit->Disable(); - m_pVclFrameMove->Disable(); - m_pEdRange->Disable(); + m_xVclFrameLimit->set_sensitive(false); + m_xVclFrameMove->set_sensitive(false); + m_xEdRange->set_sensitive(false); } else { - m_pVclFrameLimit->Enable(); - m_pVclFrameMove->Enable(); - m_pEdRange->Enable(); + m_xVclFrameLimit->set_sensitive(true); + m_xVclFrameMove->set_sensitive(true); + m_xEdRange->set_sensitive(true); if (bOk) { // Check the given range to make sure it's valid. @@ -117,14 +97,14 @@ void DataStreamDlg::UpdateEnable() bOk = false; } } - m_pBtnOk->Enable(bOk); - setOptimalLayoutSize(); + m_xBtnOk->set_sensitive(bOk); +// setOptimalLayoutSize(); } ScRange DataStreamDlg::GetStartRange() { - OUString aStr = m_pEdRange->GetText(); - ScDocument& rDoc = mpDocShell->GetDocument(); + OUString aStr = m_xEdRange->get_text(); + ScDocument& rDoc = m_pDocShell->GetDocument(); ScRange aRange; ScRefFlags nRes = aRange.Parse(aStr, &rDoc, rDoc.GetAddressConvention()); if ( ((nRes & ScRefFlags::VALID) == ScRefFlags::ZERO) || !aRange.IsValid()) @@ -143,32 +123,32 @@ ScRange DataStreamDlg::GetStartRange() void DataStreamDlg::Init( const DataStream& rStrm ) { - m_pCbUrl->SetText(rStrm.GetURL()); - ScDocument& rDoc = mpDocShell->GetDocument(); + m_xCbUrl->SetText(rStrm.GetURL()); + ScDocument& rDoc = m_pDocShell->GetDocument(); ScRange aRange = rStrm.GetRange(); ScRange aTopRange = aRange; aTopRange.aEnd.SetRow(aTopRange.aStart.Row()); OUString aStr = aTopRange.Format(ScRefFlags::RANGE_ABS_3D, &rDoc, rDoc.GetAddressConvention()); - m_pEdRange->SetText(aStr); + m_xEdRange->set_text(aStr); SCROW nRows = aRange.aEnd.Row() - aRange.aStart.Row() + 1; if (aRange.aEnd.Row() == MAXROW) - m_pRBUnlimited->Check(); + m_xRBUnlimited->set_active(true); else { - m_pRBMaxLimit->Check(); - m_pEdLimit->SetText(OUString::number(nRows)); + m_xRBMaxLimit->set_active(true); + m_xEdLimit->set_text(OUString::number(nRows)); } DataStream::MoveType eMove = rStrm.GetMove(); switch (eMove) { case DataStream::MOVE_DOWN: - m_pRBDataDown->Check(); + m_xRBDataDown->set_active(true); break; case DataStream::RANGE_DOWN: - m_pRBRangeDown->Check(); + m_xRBRangeDown->set_active(true); break; case DataStream::MOVE_UP: case DataStream::NO_MOVE: @@ -176,7 +156,7 @@ void DataStreamDlg::Init( const DataStream& rStrm ) ; } - m_pCBRefreshOnEmpty->Check(rStrm.IsRefreshOnEmptyLine()); + m_xCBRefreshOnEmpty->set_active(rStrm.IsRefreshOnEmptyLine()); UpdateEnable(); } @@ -189,18 +169,18 @@ void DataStreamDlg::StartStream() return; sal_Int32 nLimit = 0; - if (m_pRBMaxLimit->IsChecked()) - nLimit = m_pEdLimit->GetText().toInt32(); - OUString rURL = m_pCbUrl->GetText(); + if (m_xRBMaxLimit->get_active()) + nLimit = m_xEdLimit->get_text().toInt32(); + OUString rURL = m_xCbUrl->get_active_text(); sal_uInt32 nSettings = 0; - if (m_pRBValuesInLine->IsChecked()) + if (m_xRBValuesInLine->get_active()) nSettings |= DataStream::VALUES_IN_LINE; DataStream::MoveType eMove = - m_pRBRangeDown->IsChecked() ? DataStream::RANGE_DOWN : DataStream::MOVE_DOWN; + m_xRBRangeDown->get_active() ? DataStream::RANGE_DOWN : DataStream::MOVE_DOWN; - DataStream* pStream = DataStream::Set(mpDocShell, rURL, aStartRange, nLimit, eMove, nSettings); - pStream->SetRefreshOnEmptyLine(m_pCBRefreshOnEmpty->IsChecked()); + DataStream* pStream = DataStream::Set(m_pDocShell, rURL, aStartRange, nLimit, eMove, nSettings); + pStream->SetRefreshOnEmptyLine(m_xCBRefreshOnEmpty->get_active()); DataStream::MakeToolbarVisible(); pStream->StartImport(); } diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 8d6c3955f4da..df6497bcc660 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -756,15 +756,15 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) break; case SID_DATA_STREAMS: { - ScopedVclPtrInstance< sc::DataStreamDlg > aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() ); + sc::DataStreamDlg aDialog(GetViewData()->GetDocShell(), pTabViewShell->GetFrameWeld()); ScDocument *pDoc = GetViewData()->GetDocument(); sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager(); sc::DataStream* pStrm = rMgr.getDataStream(); if (pStrm) - aDialog->Init(*pStrm); + aDialog.Init(*pStrm); - if (aDialog->Execute() == RET_OK) - aDialog->StartStream(); + if (aDialog.run() == RET_OK) + aDialog.StartStream(); } break; case SID_DATA_STREAMS_PLAY: diff --git a/sc/uiconfig/scalc/ui/datastreams.ui b/sc/uiconfig/scalc/ui/datastreams.ui index 1e21c1c1ed08..b604caa04a9d 100644 --- a/sc/uiconfig/scalc/ui/datastreams.ui +++ b/sc/uiconfig/scalc/ui/datastreams.ui @@ -1,18 +1,80 @@ - + - False 6 Live Data Streams + True + 0 + 0 dialog + + + False vertical 12 + + + False + end + + + gtk-ok + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + gtk-help + True + True + True + True + + + False + True + 2 + True + + + + + False + True + end + 0 + + True @@ -56,17 +118,17 @@ - + True False True Enter the URL of the source document in the local file system or Internet here. True True - 48 - False + True + True @@ -125,7 +187,6 @@ 0 True True - addressvalue 0 @@ -153,6 +214,7 @@ True True True + True 1 @@ -254,7 +316,6 @@ True 0 True - rangedown False @@ -347,7 +408,6 @@ 0 True True - unlimited 0 @@ -359,6 +419,7 @@ True True True + True 1000 @@ -421,63 +482,6 @@ 0 - - - False - end - - - gtk-ok - True - True - True - True - True - True - - - False - True - 0 - - - - - gtk-cancel - True - True - True - True - - - False - True - 1 - - - - - gtk-help - True - True - True - True - - - False - True - 2 - True - - - - - False - True - end - 0 - - -- cgit