o3tl/inc/o3tl/sorted_vector.hxx    |   12 +++++++-
 sw/inc/ndhints.hxx                 |    2 -
 sw/source/core/txtnode/ndhints.cxx |   52 ++++++-------------------------------
 sw/source/ui/shells/textsh1.cxx    |    1 
 4 files changed, 21 insertions(+), 46 deletions(-)

New commits:
commit fd5a921a00f034817f67e7e00bd61f0a3f851441
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Jan 11 11:27:52 2013 +0100

    SwpHintsArray::Resort(): remove mostly unused return value
    
    Change-Id: Ia330e545c2727efb6e1b12c4c317f86f9ebdf955

diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 475d87a..0d7a158 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -91,7 +91,7 @@ protected:
 public:
     void Insert( const SwTxtAttr *pHt );
     void DeleteAtPos( const sal_uInt16 nPosInStart );
-    bool Resort();
+    void Resort();
     SwTxtAttr * Cut( const sal_uInt16 nPosInStart );
 
     inline const SwTxtAttr * GetStart( const sal_uInt16 nPos ) const
diff --git a/sw/source/core/txtnode/ndhints.cxx 
b/sw/source/core/txtnode/ndhints.cxx
index a627c1d..2ebdef8 100644
--- a/sw/source/core/txtnode/ndhints.cxx
+++ b/sw/source/core/txtnode/ndhints.cxx
@@ -167,7 +167,8 @@ sal_uInt16 SwpHintsArray::GetPos( const SwTxtAttr *pHt ) 
const
         { \
             SAL_WARN("sw.core", text); \
             DumpHints(m_HintStarts, m_HintEnds); \
-            return !(const_cast<SwpHintsArray*>(this))->Resort(); \
+            (const_cast<SwpHintsArray*>(this))->Resort(); \
+            return false; \
         }
 
 bool SwpHintsArray::Check() const
@@ -315,11 +316,10 @@ bool SwpHintsArray::Check() const
 // sort order of the m_HintStarts, m_HintEnds arrays, so this method is needed
 // to restore the order.
 
-bool SwpHintsArray::Resort()
+void SwpHintsArray::Resort()
 {
     m_HintStarts.Resort();
     m_HintEnds.Resort();
-    return false; // TODO: probably unused return value?
 }
 
 
commit c59355e936446fe55960209e543b072acb6b2170
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Jan 11 11:04:31 2013 +0100

    fdo#58793: re-implement SwpHintsArray::Resort():
    
    The previous implementation uses sorted_vector::insert, which relies on
    the array already being sorted.
    
    Change-Id: I4a2e49e7d8fcfd934f8990be61f83d00d1a09ddd

diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index d8bceb7..3028f03 100644
--- a/o3tl/inc/o3tl/sorted_vector.hxx
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -155,6 +155,16 @@ public:
         clear();
     }
 
+    // fdo#58793: some existing code in Writer (SwpHintsArray)
+    // routinely modifies the members of the vector in a way that
+    // violates the sort order, and then re-sorts the array.
+    // This is a kludge to enable that code to work.
+    // If you are calling this function, you are Doing It Wrong!
+    void Resort()
+    {
+        std::stable_sort(begin_nonconst(), end_nonconst(), Compare());
+    }
+
 private:
 
     typename base_t::iterator begin_nonconst() { return base_t::begin(); }
@@ -191,7 +201,7 @@ struct find_unique
     }
 };
 
-/** the elments are partially ordered by Compare,
+/** the elements are partially ordered by Compare,
     2 elements are allowed if they are not the same element (pointer equal)
   */
 template<class Value, class Compare>
diff --git a/sw/source/core/txtnode/ndhints.cxx 
b/sw/source/core/txtnode/ndhints.cxx
index aa0a36d..a627c1d 100644
--- a/sw/source/core/txtnode/ndhints.cxx
+++ b/sw/source/core/txtnode/ndhints.cxx
@@ -310,50 +310,16 @@ bool SwpHintsArray::Check() const
  *                          SwpHintsArray::Resort()
  *************************************************************************/
 
-// Resort() wird vor jedem Insert und Delete gerufen.
-// Wenn Textmasse geloescht wird, so werden die Indizes in
-// ndtxt.cxx angepasst. Leider erfolgt noch keine Neusortierung
-// auf gleichen Positionen.
+// Resort() is called before every Insert and Delete.
+// Various SwTxtNode methods modify hints in a way that violates the
+// sort order of the m_HintStarts, m_HintEnds arrays, so this method is needed
+// to restore the order.
 
 bool SwpHintsArray::Resort()
 {
-    bool bResort = false;
-    const SwTxtAttr *pLast = 0;
-    sal_uInt16 i;
-
-    for ( i = 0; i < m_HintStarts.size(); ++i )
-    {
-        SwTxtAttr *pHt = m_HintStarts[i];
-        if( pLast && !lcl_IsLessStart( *pLast, *pHt ) )
-        {
-            m_HintStarts.erase( m_HintStarts.begin() + i );
-            m_HintStarts.insert( pHt );
-            pHt = m_HintStarts[i];
-            if ( pHt != pLast )
-                --i;
-            bResort = true;
-        }
-        pLast = pHt;
-    }
-
-    pLast = 0;
-    for ( i = 0; i < m_HintEnds.size(); ++i )
-    {
-        SwTxtAttr *pHt = m_HintEnds[i];
-        if( pLast && !lcl_IsLessEnd( *pLast, *pHt ) )
-        {
-            m_HintEnds.erase( m_HintEnds.begin() + i );
-            m_HintEnds.insert( pHt );
-            pHt = m_HintEnds[i]; // normalerweise == pLast
-            // Wenn die Unordnung etwas groesser ist (24200),
-            // muessen wir Position i erneut vergleichen.
-            if ( pLast != pHt )
-                --i;
-            bResort = true;
-        }
-        pLast = pHt;
-    }
-    return bResort;
+    m_HintStarts.Resort();
+    m_HintEnds.Resort();
+    return false; // TODO: probably unused return value?
 }
 
 
commit 689d9af3e3adb12c507e141cc25ac35ec88bb5c5
Author: Michael Stahl <mst...@redhat.com>
Date:   Thu Jan 10 15:14:02 2013 +0100

    sw: FN_FORMAT_RESET: do not reset Ruby text
    
    It does not seem to be "formatting" to me, more like a content entity.
    
    Change-Id: I89ceb9aec47a382a06abf0933830864a84000194

diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index fba6659..36a10d8 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -485,7 +485,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1,
                 RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1,
                 RES_PARATR_BEGIN, RES_PARATR_END-1,
-                RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
                 RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
                 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
                 0
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to