summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--include/vcl/ITiledRenderable.hxx13
-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
-rw-r--r--sfx2/source/view/lokhelper.cxx10
-rw-r--r--sfx2/source/view/viewsh.cxx5
9 files changed, 99 insertions, 2 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index eaa7abe9785c..b2bf16aa99ab 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -58,6 +58,8 @@ public:
static void destroyView(int nId);
/// Set a view shell as current one.
static void setView(int nId);
+ /// Set the edit mode for a document with callbacks disabled.
+ static void setEditMode(int nMode, vcl::ITiledRenderable* pDoc);
/// Get view shell with id
static SfxViewShell* getViewOfId(int nId);
/// Get the currently active view.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 5d1a44ff07be..6196faa4ca4a 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -365,6 +365,8 @@ public:
void setTiledSearching(bool bTiledSearching);
/// See lok::Document::getPart().
virtual int getPart() const;
+ /// See lok::Document::getMode().
+ virtual int getEditMode() const;
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
/// See OutlinerViewShell::GetViewShellId().
ViewShellId GetViewShellId() const override;
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 2562ce8b187f..f06193172702 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -118,6 +118,19 @@ public:
virtual void setPartMode(int) {}
/**
+ * Get the currently used EditMode (supported in Impress).
+ */
+ virtual int getEditMode()
+ {
+ return 0;
+ }
+
+ /**
+ * Set the currently used EditMode (supported in Impress).
+ */
+ virtual void setEditMode(int) {}
+
+ /**
* Setup various document properties that are needed for the document to
* be renderable via tiled rendering.
*/
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();
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index b168538fe0c8..c631aa8d6257 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -125,6 +125,12 @@ int SfxLokHelper::createView(int nDocId)
return -1;
}
+void SfxLokHelper::setEditMode(int nMode, vcl::ITiledRenderable* pDoc)
+{
+ DisableCallbacks dc;
+ pDoc->setEditMode(nMode);
+}
+
void SfxLokHelper::destroyView(int nId)
{
const SfxApplication* pApp = SfxApplication::Get();
@@ -359,6 +365,7 @@ static OString lcl_generateJSON(const SfxViewShell* pView, const boost::property
boost::property_tree::ptree aMessageProps = rTree;
aMessageProps.put("viewId", SfxLokHelper::getView(pView));
aMessageProps.put("part", pView->getPart());
+ aMessageProps.put("mode", pView->getEditMode());
std::stringstream aStream;
boost::property_tree::write_json(aStream, aMessageProps, false /* pretty */);
const std::string aString = aStream.str();
@@ -370,7 +377,8 @@ static inline OString lcl_generateJSON(const SfxViewShell* pView, int nViewId, s
{
assert(pView != nullptr && "pView must be valid");
return OString::Concat("{ \"viewId\": \"") + OString::number(nViewId)
- + "\", \"part\": \"" + OString::number(pView->getPart()) + "\", \"" + rKey + "\": \""
+ + "\", \"part\": \"" + OString::number(pView->getPart()) + "\", \"mode\": \""
+ + OString::number(pView->getEditMode()) + "\", \"" + rKey + "\": \""
+ lcl_sanitizeJSONAsValue(rPayload) + "\" }";
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 1363d07c1eb5..c21790aa9be5 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1617,6 +1617,11 @@ int SfxViewShell::getPart() const
return 0;
}
+int SfxViewShell::getEditMode() const
+{
+ return 0;
+}
+
ViewShellId SfxViewShell::GetViewShellId() const
{
return pImpl->m_nViewShellId;