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

Michael Stahl mstahl at redhat.com
Tue Aug 30 19:44:29 UTC 2016


 dev/null                           |binary
 sw/source/core/docnode/ndtbl.cxx   |   14 ++------------
 sw/source/core/unocore/unotext.cxx |   23 +++++++++++++----------
 3 files changed, 15 insertions(+), 22 deletions(-)

New commits:
commit dc83b3ae470914dbcb08fe1f0a4a4e1a1d3d8e19
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 30 21:17:32 2016 +0200

    Revert "fftester: non-contiguous cells"
    
    This reverts commit 9accbfa0a52433cf03fe186fc69334d387981eb9.
    
    ... and the code change of "avoid crashing on load of fdo54724-1.rtf"
    commit 4ee3eabd0f058b26544c84b2b5aaf5478d921817.
    
    It's much simpler to detect early in convertToTable that there is a
    row with no cells in it, which should not be allowed.
    
    Change-Id: Iff6d235b29514edd57cc55addeefb24242595d88

diff --git a/sw/qa/core/data/rtf/fail/table-1.rtf b/sw/qa/core/data/rtf/fail/table-1.rtf
deleted file mode 100644
index c333a10..0000000
Binary files a/sw/qa/core/data/rtf/fail/table-1.rtf and /dev/null differ
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 216070e..0abfc39 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1181,7 +1181,6 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
         ++aRg.aEnd;
     }
 
-    bool bFailure = false;
 
     {
         // TODO: this is not Undo-able - only good enough for file import
@@ -1189,17 +1188,11 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
         SwNodeIndex const prev(rTableNodes.begin()->begin()->aStart, -1);
         SwNodeIndex const* pPrev(&prev);
         // pPrev could point to non-textnode now
-        for (auto row = rTableNodes.begin(); row != rTableNodes.end() && !bFailure; ++row)
+        for (auto row = rTableNodes.begin(); row != rTableNodes.end(); ++row)
         {
             for (auto cell = row->begin(); cell != row->end(); ++cell)
             {
-                bFailure = (SwNodeIndex(*pPrev, +1) != cell->aStart);
-                if (bFailure)
-                {
-                    SAL_WARN("sw.core", "cell start is not directly after previous cell end");
-                    break;
-                }
-
+                assert(SwNodeIndex(*pPrev, +1) == cell->aStart);
                 SwPaM pam(cell->aStart, 0, *pPrev,
                         (pPrev->GetNode().IsContentNode())
                             ? pPrev->GetNode().GetContentNode()->Len() : 0);
@@ -1219,9 +1212,6 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
 
     GetIDocumentUndoRedo().DoUndo(bUndo);
 
-    if (bFailure)
-        return nullptr;
-
     // Create the Box/Line/Table construct
     SwTableBoxFormat* pBoxFormat = MakeTableBoxFormat();
     SwTableLineFormat* pLineFormat = MakeTableLineFormat();
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 391fa0c..24d0822 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2230,20 +2230,23 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
             pTableRanges[nRow].getConstArray();
         const sal_Int32 nCells(pTableRanges[nRow].getLength());
 
+        if (0 == nCells) // this would lead to no pLastCell below
+        {                // and make it impossible to detect node gaps
+            bExcept = true;
+            break;
+        }
+
         for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
         {
-            SwNodeRange *pLastCell;
-            if (nCell == 0 && nRow == 0)
-            {
-                pLastCell = nullptr;
-            }
-            else
-            {
-                std::vector<SwNodeRange>& rRowOfPrevCell = nCell ? aRowNodes : *aTableNodes.rbegin();
-                pLastCell = !rRowOfPrevCell.empty() ? &*rRowOfPrevCell.rbegin() : nullptr;
-            }
+            SwNodeRange *const pLastCell(
+                (nCell == 0)
+                    ? ((nRow == 0)
+                        ? nullptr
+                        : &*aTableNodes.rbegin()->rbegin())
+                    : &*aRowNodes.rbegin());
             m_pImpl->ConvertCell(pRow[nCell], aRowNodes, pLastCell, bExcept);
         }
+        assert(bExcept || !aRowNodes.empty());
         aTableNodes.push_back(aRowNodes);
     }
 


More information about the Libreoffice-commits mailing list