[Libreoffice-commits] core.git: lingucomponent/source

Andras Timar andras.timar at collabora.com
Mon Dec 9 13:27:40 PST 2013


 lingucomponent/source/spellcheck/spell/sspellimp.cxx |   42 ++++++++-----------
 lingucomponent/source/spellcheck/spell/sspellimp.hxx |    3 -
 2 files changed, 19 insertions(+), 26 deletions(-)

New commits:
commit 7666149128dc6381481303fe46a3a374f31bee1f
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Dec 9 22:37:16 2013 +0100

    Revert "fdo#56443 allow different name for .dic and .aff files"
    
    This reverts commit cb56ab9bca5e917d86a7dc24eb144353c405f07c.

diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
index bce00cc..e3a79df 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
@@ -66,8 +66,7 @@ SpellChecker::SpellChecker() :
     aDicts(NULL),
     aDEncs(NULL),
     aDLocs(NULL),
-    aDAffNames(NULL),
-    aDDicNames(NULL),
+    aDNames(NULL),
     numdict(0),
     aEvtListeners(GetLinguMutex()),
     pPropHelper(NULL),
@@ -87,8 +86,7 @@ SpellChecker::~SpellChecker()
     }
     delete[] aDEncs;
     delete[] aDLocs;
-    delete[] aDAffNames;
-    delete[] aDDicNames;
+    delete[] aDNames;
     if (pPropHelper)
     {
         pPropHelper->RemoveAsPropListener();
@@ -185,8 +183,7 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
             aDicts  = new Hunspell* [numdict];
             aDEncs  = new rtl_TextEncoding [numdict];
             aDLocs  = new Locale [numdict];
-            aDAffNames = new OUString [numdict];
-            aDDicNames = new OUString [numdict];
+            aDNames = new OUString [numdict];
             k = 0;
             for (aDictIt = aDics.begin();  aDictIt != aDics.end();  ++aDictIt)
             {
@@ -204,16 +201,13 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
                         aDicts[k]  = NULL;
                         aDEncs[k]  = RTL_TEXTENCODING_DONTKNOW;
                         aDLocs[k]  = LanguageTag::convertToLocale( aLocaleNames[i] );
-                        if ((aDictIt->aLocations[0]).endsWith(".aff"))
-                        {
-                            aDAffNames[k] = aDictIt->aLocations[0];
-                            aDDicNames[k] = aDictIt->aLocations[1];
-                        }
-                        else
-                        {
-                            aDAffNames[k] = aDictIt->aLocations[1];
-                            aDDicNames[k] = aDictIt->aLocations[0];
-                        }
+                        // also both files have to be in the same directory and the
+                        // file names must only differ in the extension (.aff/.dic).
+                        // Thus we use the first location only and strip the extension part.
+                        OUString aLocation = aDictIt->aLocations[0];
+                        sal_Int32 nPos = aLocation.lastIndexOf( '.' );
+                        aLocation = aLocation.copy( 0, nPos );
+                        aDNames[k] = aLocation;
 
                         ++k;
                     }
@@ -231,10 +225,8 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
             aDEncs = NULL;
             delete[] aDLocs;
             aDLocs  = NULL;
-            delete[] aDAffNames;
-            delete[] aDDicNames;
-            aDAffNames = NULL;
-            aDDicNames = NULL;
+            delete[] aDNames;
+            aDNames = NULL;
             aSuppLocales.realloc(0);
         }
     }
@@ -311,16 +303,18 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL
             {
                 if (!aDicts[i])
                 {
+                    OUString dicpath = aDNames[i] + ".dic";
+                    OUString affpath = aDNames[i] + ".aff";
                     OUString dict;
                     OUString aff;
-                    osl::FileBase::getSystemPathFromFileURL(aDDicNames[i],dict);
-                    osl::FileBase::getSystemPathFromFileURL(aDAffNames[i],aff);
+                    osl::FileBase::getSystemPathFromFileURL(dicpath,dict);
+                    osl::FileBase::getSystemPathFromFileURL(affpath,aff);
                     OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding()));
                     OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding()));
 
 #if defined(WNT)
-                    // workaround for Windows specific problem that the
-                    // path length in calls to 'fopen' is limited to somewhat
+                    // workaround for Windows specifc problem that the
+                    // path length in calls to 'fopen' is limted to somewhat
                     // about 120+ characters which will usually be exceed when
                     // using dictionaries as extensions.
                     aTmpaff = Win_GetShortPathName( aff );
diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx
index 47c1c31..89ac20e 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx
@@ -63,8 +63,7 @@ class SpellChecker :
     Hunspell **                        aDicts;
     rtl_TextEncoding *                 aDEncs;
     Locale *                           aDLocs;
-    OUString *                         aDAffNames;
-    OUString *                         aDDicNames;
+    OUString *                         aDNames;
     sal_Int32                          numdict;
 
     ::cppu::OInterfaceContainerHelper       aEvtListeners;


More information about the Libreoffice-commits mailing list