sw/qa/extras/rtfexport/data/tdf148578.rtf                |   12 ++++++++
 sw/qa/extras/rtfexport/rtfexport3.cxx                    |   21 +++++++++++++++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    5 ---
 3 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit 78e91fd2bf7fe7d92020e7d9d9a2c6c25c8da830
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Thu Jan 5 18:17:12 2023 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Mon Jan 9 23:45:03 2023 +0000

    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.behr...@allotropia.de>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145196

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 6c1a4d524b7f..5cbf173d35fb 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 2e962260c79c..97fea78eba2a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -618,12 +618,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 - nGapHalf - 
rInfo.nLeftBorderDistance;
             m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::Any( 
nAdjustedMargin ) );

Reply via email to