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

New commits:
commit cb56ab9bca5e917d86a7dc24eb144353c405f07c
Author: Andras Timar <andras.ti...@collabora.com>
Date:   Mon Dec 9 20:22:26 2013 +0100

    fdo#56443 allow different name for .dic and .aff files
    
    For example, de_CH_frami.dic and de_AT_frami.dic use de_DE_frami.aff.
    
    Change-Id: I1d3770ad871b4714f7e595e1cd13f5fd7f224a1f

diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx 
b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
index e3a79df..bce00cc 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
@@ -66,7 +66,8 @@ SpellChecker::SpellChecker() :
     aDicts(NULL),
     aDEncs(NULL),
     aDLocs(NULL),
-    aDNames(NULL),
+    aDAffNames(NULL),
+    aDDicNames(NULL),
     numdict(0),
     aEvtListeners(GetLinguMutex()),
     pPropHelper(NULL),
@@ -86,7 +87,8 @@ SpellChecker::~SpellChecker()
     }
     delete[] aDEncs;
     delete[] aDLocs;
-    delete[] aDNames;
+    delete[] aDAffNames;
+    delete[] aDDicNames;
     if (pPropHelper)
     {
         pPropHelper->RemoveAsPropListener();
@@ -183,7 +185,8 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
             aDicts  = new Hunspell* [numdict];
             aDEncs  = new rtl_TextEncoding [numdict];
             aDLocs  = new Locale [numdict];
-            aDNames = new OUString [numdict];
+            aDAffNames = new OUString [numdict];
+            aDDicNames = new OUString [numdict];
             k = 0;
             for (aDictIt = aDics.begin();  aDictIt != aDics.end();  ++aDictIt)
             {
@@ -201,13 +204,16 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
                         aDicts[k]  = NULL;
                         aDEncs[k]  = RTL_TEXTENCODING_DONTKNOW;
                         aDLocs[k]  = LanguageTag::convertToLocale( 
aLocaleNames[i] );
-                        // 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;
+                        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];
+                        }
 
                         ++k;
                     }
@@ -225,8 +231,10 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
             aDEncs = NULL;
             delete[] aDLocs;
             aDLocs  = NULL;
-            delete[] aDNames;
-            aDNames = NULL;
+            delete[] aDAffNames;
+            delete[] aDDicNames;
+            aDAffNames = NULL;
+            aDDicNames = NULL;
             aSuppLocales.realloc(0);
         }
     }
@@ -303,18 +311,16 @@ 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(dicpath,dict);
-                    osl::FileBase::getSystemPathFromFileURL(affpath,aff);
+                    
osl::FileBase::getSystemPathFromFileURL(aDDicNames[i],dict);
+                    osl::FileBase::getSystemPathFromFileURL(aDAffNames[i],aff);
                     OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding()));
                     OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding()));
 
 #if defined(WNT)
-                    // workaround for Windows specifc problem that the
-                    // path length in calls to 'fopen' is limted to somewhat
+                    // workaround for Windows specific problem that the
+                    // path length in calls to 'fopen' is limited 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 89ac20e..47c1c31 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx
@@ -63,7 +63,8 @@ class SpellChecker :
     Hunspell **                        aDicts;
     rtl_TextEncoding *                 aDEncs;
     Locale *                           aDLocs;
-    OUString *                         aDNames;
+    OUString *                         aDAffNames;
+    OUString *                         aDDicNames;
     sal_Int32                          numdict;
 
     ::cppu::OInterfaceContainerHelper       aEvtListeners;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to