From a7e9db8338e93921ede5892545ce18655d08aad5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 16 Sep 2018 14:24:12 +0100 Subject: weld SdPageDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id9c78651d3eb315bf2e982eef48ef24071bfc79b Reviewed-on: https://gerrit.libreoffice.org/60550 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sd/inc/sdabstdlg.hxx | 2 +- sd/qa/unit/dialogs-test.cxx | 3 +- sd/source/ui/dlg/dlgpage.cxx | 29 +++++---- sd/source/ui/dlg/sddlgfact.cxx | 40 ++++++++++++- sd/source/ui/dlg/sddlgfact.hxx | 22 ++++++- sd/source/ui/func/fupage.cxx | 2 +- sd/source/ui/inc/dlgpage.hxx | 9 +-- sd/uiconfig/sdraw/ui/drawpagedialog.ui | 104 ++++++++++++++++++++++++++++----- 8 files changed, 169 insertions(+), 42 deletions(-) (limited to 'sd') diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx index 332312ae77ba..f9c364c3a428 100644 --- a/sd/inc/sdabstdlg.hxx +++ b/sd/inc/sdabstdlg.hxx @@ -171,7 +171,7 @@ public: virtual VclPtr CreateCopyDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View* pView ) = 0; virtual VclPtr CreateSdCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc) = 0; virtual VclPtr CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) = 0; - virtual VclPtr CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) = 0; + virtual VclPtr CreateSdTabPageDialog(weld::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) = 0; virtual VclPtr CreateSdModifyFieldDlg(weld::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) = 0; virtual VclPtr CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) = 0; virtual VclPtr CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& rStr) = 0; diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx index dd9a6d989bec..1fe44cc04243 100644 --- a/sd/qa/unit/dialogs-test.cxx +++ b/sd/qa/unit/dialogs-test.cxx @@ -327,8 +327,9 @@ VclPtr SdDialogsTest::createDialogByID(sal_uInt32 nID) // CreateSdTabPageDialog(const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage = true) override; // needs a special SfxItemSet with merged content from page and other stuff, crashes without that (2nd page) // needs a 'SfxObjectShell* pDocShell', crashes without. Also sufficient: FillStyleItemSet with XFILL_NONE set + auto const parent = getViewShell()->GetActiveWindow(); pRetval = getSdAbstractDialogFactory()->CreateSdTabPageDialog( - getViewShell()->GetActiveWindow(), + parent == nullptr ? nullptr : parent->GetFrameWeld(), &getEmptyFillStyleSfxItemSet(), getDocShell(), true); diff --git a/sd/source/ui/dlg/dlgpage.cxx b/sd/source/ui/dlg/dlgpage.cxx index 75933ae73271..97e03977ef1a 100644 --- a/sd/source/ui/dlg/dlgpage.cxx +++ b/sd/source/ui/dlg/dlgpage.cxx @@ -33,12 +33,9 @@ /** * Constructor of tab dialog: appends pages to the dialog */ -SdPageDlg::SdPageDlg( SfxObjectShell const * pDocSh, vcl::Window* pParent, const SfxItemSet* pAttr, bool bAreaPage ) : - SfxTabDialog ( pParent - ,"DrawPageDialog" - ,"modules/sdraw/ui/drawpagedialog.ui" - , pAttr ), - mpDocShell ( pDocSh ) +SdPageDlg::SdPageDlg(SfxObjectShell const * pDocSh, weld::Window* pParent, const SfxItemSet* pAttr, bool bAreaPage) + : SfxTabDialogController(pParent, "modules/sdraw/ui/drawpagedialog.ui", "DrawPageDialog", pAttr) + , mpDocShell(pDocSh) { SvxColorListItem const * pColorListItem = mpDocShell->GetItem( SID_COLOR_TABLE ); SvxGradientListItem const * pGradientListItem = mpDocShell->GetItem( SID_GRADIENT_LIST ); @@ -54,28 +51,28 @@ SdPageDlg::SdPageDlg( SfxObjectShell const * pDocSh, vcl::Window* pParent, const SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - mnPage = AddTabPage( "RID_SVXPAGE_PAGE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), nullptr ); - mnArea = AddTabPage( "RID_SVXPAGE_AREA", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), nullptr ); - mnTransparence = AddTabPage( "RID_SVXPAGE_TRANSPARENCE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), nullptr ); + AddTabPage("RID_SVXPAGE_PAGE", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PAGE), nullptr); + AddTabPage("RID_SVXPAGE_AREA", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_AREA), nullptr); + AddTabPage("RID_SVXPAGE_TRANSPARENCE", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TRANSPARENCE), nullptr); - if(!bAreaPage) // I have to add the page before I remove it ! + if (!bAreaPage) // I have to add the page before I remove it ! { - RemoveTabPage( "RID_SVXPAGE_AREA" ); - RemoveTabPage( "RID_SVXPAGE_TRANSPARENCE" ); + RemoveTabPage("RID_SVXPAGE_AREA"); + RemoveTabPage("RID_SVXPAGE_TRANSPARENCE"); } } -void SdPageDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) +void SdPageDlg::PageCreated(const OString& rId, SfxTabPage& rPage) { SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); - if (nId == mnPage) + if (rId == "RID_SVXPAGE_PAGE") { aSet.Put (SfxAllEnumItem(sal_uInt16(SID_ENUM_PAGE_MODE), SVX_PAGE_MODE_PRESENTATION)); aSet.Put (SfxAllEnumItem(sal_uInt16(SID_PAPER_START), PAPER_A0)); aSet.Put (SfxAllEnumItem(sal_uInt16(SID_PAPER_END), PAPER_E)); rPage.PageCreated(aSet); } - else if (nId == mnArea) + else if (rId == "RID_SVXPAGE_AREA") { aSet.Put (SvxColorListItem(mpColorList,SID_COLOR_TABLE)); aSet.Put (SvxGradientListItem(mpGradientList,SID_GRADIENT_LIST)); @@ -87,7 +84,7 @@ void SdPageDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,0)); rPage.PageCreated(aSet); } - else if (nId == mnTransparence) + else if (rId == "RID_SVXPAGE_TRANSPARENCE") { aSet.Put(SfxUInt16Item(SID_PAGE_TYPE,0)); aSet.Put(SfxUInt16Item(SID_DLG_TYPE,1)); diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index 22581ad31aaa..7173bfc0c533 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -164,6 +164,42 @@ void SdAbstractTabDialog_Impl::SetText( const OUString& rStr ) pDlg->SetText( rStr ); } +short SdAbstractTabController_Impl::Execute() +{ + return m_xDlg->execute(); +} + +void SdAbstractTabController_Impl::SetCurPageId( const OString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* SdAbstractTabController_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const sal_uInt16* SdAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void SdAbstractTabController_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +bool SdAbstractTabController_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +//From class Window. +void SdAbstractTabController_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + void AbstractBulletDialog_Impl::SetCurPageId( const OString& rName ) { static_cast< ::sd::OutlineBulletDlg*>(pDlg.get())->SetCurPageId( rName ); @@ -353,9 +389,9 @@ VclPtr SdAbstractDialogFactory_Impl::CreateSdTabCharDialo return VclPtr::Create( VclPtr::Create(pParent, pAttr, pDocShell) ); } -VclPtr SdAbstractDialogFactory_Impl::CreateSdTabPageDialog(vcl::Window* pParent, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage ) +VclPtr SdAbstractDialogFactory_Impl::CreateSdTabPageDialog(weld::Window* pParent, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage ) { - return VclPtr::Create( VclPtr::Create( pDocShell, pParent, pAttr, bAreaPage ) ); + return VclPtr::Create(o3tl::make_unique(pDocShell, pParent, pAttr, bAreaPage)); } VclPtr SdAbstractDialogFactory_Impl::CreateSdModifyFieldDlg(weld::Window* pParent, const SvxFieldData* pInField, const SfxItemSet& rSet) diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index 10880bd9b46f..16c0b0be361d 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -128,6 +128,26 @@ class SdAbstractTabDialog_Impl : public SfxAbstractTabDialog virtual void SetText( const OUString& rStr ) override; }; +class SdAbstractTabController_Impl : public SfxAbstractTabDialog +{ +protected: + std::shared_ptr m_xDlg; +public: + explicit SdAbstractTabController_Impl(std::unique_ptr p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) 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 AbstractBulletDialog_Impl : public SfxAbstractTabDialog { DECL_ABSTDLG_BASE( AbstractBulletDialog_Impl,SfxTabDialog ) @@ -291,7 +311,7 @@ public: virtual VclPtr CreateCopyDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; virtual VclPtr CreateSdCustomShowDlg(weld::Window* pParent, SdDrawDocument& rDrawDoc) override; virtual VclPtr CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override; - virtual VclPtr CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) override; + virtual VclPtr CreateSdTabPageDialog(weld::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) override; virtual VclPtr CreateSdModifyFieldDlg(weld::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) override; virtual VclPtr CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; virtual VclPtr CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) override; diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index c5b38dba95be..a514f84be3cd 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -330,7 +330,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent) { // create the dialog SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr pDlg( pFact->CreateSdTabPageDialog(mpViewShell->GetActiveWindow(), &aMergedAttr, mpDocSh, mbDisplayBackgroundTabPage) ); + ScopedVclPtr pDlg( pFact->CreateSdTabPageDialog(mpViewShell->GetFrameWeld(), &aMergedAttr, mpDocSh, mbDisplayBackgroundTabPage) ); if( pDlg->Execute() == RET_OK ) pTempSet.reset( new SfxItemSet(*pDlg->GetOutputItemSet()) ); } diff --git a/sd/source/ui/inc/dlgpage.hxx b/sd/source/ui/inc/dlgpage.hxx index 632ae583ebfa..b0ffd2aa7454 100644 --- a/sd/source/ui/inc/dlgpage.hxx +++ b/sd/source/ui/inc/dlgpage.hxx @@ -28,7 +28,7 @@ enum class ChangeType; /** * Page configuration-tab-dialog */ -class SdPageDlg : public SfxTabDialog +class SdPageDlg : public SfxTabDialogController { private: const SfxObjectShell* mpDocShell; @@ -38,14 +38,11 @@ private: XHatchListRef mpHatchingList; XBitmapListRef mpBitmapList; XPatternListRef mpPatternList; - sal_uInt16 mnArea; - sal_uInt16 mnPage; - sal_uInt16 mnTransparence; public: - SdPageDlg( SfxObjectShell const * pDocSh, vcl::Window* pParent, const SfxItemSet* pAttr, bool bAreaPage ); + SdPageDlg(SfxObjectShell const * pDocSh, weld::Window* pParent, const SfxItemSet* pAttr, bool bAreaPage); - virtual void PageCreated(sal_uInt16 nId, SfxTabPage& rPage) override; + virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; }; #endif // INCLUDED_SD_SOURCE_UI_INC_DLGPAGE_HXX diff --git a/sd/uiconfig/sdraw/ui/drawpagedialog.ui b/sd/uiconfig/sdraw/ui/drawpagedialog.ui index 1d21e7f6c36b..7e06dc3d51e6 100644 --- a/sd/uiconfig/sdraw/ui/drawpagedialog.ui +++ b/sd/uiconfig/sdraw/ui/drawpagedialog.ui @@ -1,5 +1,5 @@ - + @@ -7,6 +7,9 @@ 6 Page Setup dialog + + + False @@ -17,12 +20,10 @@ False end - - gtk-ok + + gtk-revert-to-saved True True - True - True True True @@ -33,10 +34,12 @@ - - gtk-cancel + + gtk-ok True True + True + True True True @@ -47,8 +50,8 @@ - - gtk-help + + gtk-cancel True True True @@ -58,12 +61,11 @@ False True 2 - True - - gtk-revert-to-saved + + gtk-help True True True @@ -73,6 +75,7 @@ False True 3 + True @@ -86,9 +89,10 @@ True - False + True True True + True True @@ -96,6 +100,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -115,6 +143,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1 @@ -138,6 +190,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + 2 @@ -164,10 +240,10 @@ + reset ok cancel help - reset -- cgit