summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-03-16 11:22:41 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-03-16 10:54:36 +0100
commit1f3630e2fb35389835cb326a46bd539660942632 (patch)
tree2fc6509e8fba182c5ba89f951e1294b196a706cf
parent7619390bd15fa26fc8f74d75f187cf8bf2fca58b (diff)
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@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf116403-considerborders.odtbin0 -> 9284 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx26
-rw-r--r--sw/source/core/tox/ToxTabStopTokenHandler.cxx5
3 files changed, 31 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt
Binary files 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;
}