[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Mon Mar 19 14:57:52 UTC 2018


 sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx                       |   26 +++++++++++++++
 sw/source/core/tox/ToxTabStopTokenHandler.cxx            |    5 ++
 3 files changed, 31 insertions(+)

New commits:
commit e0b94a575024b6d20c4adb117a6d3a0079d80d39
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Fri Mar 16 11:22:41 2018 +0300

    tdf#116403: consider borders when updating right-aligned tab in index
    
    Change-Id: I415d8fcfdd75e6d608ec2e3ba228146cf8139278
    Reviewed-on: https://gerrit.libreoffice.org/51388
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/51488
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt
new file mode 100644
index 000000000000..c0fb91ad7eb3
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 44a5903bcd02..a83f71f65136 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -243,6 +243,7 @@ public:
     void testTdf113790();
     void testTdf115013();
     void testTdf115132();
+    void testTdf116403();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -373,6 +374,7 @@ public:
     CPPUNIT_TEST(testTdf113790);
     CPPUNIT_TEST(testTdf115013);
     CPPUNIT_TEST(testTdf115132);
+    CPPUNIT_TEST(testTdf116403);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4757,6 +4759,30 @@ void SwUiWriterTest::testTdf115132()
     }
 }
 
+void SwUiWriterTest::testTdf116403()
+{
+    createDoc("tdf116403-considerborders.odt");
+    // Check that before ToX update, the tab stop position is the old one
+    uno::Reference<text::XTextRange> xParagraph = getParagraph(2, "1\t1");
+    auto aTabs = getProperty<uno::Sequence<style::TabStop>>(xParagraph, "ParaTabStops");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(17000), aTabs[0].Position);
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    const SwTOXBase* pTOX = pWrtShell->GetTOX(0);
+    CPPUNIT_ASSERT(pTOX);
+    pWrtShell->UpdateTableOf(*pTOX);
+
+    xParagraph = getParagraph(2, "1\t1");
+    aTabs = getProperty<uno::Sequence<style::TabStop>>(xParagraph, "ParaTabStops");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
+    // This was still 17000, refreshing ToX didn't take borders spacings and widths into account
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Page borders must be considered for right-aligned tabstop",
+        static_cast<sal_Int32>(17000 - 2 * 500 - 2 * 1), aTabs[0].Position);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
index f31e0456fcc3..53bae640e396 100644
--- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx
+++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
@@ -93,6 +93,11 @@ DefaultToxTabStopTokenHandler::CalculatePageMarginFromPageDescription(const SwTe
     const SwFrameFormat& rPgDscFormat = pPageDesc->GetMaster();
     long result = rPgDscFormat.GetFrameSize().GetWidth() - rPgDscFormat.GetLRSpace().GetLeft()
             - rPgDscFormat.GetLRSpace().GetRight();
+    // Also consider borders
+    const SvxBoxItem& rBox = rPgDscFormat.GetBox();
+    for (SvxBoxItemLine eLine : { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT })
+        if (const editeng::SvxBorderLine* pBorder = rBox.GetLine(eLine))
+            result -= pBorder->GetWidth() + rBox.GetDistance(eLine);
     return result;
 }
 


More information about the Libreoffice-commits mailing list