summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2023-01-05 18:17:12 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2023-01-09 07:54:51 +0000
commit788cc6ff3b186ceb8f265e53b5482f808f6536f4 (patch)
tree4d23a4ecfafc87130d45b0293bf005bb72810ec2
parent8ae84bb5566e12df64236a116b9d1889d6f5f052 (diff)
tdf#148578: Do not apply table shift for RTF
Table shift based on cell lect margin should be applied for DOCX (earlier compat options) but not actual for RTF. Maybe earlier RTF version did behave this way, but nowadays this behavior does not match MS Word 365. Change-Id: Icdc4fa6298167fe5f263c85164d7c4c4176be25f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145088 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--sw/qa/extras/rtfexport/data/tdf148578.rtf12
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx21
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx5
3 files changed, 34 insertions, 4 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf148578.rtf b/sw/qa/extras/rtfexport/data/tdf148578.rtf
new file mode 100644
index 000000000000..256d63898770
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf148578.rtf
@@ -0,0 +1,12 @@
+{\rtf1
+
+\trowd
+\trgaph567
+\cellx1851
+\cellx9206
+\pard\plain\intbl 1000\cell
+\pard\plain\intbl XX_XX_XXX1\cell
+\row
+
+\pard MMMM
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 55f5a0362174..a79e92814222 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -514,6 +514,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127806)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(635), aSize.Width);
}
+DECLARE_RTFEXPORT_TEST(testTdf148578, "tdf148578.rtf")
+{
+ // \trgaph567 should affect only table cell margings (~1cm),
+ // but do not shift table, since \trleft is not provided
+ uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xTable, "LeftMargin"));
+
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1000),
+ getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1000),
+ getProperty<sal_Int32>(xCell, "RightBorderDistance"));
+
+ xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1000),
+ getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1000),
+ getProperty<sal_Int32>(xCell, "RightBorderDistance"));
+}
+
DECLARE_RTFEXPORT_TEST(testInvalidParagraphStyle, "invalidParagraphStyle.rtf")
{
// Given test has character style #30, but referred as paragraph style #30
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 47a2424c298a..58d96a9cd8f5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -613,12 +613,9 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
// tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level tables are handled the same as nested tables;
// the default behavior when DOCX doesn't define "compatibilityMode" option is to add the cell spacing
-
- // Undefined should not be possible any more for DOCX, but it is for RTF.
- // In any case, continue to treat undefined as version 12 during import.
sal_Int32 nMode = m_rDMapper_Impl.GetSettingsTable()->GetWordCompatibilityMode();
- if (((nMode < 0) || (0 < nMode && nMode <= 14)) && rInfo.nNestLevel == 1)
+ if (0 < nMode && nMode <= 14 && rInfo.nNestLevel == 1)
{
const sal_Int32 nAdjustedMargin = nLeftMargin - rInfo.nLeftBorderDistance;
m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::Any( nAdjustedMargin ) );