[libreoffice/f17] Resolves: rhbz#820283 Writer: fix crashes in DOCX table import
Michael Stahl
mstahl at fedoraproject.org
Thu Oct 4 18:31:53 UTC 2012
commit fc035ef9bf88fd77935a2c0f289ddf22a20d9a26
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Oct 4 20:31:24 2012 +0200
Resolves: rhbz#820283 Writer: fix crashes in DOCX table import
...-fdo-55462-sw-better-fix-for-DOCX-table-i.patch | 94 ++++++++++++++++++++
...z-820283-fix-crashes-in-DOCX-table-import.patch | 47 ----------
libreoffice.spec | 8 +-
3 files changed, 99 insertions(+), 50 deletions(-)
---
diff --git a/0001-rhbz-820283-fdo-55462-sw-better-fix-for-DOCX-table-i.patch b/0001-rhbz-820283-fdo-55462-sw-better-fix-for-DOCX-table-i.patch
new file mode 100644
index 0000000..96e6a56
--- /dev/null
+++ b/0001-rhbz-820283-fdo-55462-sw-better-fix-for-DOCX-table-i.patch
@@ -0,0 +1,94 @@
+From 7189ce8281811d386b46504c60c3414af4b097ec Mon Sep 17 00:00:00 2001
+From: Michael Stahl <mstahl at redhat.com>
+Date: Thu, 4 Oct 2012 19:17:56 +0200
+Subject: [PATCH] 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
+---
+ sw/source/core/docnode/ndtbl.cxx | 51 +++++++++++++++++++---------------------
+ 1 file changed, 24 insertions(+), 27 deletions(-)
+
+diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
+index ca006bc..44a7556 100644
+--- a/sw/source/core/docnode/ndtbl.cxx
++++ b/sw/source/core/docnode/ndtbl.cxx
+@@ -1260,6 +1260,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.Count();
++ 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[rBoxes.Count() - 1]);
++ }
++ }
++ // 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,
+@@ -1371,33 +1394,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;
+--
+1.7.11.4
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 4d1b5c7..86a676e 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -159,7 +159,7 @@ Patch41: 0001-n-744509-Alignment-of-text-is-wrong.patch
Patch42: 0001-rhbz-826526-Inform-user-about-unsupported-PDF-encryp.patch
Patch43: 0001-rhbz-852128-sw-avoid-table-undo-crash.patch
Patch44: 0002-rhbz-689053-fix-crash-following-delete-at-last-table.patch
-Patch45: 0003-rhbz-820283-fix-crashes-in-DOCX-table-import.patch
+Patch45: 0001-rhbz-820283-fdo-55462-sw-better-fix-for-DOCX-table-i.patch
Patch46: 0004-rhbz-827695-sw-prevent-crashes-after-incomplete-prin.patch
Patch47: 0001-fdo-49819-fdo-54609-Do-not-consider-timestamp-differ.patch
@@ -1036,7 +1036,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch42 -p1 -b .rhbz-826526-Inform-user-about-unsupported-PDF-encryp.patch
%patch43 -p1 -b .rhbz-852128-sw-avoid-table-undo-crash.patch
%patch44 -p1 -b .rhbz-689053-fix-crash-following-delete-at-last-table.patch
-%patch45 -p1 -b .rhbz-820283-fix-crashes-in-DOCX-table-import.patch
+%patch45 -p1 -b .rhbz-820283-fdo-55462-sw-better-fix-for-DOCX-table-i.patch
%patch46 -p1 -b .rhbz-827695-sw-prevent-crashes-after-incomplete-prin.patch
%patch47 -p1 -b .fdo-49819-fdo-54609-Do-not-consider-timestamp-differ.patch
@@ -2325,8 +2325,10 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%endif
%changelog
-* Thu Oct 04 2012 David Tardon <dtardon at redhat.com> - 1:3.5.7.2-2-UNBUILT_PENDING_DOCX_FIX
+* Thu Oct 04 2012 David Tardon <dtardon at redhat.com> - 1:3.5.7.2-2-UNBUILT
- Resolves: rhbz#863052 fix ZipIOException on mismatched timestamps
+- Resolves: rhbz#820283 Writer: fix crashes in DOCX table import
+- Resolves: rhbz#861680 Writer: DOCX import: fix crash on tables in substreams
* Thu Oct 04 2012 David Tardon <dtardon at redhat.com> - 1:3.5.7.2-1
- update to 3.5.7
More information about the scm-commits
mailing list