[Libreoffice-commits] core.git: 2 commits - hunspell/hunspell.rhbz918938.patch hunspell/UnpackedTarball_hunspell.mk svtools/inc svtools/source

Caolán McNamara caolanm at redhat.com
Wed Mar 13 10:04:43 PDT 2013


 hunspell/UnpackedTarball_hunspell.mk |    1 
 hunspell/hunspell.rhbz918938.patch   |   72 +++++++++++++++++++++++++++++++++++
 svtools/inc/svtools/valueset.hxx     |   10 ++--
 svtools/source/control/valueset.cxx  |   23 +++++------
 4 files changed, 89 insertions(+), 17 deletions(-)

New commits:
commit da2c8c7d1789109fd4099731f2f0188c540aa94d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 13 16:59:32 2013 +0000

    Resolves: rhbz#918938 crash in danish thesaurus/spell interaction
    
    Change-Id: I911fc382a8e4b895262dcd5ae5c67c4a81e6aad4

diff --git a/hunspell/UnpackedTarball_hunspell.mk b/hunspell/UnpackedTarball_hunspell.mk
index 9ba9dc3..1e0544a 100644
--- a/hunspell/UnpackedTarball_hunspell.mk
+++ b/hunspell/UnpackedTarball_hunspell.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,hunspell,\
 	hunspell/hunspell-1.3.2-nullptr.patch \
 	hunspell/hunspell-1.3.2-literal.patch \
 	hunspell/hunspell-1.3.2-compound.patch \
+	hunspell/hunspell.rhbz918938.patch \
 ))
 
 ifeq ($(COM),MSC)
diff --git a/hunspell/hunspell.rhbz918938.patch b/hunspell/hunspell.rhbz918938.patch
new file mode 100644
index 0000000..8d23503
--- /dev/null
+++ b/hunspell/hunspell.rhbz918938.patch
@@ -0,0 +1,72 @@
+--- misc/hunspell-1.3.2/src/hunspell/hunspell.cxx	2011-02-02 12:04:29.000000000 +0000
++++ misc/build/hunspell-1.3.2/src/hunspell/hunspell.cxx	2013-03-13 16:50:50.667928521 +0000
+@@ -12,6 +12,8 @@
+ #endif
+ #include "csutil.hxx"
+ 
++#include <string>
++
+ Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key)
+ {
+     encoding = NULL;
+@@ -1710,6 +1712,19 @@
+     return n;
+ }
+ 
++namespace
++{
++    void myrep(std::string& str, const std::string& search, const std::string& replace)
++    {
++        size_t pos = 0;
++        while ((pos = str.find(search, pos)) != std::string::npos)
++        {
++           str.replace(pos, search.length(), replace);
++           pos += replace.length();
++        }
++    }
++}
++
+ int Hunspell::spellml(char*** slst, const char * word)
+ {
+   char *q, *q2;
+@@ -1721,26 +1736,26 @@
+   q2 = strstr(q2, "<word");
+   if (!q2) return 0; // bad XML input
+   if (check_xml_par(q, "type=", "analyze")) {
+-      int n = 0, s = 0;
++      int n = 0;
+       if (get_xml_par(cw, strchr(q2, '>'), MAXWORDUTF8LEN - 10)) n = analyze(slst, cw);
+       if (n == 0) return 0;
+       // convert the result to <code><a>ana1</a><a>ana2</a></code> format
+-      for (int i = 0; i < n; i++) s+= strlen((*slst)[i]);
+-      char * r = (char *) malloc(6 + 5 * s + 7 * n + 7 + 1); // XXX 5*s->&->&
+-      if (!r) return 0;
+-      strcpy(r, "<code>");
++      std::string r;
++      r.append("<code>");
+       for (int i = 0; i < n; i++) {
+-        int l = strlen(r);
+-        strcpy(r + l, "<a>");
+-        strcpy(r + l + 3, (*slst)[i]);
+-        mystrrep(r + l + 3, "\t", " ");
+-        mystrrep(r + l + 3, "<", "<");
+-        mystrrep(r + l + 3, "&", "&");
+-        strcat(r, "</a>");
++        r.append("<a>");
++
++        std::string entry((*slst)[i]);
+         free((*slst)[i]);
++        myrep(entry, "\t", " ");
++        myrep(entry, "<", "<");
++        myrep(entry, "&", "&");
++        r.append(entry);
++
++        r.append("</a>");
+       }
+-      strcat(r, "</code>");
+-      (*slst)[0] = r;
++      r.append("</code>");
++      (*slst)[0] = mystrdup(r.c_str());
+       return 1;
+   } else if (check_xml_par(q, "type=", "stem")) {
+       if (get_xml_par(cw, strchr(q2, '>'), MAXWORDUTF8LEN - 1)) return stem(slst, cw);
commit 7cce1a450c4dd818e7b050313552d722a17f6c36
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 13 17:03:55 2013 +0000

    XubString->OUString
    
    Change-Id: I9e61476f833d409fabe5ae4452c7fff1fbbd74d2

diff --git a/svtools/inc/svtools/valueset.hxx b/svtools/inc/svtools/valueset.hxx
index 8eb23c0..ff032fd 100644
--- a/svtools/inc/svtools/valueset.hxx
+++ b/svtools/inc/svtools/valueset.hxx
@@ -251,7 +251,7 @@ private:
     SVT_DLLPRIVATE void         ImplInitScrollBar();
     SVT_DLLPRIVATE void         ImplDeleteItems();
     SVT_DLLPRIVATE void         ImplFormatItem( ValueSetItem* pItem, Rectangle aRect );
-    SVT_DLLPRIVATE void         ImplDrawItemText( const XubString& rStr );
+    SVT_DLLPRIVATE void         ImplDrawItemText(const OUString& rStr);
     SVT_DLLPRIVATE void         ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel );
     SVT_DLLPRIVATE void         ImplDrawSelect();
     SVT_DLLPRIVATE void         ImplHideSelect( sal_uInt16 nItemId );
@@ -315,10 +315,10 @@ public:
     void            InsertItem( sal_uInt16 nItemId, const Color& rColor,
                                 size_t nPos = VALUESET_APPEND );
     void            InsertItem( sal_uInt16 nItemId,
-                                const Image& rImage, const XubString& rStr,
+                                const Image& rImage, const OUString& rStr,
                                 size_t nPos = VALUESET_APPEND );
     void            InsertItem( sal_uInt16 nItemId,
-                                const Color& rColor, const XubString& rStr,
+                                const Color& rColor, const OUString& rStr,
                                 size_t nPos = VALUESET_APPEND );
     void            InsertItem( sal_uInt16 nItemId,
                                 size_t nPos = VALUESET_APPEND );
@@ -357,8 +357,8 @@ public:
     Color           GetItemColor( sal_uInt16 nItemId ) const;
     void            SetItemData( sal_uInt16 nItemId, void* pData );
     void*           GetItemData( sal_uInt16 nItemId ) const;
-    void            SetItemText( sal_uInt16 nItemId, const XubString& rStr );
-    XubString       GetItemText( sal_uInt16 nItemId ) const;
+    void            SetItemText( sal_uInt16 nItemId, const OUString& rStr );
+    OUString        GetItemText( sal_uInt16 nItemId ) const;
     void            SetColor( const Color& rColor );
     void            SetColor() { SetColor( Color( COL_TRANSPARENT ) ); }
     Color           GetColor() const { return maColor; }
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 7f62b89..c0afffd 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -678,13 +678,13 @@ void ValueSet::Format()
 
 // -----------------------------------------------------------------------
 
-void ValueSet::ImplDrawItemText( const XubString& rText )
+void ValueSet::ImplDrawItemText(const OUString& rText)
 {
     if ( !(GetStyle() & WB_NAMEFIELD) )
         return;
 
     Size    aWinSize = GetOutputSizePixel();
-    long    nTxtWidth = GetTextWidth( rText );
+    long    nTxtWidth = GetTextWidth(rText);
     long    nTxtOffset = mnTextOffset;
 
     // delete rectangle and show text
@@ -716,8 +716,7 @@ void ValueSet::ImplDrawSelect()
 
     if ( !bFocus && !bDrawSel )
     {
-        XubString aEmptyStr;
-        ImplDrawItemText( aEmptyStr );
+        ImplDrawItemText(OUString());
         return;
     }
 
@@ -885,7 +884,7 @@ void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool
                 ShowFocus( aRect2 );
         }
 
-        ImplDrawItemText( pItem->maText );
+        ImplDrawItemText(pItem->maText);
     }
 }
 
