summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-08-30 17:04:53 +0200
committerCaolán McNamara <caolanm@redhat.com>2021-08-31 21:01:17 +0200
commit6325c1a6d38ce3a67e6b4b538d1852fa5fc9cb3b (patch)
tree736896f76ddbf191b678d0229e94195a56f04690
parent9919b1c017dca81f5bf54aa27f0fda615c1bd2da (diff)
tdf#103612 sw: fix confusing inheritance of section hidden flag
SwSectionData has 3 confusing boolean members for hiding: * m_bHidden corresponds to the Hide checkbox in the UI * m_bCondHiddenFlag stores the result of evaluating the hide condition * m_bHiddenFlag is the final computed result that indicates that this section is hidden Now, the first 2 flags determine m_bHiddenFlag = true, but there's another possibility: m_bHiddenFlag is also true if there is a parent section for which m_bHiddenFlag is true (because of course this hides all section content including nested sections)... the latter situation is apparently handled in SwSectionFormat::UpdateParent(). The code in SwSection::SwSection() checks the parent's m_bHiddenFlag but then sets the child's m_bHidden, which looks very wrong, so remove this. Also adapt 2 other places that look like they should be checking a different flag. Change-Id: I58d9c878b58ad6cd878f450072178006b4c7ebb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121314 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 91b0024965908c692bea40f47c58ea9d1bf8a596) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121283 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/inc/section.hxx6
-rw-r--r--sw/qa/extras/uiwriter/data/DUMMY.odmbin0 -> 8336 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/DUMMY1.odtbin0 -> 8473 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx28
-rw-r--r--sw/source/core/docnode/ndsect.cxx4
-rw-r--r--sw/source/core/docnode/section.cxx5
6 files changed, 33 insertions, 10 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 7aa1107b17f5..0647e0273334 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -62,7 +62,7 @@ private:
SectionType m_eType;
OUString m_sSectionName;
- OUString m_sCondition;
+ OUString m_sCondition; ///< Hide condition
OUString m_sLinkFileName;
OUString m_sLinkFilePassword; // Must be changed to Sequence.
css::uno::Sequence <sal_Int8> m_Password;
@@ -77,8 +77,8 @@ private:
// Edit in readonly sections.
bool m_bEditInReadonlyFlag : 1;
- bool m_bHidden : 1; // All paragraphs hidden?
- bool m_bCondHiddenFlag : 1; // Hiddenflag for condition.
+ bool m_bHidden : 1; ///< Section is hidden, unless condition evalutes `false'
+ bool m_bCondHiddenFlag : 1; ///< Hide condition evaluated `true'
bool m_bConnectFlag : 1; // Connected to server?
public:
diff --git a/sw/qa/extras/uiwriter/data/DUMMY.odm b/sw/qa/extras/uiwriter/data/DUMMY.odm
new file mode 100644
index 000000000000..6c6713604119
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/DUMMY.odm
Binary files differ
diff --git a/sw/qa/extras/uiwriter/data/DUMMY1.odt b/sw/qa/extras/uiwriter/data/DUMMY1.odt
new file mode 100644
index 000000000000..127b4a7c6ed6
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/DUMMY1.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index f8be215965d8..3f9901572220 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2652,6 +2652,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128106)
tempDir.EnableKillingFile();
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf103612)
+{
+ SwDoc* const pGlobalDoc = createSwDoc(DATA_DIRECTORY, "DUMMY.odm");
+ CPPUNIT_ASSERT_EQUAL(
+ size_t(1),
+ pGlobalDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks().size());
+ pGlobalDoc->getIDocumentLinksAdministration().GetLinkManager().UpdateAllLinks(false, false,
+ nullptr);
+
+ xmlDocUniquePtr pLayout = parseLayoutDump();
+
+ assertXPath(pLayout, "/root/page[1]/body/section[1]/txt[1]/LineBreak[1]", "Line",
+ "Text before section");
+ // the inner section and its content was hidden
+ assertXPath(pLayout, "/root/page[1]/body/section[2]/txt[1]/LineBreak[1]", "Line",
+ "Text inside section before ToC");
+ assertXPath(pLayout, "/root/page[1]/body/section[3]/txt[1]/LineBreak[1]", "Line",
+ "Table of Contents");
+ assertXPath(pLayout, "/root/page[1]/body/section[4]/txt[1]/LineBreak[1]", "Line",
+ "First header*1");
+ assertXPath(pLayout, "/root/page[1]/body/section[4]/txt[2]/LineBreak[1]", "Line",
+ "Second header*1");
+ assertXPath(pLayout, "/root/page[1]/body/section[5]/txt[2]/LineBreak[1]", "Line",
+ "Text inside section after ToC");
+ assertXPath(pLayout, "/root/page[1]/body/section[6]/txt[1]/LineBreak[1]", "Line",
+ "Text after section");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 26647f2355cf..73c524774bde 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -915,7 +915,7 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx,
// We could optimize this, by not removing already contained Frames and recreating them,
// but by simply rewiring them
- bool bInsFrame = bCreateFrames && !pSectNd->GetSection().IsHidden() &&
+ bool bInsFrame = bCreateFrames && !pSectNd->GetSection().IsHiddenFlag() &&
GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell();
SwNode2LayoutSaveUpperFrames *pNode2Layout = nullptr;
if( bInsFrame )
@@ -1052,7 +1052,7 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
if( !(rNds.IsDocNodes() && rNds.GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell()) )
return;
- if( GetSection().IsHidden() || IsContentHidden() )
+ if (GetSection().IsHiddenFlag() || IsContentHidden())
{
SwNodeIndex aIdx( *EndOfSectionNode() );
SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 9d300621da0e..9491b56b53c3 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -201,11 +201,6 @@ SwSection::SwSection(
SwSection *const pParentSect = GetParent();
if( pParentSect )
{
- if( pParentSect->IsHiddenFlag() )
- {
- SetHidden();
- }
-
m_Data.SetProtectFlag( pParentSect->IsProtectFlag() );
// edit in readonly sections
m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() );