From 1a57e75bba8c10f0a3fcedace57b746e0fdf1967 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 17 Oct 2019 14:16:21 +0100 Subject: weld ScDataProviderDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drop changing the button colors, every other button is content not to change its color. fix up some crashes while I'm here. Change-Id: Icec54106441810a5152e7dab3ac7d5a55551ab07 Reviewed-on: https://gerrit.libreoffice.org/80994 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/source/ui/inc/dataproviderdlg.hxx | 50 +- sc/source/ui/inc/datatableview.hxx | 11 +- sc/source/ui/miscdlgs/dataproviderdlg.cxx | 832 +++++++-------------- sc/source/ui/miscdlgs/datatableview.cxx | 15 +- sc/source/ui/view/cellsh2.cxx | 6 +- sc/uiconfig/scalc/ui/aggregatefunctionentry.ui | 20 +- sc/uiconfig/scalc/ui/dataproviderdlg.ui | 186 ++++- sc/uiconfig/scalc/ui/dataproviderentry.ui | 23 +- .../scalc/ui/datetimetransformationentry.ui | 20 +- sc/uiconfig/scalc/ui/deletecolumnentry.ui | 20 +- sc/uiconfig/scalc/ui/mergecolumnentry.ui | 20 +- sc/uiconfig/scalc/ui/numbertransformationentry.ui | 20 +- .../scalc/ui/replacenulltransformationentry.ui | 20 +- sc/uiconfig/scalc/ui/sorttransformationentry.ui | 27 +- sc/uiconfig/scalc/ui/splitcolumnentry.ui | 20 +- sc/uiconfig/scalc/ui/texttransformationentry.ui | 20 +- 16 files changed, 645 insertions(+), 665 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx index 441c4929abbb..2cc636973145 100644 --- a/sc/source/ui/inc/dataproviderdlg.hxx +++ b/sc/source/ui/inc/dataproviderdlg.hxx @@ -12,46 +12,48 @@ #include -#include -#include -#include -#include - +#include +#include +#include #include "datatableview.hxx" - #include class ScDocument; class ScDataProviderBaseControl; +class ScDataTransformationBaseControl; class ScDBData; -class ScDataProviderDlg : public ModalDialog +class ScDataProviderDlg : public weld::GenericDialogController { private: - - std::shared_ptr mpDoc; - VclPtr mpTable; - VclPtr mpList; - VclPtr mpBar; - VclPtr mpDataProviderCtrl; - VclPtr mpDBRanges; - sal_uInt32 mpIndex; + std::shared_ptr mxDoc; + std::unique_ptr mxStartMenu; + std::unique_ptr mxColumnMenu; + std::unique_ptr mxBox; + css::uno::Reference m_xTableParent; + VclPtr mxTable; + std::unique_ptr mxScroll; + std::unique_ptr mxList; + std::unique_ptr mxDataProviderCtrl; + std::unique_ptr mxDBRanges; + + std::vector> maControls; + + Idle maIdle; + + sal_uInt32 mnIndex; ScDBData* pDBData; void InitMenu(); - DECL_LINK( StartMenuHdl, Menu*, bool ); - DECL_LINK( ColumnMenuHdl, Menu*, bool ); - DECL_LINK( ImportHdl, Window*, void ); + DECL_LINK( StartMenuHdl, const OString&, void ); + DECL_LINK( ColumnMenuHdl, const OString&, void ); + DECL_LINK( ImportHdl, ScDataProviderBaseControl*, void ); + DECL_LINK( ScrollToEnd, Timer*, void ); public: - - ScDataProviderDlg(vcl::Window* pWindow, std::shared_ptr pDoc, const ScDocument* pDocument); - + ScDataProviderDlg(weld::Window* pWindow, std::shared_ptr pDoc, const ScDocument* pDocument); virtual ~ScDataProviderDlg() override; - virtual void dispose() override; - - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; void applyAndQuit(); void cancelAndQuit(); diff --git a/sc/source/ui/inc/datatableview.hxx b/sc/source/ui/inc/datatableview.hxx index 30d9c0a17c23..690a088368f4 100644 --- a/sc/source/ui/inc/datatableview.hxx +++ b/sc/source/ui/inc/datatableview.hxx @@ -20,8 +20,9 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_DATATABLEVIEW_HXX #define INCLUDED_SC_SOURCE_UI_INC_DATATABLEVIEW_HXX +#include #include - +#include #include #include #include "hdrcont.hxx" @@ -81,6 +82,7 @@ class SC_DLLPUBLIC ScDataTableView : public Control { std::shared_ptr mpDoc; std::unique_ptr mpSelectionEngine; + VclPtr mpTopLeft; VclPtr mpColView; VclPtr mpRowView; VclPtr mpVScroll; @@ -93,12 +95,8 @@ class SC_DLLPUBLIC ScDataTableView : public Control DECL_LINK( ScrollHdl, ScrollBar*, void ); -protected: - - virtual Size GetOptimalSize() const override; - public: - ScDataTableView(vcl::Window* pParent); + ScDataTableView(const css::uno::Reference &rParent); void Init(std::shared_ptr pDoc); @@ -110,6 +108,7 @@ public: virtual void MouseButtonUp(const MouseEvent& rMEvt) override; virtual void Resize() override; virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual Size GetOptimalSize() const override; void getColRange(SCCOL& rStartCol, SCCOL& rEndCol) const; void getRowRange(SCROW& rStartRow, SCROW& rEndRow) const; diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index 4868b560b906..ff58fd04ce9c 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -18,124 +18,77 @@ #include #include #include +#include #include -#include -#include -#include -#include -constexpr int MENU_START = 0; -constexpr int MENU_COLUMN = 1; - -class ScDataProviderBaseControl : public VclContainer, - public VclBuilderContainer +class ScDataProviderBaseControl { - VclPtr maGrid; - VclPtr maProviderList; - VclPtr maEditURL; - VclPtr maEditID; - VclPtr mpApplyBtn; + std::unique_ptr mxBuilder; + std::unique_ptr mxGrid; + std::unique_ptr mxProviderList; + std::unique_ptr mxEditURL; + std::unique_ptr mxEditID; + std::unique_ptr mxApplyBtn; + + OUString msApplyTooltip; - Link const maImportCallback; + Link const maImportCallback; - DECL_LINK(ProviderSelectHdl, ListBox&, void); - DECL_LINK(IDEditHdl, Edit&, void); - DECL_LINK(URLEditHdl, Edit&, void); - DECL_LINK(ApplyBtnHdl, Button*, void); + DECL_LINK(ProviderSelectHdl, weld::ComboBox&, void); + DECL_LINK(IDEditHdl, weld::Entry&, void); + DECL_LINK(URLEditHdl, weld::Entry&, void); + DECL_LINK(ApplyBtnHdl, weld::Button&, void); void updateApplyBtn(bool bValidConfig); public: - ScDataProviderBaseControl(vcl::Window* pParent, const Link& rImportCallback); - ~ScDataProviderBaseControl() override; - - virtual void dispose() override; - virtual void setAllocation(const Size &rAllocation) override; - virtual Size calculateRequisition() const override; + ScDataProviderBaseControl(weld::Container* pParent, const Link& rImportCallback); void isValid(); sc::ExternalDataSource getDataSource(ScDocument* pDoc); }; -ScDataProviderBaseControl::ScDataProviderBaseControl(vcl::Window* pParent, - const Link& rImportCallback): - VclContainer(pParent, WB_CLIPCHILDREN | WB_BORDER), - maImportCallback(rImportCallback) +ScDataProviderBaseControl::ScDataProviderBaseControl(weld::Container* pParent, + const Link& rImportCallback) + : mxBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/dataproviderentry.ui")) + , mxGrid(mxBuilder->weld_container("grid")) + , mxProviderList(mxBuilder->weld_combo_box("provider_lst")) + , mxEditURL(mxBuilder->weld_entry("ed_url")) + , mxEditID(mxBuilder->weld_entry("ed_id")) + , mxApplyBtn(mxBuilder->weld_button("apply")) + , maImportCallback(rImportCallback) { - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "modules/scalc/ui/dataproviderentry.ui")); - - get(maGrid, "grid"); - get(maProviderList, "provider_lst"); - get(maEditURL, "ed_url"); - get(maEditID, "ed_id"); - auto aDataProvider = sc::DataProviderFactory::getDataProviders(); for (const auto& rDataProvider : aDataProvider) { - maProviderList->InsertEntry(rDataProvider); + mxProviderList->append_text(rDataProvider); } - maProviderList->SetSelectHdl(LINK(this, ScDataProviderBaseControl, ProviderSelectHdl)); - maEditID->SetModifyHdl(LINK(this, ScDataProviderBaseControl, IDEditHdl)); - maEditURL->SetModifyHdl(LINK(this, ScDataProviderBaseControl, URLEditHdl)); - - mpApplyBtn = VclPtr::Create(maGrid, WB_FLATBUTTON); - mpApplyBtn->set_grid_top_attach(1); - mpApplyBtn->set_grid_left_attach(5); - mpApplyBtn->SetQuickHelpText("Apply Changes"); - mpApplyBtn->SetControlForeground(COL_GREEN); - mpApplyBtn->SetControlBackground(COL_GREEN); - mpApplyBtn->SetBackground(Wallpaper(COL_LIGHTGREEN)); - mpApplyBtn->SetModeImage(Image(StockImage::Yes, "sc/res/xml_element.png")); - mpApplyBtn->Show(); - mpApplyBtn->SetClickHdl(LINK(this, ScDataProviderBaseControl, ApplyBtnHdl)); - SetSizePixel(GetOptimalSize()); - isValid(); -} - -ScDataProviderBaseControl::~ScDataProviderBaseControl() -{ - disposeOnce(); -} - -void ScDataProviderBaseControl::dispose() -{ - maEditID.clear(); - maEditURL.clear(); - maProviderList.clear(); - mpApplyBtn.disposeAndClear(); - maGrid.clear(); - disposeBuilder(); - VclContainer::dispose(); -} - -Size ScDataProviderBaseControl::calculateRequisition() const -{ - return getLayoutRequisition(*maGrid); -} + mxProviderList->connect_changed(LINK(this, ScDataProviderBaseControl, ProviderSelectHdl)); + mxEditID->connect_changed(LINK(this, ScDataProviderBaseControl, IDEditHdl)); + mxEditURL->connect_changed(LINK(this, ScDataProviderBaseControl, URLEditHdl)); -void ScDataProviderBaseControl::setAllocation(const Size &rAllocation) -{ - setLayoutPosSize(*maGrid, Point(0, 0), rAllocation); + msApplyTooltip = mxApplyBtn->get_tooltip_text(); + mxApplyBtn->connect_clicked(LINK(this, ScDataProviderBaseControl, ApplyBtnHdl)); + isValid(); } void ScDataProviderBaseControl::isValid() { - bool bValid = !maProviderList->GetSelectedEntry().isEmpty(); - bValid &= !maEditURL->GetText().isEmpty(); - Invalidate(); + bool bValid = !mxProviderList->get_active_text().isEmpty(); + bValid &= !mxEditURL->get_text().isEmpty(); updateApplyBtn(bValid); } sc::ExternalDataSource ScDataProviderBaseControl::getDataSource(ScDocument* pDoc) { - OUString aURL = maEditURL->GetText(); - OUString aProvider = maProviderList->GetSelectedEntry(); + OUString aURL = mxEditURL->get_text(); + OUString aProvider = mxProviderList->get_active_text(); sc::ExternalDataSource aSource(aURL, aProvider, pDoc); - OUString aID = maEditID->GetText(); + OUString aID = mxEditID->get_text(); aSource.setID(aID); return aSource; } @@ -144,39 +97,67 @@ void ScDataProviderBaseControl::updateApplyBtn(bool bValidConfig) { if (!bValidConfig) { - mpApplyBtn->Disable(); - mpApplyBtn->SetQuickHelpText(""); + mxApplyBtn->set_sensitive(false); + mxApplyBtn->set_tooltip_text(OUString()); return; } - else - { - mpApplyBtn->Enable(); - mpApplyBtn->SetBackground(Wallpaper(COL_YELLOW)); - mpApplyBtn->SetQuickHelpText("Apply Changes"); - } + + mxApplyBtn->set_sensitive(true); + mxApplyBtn->set_tooltip_text(msApplyTooltip); } -IMPL_LINK_NOARG(ScDataProviderBaseControl, ProviderSelectHdl, ListBox&, void) +IMPL_LINK_NOARG(ScDataProviderBaseControl, ProviderSelectHdl, weld::ComboBox&, void) { isValid(); } -IMPL_LINK_NOARG(ScDataProviderBaseControl, IDEditHdl, Edit&, void) +IMPL_LINK_NOARG(ScDataProviderBaseControl, IDEditHdl, weld::Entry&, void) { isValid(); } -IMPL_LINK_NOARG(ScDataProviderBaseControl, URLEditHdl, Edit&, void) +IMPL_LINK_NOARG(ScDataProviderBaseControl, URLEditHdl, weld::Entry&, void) { isValid(); } -IMPL_LINK_NOARG(ScDataProviderBaseControl, ApplyBtnHdl, Button*, void) +IMPL_LINK_NOARG(ScDataProviderBaseControl, ApplyBtnHdl, weld::Button&, void) { updateApplyBtn(true); maImportCallback.Call(this); } +class ScDataTransformationBaseControl +{ +protected: + std::unique_ptr mxBuilder; + std::unique_ptr mxGrid; + weld::Container* mpContainer; + + sal_uInt32 mnIndex; + +public: + ScDataTransformationBaseControl(weld::Container* pParent, const OUString& rUIFile, sal_uInt32 nIndex); + virtual ~ScDataTransformationBaseControl(); + + void updateIndex(sal_uInt32 nIndex) { mnIndex = nIndex; } + + virtual std::shared_ptr getTransformation() = 0; +}; + +ScDataTransformationBaseControl::ScDataTransformationBaseControl(weld::Container* pParent, const OUString& rUIFile, sal_uInt32 nIndex) + : mxBuilder(Application::CreateBuilder(pParent, rUIFile)) + , mxGrid(mxBuilder->weld_container("grid")) + , mpContainer(pParent) + , mnIndex(nIndex) +{ +} + +ScDataTransformationBaseControl::~ScDataTransformationBaseControl() +{ + mpContainer->move(mxGrid.get(), nullptr); +} + namespace { struct MenuData @@ -203,98 +184,33 @@ MenuData aColumnData[] = { { 8, "Date & Time Transformations", &ScDataProviderDlg::dateTimeTransformation } }; -class ScDataTransformationBaseControl : public VclContainer, - public VclBuilderContainer -{ - VclPtr maGrid; - -public: - ScDataTransformationBaseControl(vcl::Window* pParent, const OUString& rUIFile); - ~ScDataTransformationBaseControl() override; - - virtual void dispose() override; - virtual void setAllocation(const Size &rAllocation) override; - virtual Size calculateRequisition() const override; - - virtual std::shared_ptr getTransformation() = 0; -}; - -ScDataTransformationBaseControl::ScDataTransformationBaseControl(vcl::Window* pParent, const OUString& rUIFile): - VclContainer(pParent, WB_BORDER | WB_CLIPCHILDREN) -{ - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), rUIFile)); - - get(maGrid, "grid"); - SetSizePixel(GetOptimalSize()); -} - -ScDataTransformationBaseControl::~ScDataTransformationBaseControl() -{ - disposeOnce(); -} - -void ScDataTransformationBaseControl::dispose() -{ - maGrid.clear(); - - VclContainer::dispose(); -} - -Size ScDataTransformationBaseControl::calculateRequisition() const -{ - return getLayoutRequisition(*maGrid); -} - -void ScDataTransformationBaseControl::setAllocation(const Size &rAllocation) -{ - setLayoutPosSize(*maGrid, Point(0, 0), rAllocation); -} - class ScDeleteColumnTransformationControl : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - ScDeleteColumnTransformationControl(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScDeleteColumnTransformationControl() override; - - virtual void dispose() override; + ScDeleteColumnTransformationControl(weld::Container* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScDeleteColumnTransformationControl::ScDeleteColumnTransformationControl( - vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/deletecolumnentry.ui") - , maIndex(aIndex) + weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/deletecolumnentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(maColumnNums, "ed_columns"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScDeleteColumnTransformationControl, DeleteHdl)); -} - -ScDeleteColumnTransformationControl::~ScDeleteColumnTransformationControl() -{ - disposeOnce(); -} - -void ScDeleteColumnTransformationControl::dispose() -{ - maColumnNums.clear(); - maDelete.clear(); - - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScDeleteColumnTransformationControl, DeleteHdl)); } std::shared_ptr ScDeleteColumnTransformationControl::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); + OUString aColumnString = mxColumnNums->get_text(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set ColNums; for (const auto& rColStr : aSplitColumns) @@ -316,53 +232,35 @@ std::shared_ptr ScDeleteColumnTransformationControl::get class ScSplitColumnTransformationControl : public ScDataTransformationBaseControl { private: - VclPtr maSeparator; - VclPtr maNumColumns; + std::unique_ptr mxSeparator; + std::unique_ptr mxNumColumns; + std::unique_ptr mxDelete; SCCOL mnCol; - VclPtr maDelete; - sal_uInt32 maIndex; std::function maDeleteTransformation; public: - ScSplitColumnTransformationControl(vcl::Window* pParent, SCCOL nCol, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScSplitColumnTransformationControl() override; - - virtual void dispose() override; + ScSplitColumnTransformationControl(weld::Container* pParent, SCCOL nCol, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScSplitColumnTransformationControl::ScSplitColumnTransformationControl( - vcl::Window* pParent, SCCOL nCol, sal_uInt32 aIndex, + weld::Container* pParent, SCCOL nCol, sal_uInt32 nIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/splitcolumnentry.ui") + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/splitcolumnentry.ui", nIndex) + , mxSeparator(mxBuilder->weld_entry("ed_separator")) + , mxNumColumns(mxBuilder->weld_spin_button("num_cols")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , mnCol(nCol) - , maIndex(aIndex) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(maSeparator, "ed_separator"); - get(maNumColumns, "num_cols"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScSplitColumnTransformationControl, DeleteHdl)); -} - -ScSplitColumnTransformationControl::~ScSplitColumnTransformationControl() -{ - disposeOnce(); -} - -void ScSplitColumnTransformationControl::dispose() -{ - maSeparator.clear(); - maNumColumns.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScSplitColumnTransformationControl, DeleteHdl)); } std::shared_ptr ScSplitColumnTransformationControl::getTransformation() { - OUString aSeparator = maSeparator->GetText(); + OUString aSeparator = mxSeparator->get_text(); sal_Unicode cSeparator = aSeparator.isEmpty() ? ',' : aSeparator[0]; return std::make_shared(mnCol, cSeparator); } @@ -370,34 +268,28 @@ std::shared_ptr ScSplitColumnTransformationControl::getT class ScMergeColumnTransformationControl : public ScDataTransformationBaseControl { private: - - VclPtr mpSeparator; - VclPtr mpEdColumns; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxSeparator; + std::unique_ptr mxEdColumns; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - ScMergeColumnTransformationControl(vcl::Window* pParent, SCCOL nStartCol, SCCOL nEndCol, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScMergeColumnTransformationControl() override; - - virtual void dispose() override; + ScMergeColumnTransformationControl(weld::Container* pParent, SCCOL nStartCol, SCCOL nEndCol, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScMergeColumnTransformationControl::ScMergeColumnTransformationControl( - vcl::Window* pParent, SCCOL nStartCol, SCCOL nEndCol, sal_uInt32 aIndex, + weld::Container* pParent, SCCOL nStartCol, SCCOL nEndCol, sal_uInt32 nIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/mergecolumnentry.ui") - , maIndex(aIndex) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/mergecolumnentry.ui", nIndex) + , mxSeparator(mxBuilder->weld_entry("ed_separator")) + , mxEdColumns(mxBuilder->weld_entry("ed_columns")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(mpSeparator, "ed_separator"); - get(mpEdColumns, "ed_columns"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScMergeColumnTransformationControl, DeleteHdl)); + mxDelete->connect_clicked(LINK(this,ScMergeColumnTransformationControl, DeleteHdl)); OUStringBuffer aBuffer; @@ -408,26 +300,12 @@ ScMergeColumnTransformationControl::ScMergeColumnTransformationControl( aBuffer.append(";").append(OUString::number(nCol + 1)); } - mpEdColumns->SetText(aBuffer.makeStringAndClear()); -} - -ScMergeColumnTransformationControl::~ScMergeColumnTransformationControl() -{ - disposeOnce(); -} - -void ScMergeColumnTransformationControl::dispose() -{ - mpSeparator.clear(); - mpEdColumns.clear(); - maDelete.clear(); - - ScDataTransformationBaseControl::dispose(); + mxEdColumns->set_text(aBuffer.makeStringAndClear()); } std::shared_ptr ScMergeColumnTransformationControl::getTransformation() { - OUString aColumnString = mpEdColumns->GetText(); + OUString aColumnString = mxEdColumns->get_text(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aMergedColumns; for (const auto& rColStr : aSplitColumns) @@ -442,59 +320,39 @@ std::shared_ptr ScMergeColumnTransformationControl::getT // translate from 1-based column notations to internal Calc one aMergedColumns.insert(nCol - 1); } - return std::make_shared(aMergedColumns, mpSeparator->GetText()); + return std::make_shared(aMergedColumns, mxSeparator->get_text()); } class ScSortTransformationControl : public ScDataTransformationBaseControl { private: - - VclPtr mpAscending; - VclPtr mpEdColumns; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxAscending; + std::unique_ptr mxEdColumns; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - ScSortTransformationControl(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScSortTransformationControl() override; - - virtual void dispose() override; + ScSortTransformationControl(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScSortTransformationControl::ScSortTransformationControl( - vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/sorttransformationentry.ui") - , maIndex(aIndex) + weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/sorttransformationentry.ui", nIndex) + , mxAscending(mxBuilder->weld_check_button("ed_ascending")) + , mxEdColumns(mxBuilder->weld_entry("ed_columns")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(mpAscending, "ed_ascending"); - get(mpEdColumns, "ed_columns"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScSortTransformationControl, DeleteHdl)); -} - -ScSortTransformationControl::~ScSortTransformationControl() -{ - disposeOnce(); -} - -void ScSortTransformationControl::dispose() -{ - mpAscending.clear(); - mpEdColumns.clear(); - maDelete.clear(); - - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScSortTransformationControl, DeleteHdl)); } std::shared_ptr ScSortTransformationControl::getTransformation() { - OUString aColStr = mpEdColumns->GetText(); - bool aIsAscending = mpAscending->IsChecked(); + OUString aColStr = mxEdColumns->get_text(); + bool aIsAscending = mxAscending->get_active(); SCCOL aColumn = 0; sal_Int32 nCol = aColStr.toInt32(); if (nCol > 0 && nCol <= MAXCOL) @@ -512,51 +370,32 @@ std::shared_ptr ScSortTransformationControl::getTransfor class ScColumnTextTransformation : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maType; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxType; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - - ScColumnTextTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScColumnTextTransformation() override; - - virtual void dispose() override; + ScColumnTextTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScColumnTextTransformation::ScColumnTextTransformation( - vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/texttransformationentry.ui") - , maIndex(aIndex) + weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/texttransformationentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxType(mxBuilder->weld_combo_box("ed_lst")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(maColumnNums, "ed_columns"); - get(maType, "ed_lst"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScColumnTextTransformation, DeleteHdl)); -} - -ScColumnTextTransformation::~ScColumnTextTransformation() -{ - disposeOnce(); -} - -void ScColumnTextTransformation::dispose() -{ - maColumnNums.clear(); - maType.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScColumnTextTransformation, DeleteHdl)); } std::shared_ptr ScColumnTextTransformation::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); + OUString aColumnString = mxColumnNums->get_text(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aColumns; for (const auto& rColStr : aSplitColumns) @@ -572,7 +411,7 @@ std::shared_ptr ScColumnTextTransformation::getTransform aColumns.insert(nCol - 1); } - sal_Int32 nPos = maType->GetSelectedEntryPos(); + sal_Int32 nPos = mxType->get_active(); switch (nPos) { case 0: @@ -593,52 +432,33 @@ std::shared_ptr ScColumnTextTransformation::getTransform class ScAggregateFunction : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maType; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxType; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - - ScAggregateFunction(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScAggregateFunction() override; - - virtual void dispose() override; + ScAggregateFunction(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; -ScAggregateFunction::ScAggregateFunction(vcl::Window* pParent, sal_uInt32 aIndex, +ScAggregateFunction::ScAggregateFunction(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/aggregatefunctionentry.ui") - , maIndex(aIndex) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/aggregatefunctionentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxType(mxBuilder->weld_combo_box("ed_lst")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(maColumnNums, "ed_columns"); - get(maType, "ed_lst"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScAggregateFunction, DeleteHdl)); -} - -ScAggregateFunction::~ScAggregateFunction() -{ - disposeOnce(); -} - -void ScAggregateFunction::dispose() -{ - maColumnNums.clear(); - maType.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScAggregateFunction, DeleteHdl)); } std::shared_ptr ScAggregateFunction::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); - sal_Int32 nPos = maType->GetSelectedEntryPos(); + OUString aColumnString = mxColumnNums->get_text(); + sal_Int32 nPos = mxType->get_active(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aColumns; for (const auto& rColStr : aSplitColumns) @@ -673,52 +493,33 @@ std::shared_ptr ScAggregateFunction::getTransformation() class ScNumberTransformation : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maType; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxType; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - - ScNumberTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScNumberTransformation() override; - - virtual void dispose() override; + ScNumberTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; ScNumberTransformation::ScNumberTransformation( - vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation) - : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/numbertransformationentry.ui") - , maIndex(aIndex) + weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/numbertransformationentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxType(mxBuilder->weld_combo_box("ed_lst")) + , mxDelete(mxBuilder->weld_button("ed_delete")) , maDeleteTransformation(std::move(aDeleteTransformation)) { - get(maColumnNums, "ed_columns"); - get(maType, "ed_lst"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScNumberTransformation, DeleteHdl)); -} - -ScNumberTransformation::~ScNumberTransformation() -{ - disposeOnce(); -} - -void ScNumberTransformation::dispose() -{ - maColumnNums.clear(); - maType.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScNumberTransformation, DeleteHdl)); } std::shared_ptr ScNumberTransformation::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); - sal_Int32 nPos = maType->GetSelectedEntryPos(); + OUString aColumnString = mxColumnNums->get_text(); + sal_Int32 nPos = mxType->get_active(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aColumns; for (const auto& rColStr : aSplitColumns) @@ -771,51 +572,34 @@ std::shared_ptr ScNumberTransformation::getTransformatio class ScReplaceNullTransformation : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maReplaceString; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxReplaceString; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - ScReplaceNullTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScReplaceNullTransformation() override; - - virtual void dispose() override; + ScReplaceNullTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; -ScReplaceNullTransformation::ScReplaceNullTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation): - ScDataTransformationBaseControl(pParent,"modules/scalc/ui/replacenulltransformationentry.ui"), - maIndex(aIndex), - maDeleteTransformation(aDeleteTransformation) -{ - get(maColumnNums, "ed_columns"); - get(maReplaceString, "ed_str"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScReplaceNullTransformation, DeleteHdl)); -} - -ScReplaceNullTransformation::~ScReplaceNullTransformation() +ScReplaceNullTransformation::ScReplaceNullTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent,"modules/scalc/ui/replacenulltransformationentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxReplaceString(mxBuilder->weld_entry("ed_str")) + , mxDelete(mxBuilder->weld_button("ed_delete")) + , maDeleteTransformation(aDeleteTransformation) { - disposeOnce(); + mxDelete->connect_clicked(LINK(this,ScReplaceNullTransformation, DeleteHdl)); } -void ScReplaceNullTransformation::dispose() -{ - maColumnNums.clear(); - maReplaceString.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); -} std::shared_ptr ScReplaceNullTransformation::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); - OUString aReplaceWithString = maReplaceString->GetText(); + OUString aColumnString = mxColumnNums->get_text(); + OUString aReplaceWithString = mxReplaceString->get_text(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aColumns; for (const auto& rColStr : aSplitColumns) @@ -837,51 +621,33 @@ std::shared_ptr ScReplaceNullTransformation::getTransfor class ScDateTimeTransformation : public ScDataTransformationBaseControl { private: - VclPtr maColumnNums; - VclPtr maType; - VclPtr maDelete; - sal_uInt32 maIndex; + std::unique_ptr mxColumnNums; + std::unique_ptr mxType; + std::unique_ptr mxDelete; std::function maDeleteTransformation; public: - ScDateTimeTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation); - ~ScDateTimeTransformation() override; - - virtual void dispose() override; + ScDateTimeTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation); virtual std::shared_ptr getTransformation() override; - DECL_LINK(DeleteHdl, Button*, void); + DECL_LINK(DeleteHdl, weld::Button&, void); }; -ScDateTimeTransformation::ScDateTimeTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function aDeleteTransformation): - ScDataTransformationBaseControl(pParent,"modules/scalc/ui/datetimetransformationentry.ui"), - maIndex(aIndex), - maDeleteTransformation(aDeleteTransformation) -{ - get(maColumnNums, "ed_columns"); - get(maType, "ed_lst"); - get(maDelete, "ed_delete"); - maDelete->SetClickHdl(LINK(this,ScDateTimeTransformation, DeleteHdl)); -} - -ScDateTimeTransformation::~ScDateTimeTransformation() +ScDateTimeTransformation::ScDateTimeTransformation(weld::Container* pParent, sal_uInt32 nIndex, std::function aDeleteTransformation) + : ScDataTransformationBaseControl(pParent,"modules/scalc/ui/datetimetransformationentry.ui", nIndex) + , mxColumnNums(mxBuilder->weld_entry("ed_columns")) + , mxType(mxBuilder->weld_combo_box("ed_lst")) + , mxDelete(mxBuilder->weld_button("ed_delete")) + , maDeleteTransformation(aDeleteTransformation) { - disposeOnce(); -} - -void ScDateTimeTransformation::dispose() -{ - maColumnNums.clear(); - maType.clear(); - maDelete.clear(); - ScDataTransformationBaseControl::dispose(); + mxDelete->connect_clicked(LINK(this,ScDateTimeTransformation, DeleteHdl)); } std::shared_ptr ScDateTimeTransformation::getTransformation() { - OUString aColumnString = maColumnNums->GetText(); - sal_Int32 nPos = maType->GetSelectedEntryPos(); + OUString aColumnString = mxColumnNums->get_text(); + sal_Int32 nPos = mxType->get_active(); std::vector aSplitColumns = comphelper::string::split(aColumnString, ';'); std::set aColumns; for (const auto& rColStr : aSplitColumns) @@ -943,194 +709,170 @@ std::shared_ptr ScDateTimeTransformation::getTransformat } -ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr pDoc, +ScDataProviderDlg::ScDataProviderDlg(weld::Window* pParent, std::shared_ptr pDoc, const ScDocument* pDocument) - : ModalDialog(pParent, "dataproviderdlg", "modules/scalc/ui/dataproviderdlg.ui") - , mpDoc(std::move(pDoc)) - , mpBar(VclPtr::Create()) -{ - get(mpTable, "data_table"); - get(mpList, "operation_ctrl"); - get(mpDBRanges, "select_db_range"); - mpTable->Init(mpDoc); - mpIndex = 0; + : GenericDialogController(pParent, "modules/scalc/ui/dataproviderdlg.ui", "dataproviderdlg") + , mxDoc(std::move(pDoc)) + , mxStartMenu(m_xBuilder->weld_menu("start")) + , mxColumnMenu(m_xBuilder->weld_menu("column")) + , mxBox(m_xBuilder->weld_container("data_table")) + , m_xTableParent(mxBox->CreateChildFrame()) + , mxTable(VclPtr::Create(m_xTableParent)) + , mxScroll(m_xBuilder->weld_scrolled_window("scroll")) + , mxList(m_xBuilder->weld_container("operation_ctrl")) + , mxDataProviderCtrl(new ScDataProviderBaseControl(mxList.get(), LINK(this, ScDataProviderDlg, ImportHdl))) + , mxDBRanges(m_xBuilder->weld_combo_box("select_db_range")) + , mnIndex(0) +{ + Size aPrefSize = mxTable->GetOptimalSize(); + mxBox->set_size_request(aPrefSize.Width(), aPrefSize.Height()); + mxTable->Show(); + + mxTable->Init(mxDoc); ScDBCollection* pDBCollection = pDocument->GetDBCollection(); auto& rNamedDBs = pDBCollection->getNamedDBs(); for (auto& rNamedDB : rNamedDBs) { - mpDBRanges->InsertEntry(rNamedDB->GetName()); + mxDBRanges->append_text(rNamedDB->GetName()); } - mpDataProviderCtrl = VclPtr::Create(mpList, LINK(this, ScDataProviderDlg, ImportHdl)); - mpList->addEntry(mpDataProviderCtrl); - mpIndex++; pDBData = new ScDBData("data", 0, 0, 0, MAXCOL, MAXROW); - bool bSuccess = mpDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr(pDBData)); + bool bSuccess = mxDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr(pDBData)); SAL_WARN_IF(!bSuccess, "sc", "temporary warning"); InitMenu(); -} -ScDataProviderDlg::~ScDataProviderDlg() -{ - disposeOnce(); + maIdle.SetPriority( TaskPriority::LOWEST ); + maIdle.SetInvokeHandler( LINK( this, ScDataProviderDlg, ScrollToEnd) ); } -void ScDataProviderDlg::dispose() +ScDataProviderDlg::~ScDataProviderDlg() { - mpDataProviderCtrl.clear(); - mpTable.clear(); - mpList.clear(); - mpDBRanges.clear(); - mpBar.disposeAndClear(); - - ModalDialog::dispose(); + mxTable.disposeAndClear(); + m_xTableParent->dispose(); + m_xTableParent.clear(); } void ScDataProviderDlg::InitMenu() { - mpBar->InsertItem(MENU_START, "Start"); - VclPtrInstance pPopup; for (const auto& itrStartData : aStartData) - { - pPopup->InsertItem(itrStartData.nMenuID, OUString::createFromAscii(itrStartData.aMenuName)); - } - - mpBar->SetPopupMenu(MENU_START, pPopup); - pPopup->SetSelectHdl(LINK(this, ScDataProviderDlg, StartMenuHdl)); + mxStartMenu->append(OUString::number(itrStartData.nMenuID), OUString::createFromAscii(itrStartData.aMenuName)); + mxStartMenu->connect_activate(LINK(this, ScDataProviderDlg, StartMenuHdl)); - mpBar->InsertItem(MENU_COLUMN, "Column"); - VclPtrInstance pColumnMenu; for (const auto& itrColumnData : aColumnData) - { - pColumnMenu->InsertItem(itrColumnData.nMenuID, OUString::createFromAscii(itrColumnData.aMenuName)); - } - pColumnMenu->SetSelectHdl(LINK(this, ScDataProviderDlg, ColumnMenuHdl)); - - mpBar->SetPopupMenu(MENU_COLUMN, pColumnMenu); - - SetMenuBar(mpBar.get()); + mxColumnMenu->append(OUString::number(itrColumnData.nMenuID), OUString::createFromAscii(itrColumnData.aMenuName)); + mxColumnMenu->connect_activate(LINK(this, ScDataProviderDlg, ColumnMenuHdl)); } -void ScDataProviderDlg::MouseButtonUp(const MouseEvent& rMEvt) -{ - VclPtr mpText = VclPtr::Create(mpList); - mpText->SetText("Some Text " + OUString::number(rMEvt.GetPosPixel().X()) + "x" + OUString::number(rMEvt.GetPosPixel().getY())); - mpText->SetSizePixel(Size(400, 20)); - mpList->addEntry(mpText); - mpIndex++; -} - -IMPL_LINK(ScDataProviderDlg, StartMenuHdl, Menu*, pMenu, bool) +IMPL_LINK(ScDataProviderDlg, StartMenuHdl, const OString&, rIdent, void) { + auto nId = rIdent.toInt32(); for (auto& i: aStartData) { - if (i.nMenuID == pMenu->GetCurItemId()) + if (i.nMenuID == nId) { i.maCallback(this); - return true; + return; } } - return true; } -IMPL_LINK(ScDataProviderDlg, ColumnMenuHdl, Menu*, pMenu, bool) +IMPL_LINK_NOARG(ScDataProviderDlg, ScrollToEnd, Timer*, void) +{ + mxScroll->vadjustment_set_value(mxScroll->vadjustment_get_upper()); +} + +IMPL_LINK(ScDataProviderDlg, ColumnMenuHdl, const OString&, rIdent, void) { + auto nId = rIdent.toInt32(); for (auto& i: aColumnData) { - if (i.nMenuID == pMenu->GetCurItemId()) + if (i.nMenuID == nId) { i.maCallback(this); - return true; + // scroll to bottom when something added to the list + maIdle.Start(); + return; } } - return true; } -IMPL_LINK(ScDataProviderDlg, ImportHdl, Window*, pCtrl, void) +IMPL_LINK(ScDataProviderDlg, ImportHdl, ScDataProviderBaseControl*, pCtrl, void) { - if (pCtrl == mpDataProviderCtrl.get()) + if (pCtrl == mxDataProviderCtrl.get()) { - import(mpDoc.get(), true); + import(mxDoc.get(), true); } } void ScDataProviderDlg::applyAndQuit() { - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } void ScDataProviderDlg::cancelAndQuit() { - EndDialog(RET_CANCEL); + m_xDialog->response(RET_CANCEL); } void ScDataProviderDlg::deleteColumn() -{ std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pDeleteColumnEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pDeleteColumnEntry); +{ + std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::splitColumn() { SCCOL nStartCol = -1; SCCOL nEndCol = -1; - mpTable->getColRange(nStartCol, nEndCol); + mxTable->getColRange(nStartCol, nEndCol); std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pSplitColumnEntry = VclPtr::Create(mpList, nStartCol, mpIndex++, adeleteTransformation); - mpList->addEntry(pSplitColumnEntry); + maControls.emplace_back(std::make_unique(mxList.get(), nStartCol, mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::mergeColumns() { SCCOL nStartCol = -1; SCCOL nEndCol = -1; - mpTable->getColRange(nStartCol, nEndCol); + mxTable->getColRange(nStartCol, nEndCol); std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pMergeColumnEntry = VclPtr::Create(mpList, nStartCol, nEndCol, mpIndex++, adeleteTransformation); - mpList->addEntry(pMergeColumnEntry); + maControls.emplace_back(std::make_unique(mxList.get(), nStartCol, nEndCol, mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::textTransformation() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pTextTransforamtionEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pTextTransforamtionEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::sortTransformation() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pSortTransforamtionEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pSortTransforamtionEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::aggregateFunction() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pAggregateFuntionEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pAggregateFuntionEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::numberTransformation() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pNumberTransformationEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pNumberTransformationEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::replaceNullTransformation() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pReplaceNullTransformationEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pReplaceNullTransformationEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } void ScDataProviderDlg::dateTimeTransformation() { std::function adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1); - VclPtr pDateTimeTransformationEntry = VclPtr::Create(mpList, mpIndex++, adeleteTransformation); - mpList->addEntry(pDateTimeTransformationEntry); + maControls.emplace_back(std::make_unique(mxList.get(), mnIndex++, adeleteTransformation)); } namespace { @@ -1147,79 +889,79 @@ bool hasDBName(const OUString& rName, ScDBCollection* pDBCollection) void ScDataProviderDlg::import(ScDocument* pDoc, bool bInternal) { - sc::ExternalDataSource aSource = mpDataProviderCtrl->getDataSource(pDoc); + sc::ExternalDataSource aSource = mxDataProviderCtrl->getDataSource(pDoc); - std::vector> aListEntries = mpList->getEntries(); - for (size_t i = 1; i < aListEntries.size(); ++i) + for (size_t i = 0; i < maControls.size(); ++i) { - ScDataTransformationBaseControl* pTransformationCtrl = dynamic_cast(aListEntries[i].get()); - if (!pTransformationCtrl) - { - SAL_WARN("sc", "all children except the provider should inherit from the base control"); - continue; - } + ScDataTransformationBaseControl* pTransformationCtrl = maControls[i].get(); aSource.AddDataTransformation(pTransformationCtrl->getTransformation()); } if (bInternal) aSource.setDBData(pDBData->GetName()); else { - aSource.setDBData(mpDBRanges->GetSelectedEntry()); + aSource.setDBData(mxDBRanges->get_active_text()); if (!hasDBName(aSource.getDBName(), pDoc->GetDBCollection())) return; pDoc->GetExternalDataMapper().insertDataSource(aSource); } aSource.refresh(pDoc, true); - mpTable->Invalidate(); + mxTable->Invalidate(); } void ScDataProviderDlg::deletefromList(sal_uInt32 nIndex) { - mpList->deleteEntry(nIndex); + auto itr = maControls.erase(maControls.begin() + nIndex); + while (itr != maControls.end()) + { + (*itr)->updateIndex(nIndex++); + ++itr; + } + --mnIndex; } -IMPL_LINK_NOARG(ScDeleteColumnTransformationControl, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScDeleteColumnTransformationControl, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScSplitColumnTransformationControl, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScSplitColumnTransformationControl, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScMergeColumnTransformationControl, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScMergeColumnTransformationControl, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScNumberTransformation, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScNumberTransformation, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScAggregateFunction, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScAggregateFunction, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScSortTransformationControl, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScSortTransformationControl, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScColumnTextTransformation, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScColumnTextTransformation, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScReplaceNullTransformation, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScReplaceNullTransformation, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } -IMPL_LINK_NOARG(ScDateTimeTransformation, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(ScDateTimeTransformation, DeleteHdl, weld::Button&, void) { - maDeleteTransformation(maIndex); + maDeleteTransformation(mnIndex); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/miscdlgs/datatableview.cxx b/sc/source/ui/miscdlgs/datatableview.cxx index 4e8c8bc21cbd..6d08630d009f 100644 --- a/sc/source/ui/miscdlgs/datatableview.cxx +++ b/sc/source/ui/miscdlgs/datatableview.cxx @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -139,9 +139,10 @@ void ScDataTableRowView::HideEntries(SCCOLROW nPos, SCCOLROW nEndPos) } } -ScDataTableView::ScDataTableView(vcl::Window* pParent): - Control(pParent), +ScDataTableView::ScDataTableView(const css::uno::Reference &rParent) : + Control(VCLUnoHelper::GetWindow(rParent)), mpSelectionEngine(new SelectionEngine(this)), + mpTopLeft(VclPtr::Create(this, WB_SIZEABLE)), mpColView(VclPtr::Create(this, mpSelectionEngine.get())), mpRowView(VclPtr::Create(this, mpSelectionEngine.get())), mpVScroll(VclPtr::Create(this, WinBits(WB_VSCROLL | WB_DRAG))), @@ -149,6 +150,7 @@ ScDataTableView::ScDataTableView(vcl::Window* pParent): mnFirstVisibleRow(0), mnFirstVisibleCol(0) { + mpTopLeft->setPosSizePixel(0, 0, nRowHeaderWidth, nColHeaderHeight); mpColView->setPosSizePixel(nRowHeaderWidth, 0, nRowHeaderWidth, nColHeaderHeight); mpRowView->setPosSizePixel(0, nColHeaderHeight, nRowHeaderWidth, nColHeaderHeight); @@ -160,6 +162,7 @@ ScDataTableView::ScDataTableView(vcl::Window* pParent): mpHScroll->SetRangeMax(50); mpHScroll->SetEndScrollHdl(LINK(this, ScDataTableView, ScrollHdl)); + mpTopLeft->Show(); mpColView->Show(); mpRowView->Show(); mpVScroll->Show(); @@ -173,8 +176,6 @@ void ScDataTableView::Init(std::shared_ptr pDoc) mpRowView->Init(mpDoc.get()); } -VCL_BUILDER_FACTORY(ScDataTableView) - ScDataTableView::~ScDataTableView() { disposeOnce(); @@ -182,6 +183,7 @@ ScDataTableView::~ScDataTableView() void ScDataTableView::dispose() { + mpTopLeft.disposeAndClear(); mpColView.disposeAndClear(); mpRowView.disposeAndClear(); mpVScroll.disposeAndClear(); @@ -263,6 +265,7 @@ void ScDataTableView::MouseButtonUp(const MouseEvent& rMEvt) void ScDataTableView::Resize() { Size aSize = GetSizePixel(); + mpTopLeft->setPosSizePixel(0, 0, nRowHeaderWidth, nColHeaderHeight); mpColView->setPosSizePixel(nRowHeaderWidth, 0, aSize.Width() - nScrollBarSize, nColHeaderHeight); mpRowView->setPosSizePixel(0, nColHeaderHeight, nRowHeaderWidth, aSize.Height()); @@ -292,7 +295,7 @@ void ScDataTableView::Paint(vcl::RenderContext& rRenderContext, const tools::Rec Size ScDataTableView::GetOptimalSize() const { - return Size(600, 200); + return Size(600, 400); } void ScDataTableView::getColRange(SCCOL& rStartCol, SCCOL& rEndCol) const diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 3e9cb3d4ae88..1a886fa3e3c0 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -796,10 +796,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) std::shared_ptr xDoc(new ScDocument, o3tl::default_delete()); xDoc->InsertTab(0, "test"); ScDocument* pDoc = GetViewData()->GetDocument(); - ScopedVclPtrInstance< ScDataProviderDlg > aDialog( pTabViewShell->GetLegacyDialogParent(), xDoc, pDoc); - if (aDialog->Execute() == RET_OK) + ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, pDoc); + if (aDialog.run() == RET_OK) { - aDialog->import(pDoc); + aDialog.import(pDoc); } } break; diff --git a/sc/uiconfig/scalc/ui/aggregatefunctionentry.ui b/sc/uiconfig/scalc/ui/aggregatefunctionentry.ui index defe0bac76b6..369061d2d051 100644 --- a/sc/uiconfig/scalc/ui/aggregatefunctionentry.ui +++ b/sc/uiconfig/scalc/ui/aggregatefunctionentry.ui @@ -1,5 +1,5 @@ - + @@ -101,16 +101,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/dataproviderdlg.ui b/sc/uiconfig/scalc/ui/dataproviderdlg.ui index ead166b83cf2..e8774906ed14 100644 --- a/sc/uiconfig/scalc/ui/dataproviderdlg.ui +++ b/sc/uiconfig/scalc/ui/dataproviderdlg.ui @@ -1,60 +1,89 @@ - + - - + False + True + dialog + + + - True False - - - True + vertical + 2 + + False + end + + + + + + False - True + False 0 - + True False - vertical - + True False - - + _Start + True + + True False - Database Range: - - - - - 0 - 0 - - - + + + + + True + False + _Column + True + + True False - - - - - 1 - 0 - + + + + + + False + True + 0 + + + + + True + False + True + True + + + True + False + True + True + + @@ -64,9 +93,93 @@ - + True False + vertical + + + True + False + + + True + False + Database Range: + + + + + + 0 + 0 + + + + + True + False + + + + + + 1 + 0 + + + + + False + True + 0 + + + + + True + True + True + never + in + + + True + False + True + + + True + False + True + vertical + + + True + False + True + vertical + + + + + + False + True + 0 + + + + + + + + + False + True + 1 + + False @@ -74,23 +187,14 @@ 1 - - - False True - 1 + 2 - - - - - - diff --git a/sc/uiconfig/scalc/ui/dataproviderentry.ui b/sc/uiconfig/scalc/ui/dataproviderentry.ui index 25257a267a9b..68c523df36b3 100644 --- a/sc/uiconfig/scalc/ui/dataproviderentry.ui +++ b/sc/uiconfig/scalc/ui/dataproviderentry.ui @@ -1,7 +1,12 @@ - + + + True + False + sc/res/xml_element.png + True False @@ -10,7 +15,7 @@ 6 12 - + True False @@ -73,7 +78,19 @@ - + + True + True + True + Apply Changes + image1 + none + True + + + 4 + 1 + diff --git a/sc/uiconfig/scalc/ui/datetimetransformationentry.ui b/sc/uiconfig/scalc/ui/datetimetransformationentry.ui index f32de1922c08..69e206c2ff5c 100644 --- a/sc/uiconfig/scalc/ui/datetimetransformationentry.ui +++ b/sc/uiconfig/scalc/ui/datetimetransformationentry.ui @@ -1,5 +1,5 @@ - + @@ -115,16 +115,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/deletecolumnentry.ui b/sc/uiconfig/scalc/ui/deletecolumnentry.ui index b844793b16f6..7b09d558347b 100644 --- a/sc/uiconfig/scalc/ui/deletecolumnentry.ui +++ b/sc/uiconfig/scalc/ui/deletecolumnentry.ui @@ -1,5 +1,5 @@ - + @@ -60,16 +60,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/mergecolumnentry.ui b/sc/uiconfig/scalc/ui/mergecolumnentry.ui index 35b0efc1d5bf..c5afab6feb8c 100644 --- a/sc/uiconfig/scalc/ui/mergecolumnentry.ui +++ b/sc/uiconfig/scalc/ui/mergecolumnentry.ui @@ -1,5 +1,5 @@ - + @@ -81,16 +81,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/numbertransformationentry.ui b/sc/uiconfig/scalc/ui/numbertransformationentry.ui index 9e6a9afc44cc..5f0e395dd0bc 100644 --- a/sc/uiconfig/scalc/ui/numbertransformationentry.ui +++ b/sc/uiconfig/scalc/ui/numbertransformationentry.ui @@ -1,5 +1,5 @@ - + @@ -110,16 +110,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui b/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui index 050e8a602b90..816c711b5c13 100644 --- a/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui +++ b/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui @@ -1,5 +1,5 @@ - + @@ -93,16 +93,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/sorttransformationentry.ui b/sc/uiconfig/scalc/ui/sorttransformationentry.ui index 7f7d41cf614c..dbf93d6fec58 100644 --- a/sc/uiconfig/scalc/ui/sorttransformationentry.ui +++ b/sc/uiconfig/scalc/ui/sorttransformationentry.ui @@ -1,5 +1,5 @@ - + @@ -32,9 +32,11 @@ False - True Ascending Order + True True + False + False 1 @@ -68,6 +70,9 @@ 1 + + + False @@ -77,16 +82,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/splitcolumnentry.ui b/sc/uiconfig/scalc/ui/splitcolumnentry.ui index c97ff0d9d9ce..137492797c8a 100644 --- a/sc/uiconfig/scalc/ui/splitcolumnentry.ui +++ b/sc/uiconfig/scalc/ui/splitcolumnentry.ui @@ -1,5 +1,5 @@ - + @@ -85,16 +85,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 diff --git a/sc/uiconfig/scalc/ui/texttransformationentry.ui b/sc/uiconfig/scalc/ui/texttransformationentry.ui index c9ae6b0ddcfe..702196356b0b 100644 --- a/sc/uiconfig/scalc/ui/texttransformationentry.ui +++ b/sc/uiconfig/scalc/ui/texttransformationentry.ui @@ -1,5 +1,5 @@ - + @@ -101,16 +101,28 @@ + Cancel True True - Cancel + False - 1 - 1 + False + True + 2 + + 0 + 1 + + + + + True + False + 0 0 -- cgit