diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-26 12:40:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-28 22:02:53 +0200 |
commit | 4dbce627d3643babaf90a93c70b365ff08abfca6 (patch) | |
tree | daf5b62ad5a5c8d99ec721b22b22733800d2a3a4 /sw/source | |
parent | 5fa446204e1e686412d84562750d9802bf1b9468 (diff) |
weld SwEnvDlg
Change-Id: Ib92f790030ca6fbf64273cf45c710b2f698f45a4
Reviewed-on: https://gerrit.libreoffice.org/53569
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 37 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 20 | ||||
-rw-r--r-- | sw/source/ui/envelp/envfmt.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/envelp/envfmt.hxx | 7 | ||||
-rw-r--r-- | sw/source/ui/envelp/envlop1.cxx | 36 | ||||
-rw-r--r-- | sw/source/ui/envelp/envprt.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/app/appenv.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/envlop.hxx | 21 |
8 files changed, 81 insertions, 54 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 3df60e9b35e0..a0b0d95e3897 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -127,6 +127,10 @@ short AbstractMultiTOXMarkDlg_Impl::Execute() { return m_xDlg->execute(); } +short AbstractTabController_Impl::Execute() +{ + return m_xDlg->execute(); +} IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); short AbstractSwConvertTableDlg_Impl::Execute() { @@ -212,6 +216,32 @@ void AbstractTabDialog_Impl::SetText( const OUString& rStr ) pDlg->SetText( rStr ); } +void AbstractTabController_Impl::SetCurPageId( const OString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* AbstractTabController_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const sal_uInt16* AbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void AbstractTabController_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +//From class Window. +void AbstractTabController_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + IMPL_LINK_NOARG(AbstractApplyTabDialog_Impl, ApplyHdl, Button*, void) { if (pDlg->Apply()) @@ -758,12 +788,11 @@ VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDown return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(new sw::DropDownFieldDialog(pParent, rSh, pField, bPrevButton, bNextButton)); } -VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, - bool bInsert ) + bool bInsert) { - VclPtr<SfxTabDialog> pDlg = VclPtr<SwEnvDlg>::Create( pParent, rSet, pWrtSh,pPrt, bInsert ); - return VclPtr<AbstractTabDialog_Impl>::Create( pDlg ); + return VclPtr<AbstractTabController_Impl>::Create(new SwEnvDlg(pParent, rSet, pWrtSh,pPrt, bInsert)); } VclPtr<AbstractSwLabDlg> SwAbstractDialogFactory_Impl::CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 1be0a93ab046..3afdec171700 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -223,6 +223,24 @@ class AbstractTabDialog_Impl : virtual public SfxAbstractTabDialog virtual void SetText( const OUString& rStr ) override; }; +class AbstractTabController_Impl : virtual public SfxAbstractTabDialog +{ +protected: + std::unique_ptr<SfxTabDialogController> m_xDlg; +public: + explicit AbstractTabController_Impl(SfxTabDialogController* p) + : m_xDlg(p) + { + } + virtual short Execute() override; + virtual void SetCurPageId( const OString &rName ) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; + virtual void SetInputSet( const SfxItemSet* pInSet ) override; + //From class Window. + virtual void SetText( const OUString& rStr ) override; +}; + class AbstractApplyTabDialog_Impl : public AbstractTabDialog_Impl, virtual public SfxAbstractApplyTabDialog { public: @@ -550,7 +568,7 @@ public: virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; - virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override; virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) override; diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index a7aaaf4cbd8c..4d264417f664 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -241,7 +241,7 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender) bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS)); OSL_ENSURE(pColl, "Text collection missing"); - if (rIdent == "character") + if (rIdent.startsWith("character")) { SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); @@ -253,7 +253,8 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender) OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); const OUString sFormatStr = pColl->GetName(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr)); + ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(nullptr /*TODO*/, pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr)); + //ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr)); OSL_ENSURE(pDlg, "Dialog creation failed!"); if (pDlg->Execute() == RET_OK) { @@ -262,7 +263,7 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender) pCollSet->Put(aOutputSet); } } - else if (rIdent == "paragraph") + else if (rIdent.startsWith("paragraph")) { SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); @@ -290,7 +291,8 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender) ::PrepareBoxInfo( aTmpSet, *pSh ); const OUString sFormatStr = pColl->GetName(); - VclPtrInstance< SwParaDlg > pDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr); + VclPtrInstance< SwParaDlg > pDlg(nullptr /*TODO*/, pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr); + //VclPtrInstance< SwParaDlg > pDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr); if ( pDlg->Execute() == RET_OK ) { diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx index d5aec6713fe5..20d445f14c61 100644 --- a/sw/source/ui/envelp/envfmt.hxx +++ b/sw/source/ui/envelp/envfmt.hxx @@ -26,7 +26,7 @@ class SwTextFormatColl; class SwEnvFormatPage : public SfxTabPage { - VclPtr<SwEnvDlg> m_pDialog; + SwEnvDlg* m_pDialog; std::vector<sal_uInt16> m_aIDs; std::unique_ptr<weld::MetricSpinButton> m_xAddrLeftField; @@ -59,11 +59,6 @@ class SwEnvFormatPage : public SfxTabPage public: SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet); void Init(SwEnvDlg* pDialog); - virtual void dispose() override - { - m_pDialog.clear(); - SfxTabPage::dispose(); - } virtual ~SwEnvFormatPage() override; static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet); diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx index 28926fb9b2dd..e7ae5d3a4ea1 100644 --- a/sw/source/ui/envelp/envlop1.cxx +++ b/sw/source/ui/envelp/envlop1.cxx @@ -63,8 +63,6 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { vcl::RenderContext& rRenderContext = aPayload.first; - //SetMapMode(MapMode(MapUnit::MapPixel)); - const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor()); rRenderContext.Erase(); @@ -124,51 +122,43 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.DrawRect(tools::Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH))); } -SwEnvDlg::SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet, +SwEnvDlg::SwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) - : SfxTabDialog(pParent, "EnvDialog", - "modules/swriter/ui/envdialog.ui", &rSet) + : SfxTabDialogController(pParent, "modules/swriter/ui/envdialog.ui", "EnvDialog", &rSet) , aEnvItem(static_cast<const SwEnvItem&>( rSet.Get(FN_ENVELOP))) , pSh(pWrtSh) , pPrinter(pPrt) , pAddresseeSet(nullptr) , pSenderSet(nullptr) - , m_nEnvPrintId(0) + , m_xModify(m_xBuilder->weld_button("modify")) { if (!bInsert) { - GetUserButton()->SetText(get<PushButton>("modify")->GetText()); + GetUserButton()->set_label(m_xModify->get_label()); } - m_nEnvAddressId = AddTabPage("envelope", SwEnvPage ::Create, nullptr); - m_nEnvFormatId = AddTabPage("format", SwEnvFormatPage::Create, nullptr); - m_nEnvPrintId = AddTabPage("printer", SwEnvPrtPage::Create, nullptr); + AddTabPage("envelope", SwEnvPage::Create, nullptr); + AddTabPage("format", SwEnvFormatPage::Create, nullptr); + AddTabPage("printer", SwEnvPrtPage::Create, nullptr); } SwEnvDlg::~SwEnvDlg() { - disposeOnce(); -} - -void SwEnvDlg::dispose() -{ delete pAddresseeSet; delete pSenderSet; - pPrinter.clear(); - SfxTabDialog::dispose(); } -void SwEnvDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) +void SwEnvDlg::PageCreated(const OString& rId, SfxTabPage &rPage) { - if (nId == m_nEnvPrintId) + if (rId == "printer") { static_cast<SwEnvPrtPage*>(&rPage)->SetPrt(pPrinter); } - else if (nId == m_nEnvAddressId) + else if (rId == "envelope") { static_cast<SwEnvPage*>(&rPage)->Init(this); } - else if (nId == m_nEnvFormatId) + else if (rId == "format") { static_cast<SwEnvFormatPage*>(&rPage)->Init(this); } @@ -176,7 +166,7 @@ void SwEnvDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) short SwEnvDlg::Ok() { - short nRet = SfxTabDialog::Ok(); + short nRet = SfxTabDialogController::Ok(); if (nRet == RET_OK || nRet == RET_USER) { @@ -209,7 +199,7 @@ SwEnvPage::SwEnvPage(TabPageParent pParent, const SfxItemSet& rSet) , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview"))) { auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10)); - auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 20); + auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 25); m_xAddrEdit->set_size_request(nTextBoxWidth, nTextBoxHeight); m_xSenderEdit->set_size_request(nTextBoxWidth, nTextBoxHeight); diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx index 94b7d0886eef..a8c093c381fe 100644 --- a/sw/source/ui/envelp/envprt.hxx +++ b/sw/source/ui/envelp/envprt.hxx @@ -50,7 +50,7 @@ class SwEnvPrtPage : public SfxTabPage DECL_LINK(AlignHdl, weld::ToggleButton&, void); DECL_LINK(ButtonHdl, weld::Button&, void ); - SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetTabDialog()); } + SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetDialogController()); } using TabPage::ActivatePage; using TabPage::DeactivatePage; diff --git a/sw/source/uibase/app/appenv.cxx b/sw/source/uibase/app/appenv.cxx index 3d860da8654f..bcb6932b2e1d 100644 --- a/sw/source/uibase/app/appenv.cxx +++ b/sw/source/uibase/app/appenv.cxx @@ -214,7 +214,7 @@ void SwModule::InsertEnv( SfxRequest& rReq ) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg.disposeAndReset(pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange )); + pDlg.disposeAndReset(pFact->CreateSwEnvDlg(pParent ? pParent->GetFrameWeld() : nullptr, aSet, pOldSh, pTempPrinter, !bEnvChange)); OSL_ENSURE(pDlg, "Dialog creation failed!"); nMode = pDlg->Execute(); } diff --git a/sw/source/uibase/inc/envlop.hxx b/sw/source/uibase/inc/envlop.hxx index 989e50cfd4da..4d1b640b2bd1 100644 --- a/sw/source/uibase/inc/envlop.hxx +++ b/sw/source/uibase/inc/envlop.hxx @@ -53,7 +53,7 @@ class SwEnvPreview { private: std::unique_ptr<weld::DrawingArea> m_xDrawingArea; - VclPtr<SwEnvDlg> m_pDialog; + SwEnvDlg* m_pDialog; Size m_aSize; DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); @@ -65,7 +65,7 @@ public: void queue_draw() { m_xDrawingArea->queue_draw(); } }; -class SwEnvDlg : public SfxTabDialog +class SwEnvDlg : public SfxTabDialogController { friend class SwEnvPage; friend class SwEnvFormatPage; @@ -77,22 +77,20 @@ friend class SwEnvPreview; VclPtr<Printer> pPrinter; SfxItemSet *pAddresseeSet; SfxItemSet *pSenderSet; - sal_uInt16 m_nEnvPrintId; - sal_uInt16 m_nEnvAddressId; - sal_uInt16 m_nEnvFormatId; - virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override; + std::unique_ptr<weld::Button> m_xModify; + + virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; virtual short Ok() override; public: - SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert); + SwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert); virtual ~SwEnvDlg() override; - virtual void dispose() override; }; class SwEnvPage : public SfxTabPage { - VclPtr<SwEnvDlg> m_pDialog; + SwEnvDlg* m_pDialog; SwWrtShell* m_pSh; OUString m_sActDBName; @@ -128,11 +126,6 @@ public: void FillItem(SwEnvItem& rItem); virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - virtual void dispose() override - { - m_pDialog.clear(); - SfxTabPage::dispose(); - } }; #endif |