sw/inc/viewopt.hxx                                     |    5 ----
 sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx         |   18 +++++++++++++++++
 sw/source/uibase/config/viewopt.cxx                    |    6 +++++
 4 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 7a6b80995f69304149e0ab7a8e1fa92a15b20d07
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Oct 4 10:04:42 2023 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Oct 9 08:15:02 2023 +0200

    LOKit: always display hidden chars when showing formatting marks
    
    This is related to the request in tdf#107658 to do the same for core.
    However, this is something fairly easily doable with an extension
    in core, so I'm not in favour of forcing one user's opinion over top
    of status quo.
    
    Doing this only for Online.
    
    make CppunitTest_sw_tiledrendering \
        CPPUNIT_TEST_NAME=testShowHiddenCharsWhenShowFormatting
    
    Change-Id: I34bbe50dd4bbff92577b18f8a05d2f8dd67ea771
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157562
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 27d0c8cbba2a9c2b6aa43e97d56f62d15b3b5bca)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157617
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index e0a3353d3b27..3b667f24871d 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -486,10 +486,7 @@ public:
     void SetTreatSubOutlineLevelsAsContent(bool b)
     { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; }
 
-    bool IsShowHiddenChar(bool bHard = false) const
-    { return !m_bReadonly && m_nCoreOptions.bCharHidden &&
-                            (m_nCoreOptions.bViewMetachars || bHard); }
-
+    bool IsShowHiddenChar(bool bHard = false) const;
     void SetShowHiddenChar( bool b )
     { m_nCoreOptions.bCharHidden = b; }
 
diff --git a/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx 
b/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx
new file mode 100644
index 000000000000..0802f6e7d314
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 18096767a570..91344a563505 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3030,6 +3030,24 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPilcrowRedlining)
     comphelper::dispatchCommand(".uno:ControlCodes", {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShowHiddenCharsWhenShowFormatting)
+{
+    // In LOKit, ignore the config setting for
+    // Tools - Options - Writer - Formatting Aids - Display Formatting - 
Hidden characters
+    // and always show hidden content when showing pilcrow formatting
+
+    createSwDoc("hiddenLoremIpsum.docx");
+
+    // Since LOKit is active in TiledRendering, turning on "Show formatting" 
will show hidden text.
+    comphelper::dispatchCommand(".uno:ControlCodes", {}); // show format marks
+    Scheduler::ProcessEventsToIdle();
+
+    // Without this patch, no body text would be visible - so only 1 page 
instead of 3.
+    CPPUNIT_ASSERT_EQUAL(3, getPages());
+
+    comphelper::dispatchCommand(".uno:ControlCodes", {});
+}
+
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testDoubleUnderlineAndStrikeOut)
 {
     // Load a document where the tracked text moving is visible with
diff --git a/sw/source/uibase/config/viewopt.cxx 
b/sw/source/uibase/config/viewopt.cxx
index fba5bae14424..fb591899ad37 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -186,6 +186,12 @@ bool SwViewOption::IsTreatSubOutlineLevelsAsContent() const
     return m_nCoreOptions.bTreatSubOutlineLevelsAsContent;
 }
 
+bool SwViewOption::IsShowHiddenChar(bool bHard) const
+{
+    bool bCharHidden = comphelper::LibreOfficeKit::isActive() ? true : 
m_nCoreOptions.bCharHidden;
+    return !m_bReadonly && bCharHidden && (m_nCoreOptions.bViewMetachars || 
bHard);
+}
+
 void SwViewOption::DrawRect( OutputDevice *pOut,
                              const SwRect &rRect, ::Color nCol )
 {

Reply via email to