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 28c1ea0bb5a43cfbe0f9795c573b3e0f2c19be37 Author: Pranam Lashkari <[email protected]> AuthorDate: Thu Feb 3 23:32:40 2022 +0530 Commit: Pranam Lashkari <[email protected]> CommitDate: Thu Feb 3 20:01:05 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 <[email protected]> Reviewed-by: Pranam Lashkari <[email protected]> diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index 436a89cc30b4..641556050cf9 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 2873e705ca6b..65614db92742 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 87a71531d62c..35caf84d649a 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> @@ -126,6 +127,8 @@ #include <tools/json_writer.hxx> #include <tools/UnitConversion.hxx> +#include <app.hrc> + #define TWIPS_PER_PIXEL 15 using namespace ::cppu; @@ -2331,11 +2334,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); } @@ -2348,9 +2352,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!"); @@ -2360,9 +2369,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!"); @@ -2372,6 +2386,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;
