summaryrefslogtreecommitdiff
path: root/sw/source/core/docnode/ndtbl.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-10-04 19:17:56 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-10-29 20:30:04 +0100
commit75bfe93856a2316874a09dcac1ba204ef48d134a (patch)
tree1d11d583bfd26af37eab38ec61f6df2e89466156 /sw/source/core/docnode/ndtbl.cxx
parent91d057474682c52e978e1ea93d05655622cc5914 (diff)
rhbz#820283, fdo#55462: sw: better fix for DOCX table import crash:
The fix in 6d2e09db4a677068095b0bebd08fbbb96620d60c is completely bogus. Only vertically merged boxes result in dummy boxes with negative span, while horizontally merged boxes result in different numbers of boxes per line. So instead of inserting boxes, adjust the width of the last box in rows that are missing boxes, such that all lines have the same width. (cherry picked from commit 4113d9664c60d004474dfc1cffbcd7dc50fa6dc4) Conflicts: sw/source/core/docnode/ndtbl.cxx Change-Id: I4e90e852b314bf6f7885bde7b450dab7c668469e Reviewed-on: https://gerrit.libreoffice.org/764 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'sw/source/core/docnode/ndtbl.cxx')
-rw-r--r--sw/source/core/docnode/ndtbl.cxx51
1 files changed, 24 insertions, 27 deletions
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index ea1f4e4c1542..0b9780794431 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1261,6 +1261,29 @@ SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
return pResult;
}
+static void
+lcl_SetTableBoxWidths2(SwTable & rTable, size_t const nMaxBoxes,
+ SwTableBoxFmt & rBoxFmt, SwDoc & rDoc)
+{
+ // rhbz#820283, fdo#55462: set default box widths so table width is covered
+ SwTableLines & rLines = rTable.GetTabLines();
+ for (size_t nTmpLine = 0; nTmpLine < rLines.Count(); ++nTmpLine)
+ {
+ SwTableBoxes & rBoxes = rLines[nTmpLine]->GetTabBoxes();
+ size_t const nMissing = nMaxBoxes - rBoxes.size();
+ if (nMissing)
+ {
+ // default width for box at the end of an incomplete line
+ SwTableBoxFmt *const pNewFmt = rDoc.MakeTableBoxFmt();
+ pNewFmt->SetFmtAttr( SwFmtFrmSize(ATT_VAR_SIZE,
+ (USHRT_MAX / nMaxBoxes) * (nMissing + 1)) );
+ pNewFmt->Add(rBoxes.back());
+ }
+ }
+ // default width for all boxes not at the end of an incomplete line
+ rBoxFmt.SetFmtAttr(SwFmtFrmSize(ATT_VAR_SIZE, USHRT_MAX / nMaxBoxes));
+}
+
SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes,
SwTableFmt* pTblFmt,
SwTableLineFmt* pLineFmt,
@@ -1372,33 +1395,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes,
nMaxBoxes = nBoxes;
}
- // die Tabelle ausgleichen, leere Sections einfuegen
- sal_uInt16 n;
-
- if( !aPosArr.empty() )
- {
- SwTableLines& rLns = pTable->GetTabLines();
- sal_uInt16 nLastPos = 0;
- for( n = 0; n < aPosArr.size(); ++n )
- {
- SwTableBoxFmt *pNewFmt = pDoc->MakeTableBoxFmt();
- pNewFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE,
- aPosArr[ n ] - nLastPos ));
- for( sal_uInt16 nLines2 = 0; nLines2 < rLns.Count(); ++nLines2 )
- //JP 24.06.98: hier muss ein Add erfolgen, da das BoxFormat
- // von der rufenden Methode noch gebraucht wird!
- pNewFmt->Add( rLns[ nLines2 ]->GetTabBoxes()[ n ] );
-
- nLastPos = aPosArr[ n ];
- }
-
- // damit die Tabelle die richtige Groesse bekommt, im BoxFormat die
- // Groesse nach "oben" transportieren.
- OSL_ENSURE( !pBoxFmt->GetDepends(), "wer ist in dem Format noch angemeldet" );
- pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nLastPos ));
- }
- else
- pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nMaxBoxes ));
+ lcl_SetTableBoxWidths2(*pTable, nMaxBoxes, *pBoxFmt, *pDoc);
// das wars doch wohl ??
return pTblNd;