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 27d0c8cbba2a9c2b6aa43e97d56f62d15b3b5bca
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Oct 4 10:04:42 2023 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Oct 5 19:21:03 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>

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index b82b970cb540..b5bf16b5ca22 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -484,10 +484,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 2e43441958f8..b3b6c948d884 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2971,6 +2971,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 93ee5f710653..1e78b1fdac02 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -184,6 +184,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