include/sfx2/lokhelper.hxx | 2 ++ include/sfx2/viewsh.hxx | 2 ++ include/vcl/ITiledRenderable.hxx | 13 +++++++++++++ sd/source/ui/inc/ViewShellBase.hxx | 4 ++++ sd/source/ui/inc/unomodel.hxx | 6 +++++- sd/source/ui/unoidl/unomodel.cxx | 23 +++++++++++++++++++++++ sd/source/ui/view/ViewShellBase.cxx | 36 ++++++++++++++++++++++++++++++++++++ sfx2/source/view/lokhelper.cxx | 10 +++++++++- sfx2/source/view/viewsh.cxx | 5 +++++ 9 files changed, 99 insertions(+), 2 deletions(-)
New commits: commit ffe011c53dd34f73c41f2a220bbf305c7449f8fe Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Aug 29 08:40:14 2022 +0200 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Oct 21 15:04:31 2022 +0200 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index d66c2f71bffd..7e899766785d 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -56,6 +56,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 9f085fca62e3..3fb70cd11719 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -360,6 +360,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 32a9a0010ef9..a26c1e6675ea 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -118,6 +118,19 @@ public: /// @see lok::Document::setPartMode(). 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 d7f37ba974df..005ec5794b81 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 78b39b6ff0ed..a71f3e9d1747 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2320,7 +2320,10 @@ OUString SdXImpressDocument::getPartInfo(int nPart) OUString::number(static_cast<unsigned int>(bIsSelected)) + "\", \"masterPageCount\": \"" + OUString::number(nMasterPageCount) + + "\", \"mode\": \"" + + OUString::number(getEditMode()) + "\" }"; + return aPartInfo; } @@ -2438,6 +2441,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 7cc5a58b8da5..9d38c10a145e 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(*const_cast<ViewShellBase*>(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 c1e8c929345d..ccd88eb5ff6b 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 0e9279dedeb3..87e5a44fbe9b 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;