[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 30 18:13:46 UTC 2021


 sw/inc/section.hxx                    |    6 +++---
 sw/qa/extras/uiwriter/data/DUMMY.odm  |binary
 sw/qa/extras/uiwriter/data/DUMMY1.odt |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx   |   28 ++++++++++++++++++++++++++++
 sw/source/core/docnode/ndsect.cxx     |    4 ++--
 sw/source/core/docnode/section.cxx    |    5 -----
 6 files changed, 33 insertions(+), 10 deletions(-)

New commits:
commit 91b0024965908c692bea40f47c58ea9d1bf8a596
Author:     Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Mon Aug 30 17:04:53 2021 +0200
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Mon Aug 30 20:13:14 2021 +0200

    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 at allotropia.de>

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
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/DUMMY.odm 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
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/DUMMY1.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index c283f3022803..7ea98b947995 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2690,6 +2690,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 627475de7e89..ff7946ed3b3b 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 f69764b9035b..afa8b905e99e 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() );


More information about the Libreoffice-commits mailing list