[Libreoffice-commits] core.git: sw/qa sw/source
Mike Kaganski
mike.kaganski at collabora.com
Fri Mar 16 09:55:03 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 1f3630e2fb35389835cb326a46bd539660942632
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>
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 63f02288c8f4..9ef300b9bac0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -306,6 +306,7 @@ public:
void testTdf115065();
void testTdf115132();
void testXDrawPagesSupplier();
+ void testTdf116403();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -489,6 +490,7 @@ public:
CPPUNIT_TEST(testTdf115065);
CPPUNIT_TEST(testTdf115132);
CPPUNIT_TEST(testXDrawPagesSupplier);
+ CPPUNIT_TEST(testTdf116403);
CPPUNIT_TEST_SUITE_END();
private:
@@ -6020,6 +6022,30 @@ void SwUiWriterTest::testXDrawPagesSupplier()
xDrawPage.get(), xDrawPageFromXDrawPages.get());
}
+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 6de76cb4f2c7..3fd3abb8abb1 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