sd/sdi/sdraw.sdi | 2 - sd/source/ui/inc/unomodel.hxx | 1 sd/source/ui/unoidl/unomodel.cxx | 43 +++++++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 7 deletions(-)
New commits: commit d2a3333ba6f354027a248bbfb2e1b8359d403c52 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Feb 3 23:32:40 2022 +0530 Commit: Pranam Lashkari <lpra...@collabora.com> CommitDate: Fri Feb 4 12:38:44 2022 +0100 Added master slide handling in getPart* functions of SdXImpressDocument There was no option to get the master slide info from SdXImpressDocument Change-Id: Ic42a4c541c406a50ec26ec2113174ab25675a074 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129423 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Pranam Lashkari <lpra...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129480 Tested-by: Jenkins diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index 7557aa1a247a..4db38965efe0 100644 --- a/sd/sdi/sdraw.sdi +++ b/sd/sdi/sdraw.sdi @@ -3612,7 +3612,7 @@ SfxBoolItem MasterSlidesPanel SID_MASTER_SLIDES_PANEL GroupId = SfxGroupId::Modify; ] -SfxVoidItem SlideMasterPage SID_SLIDE_MASTER_MODE +SfxBoolItem SlideMasterPage SID_SLIDE_MASTER_MODE () [ AutoUpdate = FALSE, diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 62545ec2f0c4..cf88666f69bc 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -236,6 +236,7 @@ public: virtual OUString getPartName( int nPart ) override; virtual OUString getPartHash( int nPart ) override; virtual VclPtr<vcl::Window> getDocWindow() override; + bool isMasterViewMode(); virtual void setPartMode( int nPartMode ) override; diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 0bfd6fd3dc74..c7653501babe 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -46,6 +46,7 @@ #include <unomodel.hxx> #include "unopool.hxx" #include <sfx2/lokhelper.hxx> +#include <sfx2/dispatch.hxx> #include <vcl/svapp.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -127,6 +128,8 @@ #include <tools/UnitConversion.hxx> #include <svx/ColorSets.hxx> +#include <app.hrc> + using namespace ::cppu; using namespace ::com::sun::star; using namespace ::sd; @@ -2319,11 +2322,12 @@ void SdXImpressDocument::setPart( int nPart, bool bAllowChangeFocus ) int SdXImpressDocument::getParts() { - // TODO: master pages? - // Read: drviews1.cxx if (!mpDoc) return 0; + if (isMasterViewMode()) + return mpDoc->GetMasterSdPageCount(PageKind::Standard); + return mpDoc->GetSdPageCount(PageKind::Standard); } @@ -2336,9 +2340,14 @@ int SdXImpressDocument::getPart() return pViewSh->GetViewShellBase().getPart(); } -OUString SdXImpressDocument::getPartName( int nPart ) +OUString SdXImpressDocument::getPartName(int nPart) { - SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard ); + SdPage* pPage; + if (isMasterViewMode()) + pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard); + else + pPage = mpDoc->GetSdPage(nPart, PageKind::Standard); + if (!pPage) { SAL_WARN("sd", "DrawViewShell not available!"); @@ -2348,9 +2357,14 @@ OUString SdXImpressDocument::getPartName( int nPart ) return pPage->GetName(); } -OUString SdXImpressDocument::getPartHash( int nPart ) +OUString SdXImpressDocument::getPartHash(int nPart) { - SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard ); + SdPage* pPage; + if (isMasterViewMode()) + pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard); + else + pPage = mpDoc->GetSdPage(nPart, PageKind::Standard); + if (!pPage) { SAL_WARN("sd", "DrawViewShell not available!"); @@ -2360,6 +2374,23 @@ OUString SdXImpressDocument::getPartHash( int nPart ) return OUString::number(pPage->GetHashCode()); } +bool SdXImpressDocument::isMasterViewMode() +{ + DrawViewShell* pViewSh = GetViewShell(); + if (!pViewSh) + return false; + + if (pViewSh->GetDispatcher()) + { + const SfxPoolItem* xItem = nullptr; + pViewSh->GetDispatcher()->QueryState(SID_SLIDE_MASTER_MODE, xItem); + const SfxBoolItem* isMasterViewMode = dynamic_cast<const SfxBoolItem*>(xItem); + if (isMasterViewMode && isMasterViewMode->GetValue()) + return true; + } + return false; +} + VclPtr<vcl::Window> SdXImpressDocument::getDocWindow() { SolarMutexGuard aGuard;