diff -Nru mozilla.origi/extensions/spellcheck/myspell/src/mozMySpell.cpp mozilla/extensions/spellcheck/myspell/src/mozMySpell.cpp --- mozilla.origi/extensions/spellcheck/myspell/src/mozMySpell.cpp 2004-05-17 02:57:55.000000000 +0200 +++ mozilla/extensions/spellcheck/myspell/src/mozMySpell.cpp 2005-02-15 20:48:43.925147832 +0100 @@ -213,10 +213,16 @@ *dictionaries = 0; *count=0; - res = NS_GetSpecialDirectory(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(aFile)); + res = NS_GetSpecialDirectory(NS_OS_DRIVE_DIR, getter_AddRefs(aFile)); if (NS_FAILED(res)) return res; if(!aFile)return NS_ERROR_FAILURE; - res = aFile->Append(NS_LITERAL_STRING("myspell")); + res = aFile->Append(NS_LITERAL_STRING("usr")); + if (NS_FAILED(res)) return res; + res = aFile->Append(NS_LITERAL_STRING("share")); + if (NS_FAILED(res)) return res; + res = aFile->Append(NS_LITERAL_STRING("dict")); + if (NS_FAILED(res)) return res; + res = aFile->Append(NS_LITERAL_STRING("ooo")); if (NS_FAILED(res)) return res; res = aFile->GetDirectoryEntries(getter_AddRefs(dirEntries)); if (NS_FAILED(res)) return res; @@ -238,7 +244,7 @@ nsString fileName; theFile->GetLeafName(fileName); PRInt32 dotLocation = fileName.FindChar('.'); - if((dotLocation != -1) && Substring(fileName,dotLocation,4).Equals(NS_LITERAL_STRING(".dic"))){ + if((dotLocation != -1) && !Substring(fileName,0,4).Equals(NS_LITERAL_STRING("hyph")) && Substring(fileName,dotLocation,4).Equals(NS_LITERAL_STRING(".dic"))){ if(tempCount >= arraySize){ arraySize = 2 * tempCount; newPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * arraySize); @@ -252,7 +258,18 @@ nsMemory::Free(tmpPtr); tmpPtr=newPtr; } - tmpPtr[tempCount++] = ToNewUnicode(Substring(fileName,0,dotLocation)); + // HACK: handle OpenOffice.org MySpell dictionaries. + nsString tempFileName; + PRInt32 pos = fileName.FindChar('_'); + if (pos == -1) + tempFileName.Assign(fileName); + else { + tempFileName.Assign(Substring(fileName,0,pos)); + tempFileName.Append(NS_LITERAL_STRING("-")); + if (pos < fileName.Length()) + tempFileName.Append(Substring(fileName,pos+1,fileName.Length())); + } + tmpPtr[tempCount++] = ToNewUnicode(Substring(tempFileName,0,dotLocation)); } } } diff -Nru mozilla.origi/extensions/spellcheck/myspell/src/myspAffixmgr.cpp mozilla/extensions/spellcheck/myspell/src/myspAffixmgr.cpp --- mozilla.origi/extensions/spellcheck/myspell/src/myspAffixmgr.cpp 2004-06-17 22:31:43.000000000 +0200 +++ mozilla/extensions/spellcheck/myspell/src/myspAffixmgr.cpp 2005-02-15 20:48:43.926147856 +0100 @@ -97,7 +97,7 @@ } nsresult -myspAffixMgr::Load(const nsString& aDictionary) +myspAffixMgr::Load(const nsString& inDictionary) { nsresult res=NS_OK; nsCOMPtr<nsIFile> dicFile; @@ -105,10 +105,16 @@ PRBool fileExists; //get the directory - res = NS_GetSpecialDirectory(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(dicFile)); + res = NS_GetSpecialDirectory(NS_OS_DRIVE_DIR, getter_AddRefs(dicFile)); if(NS_FAILED(res)) return res; if(!dicFile)return NS_ERROR_FAILURE; - res = dicFile->Append(NS_LITERAL_STRING("myspell")); + res = dicFile->Append(NS_LITERAL_STRING("usr")); + if(NS_FAILED(res)) return res; + res = dicFile->Append(NS_LITERAL_STRING("share")); + if(NS_FAILED(res)) return res; + res = dicFile->Append(NS_LITERAL_STRING("dict")); + if(NS_FAILED(res)) return res; + res = dicFile->Append(NS_LITERAL_STRING("ooo")); if(NS_FAILED(res)) return res; res = dicFile->Exists(&fileExists); if(NS_FAILED(res)) return res; @@ -117,13 +123,38 @@ if(NS_FAILED(res)) return res; if(!dicFile)return NS_ERROR_FAILURE; + // HACK: handle OpenOffice.org MySpell dictionaries. + nsString aDictionary; + PRInt32 pos=inDictionary.FindChar('-'); + if (pos == -1) + aDictionary.Assign(inDictionary); + else { + aDictionary.Assign(Substring(inDictionary,0,pos)); + aDictionary.Append(NS_LITERAL_STRING("_")); + if (pos < inDictionary.Length()) + aDictionary.Append(Substring(inDictionary,pos+1,inDictionary.Length())); + } + //get the affix file nsString affName=aDictionary; affName.Append(NS_LITERAL_STRING(".aff")); res=affFile->Append(affName); if(NS_FAILED(res)) return res; res = affFile->Exists(&fileExists); - if(NS_FAILED(res)) return res; + if(NS_FAILED(res)) return res; + // HACK: is it more costly to compare strings instead? + if(!fileExists) { + // Try with original file name + aDictionary.Assign(inDictionary); + affName.Assign(aDictionary); + affName.Append(NS_LITERAL_STRING(".aff")); + res = dicFile->Clone(getter_AddRefs(affFile)); + if(NS_FAILED(res)) return res; + res = affFile->Append(affName); + if(NS_FAILED(res)) return res; + res = affFile->Exists(&fileExists); + if(NS_FAILED(res)) return res; + } if(!fileExists) return NS_ERROR_FAILURE; //get the dictionary file @@ -142,9 +173,10 @@ if(!affStream)return NS_ERROR_FAILURE; res = parse_file(affStream); - PRInt32 pos=aDictionary.FindChar('-'); + // HACK: inDictionnary is always in the "normalized" form + pos=inDictionary.FindChar('-'); if(pos<1) pos = 2; // FIXME should be min of 2 and aDictionary.Length() - mLanguage = Substring(aDictionary,0,pos); + mLanguage = Substring(inDictionary,0,pos); // load the dictionary nsCOMPtr<nsIInputStream> dicStream;