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 12c7668ad127e8969eb8c3bb26b7a79e8f726ce5 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 10:10:20 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> (cherry picked from commit 28c1ea0bb5a43cfbe0f9795c573b3e0f2c19be37) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129429 diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index a675db0efb5e..4efd8ec9e6a7 100644 --- a/sd/sdi/sdraw.sdi +++ b/sd/sdi/sdraw.sdi @@ -3594,7 +3594,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 60dfcb02f8d1..6b949a27bbb7 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -238,6 +238,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 5de97c06936f..e6b6012f79c6 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -45,6 +45,7 @@ #include <unomodel.hxx> #include "unopool.hxx" #include <sfx2/lokhelper.hxx> +#include <sfx2/dispatch.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -122,6 +123,8 @@ #include <tools/debug.hxx> #include <tools/diagnose_ex.h> +#include <app.hrc> + #define TWIPS_PER_PIXEL 15 using namespace ::cppu; @@ -2297,11 +2300,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); } @@ -2314,9 +2318,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!"); @@ -2326,9 +2335,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!"); @@ -2338,6 +2352,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;