linguistic/source/spelldsp.cxx |   41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

New commits:
commit ee6bf912d615d0afa438f743ddf3e4f6f5f890aa
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Jun 18 14:43:05 2024 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jun 18 17:27:21 2024 +0200

    tdf#161637 linguistic: fix apostrophe in spelling suggestions
    
    Use the correct typographic (curly) apostrophe instead of the
    obsolete straight (typewriter or ASCII) apostrophe.
    
    Follow-up to commit e6fade1ce133039d28369751b77ac8faff6e40cb
    "tdf#38395 enable smart apostrophe replacement by default" and
    commit 8de1941fe61b461be617e1e88bb362bbd8315654
    "tdf#150582 linguistic: fix always rejected words with U+2019 apostrophe".
    
    Change-Id: Ic0e9aabcce7e95703601dd74e039f2838c89c769
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169087
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index cf83b3a2e3b7..d4f6712a710c 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -59,8 +59,6 @@ class ProposalList
 {
     std::vector< OUString > aVec;
 
-    bool    HasEntry( std::u16string_view rText ) const;
-
 public:
     ProposalList()  {}
     ProposalList(const ProposalList&) = delete;
@@ -68,7 +66,7 @@ public:
 
     size_t  Count() const;
     void    Prepend( const OUString &rText );
-    void    Append( const OUString &rNew );
+    void    Append( const OUString &rNew, bool bPrepend = false );
     void    Append( const std::vector< OUString > &rNew );
     void    Append( const Sequence< OUString > &rNew );
     std::vector< OUString > GetVector() const;
@@ -76,28 +74,29 @@ public:
 
 }
 
-bool ProposalList::HasEntry( std::u16string_view rText ) const
+void ProposalList::Prepend( const OUString &rText )
+{
+    Append( rText, /*bPrepend=*/true );
+}
+
+void ProposalList::Append( const OUString &rOrig, bool bPrepend )
 {
     bool bFound = false;
+    // convert ASCII apostrophe to the typographic one
+    const OUString &rText( rOrig.indexOf( '\'' ) > -1 ? rOrig.replace('\'', 
u'’') : rOrig );
     size_t nCnt = aVec.size();
     for (size_t i = 0;  !bFound && i < nCnt;  ++i)
     {
         if (aVec[i] == rText)
             bFound = true;
     }
-    return bFound;
-}
-
-void ProposalList::Prepend( const OUString &rText )
-{
-    if (!HasEntry( rText ))
-        aVec.insert( aVec.begin(), rText );
-}
-
-void ProposalList::Append( const OUString &rText )
-{
-    if (!HasEntry( rText ))
-        aVec.push_back( rText );
+    if (!bFound)
+    {
+        if ( bPrepend )
+            aVec.insert( aVec.begin(), rText );
+        else
+            aVec.push_back( rText );
+    }
 }
 
 void ProposalList::Append( const std::vector< OUString > &rNew )
@@ -106,18 +105,14 @@ void ProposalList::Append( const std::vector< OUString > 
&rNew )
     for ( size_t i = 0;  i < nLen;  ++i)
     {
         const OUString &rText = rNew[i];
-        if (!HasEntry( rText ))
-            Append( rText );
+        Append( rText );
     }
 }
 
 void ProposalList::Append( const Sequence< OUString > &rNew )
 {
     for (const OUString& rText : rNew)
-    {
-        if (!HasEntry( rText ))
-            Append( rText );
-    }
+        Append( rText );
 }
 
 size_t ProposalList::Count() const

Reply via email to