From 338e562639f947f9aa5fcd7340fe87a57b0f3601 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 11 Mar 2019 14:55:23 +0000 Subject: weld ScAutoFormatDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I700034eefe9fb25ee331645283bd3611c88faf5b Reviewed-on: https://gerrit.libreoffice.org/69052 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/inc/scabstdlg.hxx | 2 +- sc/qa/uitest/calc_tests6/autoFormat.py | 10 +- sc/source/ui/attrdlg/scdlgfact.cxx | 17 ++- sc/source/ui/attrdlg/scdlgfact.hxx | 10 +- sc/source/ui/inc/autofmt.hxx | 12 +- sc/source/ui/inc/scuiautofmt.hxx | 49 +++---- sc/source/ui/miscdlgs/autofmt.cxx | 40 +++--- sc/source/ui/miscdlgs/scuiautofmt.cxx | 215 ++++++++++++++--------------- sc/source/ui/view/cellsh3.cxx | 4 +- sc/uiconfig/scalc/ui/autoformattable.ui | 235 ++++++++++++++++++-------------- 10 files changed, 310 insertions(+), 284 deletions(-) (limited to 'sc') diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 3c6812562c48..4a5d326049a1 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -400,7 +400,7 @@ public: virtual VclPtr CreateScTextImportOptionsDlg(weld::Window* pParent) = 0; - virtual VclPtr CreateScAutoFormatDlg(vcl::Window* pParent, + virtual VclPtr CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) = 0; diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py index e5ecb485e935..c38165f36c36 100644 --- a/sc/qa/uitest/calc_tests6/autoFormat.py +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -32,9 +32,8 @@ class autoFormat(UITestCase): alignmentcb = xDialog.getChild("alignmentcb") autofitcb = xDialog.getChild("autofitcb") - props = {"TEXT": "Financial"} - actionProps = mkPropertyValues(props) - formatlb.executeAction("SELECT", actionProps) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) numformatcb.executeAction("CLICK", tuple()) bordercb.executeAction("CLICK", tuple()) fontcb.executeAction("CLICK", tuple()) @@ -57,9 +56,8 @@ class autoFormat(UITestCase): alignmentcb = xDialog.getChild("alignmentcb") autofitcb = xDialog.getChild("autofitcb") - props = {"TEXT": "Financial"} - actionProps = mkPropertyValues(props) - formatlb.executeAction("SELECT", actionProps) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 86d8966b0409..88a153120400 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -71,7 +71,11 @@ #include IMPL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl); + +short AbstractScAutoFormatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractScColRowLabelDlg_Impl::Execute() { @@ -269,15 +273,15 @@ void AbstractScImportAsciiDlg_Impl::SaveParameters() sal_uInt16 AbstractScAutoFormatDlg_Impl::GetIndex() const { - return pDlg->GetIndex(); + return m_xDlg->GetIndex(); } OUString AbstractScAutoFormatDlg_Impl::GetCurrFormatName() { - return pDlg->GetCurrFormatName(); + return m_xDlg->GetCurrFormatName(); } -bool AbstractScColRowLabelDlg_Impl::IsCol() +bool AbstractScColRowLabelDlg_Impl::IsCol() { return m_xDlg->IsCol(); } @@ -763,13 +767,12 @@ VclPtr ScAbstractDialogFactory_Impl::CreateScTex return VclPtr::Create(std::make_unique(pParent)); } -VclPtr ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(vcl::Window* pParent, +VclPtr ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) { - VclPtr pDlg = VclPtr::Create(pParent, pAutoFormat, pSelFormatData, pViewData); - return VclPtr::Create(pDlg); + return VclPtr::Create(std::make_unique(pParent, pAutoFormat, pSelFormatData, pViewData)); } VclPtr ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg(weld::Window* pParent, diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 471d22a9e8cb..c752101f82af 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -105,7 +105,13 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg { - DECL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl, ScAutoFormatDlg) + std::unique_ptr m_xDlg; +public: + explicit AbstractScAutoFormatDlg_Impl(std::unique_ptr p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; virtual sal_uInt16 GetIndex() const override; virtual OUString GetCurrFormatName() override; }; @@ -586,7 +592,7 @@ public: virtual VclPtr CreateScTextImportOptionsDlg(weld::Window* pParent) override; - virtual VclPtr CreateScAutoFormatDlg(vcl::Window* pParent, + virtual VclPtr CreateScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, ScViewData *pViewData) override; diff --git a/sc/source/ui/inc/autofmt.hxx b/sc/source/ui/inc/autofmt.hxx index 723e1ba555f9..84a29c6b6d19 100644 --- a/sc/source/ui/inc/autofmt.hxx +++ b/sc/source/ui/inc/autofmt.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include namespace com { namespace sun { namespace star { namespace i18n { class XBreakIterator; } } } } @@ -33,13 +33,13 @@ class SvNumberFormatter; class VirtualDevice; class ScViewData; -class SC_DLLPUBLIC ScAutoFmtPreview : public vcl::Window +class SC_DLLPUBLIC ScAutoFmtPreview : public weld::CustomWidgetController { public: - ScAutoFmtPreview(vcl::Window* pParent); + ScAutoFmtPreview(); void DetectRTL(const ScViewData *pViewData); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; virtual ~ScAutoFmtPreview() override; - virtual void dispose() override; void NotifyChange( ScAutoFormatData* pNewData ); @@ -85,8 +85,8 @@ private: SAL_DLLPRIVATE void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow); SAL_DLLPRIVATE void DrawBackground(vcl::RenderContext& rRenderContext); - SAL_DLLPRIVATE void MakeFonts(sal_uInt16 nIndex, vcl::Font& rFont, - vcl::Font& rCJKFont, vcl::Font& rCTLFont ); + SAL_DLLPRIVATE void MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, + vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont); }; #endif // INCLUDED_SC_SOURCE_UI_INC_AUTOFMT_HXX diff --git a/sc/source/ui/inc/scuiautofmt.hxx b/sc/source/ui/inc/scuiautofmt.hxx index a00beb1e68de..6ddaf400ac94 100644 --- a/sc/source/ui/inc/scuiautofmt.hxx +++ b/sc/source/ui/inc/scuiautofmt.hxx @@ -18,35 +18,23 @@ */ #ifndef INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX #define INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX + +#include #include "autofmt.hxx" -class ScAutoFormatDlg : public ModalDialog +class ScAutoFormatDlg : public weld::GenericDialogController { public: - ScAutoFormatDlg(vcl::Window* pParent, + ScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, const ScViewData *pViewData); virtual ~ScAutoFormatDlg() override; - virtual void dispose() override; sal_uInt16 GetIndex() const { return nIndex; } OUString GetCurrFormatName(); private: - VclPtr m_pLbFormat; - VclPtr m_pWndPreview; - VclPtr m_pBtnOk; - VclPtr m_pBtnCancel; - VclPtr m_pBtnAdd; - VclPtr m_pBtnRemove; - VclPtr m_pBtnRename; - VclPtr m_pBtnNumFormat; - VclPtr m_pBtnBorder; - VclPtr m_pBtnFont; - VclPtr m_pBtnPattern; - VclPtr m_pBtnAlignment; - VclPtr m_pBtnAdjust; OUString const aStrTitle; OUString const aStrLabel; OUString const aStrClose; @@ -59,16 +47,31 @@ private: bool bCoreDataChanged; bool bFmtInserted; + ScAutoFmtPreview m_aWndPreview; + std::unique_ptr m_xLbFormat; + std::unique_ptr m_xBtnOk; + std::unique_ptr m_xBtnCancel; + std::unique_ptr m_xBtnAdd; + std::unique_ptr m_xBtnRemove; + std::unique_ptr m_xBtnRename; + std::unique_ptr m_xBtnNumFormat; + std::unique_ptr m_xBtnBorder; + std::unique_ptr m_xBtnFont; + std::unique_ptr m_xBtnPattern; + std::unique_ptr m_xBtnAlignment; + std::unique_ptr m_xBtnAdjust; + std::unique_ptr m_xWndPreview; + void Init (); void UpdateChecks (); - DECL_LINK( CheckHdl, Button*, void ); - DECL_LINK( AddHdl, Button*, void ); - DECL_LINK( RemoveHdl, Button*, void ); - DECL_LINK( SelFmtHdl, ListBox&, void ); - DECL_LINK( CloseHdl, Button *, void ); - DECL_LINK( DblClkHdl, ListBox&, void ); - DECL_LINK( RenameHdl, Button*, void ); + DECL_LINK( CheckHdl, weld::ToggleButton&, void ); + DECL_LINK( AddHdl, weld::Button&, void ); + DECL_LINK( RemoveHdl, weld::Button&, void ); + DECL_LINK( SelFmtHdl, weld::TreeView&, void ); + DECL_LINK( CloseHdl, weld::Button&, void ); + DECL_LINK( DblClkHdl, weld::TreeView&, void ); + DECL_LINK( RenameHdl, weld::Button&, void ); }; #endif diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index e031ccbca417..a64104548f2b 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -49,10 +49,8 @@ // ScAutoFmtPreview -ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent) - : Window(pParent) - , pCurData(nullptr) - , aVD(*this) +ScAutoFmtPreview::ScAutoFmtPreview() + : pCurData(nullptr) , bFitWidth(false) , mbRTL(false) , aStrJan(ScResId(STR_JAN)) @@ -67,11 +65,16 @@ ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent) Init(); } -VCL_BUILDER_FACTORY(ScAutoFmtPreview) +void ScAutoFmtPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + aVD.disposeAndReset(VclPtr::Create(pDrawingArea->get_ref_device())); + CustomWidgetController::SetDrawingArea(pDrawingArea); +} void ScAutoFmtPreview::Resize() { - aPrvSize = Size(GetSizePixel().Width() - 6, GetSizePixel().Height() - 30); + Size aSize(GetOutputSizePixel()); + aPrvSize = Size(aSize.Width() - 6, aSize.Height() - 30); mnLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12; mnDataColWidth1 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3; mnDataColWidth2 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4; @@ -81,13 +84,6 @@ void ScAutoFmtPreview::Resize() ScAutoFmtPreview::~ScAutoFmtPreview() { - disposeOnce(); -} - -void ScAutoFmtPreview::dispose() -{ - pNumFmt.reset(); - vcl::Window::dispose(); } static void lcl_SetFontProperties( @@ -105,12 +101,12 @@ static void lcl_SetFontProperties( rFont.SetItalic ( rPostureItem.GetValue() ); } -void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont ) +void ScAutoFmtPreview::MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont) { if ( pCurData ) { - rFont = rCJKFont = rCTLFont = GetFont(); - Size aFontSize( rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor() ); + rFont = rCJKFont = rCTLFont = rRenderContext.GetFont(); + Size aFontSize(rFont.GetFontSize().Width(), 10 * rRenderContext.GetDPIScaleFactor()); const SvxFontItem* pFontItem = pCurData->GetItem( nIndex, ATTR_FONT ); const SvxWeightItem* pWeightItem = pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT ); @@ -134,7 +130,7 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font Color aColor( pColorItem->GetValue() ); if( aColor == COL_TRANSPARENT ) - aColor = GetSettings().GetStyleSettings().GetWindowTextColor(); + aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); #define SETONALLFONTS( MethodName, Value ) \ rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value ); @@ -263,7 +259,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo vcl::Font aFont, aCJKFont, aCTLFont; Size theMaxStrSize; - MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont ); + MakeFonts(rRenderContext, nFmtIndex, aFont, aCJKFont, aCTLFont); theMaxStrSize = Size(basegfx::fround(cellRange.getWidth()), basegfx::fround(cellRange.getHeight())); theMaxStrSize.AdjustWidth( -(FRAME_OFFSET) ); @@ -413,9 +409,7 @@ void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext) void ScAutoFmtPreview::Init() { - SetBorderStyle( WindowBorderStyle::MONO ); maArray.Initialize( 5, 5 ); -// maArray.SetUseDiagDoubleClipping( false ); mnLabelColWidth = 0; mnDataColWidth1 = 0; mnDataColWidth2 = 0; @@ -491,14 +485,15 @@ void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData ) CalcCellArray( bFitWidth ); CalcLineMap(); - Invalidate(tools::Rectangle(Point(0,0), GetSizePixel())); + Invalidate(); } void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext) { + rRenderContext.Push(PushFlags::ALL); DrawModeFlags nOldDrawMode = aVD->GetDrawMode(); - Size aWndSize(GetSizePixel()); + Size aWndSize(GetOutputSizePixel()); vcl::Font aFont(aVD->GetFont()); Color aBackCol(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor()); tools::Rectangle aRect(Point(), aWndSize); @@ -521,6 +516,7 @@ void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext) aPos.setX( -aPos.X() ); rRenderContext.DrawOutDev(aPos, aWndSize, Point(), aWndSize, *aVD); aVD->SetDrawMode(nOldDrawMode); + rRenderContext.Pop(); } void ScAutoFmtPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index 4593ef712e17..fa5ced63c8b2 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -37,12 +37,11 @@ // AutoFormat-Dialog: -ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, +ScAutoFormatDlg::ScAutoFormatDlg(weld::Window* pParent, ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, const ScViewData *pViewData) - : ModalDialog(pParent, "AutoFormatTableDialog", - "modules/scalc/ui/autoformattable.ui") + : GenericDialogController(pParent, "modules/scalc/ui/autoformattable.ui", "AutoFormatTableDialog") , aStrTitle(ScResId(STR_ADD_AUTOFORMAT_TITLE)) , aStrLabel(ScResId(STR_ADD_AUTOFORMAT_LABEL)) , aStrClose(ScResId(STR_BTN_AUTOFORMAT_CLOSE)) @@ -53,83 +52,69 @@ ScAutoFormatDlg::ScAutoFormatDlg(vcl::Window* pParent, , nIndex(0) , bCoreDataChanged(false) , bFmtInserted(false) + , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) + , m_xBtnOk(m_xBuilder->weld_button("ok")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) + , m_xBtnAdd(m_xBuilder->weld_button("add")) + , m_xBtnRemove(m_xBuilder->weld_button("remove")) + , m_xBtnRename(m_xBuilder->weld_button("rename")) + , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) + , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) + , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) + , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) + , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) + , m_xBtnAdjust(m_xBuilder->weld_check_button("autofitcb")) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - get(m_pLbFormat, "formatlb"); - get(m_pWndPreview, "preview"); - m_pWndPreview->DetectRTL(pViewData); - get(m_pBtnOk, "ok"); - get(m_pBtnCancel, "cancel"); - get(m_pBtnAdd, "add"); - get(m_pBtnRemove, "remove"); - get(m_pBtnRename, "rename"); - get(m_pBtnNumFormat, "numformatcb"); - get(m_pBtnBorder, "bordercb"); - get(m_pBtnFont, "fontcb"); - get(m_pBtnPattern, "patterncb"); - get(m_pBtnAlignment, "alignmentcb"); - get(m_pBtnAdjust, "autofitcb"); + m_aWndPreview.DetectRTL(pViewData); + + const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; + const int nHeight = m_xLbFormat->get_height_rows(8); + m_xLbFormat->set_size_request(nWidth, nHeight); + m_xWndPreview->set_size_request(nWidth, nHeight); Init(); ScAutoFormat::iterator it = pFormat->begin(); - m_pWndPreview->NotifyChange(it->second.get()); + m_aWndPreview.NotifyChange(it->second.get()); } ScAutoFormatDlg::~ScAutoFormatDlg() { - disposeOnce(); -} - -void ScAutoFormatDlg::dispose() -{ - m_pLbFormat.clear(); - m_pWndPreview.clear(); - m_pBtnOk.clear(); - m_pBtnCancel.clear(); - m_pBtnAdd.clear(); - m_pBtnRemove.clear(); - m_pBtnRename.clear(); - m_pBtnNumFormat.clear(); - m_pBtnBorder.clear(); - m_pBtnFont.clear(); - m_pBtnPattern.clear(); - m_pBtnAlignment.clear(); - m_pBtnAdjust.clear(); - ModalDialog::dispose(); } void ScAutoFormatDlg::Init() { - m_pLbFormat->SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) ); - m_pBtnNumFormat->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnBorder->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnFont->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnPattern->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAlignment->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAdjust->SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); - m_pBtnAdd->SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) ); - m_pBtnRemove->SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) ); - m_pBtnOk->SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); - m_pBtnCancel->SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); - m_pBtnRename->SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); - m_pLbFormat->SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); + m_xLbFormat->connect_changed( LINK( this, ScAutoFormatDlg, SelFmtHdl ) ); + m_xBtnNumFormat->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnBorder->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnFont->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnPattern->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAlignment->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAdjust->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) ); + m_xBtnAdd->connect_clicked ( LINK( this, ScAutoFormatDlg, AddHdl ) ); + m_xBtnRemove->connect_clicked ( LINK( this, ScAutoFormatDlg, RemoveHdl ) ); + m_xBtnOk->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); + m_xBtnCancel->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); + m_xBtnRename->connect_clicked ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); + m_xLbFormat->connect_row_activated( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); for (const auto& rEntry : *pFormat) - m_pLbFormat->InsertEntry(rEntry.second->GetName()); + m_xLbFormat->append_text(rEntry.second->GetName()); if (pFormat->size() == 1) - m_pBtnRemove->Disable(); + m_xBtnRemove->set_sensitive(false); - m_pLbFormat->SelectEntryPos( 0 ); - m_pBtnRename->Disable(); - m_pBtnRemove->Disable(); + m_xLbFormat->select(0); + m_xBtnRename->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); nIndex = 0; UpdateChecks(); if ( !pSelFmtData ) { - m_pBtnAdd->Disable(); - m_pBtnRemove->Disable(); + m_xBtnAdd->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); bFmtInserted = true; } } @@ -138,63 +123,63 @@ void ScAutoFormatDlg::UpdateChecks() { const ScAutoFormatData* pData = pFormat->findByIndex(nIndex); - m_pBtnNumFormat->Check( pData->GetIncludeValueFormat() ); - m_pBtnBorder->Check( pData->GetIncludeFrame() ); - m_pBtnFont->Check( pData->GetIncludeFont() ); - m_pBtnPattern->Check( pData->GetIncludeBackground() ); - m_pBtnAlignment->Check( pData->GetIncludeJustify() ); - m_pBtnAdjust->Check( pData->GetIncludeWidthHeight() ); + m_xBtnNumFormat->set_active( pData->GetIncludeValueFormat() ); + m_xBtnBorder->set_active( pData->GetIncludeFrame() ); + m_xBtnFont->set_active( pData->GetIncludeFont() ); + m_xBtnPattern->set_active( pData->GetIncludeBackground() ); + m_xBtnAlignment->set_active( pData->GetIncludeJustify() ); + m_xBtnAdjust->set_active( pData->GetIncludeWidthHeight() ); } // Handler: -IMPL_LINK( ScAutoFormatDlg, CloseHdl, Button *, pBtn, void ) +IMPL_LINK(ScAutoFormatDlg, CloseHdl, weld::Button&, rBtn, void) { - if (pBtn == m_pBtnOk || pBtn == m_pBtnCancel) + if (&rBtn == m_xBtnOk.get() || &rBtn == m_xBtnCancel.get()) { if ( bCoreDataChanged ) ScGlobal::GetOrCreateAutoFormat()->Save(); - EndDialog( (pBtn == m_pBtnOk) ? RET_OK : RET_CANCEL ); + m_xDialog->response( (&rBtn == m_xBtnOk.get()) ? RET_OK : RET_CANCEL ); } } -IMPL_LINK_NOARG(ScAutoFormatDlg, DblClkHdl, ListBox&, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, DblClkHdl, weld::TreeView&, void) { if ( bCoreDataChanged ) ScGlobal::GetOrCreateAutoFormat()->Save(); - EndDialog( RET_OK ); + m_xDialog->response( RET_OK ); } -IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn, void ) +IMPL_LINK(ScAutoFormatDlg, CheckHdl, weld::ToggleButton&, rBtn, void) { ScAutoFormatData* pData = pFormat->findByIndex(nIndex); - bool bCheck = static_cast(pBtn)->IsChecked(); + bool bCheck = rBtn.get_active(); - if ( pBtn == m_pBtnNumFormat ) + if (&rBtn == m_xBtnNumFormat.get()) pData->SetIncludeValueFormat( bCheck ); - else if ( pBtn == m_pBtnBorder ) + else if (&rBtn == m_xBtnBorder.get()) pData->SetIncludeFrame( bCheck ); - else if ( pBtn == m_pBtnFont ) + else if (&rBtn == m_xBtnFont.get()) pData->SetIncludeFont( bCheck ); - else if ( pBtn == m_pBtnPattern ) + else if (&rBtn == m_xBtnPattern.get()) pData->SetIncludeBackground( bCheck ); - else if ( pBtn == m_pBtnAlignment ) + else if (&rBtn == m_xBtnAlignment.get()) pData->SetIncludeJustify( bCheck ); - else if ( pBtn == m_pBtnAdjust ) + else if (&rBtn == m_xBtnAdjust.get()) pData->SetIncludeWidthHeight( bCheck ); if ( !bCoreDataChanged ) { - m_pBtnCancel->SetText( aStrClose ); + m_xBtnCancel->set_label(aStrClose); bCoreDataChanged = true; } - m_pWndPreview->NotifyChange( pData ); + m_aWndPreview.NotifyChange( pData ); } -IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, weld::Button&, void) { if ( !bFmtInserted && pSelFmtData ) { @@ -204,7 +189,7 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) while ( !bOk ) { - ScStringInputDlg aDlg(GetFrameWeld(), aStrTitle, aStrLabel, aFormatName, + ScStringInputDlg aDlg(m_xDialog.get(), aStrTitle, aStrLabel, aFormatName, HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME); if (aDlg.run() == RET_OK) @@ -223,24 +208,24 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) if ( bFmtInserted ) { size_t nPos = std::distance(pFormat->begin(), it); - m_pLbFormat->InsertEntry(aFormatName, nPos); - m_pLbFormat->SelectEntry( aFormatName ); - m_pBtnAdd->Disable(); + m_xLbFormat->insert_text(nPos, aFormatName); + m_xLbFormat->select_text( aFormatName ); + m_xBtnAdd->set_sensitive(false); if ( !bCoreDataChanged ) { - m_pBtnCancel->SetText( aStrClose ); + m_xBtnCancel->set_label( aStrClose ); bCoreDataChanged = true; } - SelFmtHdl( *m_pLbFormat.get() ); + SelFmtHdl( *m_xLbFormat.get() ); bOk = true; } } if ( !bFmtInserted ) { - std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Error, VclButtonsType::OkCancel, ScResId(STR_INVALID_AFNAME))); @@ -255,30 +240,30 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, Button*, void) } } -IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, Button*, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, weld::Button&, void) { - if ( (nIndex > 0) && (m_pLbFormat->GetEntryCount() > 0) ) + if ( (nIndex > 0) && (m_xLbFormat->n_children() > 0) ) { OUString aMsg = aStrDelMsg.getToken( 0, '#' ) - + m_pLbFormat->GetSelectedEntry() + + m_xLbFormat->get_selected_text() + aStrDelMsg.getToken( 1, '#' ); - std::unique_ptr xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, aMsg)); xQueryBox->set_default_response(RET_YES); if (RET_YES == xQueryBox->run()) { - m_pLbFormat->RemoveEntry( nIndex ); - m_pLbFormat->SelectEntryPos( nIndex-1 ); + m_xLbFormat->remove(nIndex); + m_xLbFormat->select(nIndex-1); if ( nIndex-1 == 0 ) - m_pBtnRemove->Disable(); + m_xBtnRemove->set_sensitive(false); if ( !bCoreDataChanged ) { - m_pBtnCancel->SetText( aStrClose ); + m_xBtnCancel->set_label( aStrClose ); bCoreDataChanged = true; } @@ -287,23 +272,23 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, Button*, void) pFormat->erase(it); nIndex--; - SelFmtHdl( *m_pLbFormat.get() ); + SelFmtHdl( *m_xLbFormat.get() ); } } - SelFmtHdl( *m_pLbFormat.get() ); + SelFmtHdl( *m_xLbFormat.get() ); } -IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, Button*, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, weld::Button&, void) { bool bOk = false; while( !bOk ) { - OUString aFormatName = m_pLbFormat->GetSelectedEntry(); + OUString aFormatName = m_xLbFormat->get_selected_text(); OUString aEntry; - ScStringInputDlg aDlg(GetFrameWeld(), aStrRename, aStrLabel, aFormatName, + ScStringInputDlg aDlg(m_xDialog.get(), aStrRename, aStrLabel, aFormatName, HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME); if (aDlg.run() == RET_OK) { @@ -323,7 +308,7 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, Button*, void) { // no format with this name yet, so we can rename - m_pLbFormat->RemoveEntry(nIndex ); + m_xLbFormat->remove(nIndex); const ScAutoFormatData* p = pFormat->findByIndex(nIndex); std::unique_ptr pNewData(new ScAutoFormatData(*p)); @@ -335,31 +320,31 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, Button*, void) pFormat->insert(std::move(pNewData)); - m_pLbFormat->SetUpdateMode(false); - m_pLbFormat->Clear(); + m_xLbFormat->freeze(); + m_xLbFormat->clear(); for (it = pFormat->begin(); it != itEnd; ++it) { aEntry = it->second->GetName(); - m_pLbFormat->InsertEntry( aEntry ); + m_xLbFormat->append_text(aEntry); } - m_pLbFormat->SetUpdateMode(true); - m_pLbFormat->SelectEntry( aFormatName); + m_xLbFormat->thaw(); + m_xLbFormat->select_text(aFormatName); if ( !bCoreDataChanged ) { - m_pBtnCancel->SetText( aStrClose ); + m_xBtnCancel->set_label( aStrClose ); bCoreDataChanged = true; } - SelFmtHdl( *m_pLbFormat.get() ); + SelFmtHdl( *m_xLbFormat.get() ); bOk = true; bFmtRenamed = true; } } if( !bFmtRenamed ) { - std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Error, VclButtonsType::OkCancel, ScResId(STR_INVALID_AFNAME))); @@ -371,24 +356,24 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, Button*, void) } } -IMPL_LINK_NOARG(ScAutoFormatDlg, SelFmtHdl, ListBox&, void) +IMPL_LINK_NOARG(ScAutoFormatDlg, SelFmtHdl, weld::TreeView&, void) { - nIndex = m_pLbFormat->GetSelectedEntryPos(); + nIndex = m_xLbFormat->get_selected_index(); UpdateChecks(); if ( nIndex == 0 ) { - m_pBtnRename->Disable(); - m_pBtnRemove->Disable(); + m_xBtnRename->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); } else { - m_pBtnRename->Enable(); - m_pBtnRemove->Enable(); + m_xBtnRename->set_sensitive(true); + m_xBtnRemove->set_sensitive(true); } ScAutoFormatData* p = pFormat->findByIndex(nIndex); - m_pWndPreview->NotifyChange(p); + m_aWndPreview.NotifyChange(p); } OUString ScAutoFormatDlg::GetCurrFormatName() diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 5167e50a50d5..2cf985c02e2d 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -819,7 +819,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) case SID_AUTOFORMAT: { - vcl::Window* pDlgParent = pTabViewShell->GetDialogParent(); + weld::Window* pDlgParent = pTabViewShell->GetFrameWeld(); SCCOL nStartCol; SCROW nStartRow; SCTAB nStartTab; @@ -877,7 +877,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else { - std::unique_ptr xErrorBox(Application::CreateMessageDialog(pDlgParent ? pDlgParent->GetFrameWeld() : nullptr, + std::unique_ptr xErrorBox(Application::CreateMessageDialog(pDlgParent, VclMessageType::Warning, VclButtonsType::Ok, ScResId(STR_INVALID_AFAREA))); xErrorBox->run(); diff --git a/sc/uiconfig/scalc/ui/autoformattable.ui b/sc/uiconfig/scalc/ui/autoformattable.ui index eedb29905b06..21036d7284e4 100644 --- a/sc/uiconfig/scalc/ui/autoformattable.ui +++ b/sc/uiconfig/scalc/ui/autoformattable.ui @@ -1,72 +1,41 @@ - - + + - + + + + + + + + False 6 AutoFormat - normal + False + True + dialog + + + False + vertical 12 False - vertical True - start - - - gtk-ok - True - True - True - True - True - - - False - True - 0 - - + end gtk-cancel True True - True - True - - - False - True - 1 - - - - - gtk-help - True - True - True - True - - - False - True - 2 - - - - - gtk-add - True - True - True + False True @@ -76,11 +45,13 @@ - - gtk-delete + + gtk-ok True True - True + True + True + False True @@ -90,16 +61,18 @@ - - Rename + + gtk-help True True - True + False + True False True 5 + True @@ -129,51 +102,128 @@ 6 12 - - 400 - 200 + True False - 6 - 6 + 12 - - 200 - 200 + True False True True + 6 + 6 + True + + + True + False + True + True + + + 1 + 0 + + + + + True + True + True + True + in + + + True + True + True + True + liststore1 + False + False + 0 + False + + + + + + + + + 0 + + + + + + + + + 0 + 0 + + - 1 + 0 0 - 1 - 1 - + True - True - in + False + vertical + 6 + start - + + gtk-add True True - True - False - - - + False + True + + + False + True + 0 + + + + + gtk-delete + True + True + False + True + + + False + True + 1 + + + + + Rename + True + True + False + + False + True + 2 + - 0 + 1 0 - 1 - 1 @@ -217,7 +267,7 @@ 12 - _Number format + Number format True True False @@ -228,13 +278,11 @@ 0 0 - 1 - 1 - _Borders + Borders True True False @@ -245,13 +293,11 @@ 0 1 - 1 - 1 - F_ont + Font True True False @@ -262,13 +308,11 @@ 1 0 - 1 - 1 - _Pattern + Pattern True True False @@ -279,13 +323,11 @@ 1 1 - 1 - 1 - Alignmen_t + Alignment True True False @@ -296,8 +338,6 @@ 2 0 - 1 - 1 @@ -313,8 +353,6 @@ 2 1 - 1 - 1 @@ -349,12 +387,9 @@ - ok cancel + ok help - add - remove - rename -- cgit