diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-22 20:35:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-23 10:18:07 +0100 |
commit | e0bee1a05bdad73d61fb89e25b1510a12deed1f1 (patch) | |
tree | b819091e43cab6648c5f690a510a8eba59dc9b1c /sd | |
parent | 2372ce850251a3f0cfa041a5175a5957ead069e2 (diff) |
replace SdTemplatePopup_Impl
Change-Id: I734124939139e34c776e5e4fe52acde08abf24ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111364
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/UIConfig_simpress.mk | 1 | ||||
-rw-r--r-- | sd/source/ui/app/tmplctrl.cxx | 79 | ||||
-rw-r--r-- | sd/uiconfig/simpress/ui/masterpagemenu.ui | 9 |
3 files changed, 35 insertions, 54 deletions
diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk index d6b96e034661..a532a2819e2d 100644 --- a/sd/UIConfig_simpress.mk +++ b/sd/UIConfig_simpress.mk @@ -134,6 +134,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/simpress,\ sd/uiconfig/simpress/ui/layoutwindow \ sd/uiconfig/simpress/ui/masterlayoutdlg \ sd/uiconfig/simpress/ui/mastermenu \ + sd/uiconfig/simpress/ui/masterpagemenu \ sd/uiconfig/simpress/ui/masterpagepanel \ sd/uiconfig/simpress/ui/navigatorpanel \ sd/uiconfig/simpress/ui/notebookbar \ diff --git a/sd/source/ui/app/tmplctrl.cxx b/sd/source/ui/app/tmplctrl.cxx index 62d3ba6336a1..a6b89fb1dad4 100644 --- a/sd/source/ui/app/tmplctrl.cxx +++ b/sd/source/ui/app/tmplctrl.cxx @@ -18,8 +18,8 @@ */ #include <vcl/commandevent.hxx> -#include <vcl/menu.hxx> #include <vcl/status.hxx> +#include <vcl/weldutils.hxx> #include <svl/stritem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> @@ -35,38 +35,7 @@ SFX_IMPL_STATUSBAR_CONTROL( SdTemplateControl, SfxStringItem ); -// class SdTemplatePopup_Impl -------------------------------------------------- - -namespace { - -class SdTemplatePopup_Impl : public PopupMenu -{ -public: - SdTemplatePopup_Impl(); - - sal_uInt16 GetCurId() const { return nCurId; } - -private: - sal_uInt16 nCurId; - - virtual void Select() override; -}; - -} - -SdTemplatePopup_Impl::SdTemplatePopup_Impl() : - PopupMenu(), - nCurId(USHRT_MAX) -{ -} - -void SdTemplatePopup_Impl::Select() -{ - nCurId = GetCurItemId(); -} - // class SdTemplateControl ------------------------------------------ - SdTemplateControl::SdTemplateControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : @@ -110,29 +79,31 @@ void SdTemplateControl::Command( const CommandEvent& rCEvt ) if( !pDoc ) return; - ScopedVclPtrInstance<SdTemplatePopup_Impl> aPop; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/simpress/ui/masterpagemenu.ui")); + std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu")); + + const sal_uInt16 nMasterCount = pDoc->GetMasterSdPageCount(PageKind::Standard); + + for (sal_uInt16 nPage = 0; nPage < nMasterCount; ++nPage) + { + SdPage* pMaster = pDoc->GetMasterSdPage(nPage, PageKind::Standard); + if (!pMaster) + continue; + xPopup->append(OUString::number(nPage), pMaster->GetName()); + } + + ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1)); + weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), aRect); + OString sResult = xPopup->popup_at_rect(pParent, aRect); + if (!sResult.isEmpty()) { - const sal_uInt16 nMasterCount = pDoc->GetMasterSdPageCount(PageKind::Standard); - - sal_uInt16 nCount = 0; - for( sal_uInt16 nPage = 0; nPage < nMasterCount; ++nPage ) - { - SdPage* pMaster = pDoc->GetMasterSdPage(nPage, PageKind::Standard); - if( pMaster ) - aPop->InsertItem( ++nCount, pMaster->GetName() ); - } - aPop->Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); - - sal_uInt16 nCurrId = aPop->GetCurId()-1; - if( nCurrId < nMasterCount ) - { - SdPage* pMaster = pDoc->GetMasterSdPage(nCurrId, PageKind::Standard); - SfxStringItem aStyle( ATTR_PRESLAYOUT_NAME, pMaster->GetName() ); - pViewFrame->GetDispatcher()->ExecuteList( - SID_PRESENTATION_LAYOUT, SfxCallMode::SLOT, { &aStyle }); - pViewFrame->GetBindings().Invalidate(SID_PRESENTATION_LAYOUT); - pViewFrame->GetBindings().Invalidate(SID_STATUS_LAYOUT); - } + sal_uInt16 nCurrId = sResult.toUInt32(); + SdPage* pMaster = pDoc->GetMasterSdPage(nCurrId, PageKind::Standard); + SfxStringItem aStyle( ATTR_PRESLAYOUT_NAME, pMaster->GetName() ); + pViewFrame->GetDispatcher()->ExecuteList( + SID_PRESENTATION_LAYOUT, SfxCallMode::SLOT, { &aStyle }); + pViewFrame->GetBindings().Invalidate(SID_PRESENTATION_LAYOUT); + pViewFrame->GetBindings().Invalidate(SID_STATUS_LAYOUT); } } diff --git a/sd/uiconfig/simpress/ui/masterpagemenu.ui b/sd/uiconfig/simpress/ui/masterpagemenu.ui new file mode 100644 index 000000000000..5bb702561dd2 --- /dev/null +++ b/sd/uiconfig/simpress/ui/masterpagemenu.ui @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="sd"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> +</interface> |