[Libreoffice-commits] core.git: 5 commits - cui/source sc/source svx/source sw/source ucb/source vcl/win

Eike Rathke erack at redhat.com
Mon Aug 21 13:56:35 UTC 2017


 cui/source/tabpages/tppattern.cxx                       |    2 
 sc/source/core/tool/scmatrix.cxx                        |   17 +++----
 svx/source/unodraw/unopage.cxx                          |    2 
 svx/source/xoutdev/xtable.cxx                           |    8 +--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   37 +++++++++++++++-
 sw/source/core/txtnode/ndtxt.cxx                        |   10 ++--
 ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx       |    2 
 ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx      |    2 
 vcl/win/app/salinst.cxx                                 |    2 
 9 files changed, 59 insertions(+), 23 deletions(-)

New commits:
commit 25b3806ac509006573e669acc33643af3bd77380
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Aug 21 15:49:41 2017 +0200

    WalkAndMatchElements: really really limit the match, tdf#108292 follow-up
    
    getRemainingCount() could deliver a wrapped around overflow value if mnIndex
    was already greater than the end index, which could happen if when/for
    non-matching larger block sizes were added, and if then a match was found
    behind those blocks a non-requested/unexpected index was returned, which in
    turn led to the assert() being hit in ScInterpreter::CalculateLookup(). In
    non-debug could result in an invalid block position access.
    
    This happened with the bug case document of tdf#111943 which in master can be
    loaded.
    
    Also, the start and end index are not dynamic and don't have to be recalculated
    each time, so make them const; column argument values are unused after.
    
    Change-Id: Ic294cade4e8e7828bee394e5ade61d7127be6bbb

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 670041ffe275..8bea64987705 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1266,24 +1266,25 @@ template<typename Type>
 class WalkAndMatchElements
 {
     Type maMatchValue;
-    MatrixImplType::size_pair_type maSize;
-    size_t mnCol1;
-    size_t mnCol2;
+    const size_t mnStartIndex;
+    const size_t mnStopIndex;
     size_t mnResult;
     size_t mnIndex;
 
 public:
     WalkAndMatchElements(Type aMatchValue, const MatrixImplType::size_pair_type& aSize, size_t nCol1, size_t nCol2) :
         maMatchValue(aMatchValue),
-        maSize(aSize),
-        mnCol1(nCol1),
-        mnCol2(nCol2),
+        mnStartIndex( nCol1 * aSize.row ),
+        mnStopIndex( (nCol2 + 1) * aSize.row ),
         mnResult(ResultNotSet),
         mnIndex(0) {}
 
     size_t getMatching() const { return mnResult; }
 
-    size_t getRemainingCount() const { return ((mnCol2 + 1) * maSize.row) - mnIndex; }
+    size_t getRemainingCount() const
+    {
+        return mnIndex < mnStopIndex ? mnStopIndex - mnIndex : 0;
+    }
 
     size_t compare(const MatrixImplType::element_block_node_type& node) const;
 
@@ -1294,7 +1295,7 @@ public:
             return;
 
         // limit lookup to the requested columns
-        if ((mnCol1 * maSize.row) <= mnIndex && getRemainingCount() > 0)
+        if (mnStartIndex <= mnIndex && getRemainingCount() > 0)
         {
             mnResult = compare(node);
         }
commit 811081ad06661de798e83b7b227b8a0c43370c6b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Aug 21 15:31:42 2017 +0200

    sw: check the target text node, not the source
    
    Change-Id: I386f4ded70cc3deffc2f2e43709edf16eba94c63

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index f7e0acb4f9e3..5d0e74955bc0 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2079,14 +2079,14 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart,
     sal_Int32 nDestStart = rDestStart.GetIndex();      // remember old Pos
     const sal_Int32 nInitSize = pDest->m_Text.getLength();
 
-    pDest->m_Text = pDest->m_Text.replaceAt(nDestStart, 0,
-                        m_Text.copy(nTextStartIdx, nLen));
-    m_Text = m_Text.replaceAt(nTextStartIdx, nLen, "");
-    if (GetSpaceLeft() < 0)
+    if (pDest->GetSpaceLeft() < nLen)
     {   // FIXME: could only happen when called from SwRangeRedline::Show.
         // unfortunately can't really do anything here to handle that...
         abort();
     }
+    pDest->m_Text = pDest->m_Text.replaceAt(nDestStart, 0,
+                        m_Text.copy(nTextStartIdx, nLen));
+    m_Text = m_Text.replaceAt(nTextStartIdx, nLen, "");
     nLen = pDest->m_Text.getLength() - nInitSize; // update w/ current size!
     if (!nLen)                 // String didn't grow?
         return;
commit f821865d7e3a58f4690d02728852c6c910249e86
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Aug 21 15:19:03 2017 +0200

    tdf#111524 sw: don't expand annotation mark when showing redline...
    
    ... at a position directly behind the annotation mark.
    
    This happens with the the annotation "__Annotation__5847_848227920" in
    the bugdoc, followed by <text:change text:change-id="ct266312216"/>.
    
    When the redline is shown, the annotation mark expands from
    5 - 101 to 5 - 240, but the SwPostItField is of course still at 101,
    so during the ODF export lcl_FillAnnotationStartArray() asserts.
    
    The problem is that the "bDelete" parameter of SwTextNode::Update()
    disables a whole bunch of code that prevents update of positions
    of redlines, bookmarks, fly frames, and shell cursors.
    
    This was introduced in 2004 with CWS dvoea1, but there is absolutely
    no documentation of what problem it was supposed to solve.
    So just try to remove it here and see if it causes any issue.
    
    Change-Id: I2d1f78c7163eddaf0ce6bbb7c6685ca759874ec5

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 7c9ba03d4895..f7e0acb4f9e3 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2094,7 +2094,7 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart,
     if (bUpdate)
     {
         // Update all SwIndex
-        pDest->Update( rDestStart, nLen, false, true);
+        pDest->Update( rDestStart, nLen, false, false/*??? why was it true*/);
     }
 
     CHECK_SWPHINTS(pDest);
commit 685442bf71440e56fa8ae5a572d62f0a1e2c3200
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 18 23:05:53 2017 +0200

    tdf#111524 sw: delete annotation marks when creating delete redline
    
    Range annotations are represented by a SwPostItField at the end of the
    annotated range, and a AnnotationMark that covers the range (including
    the field).
    
    During a normal delete, SwUndoDelete calls
    SwUndoSaveContent::DelContentIndex(), which has a special case to remove
    the AnnotationMark if the field is deleted.
    
    The problem is that when change tracking is enabled, the AnnotationMark
    survives, but the field is moved out of the paragraph when the redlines
    are hidden (as happens during ODF export), hence
    lcl_FillAnnotationStartArray() doesn't find its field.
    
    There doesn't appear to be a good solution to this, because in ODF it's
    also not possible to represent this, because the deleted content is
    outside the text:p element.
    
    It doesn't work to delete the annotation mark in DelBookmarks(), when
    hiding the redline, because then no Undo is created to restore
    the mark, and DelBookmarks() is also called from Undo code from
    SwUndoDelete, which breaks with this change.
    
    So delete the annotation mark when creating the redline in
    DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl().
    
    Fixes the assert and the subsequent crash, which is a regression
    from 31c54fa7bb03768b425ae019096e0a0e26e9c736.
    
    Change-Id: I361ffee8e6ab86de499c25f34a96ceeaf83d9e0b

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 42572905e79c..45d192443d66 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -52,6 +52,7 @@
 #include <txatbase.hxx>
 #include <UndoRedline.hxx>
 #include <undobj.hxx>
+#include <UndoBookmark.hxx>
 #include <UndoDelete.hxx>
 #include <UndoSplitMove.hxx>
 #include <UndoOverwrite.hxx>
@@ -73,6 +74,7 @@
 #include <svx/svdouno.hxx>
 #include <tools/globname.hxx>
 #include <editeng/formatbreakitem.hxx>
+#include <o3tl/make_unique.hxx>
 #include <com/sun/star/i18n/Boundary.hpp>
 #include <memory>
 
@@ -3556,6 +3558,36 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
         SwUndoRedlineDelete* pUndo = nullptr;
         RedlineFlags eOld = m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
         m_rDoc.GetDocumentRedlineManager().checkRedlining( eOld );
+
+        auto & rDMA(*m_rDoc.getIDocumentMarkAccess());
+        std::vector<std::unique_ptr<SwUndo>> MarkUndos;
+        for (auto iter = rDMA.getAnnotationMarksBegin();
+                  iter != rDMA.getAnnotationMarksEnd(); )
+        {
+            // tdf#111524 remove annotation marks that have their field
+            // characters deleted
+            SwPosition const& rEndPos((**iter).GetMarkEnd());
+            if (*rPam.Start() < rEndPos && rEndPos <= *rPam.End())
+            {
+                if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
+                {
+                    MarkUndos.emplace_back(o3tl::make_unique<SwUndoDeleteBookmark>(**iter));
+                }
+                // iter is into annotation mark vector so must be dereferenced!
+                rDMA.deleteMark(&**iter);
+                // this invalidates iter, have to start over...
+                iter = rDMA.getAnnotationMarksBegin();
+            }
+            else
+            {   // marks are sorted by start
+                if (*rPam.End() < (**iter).GetMarkStart())
+                {
+                    break;
+                }
+                ++iter;
+            }
+        }
+
         if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
         {
 
@@ -3564,10 +3596,13 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
             //JP 06.01.98: MUSS noch optimiert werden!!!
             m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags(
                 RedlineFlags::On | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete );
-
             pUndo = new SwUndoRedlineDelete( rPam, SwUndoId::DELETE );
             const SwRewriter aRewriter = pUndo->GetRewriter();
             m_rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::DELETE, &aRewriter );
+            for (auto& it : MarkUndos)
+            {
+                m_rDoc.GetIDocumentUndoRedo().AppendUndo(it.release());
+            }
             m_rDoc.GetIDocumentUndoRedo().AppendUndo( pUndo );
         }
 
