From 810cfc0106ae0b1874681f7a8c79c36186aefcca Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 2 Mar 2018 16:28:51 +0000 Subject: weld convert text-to-table/table-to-text dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I81137c0fe0b0e243ebc5b836ac09448d746b2214 Reviewed-on: https://gerrit.libreoffice.org/50644 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/ui/dialog/swdlgfact.cxx | 10 +- sw/source/ui/dialog/swdlgfact.hxx | 9 +- sw/source/ui/table/convert.cxx | 177 +++++++++++++---------------- sw/source/uibase/inc/convert.hxx | 53 +++++---- sw/uiconfig/swriter/ui/converttexttable.ui | 86 +++++++------- 5 files changed, 161 insertions(+), 174 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index ecb89281d7fd..a2999ec607dd 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -98,7 +98,10 @@ short AbstractSwBreakDlg_Impl::Execute() return m_xDlg->run(); } IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); -IMPL_ABSTDLG_BASE(AbstractSwConvertTableDlg_Impl); +short AbstractSwConvertTableDlg_Impl::Execute() +{ + return m_xDlg->run(); +} IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl); IMPL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSwLabDlg_Impl); @@ -215,7 +218,7 @@ sal_uInt16 AbstractSwBreakDlg_Impl:: GetKind() void AbstractSwConvertTableDlg_Impl::GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, SwTableAutoFormat const*& prTAFormat) { - pDlg->GetValues(rDelim,rInsTableFlags, prTAFormat); + m_xDlg->GetValues(rDelim,rInsTableFlags, prTAFormat); } void AbstractSwInsertDBColAutoPilot_Impl::DataToDoc( const uno::Sequence< uno::Any >& rSelection, @@ -702,8 +705,7 @@ VclPtr SwAbstractDialogFactory_Impl::CreateSwCharDlg(vcl: VclPtr SwAbstractDialogFactory_Impl::CreateSwConvertTableDlg(SwView& rView, bool bToTable) { - VclPtr pDlg = VclPtr::Create(rView, bToTable); - return VclPtr::Create(pDlg); + return VclPtr::Create(new SwConvertTableDlg(rView, bToTable)); } VclPtr SwAbstractDialogFactory_Impl::CreateSwCaptionDialog ( vcl::Window *pParent, SwView &rV) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index becab7e73700..6c0418ecdf6d 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -149,7 +149,14 @@ private: class AbstractSwConvertTableDlg_Impl : public AbstractSwConvertTableDlg { - DECL_ABSTDLG_BASE( AbstractSwConvertTableDlg_Impl,SwConvertTableDlg) +protected: + std::unique_ptr m_xDlg; +public: + explicit AbstractSwConvertTableDlg_Impl(SwConvertTableDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual void GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, SwTableAutoFormat const*& prTAFormat) override; }; diff --git a/sw/source/ui/table/convert.cxx b/sw/source/ui/table/convert.cxx index 6b918a59beae..f6df42e9c9bd 100644 --- a/sw/source/ui/table/convert.cxx +++ b/sw/source/ui/table/convert.cxx @@ -46,21 +46,21 @@ void SwConvertTableDlg::GetValues( sal_Unicode& rDelim, SwInsertTableOptions& rInsTableOpts, SwTableAutoFormat const*& prTAFormat ) { - if( mpTabBtn->IsChecked() ) + if (m_xTabBtn->get_active()) { //0x0b mustn't be set when re-converting table into text - bIsKeepColumn = !mpKeepColumn->IsVisible() || mpKeepColumn->IsChecked(); + bIsKeepColumn = !m_xKeepColumn->get_visible() || m_xKeepColumn->get_active(); rDelim = bIsKeepColumn ? 0x09 : 0x0b; nSaveButtonState = 0; } - else if( mpSemiBtn->IsChecked() ) + else if (m_xSemiBtn->get_active()) { rDelim = ';'; nSaveButtonState = 1; } - else if( mpOtherBtn->IsChecked() && !mpOtherEd->GetText().isEmpty() ) + else if (m_xOtherBtn->get_active() && !m_xOtherEd->get_text().isEmpty()) { - uOther = mpOtherEd->GetText()[0]; + uOther = m_xOtherEd->get_text()[0]; rDelim = uOther; nSaveButtonState = 3; } @@ -68,7 +68,7 @@ void SwConvertTableDlg::GetValues( sal_Unicode& rDelim, { nSaveButtonState = 2; rDelim = cParaDelim; - if(mpOtherBtn->IsChecked()) + if (m_xOtherBtn->get_active()) { nSaveButtonState = 3; uOther = 0; @@ -76,15 +76,15 @@ void SwConvertTableDlg::GetValues( sal_Unicode& rDelim, } sal_uInt16 nInsMode = 0; - if (mpBorderCB->IsChecked()) + if (m_xBorderCB->get_active()) nInsMode |= tabopts::DEFAULT_BORDER; - if (mpHeaderCB->IsChecked()) + if (m_xHeaderCB->get_active()) nInsMode |= tabopts::HEADLINE; - if (mpRepeatHeaderCB->IsEnabled() && mpRepeatHeaderCB->IsChecked()) - rInsTableOpts.mnRowsToRepeat = sal_uInt16( mpRepeatHeaderNF->GetValue() ); + if (m_xRepeatHeaderCB->get_sensitive() && m_xRepeatHeaderCB->get_active()) + rInsTableOpts.mnRowsToRepeat = m_xRepeatHeaderNF->get_value(); else rInsTableOpts.mnRowsToRepeat = 0; - if (!mpDontSplitCB->IsChecked()) + if (!m_xDontSplitCB->get_active()) nInsMode |= tabopts::SPLIT_LAYOUT; if (mxTAutoFormat) @@ -93,65 +93,69 @@ void SwConvertTableDlg::GetValues( sal_Unicode& rDelim, rInsTableOpts.mnInsMode = nInsMode; } -SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable ) - : SfxModalDialog(&rView.GetViewFrame()->GetWindow(), "ConvertTextTableDialog", "modules/swriter/ui/converttexttable.ui" ) +SwConvertTableDlg::SwConvertTableDlg(SwView& rView, bool bToTable) + : m_xBuilder(Application::CreateBuilder(rView.GetViewFrame()->GetWindow().GetFrameWeld(), "modules/swriter/ui/converttexttable.ui")) + , m_xDialog(m_xBuilder->weld_dialog("ConvertTextTableDialog")) + , m_xTabBtn(m_xBuilder->weld_radio_button("tabs")) + , m_xSemiBtn(m_xBuilder->weld_radio_button("semicolons")) + , m_xParaBtn(m_xBuilder->weld_radio_button("paragraph")) + , m_xOtherBtn(m_xBuilder->weld_radio_button("other")) + , m_xOtherEd(m_xBuilder->weld_entry("othered")) + , m_xKeepColumn(m_xBuilder->weld_check_button("keepcolumn")) + , m_xOptions(m_xBuilder->weld_container("options")) + , m_xHeaderCB(m_xBuilder->weld_check_button("headingcb")) + , m_xRepeatHeaderCB(m_xBuilder->weld_check_button("repeatheading")) + , m_xRepeatRows(m_xBuilder->weld_container("repeatrows")) + , m_xRepeatHeaderNF(m_xBuilder->weld_spin_button("repeatheadersb")) + , m_xDontSplitCB(m_xBuilder->weld_check_button("dontsplitcb")) + , m_xBorderCB(m_xBuilder->weld_check_button("bordercb")) + , m_xAutoFormatBtn(m_xBuilder->weld_button("autofmt")) , sConvertTextTable(SwResId(STR_CONVERT_TEXT_TABLE)) , pShell(&rView.GetWrtShell()) { - get(mpTabBtn, "tabs"); - get(mpSemiBtn, "semicolons"); - get(mpParaBtn, "paragraph"); - get(mpOtherBtn, "other"); - get(mpOtherEd, "othered"); - get(mpKeepColumn, "keepcolumn"); - get(mpOptions, "options"); - get(mpHeaderCB, "headingcb"); - get(mpRepeatHeaderCB, "repeatheading"); - get(mpRepeatRows, "repeatrows"); - get(mpRepeatHeaderNF, "repeatheadersb"); - get(mpDontSplitCB, "dontsplitcb"); - get(mpBorderCB, "bordercb"); - get(mpAutoFormatBtn, "autofmt"); - - if(nSaveButtonState > -1) + if (nSaveButtonState > -1) { switch (nSaveButtonState) { case 0: - mpTabBtn->Check(); - mpKeepColumn->Check(bIsKeepColumn); - break; - case 1: mpSemiBtn->Check();break; - case 2: mpParaBtn->Check();break; + m_xTabBtn->set_active(true); + m_xKeepColumn->set_active(bIsKeepColumn); + break; + case 1: + m_xSemiBtn->set_active(true); + break; + case 2: + m_xParaBtn->set_active(true); + break; case 3: - mpOtherBtn->Check(); - if(uOther) - mpOtherEd->SetText(OUString(uOther)); + m_xOtherBtn->set_active(true); + if (uOther) + m_xOtherEd->set_text(OUString(uOther)); break; } } if( bToTable ) { - SetText( sConvertTextTable ); - mpAutoFormatBtn->SetClickHdl(LINK(this, SwConvertTableDlg, AutoFormatHdl)); - mpAutoFormatBtn->Show(); - mpKeepColumn->Show(); - mpKeepColumn->Enable( mpTabBtn->IsChecked() ); + m_xDialog->set_title(sConvertTextTable); + m_xAutoFormatBtn->connect_clicked(LINK(this, SwConvertTableDlg, AutoFormatHdl)); + m_xAutoFormatBtn->show(); + m_xKeepColumn->show(); + m_xKeepColumn->set_sensitive(m_xTabBtn->get_active()); } else { //hide insert options - mpOptions->Hide(); + m_xOptions->hide(); } - mpKeepColumn->SaveValue(); + m_xKeepColumn->save_state(); - Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) ); - mpTabBtn->SetClickHdl( aLk ); - mpSemiBtn->SetClickHdl( aLk ); - mpParaBtn->SetClickHdl( aLk ); - mpOtherBtn->SetClickHdl(aLk ); - mpOtherEd->Enable( mpOtherBtn->IsChecked() ); + Link aLk( LINK(this, SwConvertTableDlg, BtnHdl) ); + m_xTabBtn->connect_clicked(aLk); + m_xSemiBtn->connect_clicked(aLk); + m_xParaBtn->connect_clicked(aLk); + m_xOtherBtn->connect_clicked(aLk); + m_xOtherEd->set_sensitive(m_xOtherBtn->get_active()); const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); @@ -160,77 +164,52 @@ SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable ) SwInsertTableOptions aInsOpts = pModOpt->GetInsTableFlags(bHTMLMode); sal_uInt16 nInsTableFlags = aInsOpts.mnInsMode; - mpHeaderCB->Check( 0 != (nInsTableFlags & tabopts::HEADLINE) ); - mpRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0); - mpDontSplitCB->Check( 0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT)); - mpBorderCB->Check( 0!= (nInsTableFlags & tabopts::DEFAULT_BORDER) ); - - mpHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, CheckBoxHdl)); - mpRepeatHeaderCB->SetClickHdl(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)); - ReapeatHeaderCheckBoxHdl(nullptr); - CheckBoxHdl(nullptr); -} + m_xHeaderCB->set_active(0 != (nInsTableFlags & tabopts::HEADLINE)); + m_xRepeatHeaderCB->set_active(aInsOpts.mnRowsToRepeat > 0); + m_xDontSplitCB->set_active(0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT)); + m_xBorderCB->set_active(0!= (nInsTableFlags & tabopts::DEFAULT_BORDER)); -SwConvertTableDlg:: ~SwConvertTableDlg() -{ - disposeOnce(); -} - -void SwConvertTableDlg::dispose() -{ - mxTAutoFormat.reset(); - mpTabBtn.clear(); - mpSemiBtn.clear(); - mpParaBtn.clear(); - mpOtherBtn.clear(); - mpOtherEd.clear(); - mpKeepColumn.clear(); - mpOptions.clear(); - mpHeaderCB.clear(); - mpRepeatHeaderCB.clear(); - mpRepeatRows.clear(); - mpRepeatHeaderNF.clear(); - mpDontSplitCB.clear(); - mpBorderCB.clear(); - mpAutoFormatBtn.clear(); - SfxModalDialog::dispose(); + m_xHeaderCB->connect_clicked(LINK(this, SwConvertTableDlg, CheckBoxHdl)); + m_xRepeatHeaderCB->connect_clicked(LINK(this, SwConvertTableDlg, ReapeatHeaderCheckBoxHdl)); + ReapeatHeaderCheckBoxHdl(*m_xRepeatHeaderCB); + CheckBoxHdl(*m_xHeaderCB); } -IMPL_LINK( SwConvertTableDlg, AutoFormatHdl, Button*, pButton, void ) +IMPL_LINK_NOARG(SwConvertTableDlg, AutoFormatHdl, weld::Button&, void) { SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - ScopedVclPtr pDlg(pFact->CreateSwAutoFormatDlg(pButton->GetFrameWeld(), pShell, false, mxTAutoFormat.get())); + ScopedVclPtr pDlg(pFact->CreateSwAutoFormatDlg(m_xDialog.get(), pShell, false, mxTAutoFormat.get())); OSL_ENSURE(pDlg, "Dialog creation failed!"); if (RET_OK == pDlg->Execute()) mxTAutoFormat.reset(pDlg->FillAutoFormatOfIndex()); } -IMPL_LINK( SwConvertTableDlg, BtnHdl, Button*, pButton, void ) +IMPL_LINK(SwConvertTableDlg, BtnHdl, weld::Button&, rButton, void) { - if( pButton == mpTabBtn ) - mpKeepColumn->SetState( mpKeepColumn->GetSavedValue() ); + if (&rButton == m_xTabBtn.get()) + m_xKeepColumn->set_state(m_xKeepColumn->get_saved_state()); else { - if( mpKeepColumn->IsEnabled() ) - mpKeepColumn->SaveValue(); - mpKeepColumn->Check(); + if (m_xKeepColumn->get_sensitive()) + m_xKeepColumn->save_state(); + m_xKeepColumn->set_active(true); } - mpKeepColumn->Enable( mpTabBtn->IsChecked() ); - mpOtherEd->Enable( mpOtherBtn->IsChecked() ); + m_xKeepColumn->set_sensitive(m_xTabBtn->get_active()); + m_xOtherEd->set_sensitive(m_xOtherBtn->get_active()); } -IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl, Button*, void) +IMPL_LINK_NOARG(SwConvertTableDlg, CheckBoxHdl, weld::Button&, void) { - mpRepeatHeaderCB->Enable(mpHeaderCB->IsChecked()); - ReapeatHeaderCheckBoxHdl(nullptr); + m_xRepeatHeaderCB->set_sensitive(m_xHeaderCB->get_active()); + ReapeatHeaderCheckBoxHdl(*m_xRepeatHeaderCB); } -IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl, Button*, void) +IMPL_LINK_NOARG(SwConvertTableDlg, ReapeatHeaderCheckBoxHdl, weld::Button&, void) { - bool bEnable = mpHeaderCB->IsChecked() && mpRepeatHeaderCB->IsChecked(); - mpRepeatRows->Enable(bEnable); + bool bEnable = m_xHeaderCB->get_active() && m_xRepeatHeaderCB->get_active(); + m_xRepeatRows->set_sensitive(bEnable); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/convert.hxx b/sw/source/uibase/inc/convert.hxx index 15fc35be7ab8..6ae9a8e699c9 100644 --- a/sw/source/uibase/inc/convert.hxx +++ b/sw/source/uibase/inc/convert.hxx @@ -19,52 +19,51 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_CONVERT_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_CONVERT_HXX -#include -#include -#include -#include +#include class VclContainer; class SwTableAutoFormat; class SwView; class SwWrtShell; -class NumericField; struct SwInsertTableOptions; -class SwConvertTableDlg: public SfxModalDialog +class SwConvertTableDlg { - VclPtr mpTabBtn; - VclPtr mpSemiBtn; - VclPtr mpParaBtn; - VclPtr mpOtherBtn; - VclPtr mpOtherEd; - VclPtr mpKeepColumn; + std::unique_ptr m_xBuilder; + std::unique_ptr m_xDialog; - VclPtr mpOptions; + std::unique_ptr m_xTabBtn; + std::unique_ptr m_xSemiBtn; + std::unique_ptr m_xParaBtn; + std::unique_ptr m_xOtherBtn; + std::unique_ptr m_xOtherEd; + std::unique_ptr m_xKeepColumn; - VclPtr mpHeaderCB; - VclPtr mpRepeatHeaderCB; + std::unique_ptr m_xOptions; - VclPtr mpRepeatRows; - VclPtr mpRepeatHeaderNF; + std::unique_ptr m_xHeaderCB; + std::unique_ptr m_xRepeatHeaderCB; - VclPtr mpDontSplitCB; - VclPtr mpBorderCB; - VclPtr mpAutoFormatBtn; + std::unique_ptr m_xRepeatRows; + std::unique_ptr m_xRepeatHeaderNF; + + std::unique_ptr m_xDontSplitCB; + std::unique_ptr m_xBorderCB; + std::unique_ptr m_xAutoFormatBtn; OUString sConvertTextTable; std::unique_ptr mxTAutoFormat; SwWrtShell* pShell; - DECL_LINK( AutoFormatHdl, Button*, void ); - DECL_LINK( BtnHdl, Button*, void ); - DECL_LINK( CheckBoxHdl, Button*, void ); - DECL_LINK( ReapeatHeaderCheckBoxHdl, Button*, void ); + DECL_LINK(AutoFormatHdl, weld::Button&, void); + DECL_LINK(BtnHdl, weld::Button&, void); + DECL_LINK(CheckBoxHdl, weld::Button&, void); + DECL_LINK(ReapeatHeaderCheckBoxHdl, weld::Button&, void); public: - SwConvertTableDlg( SwView& rView, bool bToTable ); - virtual ~SwConvertTableDlg() override; - virtual void dispose() override; + SwConvertTableDlg(SwView& rView, bool bToTable); + + short run() { return m_xDialog->run(); } void GetValues( sal_Unicode& rDelim, SwInsertTableOptions& rInsTableOpts, diff --git a/sw/uiconfig/swriter/ui/converttexttable.ui b/sw/uiconfig/swriter/ui/converttexttable.ui index 03f0b1b0ecc0..1418ba60f376 100644 --- a/sw/uiconfig/swriter/ui/converttexttable.ui +++ b/sw/uiconfig/swriter/ui/converttexttable.ui @@ -1,7 +1,7 @@ - + - + 1 1000 @@ -14,6 +14,8 @@ 6 Convert Table to Text True + 0 + 0 dialog @@ -106,43 +108,19 @@ 6 12 - - True - True - - 1 - , - - - - - - Symbol - - - - - 2 - 1 - - - - - Other: + + Tabs True True False - end + half 0 + True True - tabs - - - - 1 - 1 + 0 + 0 @@ -151,7 +129,6 @@ True True False - end 0 True tabs @@ -168,7 +145,6 @@ True True False - end 0 True tabs @@ -179,21 +155,43 @@ - - Tabs + + Other: True True False - start - end - half 0 - True True + tabs + + + - 0 - 0 + 1 + 1 + + + + + True + True + 1 + 1 + 1 + , + + + + + + Symbol + + + + + 2 + 1 @@ -344,7 +342,6 @@ True True - out 1 adjustment1 @@ -407,5 +404,8 @@ cancel help + + + -- cgit v1.2.3