linguistic/source/spelldsp.cxx |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 87935b4c9f6c360759f90fd667f243a686d48d02
Author:     Justin Luth <[email protected]>
AuthorDate: Mon Oct 20 18:59:12 2025 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Sat Oct 25 23:36:15 2025 +0200

    tdf#161637 spellcheck: replace ascii ' with locale quote
    
    This is a followup inspired by duplicate bug tdf#73964,
    enhancing 24.8.0's commit ee6bf912d615d0afa438f743ddf3e4f6f5f890aa.
        tdf#161637 linguistic: fix apostrophe in spelling suggestions
    
    At the start of spell_Impl we used the local's quote
        GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd()
    and replaced it with an ascii apostrophe for dictionary checking.
    
    It only makes sense to use that same quotation in reverse
    instead of hardcoding a European U+2019 endquote.
    
    Change-Id: Id45a58cc7f9adbb2c1ae8bee7f1fe3ede07ca9c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192759
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>

diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index c79a1fce09ba..e917c32f7c0b 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -58,9 +58,10 @@ namespace {
 class ProposalList
 {
     std::vector< OUString > aVec;
+    sal_Unicode m_cSingleEndQuote = u'\''; // ASCII apostrophe
 
 public:
-    ProposalList()  {}
+    ProposalList(const std::u16string_view& rEndQuote);
     ProposalList(const ProposalList&) = delete;
     ProposalList& operator=(const ProposalList&) = delete;
 
@@ -74,6 +75,12 @@ public:
 
 }
 
+ProposalList::ProposalList(const std::u16string_view& rEndQuote)
+{
+    if (!rEndQuote.empty())
+        m_cSingleEndQuote = rEndQuote[0];
+}
+
 void ProposalList::Prepend( const OUString &rText )
 {
     Append( rText, /*bPrepend=*/true );
@@ -82,7 +89,7 @@ void ProposalList::Prepend( const OUString &rText )
 void ProposalList::Append( const OUString &rOrig, bool bPrepend )
 {
     // convert ASCII apostrophe to the typographic one
-    const OUString aText( rOrig.indexOf( '\'' ) > -1 ? rOrig.replace('\'', 
u'’') : rOrig );
+    const OUString aText(rOrig.replace('\'', m_cSingleEndQuote));
     if (std::find(aVec.begin(), aVec.end(), aText) == aVec.end())
     {
         if ( bPrepend )
@@ -439,7 +446,7 @@ Reference< XSpellAlternatives > 
SpellCheckerDispatcher::spell_Impl(
     OUString aChkWord( rWord );
     Locale aLocale( LanguageTag::convertToLocale( nLanguage ) );
 
-    // replace typographical apostroph by ascii apostroph
+    // replace typographical apostrophe by ascii apostrophe
     OUString aSingleQuote( GetLocaleDataWrapper( nLanguage 
).getQuotationMarkEnd() );
     DBG_ASSERT( 1 == aSingleQuote.getLength(), "unexpected length of quotation 
mark" );
     if (!aSingleQuote.isEmpty())
@@ -604,7 +611,7 @@ Reference< XSpellAlternatives > 
SpellCheckerDispatcher::spell_Impl(
 
     // list of proposals found (to be checked against entries of
     // negative dictionaries)
-    ProposalList aProposalList;
+    ProposalList aProposalList(aSingleQuote);
     sal_Int16 eFailureType = -1;    // no failure
     if (xRes.is())
     {

Reply via email to