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 06091871434efee484b194f218f9e030a1348110 Author: Miklos Vajna <[email protected]> AuthorDate: Tue Dec 2 09:04:50 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Dec 2 12:20:24 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/+/194907 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 4bde66ad2d4c..7bef4796d3c8 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 67cd923ece0a..ef992b7f366a 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -514,6 +514,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 35d39129a01f..be53b9411fad 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -263,10 +263,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 c363e1f3ff42..d6f7c0994eb7 100644 --- a/sw/source/uibase/uno/loktxdoc.cxx +++ b/sw/source/uibase/uno/loktxdoc.cxx @@ -1163,6 +1163,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;