@@ -1669,7 +1668,7 @@ void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor, size_t nPos
 // -----------------------------------------------------------------------
 
 void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
-                           const XubString& rText, size_t nPos )
+                           const OUString& rText, size_t nPos )
 {
     ValueSetItem* pItem = new ValueSetItem( *this );
     pItem->mnId     = nItemId;
@@ -1682,7 +1681,7 @@ void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
 // -----------------------------------------------------------------------
 
 void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor,
-                           const XubString& rText, size_t nPos )
+                           const OUString& rText, size_t nPos )
 {
     ValueSetItem* pItem = new ValueSetItem( *this );
     pItem->mnId     = nItemId;
@@ -2151,7 +2150,7 @@ void* ValueSet::GetItemData( sal_uInt16 nItemId ) const
 
 // -----------------------------------------------------------------------
 
-void ValueSet::SetItemText( sal_uInt16 nItemId, const XubString& rText )
+void ValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText)
 {
     size_t nPos = GetItemPos( nItemId );
 
@@ -2178,7 +2177,7 @@ void ValueSet::SetItemText( sal_uInt16 nItemId, const XubString& rText )
             nTempId = mnHighItemId;
 
         if ( nTempId == nItemId )
-            ImplDrawItemText( pItem->maText );
+            ImplDrawItemText(pItem->maText);
     }
 
     if (ImplHasAccessibleListeners())
@@ -2194,14 +2193,14 @@ void ValueSet::SetItemText( sal_uInt16 nItemId, const XubString& rText )
 
 // -----------------------------------------------------------------------
 
-XubString ValueSet::GetItemText( sal_uInt16 nItemId ) const
+OUString ValueSet::GetItemText( sal_uInt16 nItemId ) const
 {
     size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
         return mItemList[nPos]->maText;
-    else
-        return XubString();
+
+    return OUString();
 }
 
 // -----------------------------------------------------------------------


More information about the Libreoffice-commits mailing list