summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-12-08 17:52:56 +0300
committerAndras Timar <andras.timar@collabora.com>2018-03-19 17:57:18 +0100
commitabe99a98983130a9dd40a4c3a5a310d581288910 (patch)
tree17b2bd472b35cfdc613a84312d6cf6a02d1b071d /sw/source/filter
parent19880fe225a08c270f739174f802aefad0815f6f (diff)
tdf#114333: consider trleft for 1st cell width on import; don't...
... recalculate cell widths by factor pagewidth/tablewidth on export This makes the import and export symmetrical. Unit test included. Some existing unit tests were updated: - testTdf97035: the previous width of B1 cell (3571 twips) was not stable enough on round-trip. Old code saved table with wrong width, and incidentally that made it to output correct width of the cell. New code outputs table width correctly, and drops unneeded cell width adjustment on export, so the rounding error on initial import makes output cell width wrong. We have a cumbersome arithmetics to import cell widths from RTF: 1. In DomainMapperTableManager::sprm (case NS_ooxml::LN_CT_TblGridBase_gridCol) we do convertTwipToMM100 on initial sizes in twips; 2. Then, in DomainMapperTableManager::endOfRowAction, we do rtl::math::round((fGridWidth * 10000) / nFullWidthRelative) on the mm100 sizes (the 10000 is UNO_TABLE_COLUMN_SUM from unotbl.cxx, which allows to measure cell widths in 100ths of percent of table's width instead of absolute sizes) 3. Last, in SwTable::NewSetTabCols, we do lcl_MulDiv64<long>(nNewPos, rParm.nNewWish, nNewWidth) where rParm.nNewWish is table's width in twips (again), and nNewWidth is 10000. So, the three permutations give us twips back, but rounding errors may make result differ from initial value (as in case of cell width 1927 twips and table width 15527 twips, which results in 1926). The unstable width that resulted in roundtrip error was changed by 1. The changed unit test file is checked to still correctly test tdf#97035 - testFdo55525: previously, the testdoc was imported with wrong width (too narrow); that caused rounding error on cell width calculation. Current tested value is more correct. Change-Id: I69112521c35b316ed6df11d5e4ff7336534164bd Reviewed-on: https://gerrit.libreoffice.org/46094 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 0f9a596aa853b4f2beeff25c131246a7b31492a4)
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx21
1 files changed, 1 insertions, 20 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 6c8bb3390979..d158cc91215e 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -724,23 +724,7 @@ void RtfAttributeOutput::TableDefinition(
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
SwTwips nSz = 0;
- Point aPt;
- SwRect aRect(pFormat->FindLayoutRect(false, &aPt));
- SwTwips nPageSize = aRect.Width();
- // Handle the page size when not rendered
- if (0 == nPageSize)
- {
- const SwNode* pNode = pTableTextNodeInfoInner->getNode();
- const SwFrameFormat* pFrameFormat
- = GetExport().m_pParentFrame
- ? &GetExport().m_pParentFrame->GetFrameFormat()
- : GetExport().m_pDoc->GetPageDesc(0).GetPageFormatOfNode(*pNode, false);
-
- const SvxLRSpaceItem& rLR = pFrameFormat->GetLRSpace();
- nPageSize = pFrameFormat->GetFrameSize().GetWidth() - rLR.GetLeft() - rLR.GetRight();
- }
- SwTwips nTableSz = pFormat->GetFrameSize().GetWidth();
// Not using m_nTableDepth, which is not yet incremented here.
sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
m_aCells[nCurrentDepth] = pRow->GetCells().size();
@@ -756,10 +740,7 @@ void RtfAttributeOutput::TableDefinition(
// value of nSz is needed.
nSz += pCellFormat->GetFrameSize().GetWidth();
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
- SwTwips nCalc = nSz;
- nCalc *= nPageSize;
- nCalc /= nTableSz;
- m_aRowDefs.append((sal_Int32)(pFormat->GetLRSpace().GetLeft() + nCalc));
+ m_aRowDefs.append((sal_Int32)(pFormat->GetLRSpace().GetLeft() + nSz));
}
}