summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-04-21 14:25:38 +0300
committerAndras Timar <andras.timar@collabora.com>2020-05-08 11:54:47 +0200
commitb4bbe40e91ea7fc41c3b754cfcb9bffd6c2e1906 (patch)
treefaf132a48017db9aab88de533e82c43b2800ec28 /sw
parentf56ace63f3bae98dc0185043d85157d366fd9311 (diff)
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/+/93230 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ww8export/data/tdf73056_cellMargins.docbin0 -> 25088 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx13
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx34
3 files changed, 32 insertions, 15 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf73056_cellMargins.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 37df1b5352ae..55cc1c50ba74 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -159,6 +159,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 bba263a00c64..1a23d7dcb836 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1498,29 +1498,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 = SVBT16ToShort( 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;
+ }
}
}