commit 38fa44435a428685b4ac59ee98972a8521942225
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 18 20:53:27 2017 +0200

    fix bogus always-true asserts
    
    Most of these were converted from OSL_ASSERT
    
    Change-Id: Ia95a758cdebf72ee80d00866644d92e6bb915071

diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx
index 26e1f2b9c7b1..7b6cf2c63649 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -408,7 +408,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, Button*, void)
                 pEntry.reset(new XBitmapEntry(dynamic_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject(), aName));
             }
             else
-                assert("SvxPatternTabPage::ClickAddHdl_Impl(), XBitmapEntry* pEntry == nullptr ?");
+                assert(!"SvxPatternTabPage::ClickAddHdl_Impl(), XBitmapEntry* pEntry == nullptr ?");
         }
 
         if( pEntry )
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index 3397653a2a3d..171a511e7e11 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -75,7 +75,7 @@ SvxDrawPage::~SvxDrawPage() throw()
 {
     if( !mrBHelper.bDisposed )
     {
-        assert("SvxDrawPage must be disposed!");
+        assert(!"SvxDrawPage must be disposed!");
         acquire();
         dispose();
     }
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
index fbaba94c97e1..6bb2105988c3 100644
--- a/svx/source/xoutdev/xtable.cxx
+++ b/svx/source/xoutdev/xtable.cxx
@@ -194,7 +194,7 @@ void XPropertyList::Insert(std::unique_ptr<XPropertyEntry> pEntry, long nIndex)
 {
     if (!pEntry)
     {
-        assert("empty XPropertyEntry not allowed in XPropertyList");
+        assert(!"empty XPropertyEntry not allowed in XPropertyList");
         return;
     }
 
@@ -209,12 +209,12 @@ void XPropertyList::Replace(std::unique_ptr<XPropertyEntry> pEntry, long nIndex)
 {
     if (!pEntry)
     {
-        assert("empty XPropertyEntry not allowed in XPropertyList");
+        assert(!"empty XPropertyEntry not allowed in XPropertyList");
         return;
     }
     if (!isValidIdx(nIndex))
     {
-        assert("trying to replace invalid entry in XPropertyList");
+        assert(!"trying to replace invalid entry in XPropertyList");
         return;
     }
 
@@ -225,7 +225,7 @@ void XPropertyList::Remove(long nIndex)
 {
     if (!isValidIdx(nIndex))
     {
-        assert("trying to remove invalid entry in XPropertyList");
+        assert(!"trying to remove invalid entry in XPropertyList");
         return;
     }
 
diff --git a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
index bcca8dd0d14c..3b41f13ef0a9 100644
--- a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
@@ -162,7 +162,7 @@ serf_bucket_t * SerfPropFindReqProcImpl::createSerfRequestBucket( serf_request_t
     }
     else
     {
-        assert("Headers Bucket missing");
+        assert(!"Headers Bucket missing");
     }
 
     return req_bkt;
diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
index 77c6ba9538ab..57502dc3ccbd 100644
--- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
@@ -167,7 +167,7 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_
     }
     else
     {
-        assert("Headers Bucket missing");
+        assert(!"Headers Bucket missing");
     }
 
     return req_bkt;
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 7ea3bd526675..09532902af00 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -722,7 +722,7 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, i
             // PM_QS_POSTMESSAGE is needed, so we don't process the SendMessage from DoYield!
             while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
                                  SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD | PM_QS_POSTMESSAGE) )
-                assert( "Multiple timer messages in queue" );
+                assert(! "Multiple timer messages in queue" );
             GetSalData()->mbOnIdleRunScheduler = false;
             EmitTimerCallback();
             break;


More information about the Libreoffice-commits mailing list