diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-25 14:50:29 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-01-26 08:17:37 +0100 |
commit | 5234435a552d3d4cc421ba5c8600d8215f9f8f4b (patch) | |
tree | 1e2119fef0d34727c208b6b44210a2c516d111f1 | |
parent | 7556f924bc270497abe24f2e194fcc458b255781 (diff) |
revert: 'LOKit: always display hidden chars when showing formatting...'
and add a counter-reason test.
When we have multiple views of a document, whether in LOKit or in
desktop via "Window, New Window" then we have just one layout and render
that layout in each view. So with default settings: View, Formatting
Marks, we can correctly render the Pilcows in one view but not in the
another even though we share a single layout.
If "Show Hidden Characters" is enabled, then when "view formatting" is
also enabled then hidden characters are shown when view formatting is
enabled, and not when it is disabled.
But if "show hidden characters" are enabled, then if formatting marks
are enabled in one view and and not another then the hidden characters
will be either shown in both views or hidden in both views, depending on
whether the shared layout is done with "show/hide hidden characters". So
we currently can't show/hide the hidden characters per-view.
revert:
commit 7a6b80995f69304149e0ab7a8e1fa92a15b20d07
Date: Wed Oct 4 10:04:42 2023 -0400
LOKit: always display hidden chars when showing formatting marks
This arises from noting that in kit then on turning on formatting marks
in one view, then the other view rendering options changed, which isn't
wanted. But on attempting to keep the other ViewShell settings
unaffected it turns out to be futile given the shared layout.
Change-Id: I210b86fae84bc8137af415cb9c93dacdeab7d448
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162579
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/inc/viewopt.hxx | 5 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx | bin | 6807 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 53 | ||||
-rw-r--r-- | sw/source/uibase/config/viewopt.cxx | 6 |
4 files changed, 39 insertions, 25 deletions
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 6aaf24b65f39..a6fd5eea8a57 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -486,7 +486,10 @@ public: void SetTreatSubOutlineLevelsAsContent(bool b) { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; } - bool IsShowHiddenChar(bool bHard = false) const; + bool IsShowHiddenChar(bool bHard = false) const + { return !m_bReadonly && m_nCoreOptions.bCharHidden && + (m_nCoreOptions.bViewMetachars || bHard); } + 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 Binary files differdeleted file mode 100644 index 0802f6e7d314..000000000000 --- a/sw/qa/extras/tiledrendering/data/hiddenLoremIpsum.docx +++ /dev/null diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index ffa997cfdd67..b9d842529d68 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -757,6 +757,7 @@ namespace { bool m_bOwnSelectionSet; bool m_bViewSelectionSet; OString m_aViewSelection; + OString m_aViewRenderState; bool m_bTilesInvalidated; bool m_bViewCursorVisible; bool m_bGraphicViewSelection; @@ -904,6 +905,11 @@ namespace { m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; } break; + case LOK_CALLBACK_VIEW_RENDER_STATE: + { + m_aViewRenderState = pPayload; + } + break; case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED: { m_aRedlineTableChanged.clear(); @@ -3044,24 +3050,6 @@ 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 @@ -4131,6 +4119,35 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testRedlineTooltip) CPPUNIT_ASSERT(vec[3].toInt32() != 0); } +// toggling Formatting Marks on/off for one view should have no effect on other views +CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testToggleFormattingMarks) +{ + SwXTextDocument* pXTextDocument = createDoc(); + int nView1 = SfxLokHelper::getView(); + + SfxLokHelper::createView(); + int nView2 = SfxLokHelper::getView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + + SfxLokHelper::setView(nView1); + ViewCallback aView1; + + SfxLokHelper::setView(nView2); + ViewCallback aView2; + + OString sOrigView2RenderState = pXTextDocument->getViewRenderState(); + + comphelper::dispatchCommand(".uno:ControlCodes", {}); + + Scheduler::ProcessEventsToIdle(); + + // 1. change to view #2 shouldn't result in an update to view #1 renderstate + CPPUNIT_ASSERT(aView1.m_aViewRenderState.isEmpty()); + // 2. toggling on ControlCodes should result in view #2 render state reporting + // 'P' for Pilcrow + CPPUNIT_ASSERT_EQUAL(OString("P" + sOrigView2RenderState), aView2.m_aViewRenderState); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index fb591899ad37..fba5bae14424 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -186,12 +186,6 @@ 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 ) { |