sfx2/source/control/unoctitm.cxx | 1 + sw/inc/unotxdoc.hxx | 2 ++ sw/inc/viewopt.hxx | 5 +++++ sw/qa/uibase/uno/uno.cxx | 22 ++++++++++++++++++++++ sw/source/uibase/uno/loktxdoc.cxx | 7 +++++++ 5 files changed, 37 insertions(+)
New commits: commit 5ba4c652fab709d5d8182b4ad99bf1e676e7e6ca Author: Miklos Vajna <[email protected]> AuthorDate: Tue Dec 2 09:04:50 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Dec 2 20:51:34 2025 +0100 cool#13574 sw redline render mode: send LOK status This has 2 parts: 1) Send the status of the UNO command in the LOK case. This allows a LOK client to call getPartInfo(), when a non-standard redline render mode is activated, similar to how the Impress case can use .uno:NotesMode to react to the enter/leave of notes editing mode. 2) Implement getPartInfo() for Writer, which allows core to expose the current "mode" (0 for standard, 2 for 'omit delete'). Ignore the part number, since Writer only has 1 part in the LOK API, but expose our current mode there. With this, a suitable LOK client can repaint tiles when .uno:RedlineRenderMode is dispatched to "enter" or "leave" this "omit delete" redline render mode. Change-Id: I5115bfd6e72ac5117a16f55e8f370be92e774f7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194929 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index dad55c406b82..ec456a103d58 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1182,6 +1182,7 @@ const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList() { u"CharBackgroundExt", { PayloadType::IsActivePayload, true } }, { u"ControlCodes", { PayloadType::IsActivePayload, true } }, + { u"RedlineRenderMode", { PayloadType::IsActivePayload, true } }, { u"DefaultBullet", { PayloadType::IsActivePayload, true } }, { u"DefaultNumbering", { PayloadType::IsActivePayload, true } }, { u"Italic", { PayloadType::IsActivePayload, true } }, diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 7e1d793694ae..e440821d2e49 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -504,6 +504,8 @@ public: int getEditMode() override; /// @see vcl::ITiledRenderable::setEditMode(). void setEditMode(int nEditMode) override; + /// @see vcl::ITiledRenderable::getPartInfo(). + OUString getPartInfo(int nPart) override; void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index f07cdb15c7ed..64a80b5ffb64 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -264,10 +264,15 @@ struct SwViewColors }; /// View option to determine if some of the redlines should be omitted during rendering or not. +/// +/// This is exposed on the LOK API, don't reorder the names. enum class SwRedlineRenderMode { + /// Normal rendering. Standard, + /// Special handling of inserts to ~omit them / paint with small saturation. OmitInserts, + /// Special handling of deletes to ~omit them / paint with small saturation. OmitDeletes, }; diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx index 2848c367a13b..6a7f866091bd 100644 --- a/sw/qa/uibase/uno/uno.cxx +++ b/sw/qa/uibase/uno/uno.cxx @@ -598,6 +598,28 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testDoNotMirrorRtlDrawObjs) CPPUNIT_ASSERT(bDoNotMirrorRtlDrawObjs); } +CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testRedlineRenderModePartInfo) +{ + // Given a document with redline render mode set to "omit deletes": + createSwDoc(); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwViewOption aOpt(*pWrtShell->GetViewOptions()); + aOpt.SetRedlineRenderMode(SwRedlineRenderMode::OmitDeletes); + pWrtShell->ApplyViewOptions(aOpt); + + // When getting the LOK part info: + OUString aPartInfo = getSwTextDoc()->getPartInfo(0); + + // Then make sure we get the correct value: + std::stringstream aStream((std::string(aPartInfo.toUtf8()))); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + // Without the accompanying fix in place, this test would have failed with: + // - <unspecified file>(1): expected value + // i.e. the json "mode" key was missing. + CPPUNIT_ASSERT_EQUAL(std::string("2"), aTree.get<std::string>("mode")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uno/loktxdoc.cxx b/sw/source/uibase/uno/loktxdoc.cxx index 54c5e3b6ebba..27f0ebca1d3c 100644 --- a/sw/source/uibase/uno/loktxdoc.cxx +++ b/sw/source/uibase/uno/loktxdoc.cxx @@ -1168,6 +1168,13 @@ void SwXTextDocument::setEditMode(int nEditMode) } } +OUString SwXTextDocument::getPartInfo(int /*nPart*/) +{ + tools::JsonWriter jsonWriter; + jsonWriter.put("mode", getEditMode()); + return OUString::fromUtf8(jsonWriter.finishAndGetAsOString()); +} + void SwXTextDocument::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) { using namespace std::string_view_literals;
