summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-08-29 08:40:14 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-11-09 21:49:09 +0100
commit4c0e5d0be02ba25be0e8b4748fbf0060491de93c (patch)
tree2e4ec300992613f19e81d30db262bf23a360d9ef /sd
parent875c27dc7975de9b007a215fe1d6f171b4ef090e (diff)
lok: masterpage: introduce EditMode setter and getter for ViewShell
Change-Id: I74d3307aab8fc038bd2409b5f10a2d08db885223 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138957 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142472 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/ViewShellBase.hxx4
-rw-r--r--sd/source/ui/inc/unomodel.hxx6
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx23
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx36
4 files changed, 68 insertions, 1 deletions
diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx
index eab26ec8a1ba..7fc4af2a2da0 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -213,6 +213,10 @@ public:
OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const;
/// See SfxViewShell::getPart().
int getPart() const override;
+ /// See SfxViewShell::getEditMode().
+ int getEditMode() const override;
+ /// See SfxViewShell::setEditMode().
+ void setEditMode(int nMode);
/// See SfxViewShell::NotifyCursor().
void NotifyCursor(SfxViewShell* pViewShell) const override;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 74e21ed44131..98d5c4473f9b 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -240,8 +240,12 @@ public:
virtual VclPtr<vcl::Window> getDocWindow() override;
bool isMasterViewMode();
+ /// @see vcl::ITiledRenderable::setPartMode().
virtual void setPartMode( int nPartMode ) override;
-
+ /// @see vcl::ITiledRenderable::getEditMode().
+ virtual int getEditMode() override;
+ /// @see vcl::ITiledRenderable::setEditMode().
+ virtual void setEditMode(int) override;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
/// @see vcl::ITiledRenderable::postKeyEvent().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 990f9c84b625..2125fe109ed5 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2339,7 +2339,10 @@ OUString SdXImpressDocument::getPartInfo(int nPart)
OUString::number(static_cast<unsigned int>(bIsSelected)) +
"\", \"masterPageCount\": \"" +
OUString::number(nMasterPageCount) +
+ "\", \"mode\": \"" +
+ OUString::number(getEditMode()) +
"\" }";
+
return aPartInfo;
}
@@ -2456,6 +2459,26 @@ void SdXImpressDocument::setPartMode( int nPartMode )
pViewSh->SetPageKind( aPageKind );
}
+int SdXImpressDocument::getEditMode()
+{
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return 0;
+
+ return pViewSh->GetViewShellBase().getEditMode();
+}
+
+void SdXImpressDocument::setEditMode(int nMode)
+{
+ SolarMutexGuard aGuard;
+
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return;
+
+ pViewSh->GetViewShellBase().setEditMode(nMode);
+}
+
Size SdXImpressDocument::getDocumentSize()
{
DrawViewShell* pViewSh = GetViewShell();
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 7eea42b1aefd..3bebad697786 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -977,6 +977,42 @@ int ViewShellBase::getPart() const
return 0;
}
+int ViewShellBase::getEditMode() const
+{
+ ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
+
+ if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell))
+ {
+ switch ( pDrawViewShell->GetEditMode() )
+ {
+ case EditMode::Page:
+ return 0;
+ case EditMode::MasterPage:
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void ViewShellBase::setEditMode(int nMode)
+{
+ ViewShell* pViewShell = framework::FrameworkHelper::Instance(*this)->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
+
+ if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell))
+ {
+ switch ( nMode )
+ {
+ case 0:
+ pDrawViewShell->ChangeEditMode(EditMode::Page, false);
+ break;
+ case 1:
+ pDrawViewShell->ChangeEditMode(EditMode::MasterPage, false);
+ break;
+ }
+ }
+}
+
void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
{
ViewShell* pThisShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get();