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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Jan 6 17:50:12 UTC 2019


 sw/qa/extras/ww8import/data/tdf122425_1.doc |binary
 sw/qa/extras/ww8import/data/tdf122425_2.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx        |   66 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8graf.cxx            |    1 
 sw/source/filter/ww8/ww8par.cxx             |    7 ++
 5 files changed, 73 insertions(+), 1 deletion(-)

New commits:
commit 2e189c2464de007b3d59ba37d4f3f1cfbe5b480c
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Jan 6 19:35:41 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Jan 6 18:49:52 2019 +0100

    tdf#122425: explicitly remove borders for newly created flys
    
    After commit d398e9248c183cf988b6d985b342b0cbff93ea02, it's necessary
    to make sure that each created floating object has proper default
    border and spacing values (empty and 0), to not inherit frame style's
    non-0 values unintentionally.
    
    This fixes two places for objects in headers/footers.
    
    Change-Id: I2632bcd4066609c97aa15e39d69e9089ac691ff2
    Reviewed-on: https://gerrit.libreoffice.org/65906
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/ww8import/data/tdf122425_1.doc b/sw/qa/extras/ww8import/data/tdf122425_1.doc
new file mode 100644
index 000000000000..f0e5b148d347
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf122425_1.doc differ
diff --git a/sw/qa/extras/ww8import/data/tdf122425_2.doc b/sw/qa/extras/ww8import/data/tdf122425_2.doc
new file mode 100644
index 000000000000..8debcddc1690
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf122425_2.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index cd07887669bd..83395192985f 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -190,6 +190,72 @@ DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc")
     }
 }
 
+DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
+{
+    // This is for header text in case we use a hack for fixed-height headers
+    // (see SwWW8ImplReader::Read_HdFtTextAsHackedFrame)
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false);
+    // There are two fly frames in the document: for first page's header, and for other pages'
+    CPPUNIT_ASSERT_EQUAL(size_t(2), aPosFlyFrames.size());
+    for (const auto& rPosFlyFrame : aPosFlyFrames)
+    {
+        const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat();
+        const SfxPoolItem* pItem = nullptr;
+
+        // The LR and UL spacings and borders must all be set explicitly;
+        // spacings and border distances must be 0; borders must be absent
+
+        CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_LR_SPACE, false, &pItem));
+        auto pLR = static_cast<const SvxLRSpaceItem*>(pItem);
+        CPPUNIT_ASSERT(pLR);
+        CPPUNIT_ASSERT_EQUAL(long(0), pLR->GetLeft());
+        CPPUNIT_ASSERT_EQUAL(long(0), pLR->GetRight());
+
+        CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem));
+        auto pUL = static_cast<const SvxULSpaceItem*>(pItem);
+        CPPUNIT_ASSERT(pUL);
+        CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetUpper());
+        CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetLower());
+
+        CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_BOX, false, &pItem));
+        auto pBox = static_cast<const SvxBoxItem*>(pItem);
+        CPPUNIT_ASSERT(pBox);
+        for (auto eLine : { SvxBoxItemLine::TOP, SvxBoxItemLine::BOTTOM,
+                            SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT })
+        {
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pBox->GetDistance(eLine));
+            CPPUNIT_ASSERT(!pBox->GetLine(eLine));
+        }
+    }
+}
+
+DECLARE_WW8IMPORT_TEST(testTdf122425_2, "tdf122425_2.doc")
+{
+    // This is for graphic objects in headers/footers
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false);
+    // There is one fly frame in the document: the text box
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aPosFlyFrames.size());
+    for (const auto& rPosFlyFrame : aPosFlyFrames)
+    {
+        const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat();
+        const SfxPoolItem* pItem = nullptr;
+
+        // Check for correct explicitly-set values of UL spacings. Previously this was "DEFAULT",
+        // and resulted in inherited values (114 = 2 mm) used.
+        CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem));
+        auto pUL = static_cast<const SvxULSpaceItem*>(pItem);
+        CPPUNIT_ASSERT(pUL);
+        CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetUpper());
+        CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetLower());
+    }
+}
+
 // tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 41855fdbf6b9..25235fa64bb0 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2553,6 +2553,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
 
     // determine wrapping mode
     SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{});
+    Reader::ResetFrameFormatAttrs(aFlySet); // tdf#122425: Explicitly remove borders and spacing
     css::text::WrapTextMode eSurround = css::text::WrapTextMode_PARALLEL;
     bool bContour = false;
     switch (pF->nwr)
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 16c7850adce7..4b4ca3df60d2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2179,7 +2179,12 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(WW8_CP nStart, WW8_CP nLen,
     m_pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1;
     m_pPaM->GetPoint()->nContent.Assign(m_pPaM->GetContentNode(), 0);
 
-    SwFlyFrameFormat *pFrame = m_rDoc.MakeFlySection(RndStdIds::FLY_AT_PARA, m_pPaM->GetPoint());
+    // tdf#122425: Explicitly remove borders and spacing
+    SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{});
+    Reader::ResetFrameFormatAttrs(aFlySet);
+
+    SwFlyFrameFormat* pFrame
+        = m_rDoc.MakeFlySection(RndStdIds::FLY_AT_PARA, m_pPaM->GetPoint(), &aFlySet);
 
     SwFormatAnchor aAnch( pFrame->GetAnchor() );
     aAnch.SetType( RndStdIds::FLY_AT_PARA );


More information about the Libreoffice-commits mailing list