[Libreoffice-commits] core.git: sw/qa sw/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 10:01:57 UTC 2020


 sw/qa/extras/ww8export/data/tdf73056_cellMargins.doc |binary
 sw/qa/extras/ww8export/ww8export3.cxx                |   13 +++++++
 sw/source/filter/ww8/ww8par2.cxx                     |   34 ++++++++++---------
 3 files changed, 32 insertions(+), 15 deletions(-)

New commits:
commit 623d6cf06ccba392c1993a3b0ad271d508205e73
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Apr 21 14:25:38 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Apr 29 12:01:21 2020 +0200

    tdf#73056 doc import: table margins - unknown byte is EndCell
    
    The problem was that the cell margin that overrides the
    table defaults was only being applied to one cell,
    while a range of cells might be defined.
    
    a sprmTCellPadding is specified by a CSSA.
    The CSSA starts with an ItcFirstLim, which consists of
    a start and end cell. The end cell is NOT included.
    
    Change-Id: Ia90bc28451d39d60ce343d24b02fd3661b05d950
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92628
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ww8export/data/tdf73056_cellMargins.doc b/sw/qa/extras/ww8export/data/tdf73056_cellMargins.doc
new file mode 100644
index 000000000000..7ae12d452e94
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf73056_cellMargins.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 87bc1787e991..b447c7fd3225 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -179,6 +179,19 @@ DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc")
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Section4 is protected", false, getProperty<bool>(xSect, "IsProtected"));
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf73056_cellMargins, "tdf73056_cellMargins.doc")
+{
+    uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY );
+    uno::Reference< container::XIndexAccess >   xTables( xTablesSupplier->getTextTables(), uno::UNO_QUERY );
+    uno::Reference< text::XTextTable > xTable1( xTables->getByIndex( 0 ), uno::UNO_QUERY );
+    uno::Reference< table::XCell > xCell = xTable1->getCellByName( "B4" );
+
+    // only the first cell with specific margins was processed, leaving the rest at table defaults. Was 0.
+    uno::Reference< beans::XPropertySet > xPropSet( xCell, uno::UNO_QUERY_THROW );
+    if ( !mbExported )
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "bottom cell spacing to contents",
+            sal_Int32(101), getProperty<sal_Int32>(xPropSet, "BottomBorderDistance" ) );
+}
 DECLARE_WW8EXPORT_TEST(testTdf79435_legacyInputFields, "tdf79435_legacyInputFields.docx")
 {
     //using .docx input file to verify cross-format compatibility.
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index d11d9fb71567..dee7e04a6ad1 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1493,29 +1493,33 @@ void WW8TabBandDesc::ProcessSpecificSpacing(const sal_uInt8* pParams)
     OSL_ENSURE(nLen == 6, "Unexpected spacing len");
     if (nLen != 6)
         return;
-    sal_uInt8 nWhichCell = *pParams++;
-    OSL_ENSURE(nWhichCell < MAX_COL + 1, "Cell out of range in spacings");
-    if (nWhichCell >= MAX_COL + 1)
+
+    const sal_uInt8 nStartCell = *pParams++; // The first cell these margins could apply to.
+    const sal_uInt8 nEndCell = *pParams++;   // The cell that does NOT apply these margins.
+    OSL_ENSURE(nStartCell < MAX_COL + 1, "Cell out of range in spacings");
+    if ( nStartCell >= nEndCell || nEndCell > MAX_COL+1 )
         return;
 
-    ++pParams; //unknown byte
     sal_uInt8 nSideBits = *pParams++;
     OSL_ENSURE(nSideBits < 0x10, "Unexpected value for nSideBits");
-    nOverrideSpacing[nWhichCell] |= nSideBits;
 
-    OSL_ENSURE(nOverrideSpacing[nWhichCell] < 0x10,
-        "Unexpected value for nSideBits");
-#if OSL_DEBUG_LEVEL > 0
-    sal_uInt8 nUnknown2 = *pParams;
-    OSL_ENSURE(nUnknown2 == 0x3, "Unexpected value for spacing2");
-#endif
-    ++pParams;
+    const sal_uInt8 nSizeType = *pParams++; // Fts: FtsDxa(0x3) is the only type that mentions cellMargin
+    OSL_ENSURE(nSizeType == 0x3, "Unexpected non-twip value for margin width");
+    if ( nSizeType != 0x3 )           // i.e FtsNil: The size is wrong (or unconverted) and MUST be ignored
+        return;
+
     sal_uInt16 nValue =  SVBT16ToUInt16( pParams );
 
-    for (int i=0; i < 4; i++)
+    for (int nCell = nStartCell; nCell < nEndCell; ++nCell)
     {
-        if (nSideBits & (1 << i))
-            nOverrideValues[nWhichCell][i] = nValue;
+        nOverrideSpacing[ nCell ] |= nSideBits;
+        OSL_ENSURE(nOverrideSpacing[ nCell ] < 0x10, "Unexpected value for nSideBits");
+
+        for (int i=0; i < 4; i++)
+        {
+            if (nSideBits & (1 << i))
+                nOverrideValues[ nCell ][ i ] = nValue;
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list