[PATCH libreoffice-4-0] fdo#60886: _SetGetExpFlds: use the custom operator<

Michael Stahl (via Code Review) gerrit at gerrit.libreoffice.org
Fri Mar 1 17:03:46 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2504

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/04/2504/1

fdo#60886: _SetGetExpFlds: use the custom operator<

The calls to upper_bound in SwDoc::FldsToExpand and SwDoc::FldsToCalc
unfortunately compare the pointers and not the values pointed to,
which causes all sorts of trouble around non-updated fields.
(regression from 2815396a1813cb3956c5aba066de49a7f34bc657)

Conflicts:
	sw/source/core/doc/docfld.cxx

Change-Id: I48817247719671a16821fcb851b17b628c960a66
(cherry picked from commit 9ca5383abfb7f2f785e9f2e2d5b2565b9a60bbab)
---
M o3tl/inc/o3tl/sorted_vector.hxx
M sw/source/core/doc/docfld.cxx
2 files changed, 10 insertions(+), 7 deletions(-)



diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index 3028f03..776fd56 100644
--- a/o3tl/inc/o3tl/sorted_vector.hxx
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -122,6 +122,11 @@
         return std::lower_bound( base_t::begin(), base_t::end(), x, Compare() );
     }
 
+    const_iterator upper_bound( const Value& x ) const
+    {
+        return std::upper_bound( base_t::begin(), base_t::end(), x, Compare() );
+    }
+
     /* Searches the container for an element with a value of x
      * and returns an iterator to it if found, otherwise it returns an
      * iterator to sorted_vector::end (the element past the end of the container).
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 0fc9f44..c2d1dbc 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1097,9 +1097,8 @@
 
     if( !pUpdtFlds->GetSortLst()->empty() )
     {
-        _SetGetExpFlds::const_iterator const itLast = std::upper_bound(
-                pUpdtFlds->GetSortLst()->begin(),
-                pUpdtFlds->GetSortLst()->end(),
+        _SetGetExpFlds::const_iterator const itLast =
+            pUpdtFlds->GetSortLst()->upper_bound(
                 const_cast<_SetGetExpFld*>(&rToThisFld));
         for( _SetGetExpFlds::const_iterator it = pUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
             lcl_CalcFld( *this, rCalc, **it, pMgr );
@@ -1143,10 +1142,9 @@
     ppHashTbl = new SwHash*[ rTblSize ];
     memset( ppHashTbl, 0, sizeof( _HashStr* ) * rTblSize );
 
-    _SetGetExpFlds::const_iterator const itLast = std::upper_bound(
-        pUpdtFlds->GetSortLst()->begin(),
-        pUpdtFlds->GetSortLst()->end(),
-        const_cast<_SetGetExpFld*>(&rToThisFld));
+    _SetGetExpFlds::const_iterator const itLast =
+        pUpdtFlds->GetSortLst()->upper_bound(
+            const_cast<_SetGetExpFld*>(&rToThisFld));
 
     for( _SetGetExpFlds::const_iterator it = pUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
     {

-- 
To view, visit https://gerrit.libreoffice.org/2504
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I48817247719671a16821fcb851b17b628c960a66
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Michael Stahl <mstahl at redhat.com>



More information about the LibreOffice mailing list