1*190118d0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*190118d0SAndrew Rist * distributed with this work for additional information 6*190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*190118d0SAndrew Rist * "License"); you may not use this file except in compliance 9*190118d0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*190118d0SAndrew Rist * software distributed under the License is distributed on an 15*190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*190118d0SAndrew Rist * KIND, either express or implied. See the License for the 17*190118d0SAndrew Rist * specific language governing permissions and limitations 18*190118d0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*190118d0SAndrew Rist *************************************************************/ 21*190118d0SAndrew Rist 22*190118d0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_editeng.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp> 30cdf0e10cSrcweir #include <tools/urlobj.hxx> 31cdf0e10cSrcweir #include <tools/table.hxx> 32cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 33cdf0e10cSrcweir #include <vcl/svapp.hxx> 34cdf0e10cSrcweir #include <sot/storinfo.hxx> 35cdf0e10cSrcweir // fuer die Sort-String-Arrays aus dem SVMEM.HXX 36cdf0e10cSrcweir #define _SVSTDARR_STRINGSISORTDTOR 37cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 38cdf0e10cSrcweir #include <svl/svstdarr.hxx> 39cdf0e10cSrcweir #include <svl/fstathelper.hxx> 40cdf0e10cSrcweir #include <svtools/helpopt.hxx> 41cdf0e10cSrcweir #include <svl/urihelper.hxx> 42cdf0e10cSrcweir #include <unotools/charclass.hxx> 43cdf0e10cSrcweir #include <com/sun/star/i18n/UnicodeType.hdl> 44cdf0e10cSrcweir #include <unotools/collatorwrapper.hxx> 45cdf0e10cSrcweir #include <com/sun/star/i18n/CollatorOptions.hpp> 46cdf0e10cSrcweir #include <com/sun/star/i18n/UnicodeScript.hpp> 47cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx> 48cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx> 49cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 50cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 51cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp> 52cdf0e10cSrcweir #include <editeng/editids.hrc> 53cdf0e10cSrcweir #include <sot/storage.hxx> 54cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 55cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 56cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 57cdf0e10cSrcweir #include <editeng/escpitem.hxx> 58cdf0e10cSrcweir #include <editeng/svxacorr.hxx> 59cdf0e10cSrcweir #include <editeng/unolingu.hxx> 60cdf0e10cSrcweir #include <helpid.hrc> 61cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 62cdf0e10cSrcweir #include <com/sun/star/xml/sax/InputSource.hpp> 63cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp> 64cdf0e10cSrcweir #include <unotools/streamwrap.hxx> 65cdf0e10cSrcweir #include <SvXMLAutoCorrectImport.hxx> 66cdf0e10cSrcweir #include <SvXMLAutoCorrectExport.hxx> 67cdf0e10cSrcweir #include <ucbhelper/content.hxx> 68cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp> 69cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp> 70cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp> 71cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 72cdf0e10cSrcweir #include <vcl/help.hxx> 73cdf0e10cSrcweir 74cdf0e10cSrcweir #define CHAR_HARDBLANK ((sal_Unicode)0x00A0) 75cdf0e10cSrcweir 76cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 77cdf0e10cSrcweir using namespace ::com::sun::star::uno; 78cdf0e10cSrcweir using namespace ::com::sun::star; 79cdf0e10cSrcweir using namespace ::xmloff::token; 80cdf0e10cSrcweir using namespace ::rtl; 81cdf0e10cSrcweir using namespace ::utl; 82cdf0e10cSrcweir 83cdf0e10cSrcweir const int C_NONE = 0x00; 84cdf0e10cSrcweir const int C_FULL_STOP = 0x01; 85cdf0e10cSrcweir const int C_EXCLAMATION_MARK = 0x02; 86cdf0e10cSrcweir const int C_QUESTION_MARK = 0x04; 87cdf0e10cSrcweir 88cdf0e10cSrcweir static const sal_Char pImplWrdStt_ExcptLstStr[] = "WordExceptList"; 89cdf0e10cSrcweir static const sal_Char pImplCplStt_ExcptLstStr[] = "SentenceExceptList"; 90cdf0e10cSrcweir static const sal_Char pImplAutocorr_ListStr[] = "DocumentList"; 91cdf0e10cSrcweir static const sal_Char pXMLImplWrdStt_ExcptLstStr[] = "WordExceptList.xml"; 92cdf0e10cSrcweir static const sal_Char pXMLImplCplStt_ExcptLstStr[] = "SentenceExceptList.xml"; 93cdf0e10cSrcweir static const sal_Char pXMLImplAutocorr_ListStr[] = "DocumentList.xml"; 94cdf0e10cSrcweir 95cdf0e10cSrcweir static const sal_Char 96cdf0e10cSrcweir /* auch bei diesen Anfaengen - Klammern auf und alle Arten von Anf.Zei. */ 97cdf0e10cSrcweir sImplSttSkipChars[] = "\"\'([{\x83\x84\x89\x91\x92\x93\x94", 98cdf0e10cSrcweir /* auch bei diesen Ende - Klammern auf und alle Arten von Anf.Zei. */ 99cdf0e10cSrcweir sImplEndSkipChars[] = "\"\')]}\x83\x84\x89\x91\x92\x93\x94"; 100cdf0e10cSrcweir 101cdf0e10cSrcweir // diese Zeichen sind in Worten erlaubt: (fuer FnCptlSttSntnc) 102cdf0e10cSrcweir static const sal_Char sImplWordChars[] = "-'"; 103cdf0e10cSrcweir 104cdf0e10cSrcweir void EncryptBlockName_Imp( String& rName ); 105cdf0e10cSrcweir void DecryptBlockName_Imp( String& rName ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir 108cdf0e10cSrcweir // FileVersions Nummern fuer die Ersetzungs-/Ausnahmelisten getrennt 109cdf0e10cSrcweir #define WORDLIST_VERSION_358 1 110cdf0e10cSrcweir #define EXEPTLIST_VERSION_358 0 111cdf0e10cSrcweir 112cdf0e10cSrcweir 113cdf0e10cSrcweir _SV_IMPL_SORTAR_ALG( SvxAutocorrWordList, SvxAutocorrWordPtr ) 114cdf0e10cSrcweir TYPEINIT0(SvxAutoCorrect) 115cdf0e10cSrcweir 116cdf0e10cSrcweir typedef SvxAutoCorrectLanguageLists* SvxAutoCorrectLanguageListsPtr; 117cdf0e10cSrcweir DECLARE_TABLE( SvxAutoCorrLanguageTable_Impl, SvxAutoCorrectLanguageListsPtr) 118cdf0e10cSrcweir 119cdf0e10cSrcweir DECLARE_TABLE( SvxAutoCorrLastFileAskTable_Impl, long ) 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir inline int IsWordDelim( const sal_Unicode c ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return ' ' == c || '\t' == c || 0x0a == c || 125cdf0e10cSrcweir 0xA0 == c || 0x2011 == c || 0x1 == c; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir inline int IsLowerLetter( sal_Int32 nCharType ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir return CharClass::isLetterType( nCharType ) && 131cdf0e10cSrcweir 0 == ( ::com::sun::star::i18n::KCharacterType::UPPER & nCharType); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir inline int IsUpperLetter( sal_Int32 nCharType ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir return CharClass::isLetterType( nCharType ) && 136cdf0e10cSrcweir 0 == ( ::com::sun::star::i18n::KCharacterType::LOWER & nCharType); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir bool lcl_IsUnsupportedUnicodeChar( CharClass& rCC, const String& rTxt, 140cdf0e10cSrcweir xub_StrLen nStt, xub_StrLen nEnd ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir for( ; nStt < nEnd; ++nStt ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 145cdf0e10cSrcweir sal_Int32 nCharType; 146cdf0e10cSrcweir sal_Int32 nChType; 147cdf0e10cSrcweir nCharType = rCC.getCharacterType( rTxt, nStt ); 148cdf0e10cSrcweir nChType = rCC.getType( rTxt, nStt ); 149cdf0e10cSrcweir #endif 150cdf0e10cSrcweir short nScript = rCC.getScript( rTxt, nStt ); 151cdf0e10cSrcweir switch( nScript ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kCJKRadicalsSupplement: 154cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kHangulJamo: 155cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kCJKSymbolPunctuation: 156cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kHiragana: 157cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kKatakana: 158cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kHangulCompatibilityJamo: 159cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kEnclosedCJKLetterMonth: 160cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kCJKCompatibility: 161cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_k_CJKUnifiedIdeographsExtensionA: 162cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kCJKUnifiedIdeograph: 163cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kHangulSyllable: 164cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kCJKCompatibilityIdeograph: 165cdf0e10cSrcweir case ::com::sun::star::i18n::UnicodeScript_kHalfwidthFullwidthForm: 166cdf0e10cSrcweir return true; 167cdf0e10cSrcweir default: ; //do nothing 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir } 171cdf0e10cSrcweir return false; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir sal_Bool lcl_IsSymbolChar( CharClass& rCC, const String& rTxt, 175cdf0e10cSrcweir xub_StrLen nStt, xub_StrLen nEnd ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir for( ; nStt < nEnd; ++nStt ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 180cdf0e10cSrcweir sal_Int32 nCharType; 181cdf0e10cSrcweir sal_Int32 nChType; 182cdf0e10cSrcweir nCharType = rCC.getCharacterType( rTxt, nStt ); 183cdf0e10cSrcweir nChType = rCC.getType( rTxt, nStt ); 184cdf0e10cSrcweir #endif 185cdf0e10cSrcweir if( ::com::sun::star::i18n::UnicodeType::PRIVATE_USE == 186cdf0e10cSrcweir rCC.getType( rTxt, nStt )) 187cdf0e10cSrcweir return sal_True; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir return sal_False; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir 193cdf0e10cSrcweir static sal_Bool lcl_IsInAsciiArr( const sal_Char* pArr, const sal_Unicode c ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir sal_Bool bRet = sal_False; 196cdf0e10cSrcweir for( ; *pArr; ++pArr ) 197cdf0e10cSrcweir if( *pArr == c ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir bRet = sal_True; 200cdf0e10cSrcweir break; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir return bRet; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir SvxAutoCorrDoc::~SvxAutoCorrDoc() 206cdf0e10cSrcweir { 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir 210cdf0e10cSrcweir // wird nach dem austauschen der Zeichen von den Funktionen 211cdf0e10cSrcweir // - FnCptlSttWrd 212cdf0e10cSrcweir // - FnCptlSttSntnc 213cdf0e10cSrcweir // gerufen. Dann koennen die Worte ggfs. in die Ausnahmelisten 214cdf0e10cSrcweir // aufgenommen werden. 215cdf0e10cSrcweir void SvxAutoCorrDoc::SaveCpltSttWord( sal_uLong, xub_StrLen, const String&, 216cdf0e10cSrcweir sal_Unicode ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir LanguageType SvxAutoCorrDoc::GetLanguage( xub_StrLen , sal_Bool ) const 221cdf0e10cSrcweir { 222cdf0e10cSrcweir return LANGUAGE_SYSTEM; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir static ::com::sun::star::uno::Reference< 226cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory >& GetProcessFact() 227cdf0e10cSrcweir { 228cdf0e10cSrcweir static ::com::sun::star::uno::Reference< 229cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory > xMSF = 230cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(); 231cdf0e10cSrcweir return xMSF; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir static sal_uInt16 GetAppLang() 235cdf0e10cSrcweir { 236cdf0e10cSrcweir return Application::GetSettings().GetLanguage(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir static LocaleDataWrapper& GetLocaleDataWrapper( sal_uInt16 nLang ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir static LocaleDataWrapper aLclDtWrp( GetProcessFact(), 241cdf0e10cSrcweir SvxCreateLocale( GetAppLang() ) ); 242cdf0e10cSrcweir ::com::sun::star::lang::Locale aLcl( SvxCreateLocale( nLang )); 243cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLcl = aLclDtWrp.getLoadedLocale(); 244cdf0e10cSrcweir if( aLcl.Language != rLcl.Language || 245cdf0e10cSrcweir aLcl.Country != rLcl.Country || 246cdf0e10cSrcweir aLcl.Variant != rLcl.Variant ) 247cdf0e10cSrcweir aLclDtWrp.setLocale( aLcl ); 248cdf0e10cSrcweir return aLclDtWrp; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir static TransliterationWrapper& GetIgnoreTranslWrapper() 251cdf0e10cSrcweir { 252cdf0e10cSrcweir static int bIsInit = 0; 253cdf0e10cSrcweir static TransliterationWrapper aWrp( GetProcessFact(), 254cdf0e10cSrcweir ::com::sun::star::i18n::TransliterationModules_IGNORE_CASE | 255cdf0e10cSrcweir ::com::sun::star::i18n::TransliterationModules_IGNORE_KANA | 256cdf0e10cSrcweir ::com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH ); 257cdf0e10cSrcweir if( !bIsInit ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir aWrp.loadModuleIfNeeded( GetAppLang() ); 260cdf0e10cSrcweir bIsInit = 1; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir return aWrp; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir static CollatorWrapper& GetCollatorWrapper() 265cdf0e10cSrcweir { 266cdf0e10cSrcweir static int bIsInit = 0; 267cdf0e10cSrcweir static CollatorWrapper aCollWrp( GetProcessFact() ); 268cdf0e10cSrcweir if( !bIsInit ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir aCollWrp.loadDefaultCollator( SvxCreateLocale( GetAppLang() ), 0 ); 271cdf0e10cSrcweir bIsInit = 1; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir return aCollWrp; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir 277cdf0e10cSrcweir void SvxAutocorrWordList::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir if( nL ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" ); 282cdf0e10cSrcweir for( sal_uInt16 n=nP; n < nP + nL; n++ ) 283cdf0e10cSrcweir delete *((SvxAutocorrWordPtr*)pData+n); 284cdf0e10cSrcweir SvPtrarr::Remove( nP, nL ); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir 289cdf0e10cSrcweir sal_Bool SvxAutocorrWordList::Seek_Entry( const SvxAutocorrWordPtr aE, sal_uInt16* pP ) const 290cdf0e10cSrcweir { 291cdf0e10cSrcweir register sal_uInt16 nO = SvxAutocorrWordList_SAR::Count(), 292cdf0e10cSrcweir nM, 293cdf0e10cSrcweir nU = 0; 294cdf0e10cSrcweir if( nO > 0 ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir CollatorWrapper& rCmp = ::GetCollatorWrapper(); 297cdf0e10cSrcweir nO--; 298cdf0e10cSrcweir while( nU <= nO ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir nM = nU + ( nO - nU ) / 2; 301cdf0e10cSrcweir long nCmp = rCmp.compareString( aE->GetShort(), 302cdf0e10cSrcweir (*((SvxAutocorrWordPtr*)pData + nM))->GetShort() ); 303cdf0e10cSrcweir if( 0 == nCmp ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if( pP ) *pP = nM; 306cdf0e10cSrcweir return sal_True; 307cdf0e10cSrcweir } 308cdf0e10cSrcweir else if( 0 < nCmp ) 309cdf0e10cSrcweir nU = nM + 1; 310cdf0e10cSrcweir else if( nM == 0 ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir if( pP ) *pP = nU; 313cdf0e10cSrcweir return sal_False; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir else 316cdf0e10cSrcweir nO = nM - 1; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir } 319cdf0e10cSrcweir if( pP ) *pP = nU; 320cdf0e10cSrcweir return sal_False; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir /* -----------------18.11.98 15:28------------------- 324cdf0e10cSrcweir * 325cdf0e10cSrcweir * --------------------------------------------------*/ 326cdf0e10cSrcweir void lcl_ClearTable(SvxAutoCorrLanguageTable_Impl& rLangTable) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = rLangTable.Last(); 329cdf0e10cSrcweir while(pLists) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir delete pLists; 332cdf0e10cSrcweir pLists = rLangTable.Prev(); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir rLangTable.Clear(); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir /* -----------------03.11.06 10:15------------------- 338cdf0e10cSrcweir * 339cdf0e10cSrcweir * --------------------------------------------------*/ 340cdf0e10cSrcweir 341cdf0e10cSrcweir sal_Bool SvxAutoCorrect::IsAutoCorrectChar( sal_Unicode cChar ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir return cChar == '\0' || cChar == '\t' || cChar == 0x0a || 344cdf0e10cSrcweir cChar == ' ' || cChar == '\'' || cChar == '\"' || 345cdf0e10cSrcweir cChar == '*' || cChar == '_' || 346cdf0e10cSrcweir cChar == '.' || cChar == ',' || cChar == ';' || 347cdf0e10cSrcweir cChar == ':' || cChar == '?' || cChar == '!' || cChar == '/'; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir sal_Bool SvxAutoCorrect::NeedsHardspaceAutocorr( sal_Unicode cChar ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir return cChar == ';' || cChar == ':' || cChar == '?' || cChar == '!' || 353cdf0e10cSrcweir cChar == '/' /*case for the urls exception*/; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir /* -----------------19.11.98 10:15------------------- 357cdf0e10cSrcweir * 358cdf0e10cSrcweir * --------------------------------------------------*/ 359cdf0e10cSrcweir long SvxAutoCorrect::GetDefaultFlags() 360cdf0e10cSrcweir { 361cdf0e10cSrcweir long nRet = Autocorrect 362cdf0e10cSrcweir | CptlSttSntnc 363cdf0e10cSrcweir | CptlSttWrd 364cdf0e10cSrcweir | ChgOrdinalNumber 365cdf0e10cSrcweir | ChgToEnEmDash 366cdf0e10cSrcweir | AddNonBrkSpace 367cdf0e10cSrcweir | ChgWeightUnderl 368cdf0e10cSrcweir | SetINetAttr 369cdf0e10cSrcweir | ChgQuotes 370cdf0e10cSrcweir | SaveWordCplSttLst 371cdf0e10cSrcweir | SaveWordWrdSttLst; 372cdf0e10cSrcweir LanguageType eLang = GetAppLang(); 373cdf0e10cSrcweir switch( eLang ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir case LANGUAGE_ENGLISH: 376cdf0e10cSrcweir case LANGUAGE_ENGLISH_US: 377cdf0e10cSrcweir case LANGUAGE_ENGLISH_UK: 378cdf0e10cSrcweir case LANGUAGE_ENGLISH_AUS: 379cdf0e10cSrcweir case LANGUAGE_ENGLISH_CAN: 380cdf0e10cSrcweir case LANGUAGE_ENGLISH_NZ: 381cdf0e10cSrcweir case LANGUAGE_ENGLISH_EIRE: 382cdf0e10cSrcweir case LANGUAGE_ENGLISH_SAFRICA: 383cdf0e10cSrcweir case LANGUAGE_ENGLISH_JAMAICA: 384cdf0e10cSrcweir case LANGUAGE_ENGLISH_CARRIBEAN: 385cdf0e10cSrcweir nRet &= ~(ChgQuotes|ChgSglQuotes); 386cdf0e10cSrcweir break; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir return nRet; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir 392cdf0e10cSrcweir SvxAutoCorrect::SvxAutoCorrect( const String& rShareAutocorrFile, 393cdf0e10cSrcweir const String& rUserAutocorrFile ) 394cdf0e10cSrcweir : sShareAutoCorrFile( rShareAutocorrFile ), 395cdf0e10cSrcweir sUserAutoCorrFile( rUserAutocorrFile ), 396cdf0e10cSrcweir pLangTable( new SvxAutoCorrLanguageTable_Impl ), 397cdf0e10cSrcweir pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ), 398cdf0e10cSrcweir pCharClass( 0 ), bRunNext( false ), 399cdf0e10cSrcweir cStartDQuote( 0 ), cEndDQuote( 0 ), cStartSQuote( 0 ), cEndSQuote( 0 ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir nFlags = SvxAutoCorrect::GetDefaultFlags(); 402cdf0e10cSrcweir 403cdf0e10cSrcweir cEmDash = ByteString::ConvertToUnicode( '\x97', RTL_TEXTENCODING_MS_1252 ); 404cdf0e10cSrcweir cEnDash = ByteString::ConvertToUnicode( '\x96', RTL_TEXTENCODING_MS_1252 ); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy ) 408cdf0e10cSrcweir : sShareAutoCorrFile( rCpy.sShareAutoCorrFile ), 409cdf0e10cSrcweir sUserAutoCorrFile( rCpy.sUserAutoCorrFile ), 410cdf0e10cSrcweir 411cdf0e10cSrcweir aSwFlags( rCpy.aSwFlags ), 412cdf0e10cSrcweir 413cdf0e10cSrcweir pLangTable( new SvxAutoCorrLanguageTable_Impl ), 414cdf0e10cSrcweir pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ), 415cdf0e10cSrcweir pCharClass( 0 ), bRunNext( false ), 416cdf0e10cSrcweir 417cdf0e10cSrcweir nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)), 418cdf0e10cSrcweir cStartDQuote( rCpy.cStartDQuote ), cEndDQuote( rCpy.cEndDQuote ), 419cdf0e10cSrcweir cStartSQuote( rCpy.cStartSQuote ), cEndSQuote( rCpy.cEndSQuote ), 420cdf0e10cSrcweir cEmDash( rCpy.cEmDash ), cEnDash( rCpy.cEnDash ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir 425cdf0e10cSrcweir SvxAutoCorrect::~SvxAutoCorrect() 426cdf0e10cSrcweir { 427cdf0e10cSrcweir lcl_ClearTable(*pLangTable); 428cdf0e10cSrcweir delete pLangTable; 429cdf0e10cSrcweir delete pLastFileTable; 430cdf0e10cSrcweir delete pCharClass; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir void SvxAutoCorrect::_GetCharClass( LanguageType eLang ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir delete pCharClass; 436cdf0e10cSrcweir pCharClass = new CharClass( SvxCreateLocale( eLang )); 437cdf0e10cSrcweir eCharClassLang = eLang; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir void SvxAutoCorrect::SetAutoCorrFlag( long nFlag, sal_Bool bOn ) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir long nOld = nFlags; 443cdf0e10cSrcweir nFlags = bOn ? nFlags | nFlag 444cdf0e10cSrcweir : nFlags & ~nFlag; 445cdf0e10cSrcweir 446cdf0e10cSrcweir if( !bOn ) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir if( (nOld & CptlSttSntnc) != (nFlags & CptlSttSntnc) ) 449cdf0e10cSrcweir nFlags &= ~CplSttLstLoad; 450cdf0e10cSrcweir if( (nOld & CptlSttWrd) != (nFlags & CptlSttWrd) ) 451cdf0e10cSrcweir nFlags &= ~WrdSttLstLoad; 452cdf0e10cSrcweir if( (nOld & Autocorrect) != (nFlags & Autocorrect) ) 453cdf0e10cSrcweir nFlags &= ~ChgWordLstLoad; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457cdf0e10cSrcweir 458cdf0e10cSrcweir // Zwei Grossbuchstaben am Wort-Anfang ?? 459cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnCptlSttWrd( SvxAutoCorrDoc& rDoc, const String& rTxt, 460cdf0e10cSrcweir xub_StrLen nSttPos, xub_StrLen nEndPos, 461cdf0e10cSrcweir LanguageType eLang ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir sal_Bool bRet = sal_False; 464cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 465cdf0e10cSrcweir 466cdf0e10cSrcweir // loesche alle nicht alpanum. Zeichen am Wortanfang/-ende und 467cdf0e10cSrcweir // teste dann ( erkennt: "(min.", "/min.", usw.) 468cdf0e10cSrcweir for( ; nSttPos < nEndPos; ++nSttPos ) 469cdf0e10cSrcweir if( rCC.isLetterNumeric( rTxt, nSttPos )) 470cdf0e10cSrcweir break; 471cdf0e10cSrcweir for( ; nSttPos < nEndPos; --nEndPos ) 472cdf0e10cSrcweir if( rCC.isLetterNumeric( rTxt, nEndPos - 1 )) 473cdf0e10cSrcweir break; 474cdf0e10cSrcweir 475cdf0e10cSrcweir // Zwei Grossbuchstaben am Wort-Anfang ?? 476cdf0e10cSrcweir if( nSttPos+2 < nEndPos && 477cdf0e10cSrcweir IsUpperLetter( rCC.getCharacterType( rTxt, nSttPos )) && 478cdf0e10cSrcweir IsUpperLetter( rCC.getCharacterType( rTxt, ++nSttPos )) && 479cdf0e10cSrcweir // ist das 3. Zeichen ein klein geschiebenes Alpha-Zeichen 480cdf0e10cSrcweir IsLowerLetter( rCC.getCharacterType( rTxt, nSttPos +1 )) && 481cdf0e10cSrcweir // keine Sonder-Attribute ersetzen 482cdf0e10cSrcweir 0x1 != rTxt.GetChar( nSttPos ) && 0x2 != rTxt.GetChar( nSttPos )) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir // teste ob das Wort in einer Ausnahmeliste steht 485cdf0e10cSrcweir String sWord( rTxt.Copy( nSttPos - 1, nEndPos - nSttPos + 1 )); 486cdf0e10cSrcweir if( !FindInWrdSttExceptList(eLang, sWord) ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir sal_Unicode cSave = rTxt.GetChar( nSttPos ); 489cdf0e10cSrcweir String sChar( cSave ); 490cdf0e10cSrcweir rCC.toLower( sChar ); 491cdf0e10cSrcweir if( sChar.GetChar(0) != cSave && rDoc.ReplaceRange( nSttPos, 1, sChar )) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir if( SaveWordWrdSttLst & nFlags ) 494cdf0e10cSrcweir rDoc.SaveCpltSttWord( CptlSttWrd, nSttPos, sWord, cSave ); 495cdf0e10cSrcweir bRet = sal_True; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir } 498cdf0e10cSrcweir } 499cdf0e10cSrcweir return bRet; 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir 503cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnChgOrdinalNumber( 504cdf0e10cSrcweir SvxAutoCorrDoc& rDoc, const String& rTxt, 505cdf0e10cSrcweir xub_StrLen nSttPos, xub_StrLen nEndPos, 506cdf0e10cSrcweir LanguageType eLang ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir // 1st, 2nd, 3rd, 4 - 0th 509cdf0e10cSrcweir // 201th oder 201st 510cdf0e10cSrcweir // 12th oder 12nd 511cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 512cdf0e10cSrcweir sal_Bool bChg = sal_False; 513cdf0e10cSrcweir 514cdf0e10cSrcweir for( ; nSttPos < nEndPos; ++nSttPos ) 515cdf0e10cSrcweir if( !lcl_IsInAsciiArr( sImplSttSkipChars, rTxt.GetChar( nSttPos ) )) 516cdf0e10cSrcweir break; 517cdf0e10cSrcweir for( ; nSttPos < nEndPos; --nEndPos ) 518cdf0e10cSrcweir if( !lcl_IsInAsciiArr( sImplEndSkipChars, rTxt.GetChar( nEndPos - 1 ) )) 519cdf0e10cSrcweir break; 520cdf0e10cSrcweir 521cdf0e10cSrcweir if( 2 < nEndPos - nSttPos && 522cdf0e10cSrcweir rCC.isDigit( rTxt, nEndPos - 3 ) ) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir static sal_Char __READONLY_DATA 525cdf0e10cSrcweir sAll[] = "th", /* rest */ 526cdf0e10cSrcweir sFirst[] = "st", /* 1 */ 527cdf0e10cSrcweir sSecond[] = "nd", /* 2 */ 528cdf0e10cSrcweir sThird[] = "rd"; /* 3 */ 529cdf0e10cSrcweir static const sal_Char* __READONLY_DATA aNumberTab[ 4 ] = 530cdf0e10cSrcweir { 531cdf0e10cSrcweir sAll, sFirst, sSecond, sThird 532cdf0e10cSrcweir }; 533cdf0e10cSrcweir 534cdf0e10cSrcweir sal_Unicode c = rTxt.GetChar( nEndPos - 3 ); 535cdf0e10cSrcweir if( ( c -= '0' ) > 3 ) 536cdf0e10cSrcweir c = 0; 537cdf0e10cSrcweir 538cdf0e10cSrcweir bChg = ( ((sal_Unicode)*((aNumberTab[ c ])+0)) == 539cdf0e10cSrcweir rTxt.GetChar( nEndPos - 2 ) && 540cdf0e10cSrcweir ((sal_Unicode)*((aNumberTab[ c ])+1)) == 541cdf0e10cSrcweir rTxt.GetChar( nEndPos - 1 )) || 542cdf0e10cSrcweir ( 3 < nEndPos - nSttPos && 543cdf0e10cSrcweir ( ((sal_Unicode)*(sAll+0)) == rTxt.GetChar( nEndPos - 2 ) && 544cdf0e10cSrcweir ((sal_Unicode)*(sAll+1)) == rTxt.GetChar( nEndPos - 1 ))); 545cdf0e10cSrcweir 546cdf0e10cSrcweir if( bChg ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir // dann pruefe mal, ob alle bis zum Start alle Zahlen sind 549cdf0e10cSrcweir for( xub_StrLen n = nEndPos - 3; nSttPos < n; ) 550cdf0e10cSrcweir if( !rCC.isDigit( rTxt, --n ) ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir bChg = !rCC.isLetter( rTxt, n ); 553cdf0e10cSrcweir break; 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir if( bChg ) // dann setze mal das Escapement Attribut 557cdf0e10cSrcweir { 558cdf0e10cSrcweir SvxEscapementItem aSvxEscapementItem( DFLT_ESC_AUTO_SUPER, 559cdf0e10cSrcweir DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT ); 560cdf0e10cSrcweir rDoc.SetAttr( nEndPos - 2, nEndPos, 561cdf0e10cSrcweir SID_ATTR_CHAR_ESCAPEMENT, 562cdf0e10cSrcweir aSvxEscapementItem); 563cdf0e10cSrcweir } 564cdf0e10cSrcweir } 565cdf0e10cSrcweir 566cdf0e10cSrcweir } 567cdf0e10cSrcweir return bChg; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir 571cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnChgToEnEmDash( 572cdf0e10cSrcweir SvxAutoCorrDoc& rDoc, const String& rTxt, 573cdf0e10cSrcweir xub_StrLen nSttPos, xub_StrLen nEndPos, 574cdf0e10cSrcweir LanguageType eLang ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir sal_Bool bRet = sal_False; 577cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 578cdf0e10cSrcweir if (eLang == LANGUAGE_SYSTEM) 579cdf0e10cSrcweir eLang = GetAppLang(); 580cdf0e10cSrcweir bool bAlwaysUseEmDash = (cEmDash && (eLang == LANGUAGE_RUSSIAN || eLang == LANGUAGE_UKRAINIAN)); 581cdf0e10cSrcweir 582cdf0e10cSrcweir // ersetze " - " oder " --" durch "enDash" 583cdf0e10cSrcweir if( cEnDash && 1 < nSttPos && 1 <= nEndPos - nSttPos ) 584cdf0e10cSrcweir { 585cdf0e10cSrcweir sal_Unicode cCh = rTxt.GetChar( nSttPos ); 586cdf0e10cSrcweir if( '-' == cCh ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir if( ' ' == rTxt.GetChar( nSttPos-1 ) && 589cdf0e10cSrcweir '-' == rTxt.GetChar( nSttPos+1 )) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir xub_StrLen n; 592cdf0e10cSrcweir for( n = nSttPos+2; n < nEndPos && lcl_IsInAsciiArr( 593cdf0e10cSrcweir sImplSttSkipChars,(cCh = rTxt.GetChar( n ))); 594cdf0e10cSrcweir ++n ) 595cdf0e10cSrcweir ; 596cdf0e10cSrcweir 597cdf0e10cSrcweir // found: " --[<AnySttChars>][A-z0-9] 598cdf0e10cSrcweir if( rCC.isLetterNumeric( cCh ) ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir for( n = nSttPos-1; n && lcl_IsInAsciiArr( 601cdf0e10cSrcweir sImplEndSkipChars,(cCh = rTxt.GetChar( --n ))); ) 602cdf0e10cSrcweir ; 603cdf0e10cSrcweir 604cdf0e10cSrcweir // found: "[A-z0-9][<AnyEndChars>] --[<AnySttChars>][A-z0-9] 605cdf0e10cSrcweir if( rCC.isLetterNumeric( cCh )) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir rDoc.Delete( nSttPos, nSttPos + 2 ); 608cdf0e10cSrcweir rDoc.Insert( nSttPos, bAlwaysUseEmDash ? cEmDash : cEnDash ); 609cdf0e10cSrcweir bRet = sal_True; 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir } 614cdf0e10cSrcweir else if( 3 < nSttPos && 615cdf0e10cSrcweir ' ' == rTxt.GetChar( nSttPos-1 ) && 616cdf0e10cSrcweir '-' == rTxt.GetChar( nSttPos-2 )) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir xub_StrLen n, nLen = 1, nTmpPos = nSttPos - 2; 619cdf0e10cSrcweir if( '-' == ( cCh = rTxt.GetChar( nTmpPos-1 )) ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir --nTmpPos; 622cdf0e10cSrcweir ++nLen; 623cdf0e10cSrcweir cCh = rTxt.GetChar( nTmpPos-1 ); 624cdf0e10cSrcweir } 625cdf0e10cSrcweir if( ' ' == cCh ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir for( n = nSttPos; n < nEndPos && lcl_IsInAsciiArr( 628cdf0e10cSrcweir sImplSttSkipChars,(cCh = rTxt.GetChar( n ))); 629cdf0e10cSrcweir ++n ) 630cdf0e10cSrcweir ; 631cdf0e10cSrcweir 632cdf0e10cSrcweir // found: " - [<AnySttChars>][A-z0-9] 633cdf0e10cSrcweir if( rCC.isLetterNumeric( cCh ) ) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir cCh = ' '; 636cdf0e10cSrcweir for( n = nTmpPos-1; n && lcl_IsInAsciiArr( 637cdf0e10cSrcweir sImplEndSkipChars,(cCh = rTxt.GetChar( --n ))); ) 638cdf0e10cSrcweir ; 639cdf0e10cSrcweir // found: "[A-z0-9][<AnyEndChars>] - [<AnySttChars>][A-z0-9] 640cdf0e10cSrcweir if( rCC.isLetterNumeric( cCh )) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir rDoc.Delete( nTmpPos, nTmpPos + nLen ); 643cdf0e10cSrcweir rDoc.Insert( nTmpPos, bAlwaysUseEmDash ? cEmDash : cEnDash ); 644cdf0e10cSrcweir bRet = sal_True; 645cdf0e10cSrcweir } 646cdf0e10cSrcweir } 647cdf0e10cSrcweir } 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir // Replace [A-z0-9]--[A-z0-9] double dash with "emDash" or "enDash". 652cdf0e10cSrcweir // Finnish and Hungarian use enDash instead of emDash. 653cdf0e10cSrcweir bool bEnDash = (eLang == LANGUAGE_HUNGARIAN || eLang == LANGUAGE_FINNISH); 654cdf0e10cSrcweir if( ((cEmDash && !bEnDash) || (cEnDash && bEnDash)) && 4 <= nEndPos - nSttPos ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir String sTmp( rTxt.Copy( nSttPos, nEndPos - nSttPos ) ); 657cdf0e10cSrcweir xub_StrLen nFndPos = sTmp.SearchAscii( "--" ); 658cdf0e10cSrcweir if( STRING_NOTFOUND != nFndPos && nFndPos && 659cdf0e10cSrcweir nFndPos + 2 < sTmp.Len() && 660cdf0e10cSrcweir ( rCC.isLetterNumeric( sTmp, nFndPos - 1 ) || 661cdf0e10cSrcweir lcl_IsInAsciiArr( sImplEndSkipChars, rTxt.GetChar( nFndPos - 1 ) )) && 662cdf0e10cSrcweir ( rCC.isLetterNumeric( sTmp, nFndPos + 2 ) || 663cdf0e10cSrcweir lcl_IsInAsciiArr( sImplSttSkipChars, rTxt.GetChar( nFndPos + 2 ) ))) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir nSttPos = nSttPos + nFndPos; 666cdf0e10cSrcweir rDoc.Delete( nSttPos, nSttPos + 2 ); 667cdf0e10cSrcweir rDoc.Insert( nSttPos, (bEnDash ? cEnDash : cEmDash) ); 668cdf0e10cSrcweir bRet = sal_True; 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir return bRet; 672cdf0e10cSrcweir } 673cdf0e10cSrcweir 674cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnAddNonBrkSpace( 675cdf0e10cSrcweir SvxAutoCorrDoc& rDoc, const String& rTxt, 676cdf0e10cSrcweir xub_StrLen, xub_StrLen nEndPos, 677cdf0e10cSrcweir LanguageType eLang ) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir bool bRet = false; 680cdf0e10cSrcweir 681cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 682cdf0e10cSrcweir const lang::Locale rLocale = rCC.getLocale( ); 683cdf0e10cSrcweir 684cdf0e10cSrcweir if ( rLocale.Language == OUString::createFromAscii( "fr" ) ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir bool bFrCA = rLocale.Country == OUString::createFromAscii( "CA" ); 687cdf0e10cSrcweir OUString allChars = OUString::createFromAscii( ":;!?" ); 688cdf0e10cSrcweir OUString chars( allChars ); 689cdf0e10cSrcweir if ( bFrCA ) 690cdf0e10cSrcweir chars = OUString::createFromAscii( ":" ); 691cdf0e10cSrcweir 692cdf0e10cSrcweir sal_Unicode cChar = rTxt.GetChar( nEndPos ); 693cdf0e10cSrcweir bool bHasSpace = chars.indexOf( sal_Unicode( cChar ) ) != -1; 694cdf0e10cSrcweir bool bIsSpecial = allChars.indexOf( sal_Unicode( cChar ) ) != -1; 695cdf0e10cSrcweir if ( bIsSpecial ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir // Get the last word delimiter position 698cdf0e10cSrcweir xub_StrLen nSttWdPos = nEndPos; 699cdf0e10cSrcweir while( nSttWdPos && !IsWordDelim( rTxt.GetChar( --nSttWdPos ))) 700cdf0e10cSrcweir ; 701cdf0e10cSrcweir 702cdf0e10cSrcweir // Check the presence of "://" in the word 703cdf0e10cSrcweir xub_StrLen nStrPos = rTxt.Search( String::CreateFromAscii( "://" ), nSttWdPos + 1 ); 704cdf0e10cSrcweir if ( STRING_NOTFOUND == nStrPos && nEndPos > 0 ) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir // Check the previous char 707cdf0e10cSrcweir sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 ); 708cdf0e10cSrcweir if ( ( chars.indexOf( sal_Unicode( cPrevChar ) ) == -1 ) && cPrevChar != '\t' ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir // Remove any previous normal space 711cdf0e10cSrcweir xub_StrLen nPos = nEndPos - 1; 712cdf0e10cSrcweir while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir if ( nPos == 0 ) break; 715cdf0e10cSrcweir nPos--; 716cdf0e10cSrcweir cPrevChar = rTxt.GetChar( nPos ); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir 719cdf0e10cSrcweir if ( nPos != 0 ) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir nPos++; 722cdf0e10cSrcweir if ( nEndPos - nPos > 0 ) 723cdf0e10cSrcweir rDoc.Delete( nPos, nEndPos ); 724cdf0e10cSrcweir 725cdf0e10cSrcweir // Add the non-breaking space at the end pos 726cdf0e10cSrcweir if ( bHasSpace ) 727cdf0e10cSrcweir rDoc.Insert( nPos, CHAR_HARDBLANK ); 728cdf0e10cSrcweir bRunNext = true; 729cdf0e10cSrcweir bRet = true; 730cdf0e10cSrcweir } 731cdf0e10cSrcweir } 732cdf0e10cSrcweir else if ( chars.indexOf( sal_Unicode( cPrevChar ) ) != -1 ) 733cdf0e10cSrcweir bRunNext = true; 734cdf0e10cSrcweir } 735cdf0e10cSrcweir } 736cdf0e10cSrcweir else if ( cChar == '/' && nEndPos > 1 && rTxt.Len() > (nEndPos - 1) ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir // Remove the hardspace right before to avoid formatting URLs 739cdf0e10cSrcweir sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 ); 740cdf0e10cSrcweir sal_Unicode cMaybeSpaceChar = rTxt.GetChar( nEndPos - 2 ); 741cdf0e10cSrcweir if ( cPrevChar == ':' && cMaybeSpaceChar == CHAR_HARDBLANK ) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir rDoc.Delete( nEndPos - 2, nEndPos - 1 ); 744cdf0e10cSrcweir bRet = true; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir return bRet; 750cdf0e10cSrcweir } 751cdf0e10cSrcweir 752cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const String& rTxt, 753cdf0e10cSrcweir xub_StrLen nSttPos, xub_StrLen nEndPos, 754cdf0e10cSrcweir LanguageType eLang ) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir String sURL( URIHelper::FindFirstURLInText( rTxt, nSttPos, nEndPos, 757cdf0e10cSrcweir GetCharClass( eLang ) )); 758cdf0e10cSrcweir sal_Bool bRet = 0 != sURL.Len(); 759cdf0e10cSrcweir if( bRet ) // also Attribut setzen: 760cdf0e10cSrcweir rDoc.SetINetAttr( nSttPos, nEndPos, sURL ); 761cdf0e10cSrcweir return bRet; 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir 765cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const String& rTxt, 766cdf0e10cSrcweir xub_StrLen, xub_StrLen nEndPos, 767cdf0e10cSrcweir LanguageType eLang ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir // Bedingung: 770cdf0e10cSrcweir // Am Anfang: _ oder * hinter Space mit nachfolgenden !Space 771cdf0e10cSrcweir // Am Ende: _ oder * vor Space (Worttrenner?) 772cdf0e10cSrcweir 773cdf0e10cSrcweir sal_Unicode c, cInsChar = rTxt.GetChar( nEndPos ); // unterstreichen oder fett 774cdf0e10cSrcweir if( ++nEndPos != rTxt.Len() && 775cdf0e10cSrcweir !IsWordDelim( rTxt.GetChar( nEndPos ) ) ) 776cdf0e10cSrcweir return sal_False; 777cdf0e10cSrcweir 778cdf0e10cSrcweir --nEndPos; 779cdf0e10cSrcweir 780cdf0e10cSrcweir sal_Bool bAlphaNum = sal_False; 781cdf0e10cSrcweir xub_StrLen nPos = nEndPos, nFndPos = STRING_NOTFOUND; 782cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 783cdf0e10cSrcweir 784cdf0e10cSrcweir while( nPos ) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir switch( c = rTxt.GetChar( --nPos ) ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir case '_': 789cdf0e10cSrcweir case '*': 790cdf0e10cSrcweir if( c == cInsChar ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir if( bAlphaNum && nPos+1 < nEndPos && ( !nPos || 793cdf0e10cSrcweir IsWordDelim( rTxt.GetChar( nPos-1 ))) && 794cdf0e10cSrcweir !IsWordDelim( rTxt.GetChar( nPos+1 ))) 795cdf0e10cSrcweir nFndPos = nPos; 796cdf0e10cSrcweir else 797cdf0e10cSrcweir // Bedingung ist nicht erfuellt, also abbrechen 798cdf0e10cSrcweir nFndPos = STRING_NOTFOUND; 799cdf0e10cSrcweir nPos = 0; 800cdf0e10cSrcweir } 801cdf0e10cSrcweir break; 802cdf0e10cSrcweir default: 803cdf0e10cSrcweir if( !bAlphaNum ) 804cdf0e10cSrcweir bAlphaNum = rCC.isLetterNumeric( rTxt, nPos ); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir } 807cdf0e10cSrcweir 808cdf0e10cSrcweir if( STRING_NOTFOUND != nFndPos ) 809cdf0e10cSrcweir { 810cdf0e10cSrcweir // ueber den gefundenen Bereich das Attribut aufspannen und 811cdf0e10cSrcweir // das gefunde und am Ende stehende Zeichen loeschen 812cdf0e10cSrcweir if( '*' == cInsChar ) // Fett 813cdf0e10cSrcweir { 814cdf0e10cSrcweir SvxWeightItem aSvxWeightItem( WEIGHT_BOLD, SID_ATTR_CHAR_WEIGHT ); 815cdf0e10cSrcweir rDoc.SetAttr( nFndPos + 1, nEndPos, 816cdf0e10cSrcweir SID_ATTR_CHAR_WEIGHT, 817cdf0e10cSrcweir aSvxWeightItem); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir else // unterstrichen 820cdf0e10cSrcweir { 821cdf0e10cSrcweir SvxUnderlineItem aSvxUnderlineItem( UNDERLINE_SINGLE, SID_ATTR_CHAR_UNDERLINE ); 822cdf0e10cSrcweir rDoc.SetAttr( nFndPos + 1, nEndPos, 823cdf0e10cSrcweir SID_ATTR_CHAR_UNDERLINE, 824cdf0e10cSrcweir aSvxUnderlineItem); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir rDoc.Delete( nEndPos, nEndPos + 1 ); 827cdf0e10cSrcweir rDoc.Delete( nFndPos, nFndPos + 1 ); 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir return STRING_NOTFOUND != nFndPos; 831cdf0e10cSrcweir } 832cdf0e10cSrcweir 833cdf0e10cSrcweir 834cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc, 835cdf0e10cSrcweir const String& rTxt, sal_Bool bNormalPos, 836cdf0e10cSrcweir xub_StrLen nSttPos, xub_StrLen nEndPos, 837cdf0e10cSrcweir LanguageType eLang ) 838cdf0e10cSrcweir { 839cdf0e10cSrcweir // Grossbuchstabe am Satz-Anfang ?? 840cdf0e10cSrcweir if( !rTxt.Len() || nEndPos <= nSttPos ) 841cdf0e10cSrcweir return sal_False; 842cdf0e10cSrcweir 843cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 844cdf0e10cSrcweir String aText( rTxt ); 845cdf0e10cSrcweir const sal_Unicode *pStart = aText.GetBuffer(), 846cdf0e10cSrcweir *pStr = pStart + nEndPos, 847cdf0e10cSrcweir *pWordStt = 0, 848cdf0e10cSrcweir *pDelim = 0; 849cdf0e10cSrcweir 850cdf0e10cSrcweir sal_Bool bAtStart = sal_False, bPrevPara = sal_False; 851cdf0e10cSrcweir do { 852cdf0e10cSrcweir --pStr; 853cdf0e10cSrcweir if( rCC.isLetter( 854cdf0e10cSrcweir aText, sal::static_int_cast< xub_StrLen >( pStr - pStart ) ) ) 855cdf0e10cSrcweir { 856cdf0e10cSrcweir if( !pWordStt ) 857cdf0e10cSrcweir pDelim = pStr+1; 858cdf0e10cSrcweir pWordStt = pStr; 859cdf0e10cSrcweir } 860cdf0e10cSrcweir else if( pWordStt && 861cdf0e10cSrcweir !rCC.isDigit( 862cdf0e10cSrcweir aText, 863cdf0e10cSrcweir sal::static_int_cast< xub_StrLen >( pStr - pStart ) ) ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir if( lcl_IsInAsciiArr( sImplWordChars, *pStr ) && 866cdf0e10cSrcweir pWordStt - 1 == pStr && 867cdf0e10cSrcweir // --> FME 2005-02-14 #i38971# 868cdf0e10cSrcweir // l'intallazione at beginning of paragraph. Replaced < by <= 869cdf0e10cSrcweir (long)(pStart + 1) <= (long)pStr && 870cdf0e10cSrcweir // <-- 871cdf0e10cSrcweir rCC.isLetter( 872cdf0e10cSrcweir aText, 873cdf0e10cSrcweir sal::static_int_cast< xub_StrLen >( pStr-1 - pStart ) ) ) 874cdf0e10cSrcweir pWordStt = --pStr; 875cdf0e10cSrcweir else 876cdf0e10cSrcweir break; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir } while( 0 == ( bAtStart = (pStart == pStr)) ); 879cdf0e10cSrcweir 880cdf0e10cSrcweir 881cdf0e10cSrcweir if( !pWordStt || 882cdf0e10cSrcweir rCC.isDigit( 883cdf0e10cSrcweir aText, sal::static_int_cast< xub_StrLen >( pStr - pStart ) ) || 884cdf0e10cSrcweir IsUpperLetter( 885cdf0e10cSrcweir rCC.getCharacterType( 886cdf0e10cSrcweir aText, 887cdf0e10cSrcweir sal::static_int_cast< xub_StrLen >( pWordStt - pStart ) ) ) || 888cdf0e10cSrcweir 0x1 == *pWordStt || 0x2 == *pWordStt ) 889cdf0e10cSrcweir return sal_False; // kein zu ersetzendes Zeichen, oder schon ok 890cdf0e10cSrcweir 891cdf0e10cSrcweir // JP 27.10.97: wenn das Wort weniger als 3 Zeichen hat und der Trenner 892cdf0e10cSrcweir // ein "Num"-Trenner ist, dann nicht ersetzen! 893cdf0e10cSrcweir // Damit wird ein "a.", "a)", "a-a" nicht ersetzt! 894cdf0e10cSrcweir if( *pDelim && 2 >= pDelim - pWordStt && 895cdf0e10cSrcweir lcl_IsInAsciiArr( ".-)>", *pDelim ) ) 896cdf0e10cSrcweir return sal_False; 897cdf0e10cSrcweir 898cdf0e10cSrcweir if( !bAtStart ) // noch kein Absatz Anfang ? 899cdf0e10cSrcweir { 900cdf0e10cSrcweir if ( IsWordDelim( *pStr ) ) 901cdf0e10cSrcweir { 902cdf0e10cSrcweir while( 0 == ( bAtStart = (pStart == pStr--) ) && IsWordDelim( *pStr )) 903cdf0e10cSrcweir ; 904cdf0e10cSrcweir } 905cdf0e10cSrcweir // Asian full stop, full width full stop, full width exclamation mark 906cdf0e10cSrcweir // and full width question marks are treated as word delimiters 907cdf0e10cSrcweir else if ( 0x3002 != *pStr && 0xFF0E != *pStr && 0xFF01 != *pStr && 908cdf0e10cSrcweir 0xFF1F != *pStr ) 909cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir if( bAtStart ) // am Absatz Anfang ? 913cdf0e10cSrcweir { 914cdf0e10cSrcweir // Ueberpruefe den vorherigen Absatz, wenn es diesen gibt. 915cdf0e10cSrcweir // Wenn ja, dann pruefe auf SatzTrenner am Ende. 916cdf0e10cSrcweir const String* pPrevPara = rDoc.GetPrevPara( bNormalPos ); 917cdf0e10cSrcweir if( !pPrevPara ) 918cdf0e10cSrcweir { 919cdf0e10cSrcweir // gueltiger Trenner -> Ersetze 920cdf0e10cSrcweir String sChar( *pWordStt ); 921cdf0e10cSrcweir rCC.toUpper( sChar ); 922cdf0e10cSrcweir return sChar != *pWordStt && 923cdf0e10cSrcweir rDoc.ReplaceRange( xub_StrLen( pWordStt - pStart ), 1, sChar ); 924cdf0e10cSrcweir } 925cdf0e10cSrcweir 926cdf0e10cSrcweir aText = *pPrevPara; 927cdf0e10cSrcweir bPrevPara = sal_True; 928cdf0e10cSrcweir bAtStart = sal_False; 929cdf0e10cSrcweir pStart = aText.GetBuffer(); 930cdf0e10cSrcweir pStr = pStart + aText.Len(); 931cdf0e10cSrcweir 932cdf0e10cSrcweir do { // alle Blanks ueberlesen 933cdf0e10cSrcweir --pStr; 934cdf0e10cSrcweir if( !IsWordDelim( *pStr )) 935cdf0e10cSrcweir break; 936cdf0e10cSrcweir } while( 0 == ( bAtStart = (pStart == pStr)) ); 937cdf0e10cSrcweir 938cdf0e10cSrcweir if( bAtStart ) 939cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 940cdf0e10cSrcweir } 941cdf0e10cSrcweir 942cdf0e10cSrcweir // bis hierhier wurde [ \t]+[A-Z0-9]+ gefunden. Test jetzt auf den 943cdf0e10cSrcweir // Satztrenner. Es koennen alle 3 vorkommen, aber nicht mehrfach !! 944cdf0e10cSrcweir const sal_Unicode* pExceptStt = 0; 945cdf0e10cSrcweir if( !bAtStart ) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir sal_Bool bWeiter = sal_True; 948cdf0e10cSrcweir int nFlag = C_NONE; 949cdf0e10cSrcweir do { 950cdf0e10cSrcweir switch( *pStr ) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir // Western and Asian full stop 953cdf0e10cSrcweir case '.': 954cdf0e10cSrcweir case 0x3002 : 955cdf0e10cSrcweir case 0xFF0E : 956cdf0e10cSrcweir { 957cdf0e10cSrcweir if( nFlag & C_FULL_STOP ) 958cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 959cdf0e10cSrcweir nFlag |= C_FULL_STOP; 960cdf0e10cSrcweir pExceptStt = pStr; 961cdf0e10cSrcweir } 962cdf0e10cSrcweir break; 963cdf0e10cSrcweir case '!': 964cdf0e10cSrcweir case 0xFF01 : 965cdf0e10cSrcweir { 966cdf0e10cSrcweir if( nFlag & C_EXCLAMATION_MARK ) 967cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 968cdf0e10cSrcweir nFlag |= C_EXCLAMATION_MARK; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir break; 971cdf0e10cSrcweir case '?': 972cdf0e10cSrcweir case 0xFF1F : 973cdf0e10cSrcweir { 974cdf0e10cSrcweir if( nFlag & C_QUESTION_MARK) 975cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 976cdf0e10cSrcweir nFlag |= C_QUESTION_MARK; 977cdf0e10cSrcweir } 978cdf0e10cSrcweir break; 979cdf0e10cSrcweir default: 980cdf0e10cSrcweir if( !nFlag ) 981cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 982cdf0e10cSrcweir else 983cdf0e10cSrcweir bWeiter = sal_False; 984cdf0e10cSrcweir break; 985cdf0e10cSrcweir } 986cdf0e10cSrcweir 987cdf0e10cSrcweir if( bWeiter && pStr-- == pStart ) 988cdf0e10cSrcweir { 989cdf0e10cSrcweir // !!! wenn am Anfang, dann nie ersetzen. 990cdf0e10cSrcweir // if( !nFlag ) 991cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 992cdf0e10cSrcweir // ++pStr; 993cdf0e10cSrcweir // break; // Schleife beenden 994cdf0e10cSrcweir } 995cdf0e10cSrcweir } while( bWeiter ); 996cdf0e10cSrcweir if( C_FULL_STOP != nFlag ) 997cdf0e10cSrcweir pExceptStt = 0; 998cdf0e10cSrcweir } 999cdf0e10cSrcweir 1000cdf0e10cSrcweir if( 2 > ( pStr - pStart ) ) 1001cdf0e10cSrcweir return sal_False; 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir if( !rCC.isLetterNumeric( 1004cdf0e10cSrcweir aText, sal::static_int_cast< xub_StrLen >( pStr-- - pStart ) ) ) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir sal_Bool bValid = sal_False, bAlphaFnd = sal_False; 1007cdf0e10cSrcweir const sal_Unicode* pTmpStr = pStr; 1008cdf0e10cSrcweir while( !bValid ) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir if( rCC.isDigit( 1011cdf0e10cSrcweir aText, 1012cdf0e10cSrcweir sal::static_int_cast< xub_StrLen >( pTmpStr - pStart ) ) ) 1013cdf0e10cSrcweir { 1014cdf0e10cSrcweir bValid = sal_True; 1015cdf0e10cSrcweir pStr = pTmpStr - 1; 1016cdf0e10cSrcweir } 1017cdf0e10cSrcweir else if( rCC.isLetter( 1018cdf0e10cSrcweir aText, 1019cdf0e10cSrcweir sal::static_int_cast< xub_StrLen >( 1020cdf0e10cSrcweir pTmpStr - pStart ) ) ) 1021cdf0e10cSrcweir { 1022cdf0e10cSrcweir if( bAlphaFnd ) 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir bValid = sal_True; 1025cdf0e10cSrcweir pStr = pTmpStr; 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir else 1028cdf0e10cSrcweir bAlphaFnd = sal_True; 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir else if( bAlphaFnd || IsWordDelim( *pTmpStr ) ) 1031cdf0e10cSrcweir break; 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir if( pTmpStr == pStart ) 1034cdf0e10cSrcweir break; 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir --pTmpStr; 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir if( !bValid ) 1040cdf0e10cSrcweir return sal_False; // kein gueltiger Trenner -> keine Ersetzung 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir sal_Bool bNumericOnly = '0' <= *(pStr+1) && *(pStr+1) <= '9'; 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir // suche den Anfang vom Wort 1046cdf0e10cSrcweir while( !IsWordDelim( *pStr )) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir if( bNumericOnly && 1049cdf0e10cSrcweir rCC.isLetter( 1050cdf0e10cSrcweir aText, sal::static_int_cast< xub_StrLen >( pStr - pStart ) ) ) 1051cdf0e10cSrcweir bNumericOnly = sal_False; 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir if( pStart == pStr ) 1054cdf0e10cSrcweir break; 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir --pStr; 1057cdf0e10cSrcweir } 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir if( bNumericOnly ) // besteht nur aus Zahlen, dann nicht 1060cdf0e10cSrcweir return sal_False; 1061cdf0e10cSrcweir 1062cdf0e10cSrcweir if( IsWordDelim( *pStr )) 1063cdf0e10cSrcweir ++pStr; 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir String sWord; 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir // ueberpruefe anhand der Exceptionliste 1068cdf0e10cSrcweir if( pExceptStt ) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir sWord = String( 1071cdf0e10cSrcweir pStr, sal::static_int_cast< xub_StrLen >( pExceptStt - pStr + 1 ) ); 1072cdf0e10cSrcweir if( FindInCplSttExceptList(eLang, sWord) ) 1073cdf0e10cSrcweir return sal_False; 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir // loesche alle nicht alpanum. Zeichen am Wortanfang/-ende und 1076cdf0e10cSrcweir // teste dann noch mal ( erkennt: "(min.", "/min.", usw.) 1077cdf0e10cSrcweir String sTmp( sWord ); 1078cdf0e10cSrcweir while( sTmp.Len() && 1079cdf0e10cSrcweir !rCC.isLetterNumeric( sTmp, 0 ) ) 1080cdf0e10cSrcweir sTmp.Erase( 0, 1 ); 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir // alle hinteren nicht alphanumerische Zeichen bis auf das 1083cdf0e10cSrcweir // Letzte entfernen 1084cdf0e10cSrcweir xub_StrLen nLen = sTmp.Len(); 1085cdf0e10cSrcweir while( nLen && !rCC.isLetterNumeric( sTmp, nLen-1 ) ) 1086cdf0e10cSrcweir --nLen; 1087cdf0e10cSrcweir if( nLen + 1 < sTmp.Len() ) 1088cdf0e10cSrcweir sTmp.Erase( nLen + 1 ); 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir if( sTmp.Len() && sTmp.Len() != sWord.Len() && 1091cdf0e10cSrcweir FindInCplSttExceptList(eLang, sTmp)) 1092cdf0e10cSrcweir return sal_False; 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir if(FindInCplSttExceptList(eLang, sWord, sal_True)) 1095cdf0e10cSrcweir return sal_False; 1096cdf0e10cSrcweir } 1097cdf0e10cSrcweir 1098cdf0e10cSrcweir // Ok, dann ersetze mal 1099cdf0e10cSrcweir sal_Unicode cSave = *pWordStt; 1100cdf0e10cSrcweir nSttPos = sal::static_int_cast< xub_StrLen >( pWordStt - rTxt.GetBuffer() ); 1101cdf0e10cSrcweir String sChar( cSave ); 1102cdf0e10cSrcweir rCC.toUpper( sChar ); 1103cdf0e10cSrcweir sal_Bool bRet = sChar.GetChar(0) != cSave && rDoc.ReplaceRange( nSttPos, 1, sChar ); 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir // das Wort will vielleicht jemand haben 1106cdf0e10cSrcweir if( bRet && SaveWordCplSttLst & nFlags ) 1107cdf0e10cSrcweir rDoc.SaveCpltSttWord( CptlSttSntnc, nSttPos, sWord, cSave ); 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir return bRet; 1110cdf0e10cSrcweir } 1111cdf0e10cSrcweir //The method below is renamed from _GetQuote to GetQuote by BerryJia for Bug95846 Time:2002-8-13 15:50 1112cdf0e10cSrcweir sal_Unicode SvxAutoCorrect::GetQuote( sal_Unicode cInsChar, sal_Bool bSttQuote, 1113cdf0e10cSrcweir LanguageType eLang ) const 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir sal_Unicode cRet = bSttQuote ? ( '\"' == cInsChar 1116cdf0e10cSrcweir ? GetStartDoubleQuote() 1117cdf0e10cSrcweir : GetStartSingleQuote() ) 1118cdf0e10cSrcweir : ( '\"' == cInsChar 1119cdf0e10cSrcweir ? GetEndDoubleQuote() 1120cdf0e10cSrcweir : GetEndSingleQuote() ); 1121cdf0e10cSrcweir if( !cRet ) 1122cdf0e10cSrcweir { 1123cdf0e10cSrcweir // dann ueber die Language das richtige Zeichen heraussuchen 1124cdf0e10cSrcweir if( LANGUAGE_NONE == eLang ) 1125cdf0e10cSrcweir cRet = cInsChar; 1126cdf0e10cSrcweir else 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang ); 1129cdf0e10cSrcweir String sRet( bSttQuote 1130cdf0e10cSrcweir ? ( '\"' == cInsChar 1131cdf0e10cSrcweir ? rLcl.getDoubleQuotationMarkStart() 1132cdf0e10cSrcweir : rLcl.getQuotationMarkStart() ) 1133cdf0e10cSrcweir : ( '\"' == cInsChar 1134cdf0e10cSrcweir ? rLcl.getDoubleQuotationMarkEnd() 1135cdf0e10cSrcweir : rLcl.getQuotationMarkEnd() )); 1136cdf0e10cSrcweir cRet = sRet.Len() ? sRet.GetChar( 0 ) : cInsChar; 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir } 1139cdf0e10cSrcweir return cRet; 1140cdf0e10cSrcweir } 1141cdf0e10cSrcweir 1142cdf0e10cSrcweir void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, xub_StrLen nInsPos, 1143cdf0e10cSrcweir sal_Unicode cInsChar, sal_Bool bSttQuote, 1144cdf0e10cSrcweir sal_Bool bIns ) 1145cdf0e10cSrcweir { 1146cdf0e10cSrcweir LanguageType eLang = rDoc.GetLanguage( nInsPos, sal_False ); 1147cdf0e10cSrcweir sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang ); 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir //JP 13.02.99: damit beim Undo das "einfuegte" Zeichen wieder erscheint, 1150cdf0e10cSrcweir // wird es erstmal eingefuegt und dann ueberschrieben 1151cdf0e10cSrcweir String sChg( cInsChar ); 1152cdf0e10cSrcweir if( bIns ) 1153cdf0e10cSrcweir rDoc.Insert( nInsPos, sChg ); 1154cdf0e10cSrcweir else 1155cdf0e10cSrcweir rDoc.Replace( nInsPos, sChg ); 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir //JP 13.08.97: Bug 42477 - bei doppelten Anfuehrungszeichen muss bei 1158cdf0e10cSrcweir // franzoesischer Sprache an Anfang ein Leerzeichen dahinter 1159cdf0e10cSrcweir // und am Ende ein Leerzeichen dahinter eingefuegt werden. 1160cdf0e10cSrcweir sChg = cRet; 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir if( '\"' == cInsChar ) 1163cdf0e10cSrcweir { 1164cdf0e10cSrcweir if( LANGUAGE_SYSTEM == eLang ) 1165cdf0e10cSrcweir eLang = GetAppLang(); 1166cdf0e10cSrcweir switch( eLang ) 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir case LANGUAGE_FRENCH: 1169cdf0e10cSrcweir case LANGUAGE_FRENCH_BELGIAN: 1170cdf0e10cSrcweir case LANGUAGE_FRENCH_CANADIAN: 1171cdf0e10cSrcweir case LANGUAGE_FRENCH_SWISS: 1172cdf0e10cSrcweir case LANGUAGE_FRENCH_LUXEMBOURG: 1173cdf0e10cSrcweir // JP 09.02.99: das zusaetzliche Zeichen immer per Insert einfuegen. 1174cdf0e10cSrcweir // Es ueberschreibt nichts! 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir String s( static_cast< sal_Unicode >(0xA0) ); 1177cdf0e10cSrcweir // UNICODE code for no break space 1178cdf0e10cSrcweir if( rDoc.Insert( bSttQuote ? nInsPos+1 : nInsPos, s )) 1179cdf0e10cSrcweir { 1180cdf0e10cSrcweir if( !bSttQuote ) 1181cdf0e10cSrcweir ++nInsPos; 1182cdf0e10cSrcweir } 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir break; 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir rDoc.Replace( nInsPos, sChg ); 1189cdf0e10cSrcweir } 1190cdf0e10cSrcweir 1191cdf0e10cSrcweir String SvxAutoCorrect::GetQuote( SvxAutoCorrDoc& rDoc, xub_StrLen nInsPos, 1192cdf0e10cSrcweir sal_Unicode cInsChar, sal_Bool bSttQuote ) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir LanguageType eLang = rDoc.GetLanguage( nInsPos, sal_False ); 1195cdf0e10cSrcweir sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang ); 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir String sRet( cRet ); 1198cdf0e10cSrcweir //JP 13.08.97: Bug 42477 - bei doppelten Anfuehrungszeichen muss bei 1199cdf0e10cSrcweir // franzoesischer Sprache an Anfang ein Leerzeichen dahinter 1200cdf0e10cSrcweir // und am Ende ein Leerzeichen dahinter eingefuegt werden. 1201cdf0e10cSrcweir if( '\"' == cInsChar ) 1202cdf0e10cSrcweir { 1203cdf0e10cSrcweir if( LANGUAGE_SYSTEM == eLang ) 1204cdf0e10cSrcweir eLang = GetAppLang(); 1205cdf0e10cSrcweir switch( eLang ) 1206cdf0e10cSrcweir { 1207cdf0e10cSrcweir case LANGUAGE_FRENCH: 1208cdf0e10cSrcweir case LANGUAGE_FRENCH_BELGIAN: 1209cdf0e10cSrcweir case LANGUAGE_FRENCH_CANADIAN: 1210cdf0e10cSrcweir case LANGUAGE_FRENCH_SWISS: 1211cdf0e10cSrcweir case LANGUAGE_FRENCH_LUXEMBOURG: 1212cdf0e10cSrcweir if( bSttQuote ) 1213cdf0e10cSrcweir sRet += ' '; 1214cdf0e10cSrcweir else 1215cdf0e10cSrcweir sRet.Insert( ' ', 0 ); 1216cdf0e10cSrcweir break; 1217cdf0e10cSrcweir } 1218cdf0e10cSrcweir } 1219cdf0e10cSrcweir return sRet; 1220cdf0e10cSrcweir } 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir sal_uLong SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, 1223cdf0e10cSrcweir xub_StrLen nInsPos, sal_Unicode cChar, 1224cdf0e10cSrcweir sal_Bool bInsert ) 1225cdf0e10cSrcweir { 1226cdf0e10cSrcweir sal_uLong nRet = 0; 1227cdf0e10cSrcweir bool bIsNextRun = bRunNext; 1228cdf0e10cSrcweir bRunNext = false; // if it was set, then it has to be turned off 1229cdf0e10cSrcweir 1230cdf0e10cSrcweir do{ // only for middle check loop !! 1231cdf0e10cSrcweir if( cChar ) 1232cdf0e10cSrcweir { 1233cdf0e10cSrcweir //JP 10.02.97: doppelte Spaces verhindern 1234cdf0e10cSrcweir if( nInsPos && ' ' == cChar && 1235cdf0e10cSrcweir IsAutoCorrFlag( IgnoreDoubleSpace ) && 1236cdf0e10cSrcweir ' ' == rTxt.GetChar( nInsPos - 1 ) ) 1237cdf0e10cSrcweir { 1238cdf0e10cSrcweir nRet = IgnoreDoubleSpace; 1239cdf0e10cSrcweir break; 1240cdf0e10cSrcweir } 1241cdf0e10cSrcweir 1242cdf0e10cSrcweir sal_Bool bSingle = '\'' == cChar; 1243cdf0e10cSrcweir sal_Bool bIsReplaceQuote = 1244cdf0e10cSrcweir (IsAutoCorrFlag( ChgQuotes ) && ('\"' == cChar )) || 1245cdf0e10cSrcweir (IsAutoCorrFlag( ChgSglQuotes ) && bSingle ); 1246cdf0e10cSrcweir if( bIsReplaceQuote ) 1247cdf0e10cSrcweir { 1248cdf0e10cSrcweir sal_Unicode cPrev; 1249cdf0e10cSrcweir sal_Bool bSttQuote = !nInsPos || 1250cdf0e10cSrcweir IsWordDelim( ( cPrev = rTxt.GetChar( nInsPos-1 ))) || 1251cdf0e10cSrcweir // os: #56034# - Warum kein schliessendes Anfuehrungszeichen nach dem Bindestrich? 1252cdf0e10cSrcweir // strchr( "-([{", cPrev ) || 1253cdf0e10cSrcweir lcl_IsInAsciiArr( "([{", cPrev ) || 1254cdf0e10cSrcweir ( cEmDash && cEmDash == cPrev ) || 1255cdf0e10cSrcweir ( cEnDash && cEnDash == cPrev ); 1256cdf0e10cSrcweir 1257cdf0e10cSrcweir InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert ); 1258cdf0e10cSrcweir nRet = bSingle ? ChgSglQuotes : ChgQuotes; 1259cdf0e10cSrcweir break; 1260cdf0e10cSrcweir } 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir if( bInsert ) 1263cdf0e10cSrcweir rDoc.Insert( nInsPos, cChar ); 1264cdf0e10cSrcweir else 1265cdf0e10cSrcweir rDoc.Replace( nInsPos, cChar ); 1266cdf0e10cSrcweir 1267cdf0e10cSrcweir // Hardspaces autocorrection 1268cdf0e10cSrcweir if ( IsAutoCorrFlag( AddNonBrkSpace ) ) 1269cdf0e10cSrcweir { 1270cdf0e10cSrcweir if ( NeedsHardspaceAutocorr( cChar ) && 1271cdf0e10cSrcweir FnAddNonBrkSpace( rDoc, rTxt, 0, nInsPos, rDoc.GetLanguage( nInsPos, sal_False ) ) ) 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir nRet = AddNonBrkSpace; 1274cdf0e10cSrcweir } 1275cdf0e10cSrcweir else if ( bIsNextRun && !IsAutoCorrectChar( cChar ) ) 1276cdf0e10cSrcweir { 1277cdf0e10cSrcweir // Remove the NBSP if it wasn't an autocorrection 1278cdf0e10cSrcweir if ( nInsPos != 0 && NeedsHardspaceAutocorr( rTxt.GetChar( nInsPos - 1 ) ) && 1279cdf0e10cSrcweir cChar != ' ' && cChar != '\t' && cChar != CHAR_HARDBLANK ) 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir // Look for the last HARD_SPACE 1282cdf0e10cSrcweir xub_StrLen nPos = nInsPos - 1; 1283cdf0e10cSrcweir bool bContinue = true; 1284cdf0e10cSrcweir while ( bContinue ) 1285cdf0e10cSrcweir { 1286cdf0e10cSrcweir const sal_Unicode cTmpChar = rTxt.GetChar( nPos ); 1287cdf0e10cSrcweir if ( cTmpChar == CHAR_HARDBLANK ) 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir rDoc.Delete( nPos, nPos + 1 ); 1290cdf0e10cSrcweir nRet = AddNonBrkSpace; 1291cdf0e10cSrcweir bContinue = false; 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir else if ( !NeedsHardspaceAutocorr( cTmpChar ) || nPos == 0 ) 1294cdf0e10cSrcweir bContinue = false; 1295cdf0e10cSrcweir nPos--; 1296cdf0e10cSrcweir } 1297cdf0e10cSrcweir } 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir if( !nInsPos ) 1303cdf0e10cSrcweir break; 1304cdf0e10cSrcweir 1305cdf0e10cSrcweir xub_StrLen nPos = nInsPos - 1; 1306cdf0e10cSrcweir 1307cdf0e10cSrcweir // Bug 19286: nur direkt hinter dem "Wort" aufsetzen 1308cdf0e10cSrcweir if( IsWordDelim( rTxt.GetChar( nPos ))) 1309cdf0e10cSrcweir break; 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir // automatisches Fett oder Unterstreichen setzen? 1312cdf0e10cSrcweir if( '*' == cChar || '_' == cChar ) 1313cdf0e10cSrcweir { 1314cdf0e10cSrcweir if( IsAutoCorrFlag( ChgWeightUnderl ) && 1315cdf0e10cSrcweir FnChgWeightUnderl( rDoc, rTxt, 0, nPos+1 ) ) 1316cdf0e10cSrcweir nRet = ChgWeightUnderl; 1317cdf0e10cSrcweir break; 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir 1320cdf0e10cSrcweir while( nPos && !IsWordDelim( rTxt.GetChar( --nPos ))) 1321cdf0e10cSrcweir ; 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir // Absatz-Anfang oder ein Blank gefunden, suche nach dem Wort 1324cdf0e10cSrcweir // Kuerzel im Auto 1325cdf0e10cSrcweir xub_StrLen nCapLttrPos = nPos+1; // auf das 1. Zeichen 1326cdf0e10cSrcweir if( !nPos && !IsWordDelim( rTxt.GetChar( 0 ))) 1327cdf0e10cSrcweir --nCapLttrPos; // Absatz Anfang und kein Blank ! 1328cdf0e10cSrcweir 1329cdf0e10cSrcweir LanguageType eLang = rDoc.GetLanguage( nCapLttrPos, sal_False ); 1330cdf0e10cSrcweir if( LANGUAGE_SYSTEM == eLang ) 1331cdf0e10cSrcweir eLang = MsLangId::getSystemLanguage(); 1332cdf0e10cSrcweir CharClass& rCC = GetCharClass( eLang ); 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir // no symbol characters 1335cdf0e10cSrcweir if( lcl_IsSymbolChar( rCC, rTxt, nCapLttrPos, nInsPos )) 1336cdf0e10cSrcweir break; 1337cdf0e10cSrcweir 1338cdf0e10cSrcweir if( IsAutoCorrFlag( Autocorrect ) ) 1339cdf0e10cSrcweir { 1340cdf0e10cSrcweir const String* pPara = 0; 1341cdf0e10cSrcweir const String** ppPara = IsAutoCorrFlag(CptlSttSntnc) ? &pPara : 0; 1342cdf0e10cSrcweir 1343cdf0e10cSrcweir sal_Bool bChgWord = rDoc.ChgAutoCorrWord( nCapLttrPos, nInsPos, 1344cdf0e10cSrcweir *this, ppPara ); 1345cdf0e10cSrcweir if( !bChgWord ) 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir // JP 16.06.98: dann versuche mal alle !AlphaNum. Zeichen los zu 1348cdf0e10cSrcweir // werden und teste dann nochmals 1349cdf0e10cSrcweir //JP 22.04.99: Bug 63883 - entferne nur die "Klammern Start/-Anfaenge", 1350cdf0e10cSrcweir // alle anderen Zeichen muessen drin bleiben. 1351cdf0e10cSrcweir xub_StrLen nCapLttrPos1 = nCapLttrPos, nInsPos1 = nInsPos; 1352cdf0e10cSrcweir while( nCapLttrPos1 < nInsPos && 1353cdf0e10cSrcweir lcl_IsInAsciiArr( sImplSttSkipChars, rTxt.GetChar( nCapLttrPos1 ) ) 1354cdf0e10cSrcweir ) 1355cdf0e10cSrcweir ++nCapLttrPos1; 1356cdf0e10cSrcweir while( nCapLttrPos1 < nInsPos1 && nInsPos1 && 1357cdf0e10cSrcweir lcl_IsInAsciiArr( sImplEndSkipChars, rTxt.GetChar( nInsPos1-1 ) ) 1358cdf0e10cSrcweir ) 1359cdf0e10cSrcweir --nInsPos1; 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir if( (nCapLttrPos1 != nCapLttrPos || nInsPos1 != nInsPos ) && 1362cdf0e10cSrcweir nCapLttrPos1 < nInsPos1 && 1363cdf0e10cSrcweir rDoc.ChgAutoCorrWord( nCapLttrPos1, nInsPos1, *this, ppPara )) 1364cdf0e10cSrcweir { 1365cdf0e10cSrcweir bChgWord = sal_True; 1366cdf0e10cSrcweir nCapLttrPos = nCapLttrPos1; 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir } 1369cdf0e10cSrcweir 1370cdf0e10cSrcweir if( bChgWord ) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir nRet = Autocorrect; 1373cdf0e10cSrcweir if( pPara ) 1374cdf0e10cSrcweir { 1375cdf0e10cSrcweir xub_StrLen nEnd = nCapLttrPos; 1376cdf0e10cSrcweir while( nEnd < pPara->Len() && 1377cdf0e10cSrcweir !IsWordDelim( pPara->GetChar( nEnd ))) 1378cdf0e10cSrcweir ++nEnd; 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir // Grossbuchstabe am Satz-Anfang ?? 1381cdf0e10cSrcweir if( IsAutoCorrFlag( CptlSttSntnc ) && 1382cdf0e10cSrcweir FnCptlSttSntnc( rDoc, *pPara, sal_False, 1383cdf0e10cSrcweir nCapLttrPos, nEnd, eLang ) ) 1384cdf0e10cSrcweir nRet |= CptlSttSntnc; 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir if( IsAutoCorrFlag( ChgToEnEmDash ) && 1387cdf0e10cSrcweir FnChgToEnEmDash( rDoc, rTxt, nCapLttrPos, nEnd, eLang ) ) 1388cdf0e10cSrcweir nRet |= ChgToEnEmDash; 1389cdf0e10cSrcweir } 1390cdf0e10cSrcweir break; 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir } 1393cdf0e10cSrcweir 1394cdf0e10cSrcweir if( ( IsAutoCorrFlag( nRet = ChgOrdinalNumber ) && 1395cdf0e10cSrcweir FnChgOrdinalNumber( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) || 1396cdf0e10cSrcweir ( IsAutoCorrFlag( nRet = SetINetAttr ) && 1397cdf0e10cSrcweir ( ' ' == cChar || '\t' == cChar || 0x0a == cChar || !cChar ) && 1398cdf0e10cSrcweir FnSetINetAttr( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) ) 1399cdf0e10cSrcweir ; 1400cdf0e10cSrcweir else 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir nRet = 0; 1403cdf0e10cSrcweir bool bUnsupported = lcl_IsUnsupportedUnicodeChar( rCC, rTxt, nCapLttrPos, nInsPos ); 1404cdf0e10cSrcweir // Grossbuchstabe am Satz-Anfang ?? 1405cdf0e10cSrcweir if( !bUnsupported && 1406cdf0e10cSrcweir IsAutoCorrFlag( CptlSttSntnc ) && 1407cdf0e10cSrcweir FnCptlSttSntnc( rDoc, rTxt, sal_True, nCapLttrPos, nInsPos, eLang ) ) 1408cdf0e10cSrcweir nRet |= CptlSttSntnc; 1409cdf0e10cSrcweir 1410cdf0e10cSrcweir // Zwei Grossbuchstaben am Wort-Anfang ?? 1411cdf0e10cSrcweir if( !bUnsupported && 1412cdf0e10cSrcweir IsAutoCorrFlag( CptlSttWrd ) && 1413cdf0e10cSrcweir FnCptlSttWrd( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) 1414cdf0e10cSrcweir nRet |= CptlSttWrd; 1415cdf0e10cSrcweir 1416cdf0e10cSrcweir if( IsAutoCorrFlag( ChgToEnEmDash ) && 1417cdf0e10cSrcweir FnChgToEnEmDash( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) 1418cdf0e10cSrcweir nRet |= ChgToEnEmDash; 1419cdf0e10cSrcweir } 1420cdf0e10cSrcweir 1421cdf0e10cSrcweir } while( sal_False ); 1422cdf0e10cSrcweir 1423cdf0e10cSrcweir if( nRet ) 1424cdf0e10cSrcweir { 1425cdf0e10cSrcweir const char* aHelpIds[] = 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir HID_AUTOCORR_HELP_WORD, 1428cdf0e10cSrcweir HID_AUTOCORR_HELP_SENT, 1429cdf0e10cSrcweir HID_AUTOCORR_HELP_SENTWORD, 1430cdf0e10cSrcweir HID_AUTOCORR_HELP_ACORWORD, 1431cdf0e10cSrcweir "", 1432cdf0e10cSrcweir HID_AUTOCORR_HELP_ACORSENTWORD, 1433cdf0e10cSrcweir "", 1434cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGTOENEMDASH, 1435cdf0e10cSrcweir HID_AUTOCORR_HELP_WORDENEMDASH, 1436cdf0e10cSrcweir HID_AUTOCORR_HELP_SENTENEMDASH, 1437cdf0e10cSrcweir HID_AUTOCORR_HELP_SENTWORDENEMDASH, 1438cdf0e10cSrcweir HID_AUTOCORR_HELP_ACORWORDENEMDASH, 1439cdf0e10cSrcweir "", 1440cdf0e10cSrcweir HID_AUTOCORR_HELP_ACORSENTWORDENEMDASH, 1441cdf0e10cSrcweir "", 1442cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGQUOTES, 1443cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGSGLQUOTES, 1444cdf0e10cSrcweir HID_AUTOCORR_HELP_SETINETATTR, 1445cdf0e10cSrcweir HID_AUTOCORR_HELP_INGNOREDOUBLESPACE, 1446cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGWEIGHTUNDERL, 1447cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGFRACTIONSYMBOL, 1448cdf0e10cSrcweir HID_AUTOCORR_HELP_CHGORDINALNUMBER 1449cdf0e10cSrcweir }; 1450cdf0e10cSrcweir 1451cdf0e10cSrcweir sal_uLong nHelpId = 0; 1452cdf0e10cSrcweir if( nRet & ( Autocorrect|CptlSttSntnc|CptlSttWrd|ChgToEnEmDash ) ) 1453cdf0e10cSrcweir { 1454cdf0e10cSrcweir // von 0 - 15 1455cdf0e10cSrcweir if( nRet & ChgToEnEmDash ) 1456cdf0e10cSrcweir nHelpId += 8; 1457cdf0e10cSrcweir if( nRet & Autocorrect ) 1458cdf0e10cSrcweir nHelpId += 4; 1459cdf0e10cSrcweir if( nRet & CptlSttSntnc ) 1460cdf0e10cSrcweir nHelpId += 2; 1461cdf0e10cSrcweir if( nRet & CptlSttWrd ) 1462cdf0e10cSrcweir nHelpId += 1; 1463cdf0e10cSrcweir } 1464cdf0e10cSrcweir else 1465cdf0e10cSrcweir { 1466cdf0e10cSrcweir if( nRet & ChgQuotes) nHelpId = 16; 1467cdf0e10cSrcweir else if( nRet & ChgSglQuotes) nHelpId = 17; 1468cdf0e10cSrcweir else if( nRet & SetINetAttr) nHelpId = 18; 1469cdf0e10cSrcweir else if( nRet & IgnoreDoubleSpace) nHelpId = 19; 1470cdf0e10cSrcweir else if( nRet & ChgWeightUnderl) nHelpId = 20; 1471cdf0e10cSrcweir else if( nRet & AddNonBrkSpace) nHelpId = 21; 1472cdf0e10cSrcweir else if( nRet & ChgOrdinalNumber) nHelpId = 22; 1473cdf0e10cSrcweir } 1474cdf0e10cSrcweir 1475cdf0e10cSrcweir if( nHelpId ) 1476cdf0e10cSrcweir { 1477cdf0e10cSrcweir nHelpId -= 1; 1478cdf0e10cSrcweir Application::GetHelp()->OpenHelpAgent( aHelpIds[nHelpId] ); 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir } 1481cdf0e10cSrcweir 1482cdf0e10cSrcweir 1483cdf0e10cSrcweir return nRet; 1484cdf0e10cSrcweir } 1485cdf0e10cSrcweir 1486cdf0e10cSrcweir SvxAutoCorrectLanguageLists& SvxAutoCorrect::_GetLanguageList( 1487cdf0e10cSrcweir LanguageType eLang ) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir if( !pLangTable->IsKeyValid( sal_uLong( eLang ))) 1490cdf0e10cSrcweir CreateLanguageFile( eLang, sal_True); 1491cdf0e10cSrcweir return *pLangTable->Seek( sal_uLong( eLang ) ); 1492cdf0e10cSrcweir } 1493cdf0e10cSrcweir 1494cdf0e10cSrcweir void SvxAutoCorrect::SaveCplSttExceptList( LanguageType eLang ) 1495cdf0e10cSrcweir { 1496cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( eLang ))) 1497cdf0e10cSrcweir { 1498cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = pLangTable->Seek(sal_uLong(eLang)); 1499cdf0e10cSrcweir if( pLists ) 1500cdf0e10cSrcweir pLists->SaveCplSttExceptList(); 1501cdf0e10cSrcweir } 1502cdf0e10cSrcweir #ifdef DBG_UTIL 1503cdf0e10cSrcweir else 1504cdf0e10cSrcweir { 1505cdf0e10cSrcweir DBG_ERROR("speichern einer leeren Liste?"); 1506cdf0e10cSrcweir } 1507cdf0e10cSrcweir #endif 1508cdf0e10cSrcweir } 1509cdf0e10cSrcweir 1510cdf0e10cSrcweir void SvxAutoCorrect::SaveWrdSttExceptList(LanguageType eLang) 1511cdf0e10cSrcweir { 1512cdf0e10cSrcweir if(pLangTable->IsKeyValid(sal_uLong(eLang))) 1513cdf0e10cSrcweir { 1514cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = pLangTable->Seek(sal_uLong(eLang)); 1515cdf0e10cSrcweir if(pLists) 1516cdf0e10cSrcweir pLists->SaveWrdSttExceptList(); 1517cdf0e10cSrcweir } 1518cdf0e10cSrcweir #ifdef DBG_UTIL 1519cdf0e10cSrcweir else 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir DBG_ERROR("speichern einer leeren Liste?"); 1522cdf0e10cSrcweir } 1523cdf0e10cSrcweir #endif 1524cdf0e10cSrcweir } 1525cdf0e10cSrcweir 1526cdf0e10cSrcweir 1527cdf0e10cSrcweir // fuegt ein einzelnes Wort hinzu. Die Liste wird sofort 1528cdf0e10cSrcweir // in die Datei geschrieben! 1529cdf0e10cSrcweir sal_Bool SvxAutoCorrect::AddCplSttException( const String& rNew, 1530cdf0e10cSrcweir LanguageType eLang ) 1531cdf0e10cSrcweir { 1532cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = 0; 1533cdf0e10cSrcweir //entweder die richtige Sprache ist vorhanden oder es kommt in die allg. Liste 1534cdf0e10cSrcweir if( pLangTable->IsKeyValid(sal_uLong(eLang))) 1535cdf0e10cSrcweir pLists = pLangTable->Seek(sal_uLong(eLang)); 1536cdf0e10cSrcweir else if(pLangTable->IsKeyValid(sal_uLong(LANGUAGE_DONTKNOW))|| 1537cdf0e10cSrcweir CreateLanguageFile(LANGUAGE_DONTKNOW, sal_True)) 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir pLists = pLangTable->Seek(sal_uLong(LANGUAGE_DONTKNOW)); 1540cdf0e10cSrcweir } 1541cdf0e10cSrcweir DBG_ASSERT(pLists, "keine Autokorrekturdatei"); 1542cdf0e10cSrcweir return pLists->AddToCplSttExceptList(rNew); 1543cdf0e10cSrcweir } 1544cdf0e10cSrcweir 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir // fuegt ein einzelnes Wort hinzu. Die Liste wird sofort 1547cdf0e10cSrcweir // in die Datei geschrieben! 1548cdf0e10cSrcweir sal_Bool SvxAutoCorrect::AddWrtSttException( const String& rNew, 1549cdf0e10cSrcweir LanguageType eLang ) 1550cdf0e10cSrcweir { 1551cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = 0; 1552cdf0e10cSrcweir //entweder die richtige Sprache ist vorhanden oder es kommt in die allg. Liste 1553cdf0e10cSrcweir if(pLangTable->IsKeyValid(sal_uLong(eLang))) 1554cdf0e10cSrcweir pLists = pLangTable->Seek(sal_uLong(eLang)); 1555cdf0e10cSrcweir else if(pLangTable->IsKeyValid(sal_uLong(LANGUAGE_DONTKNOW))|| 1556cdf0e10cSrcweir CreateLanguageFile(LANGUAGE_DONTKNOW, sal_True)) 1557cdf0e10cSrcweir pLists = pLangTable->Seek(sal_uLong(LANGUAGE_DONTKNOW)); 1558cdf0e10cSrcweir DBG_ASSERT(pLists, "keine Autokorrekturdatei"); 1559cdf0e10cSrcweir return pLists->AddToWrdSttExceptList(rNew); 1560cdf0e10cSrcweir } 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir 1563cdf0e10cSrcweir 1564cdf0e10cSrcweir 1565cdf0e10cSrcweir void SvxAutoCorrect::SetUserAutoCorrFileName( const String& rNew ) 1566cdf0e10cSrcweir { 1567cdf0e10cSrcweir if( sUserAutoCorrFile != rNew ) 1568cdf0e10cSrcweir { 1569cdf0e10cSrcweir sUserAutoCorrFile = rNew; 1570cdf0e10cSrcweir 1571cdf0e10cSrcweir // sind die Listen gesetzt sind, so muessen sie jetzt geloescht 1572cdf0e10cSrcweir // werden 1573cdf0e10cSrcweir lcl_ClearTable(*pLangTable); 1574cdf0e10cSrcweir nFlags &= ~(CplSttLstLoad | WrdSttLstLoad | ChgWordLstLoad ); 1575cdf0e10cSrcweir } 1576cdf0e10cSrcweir } 1577cdf0e10cSrcweir 1578cdf0e10cSrcweir void SvxAutoCorrect::SetShareAutoCorrFileName( const String& rNew ) 1579cdf0e10cSrcweir { 1580cdf0e10cSrcweir if( sShareAutoCorrFile != rNew ) 1581cdf0e10cSrcweir { 1582cdf0e10cSrcweir sShareAutoCorrFile = rNew; 1583cdf0e10cSrcweir 1584cdf0e10cSrcweir // sind die Listen gesetzt sind, so muessen sie jetzt geloescht 1585cdf0e10cSrcweir // werden 1586cdf0e10cSrcweir lcl_ClearTable(*pLangTable); 1587cdf0e10cSrcweir nFlags &= ~(CplSttLstLoad | WrdSttLstLoad | ChgWordLstLoad ); 1588cdf0e10cSrcweir } 1589cdf0e10cSrcweir } 1590cdf0e10cSrcweir 1591cdf0e10cSrcweir 1592cdf0e10cSrcweir sal_Bool SvxAutoCorrect::GetPrevAutoCorrWord( SvxAutoCorrDoc& rDoc, 1593cdf0e10cSrcweir const String& rTxt, xub_StrLen nPos, 1594cdf0e10cSrcweir String& rWord ) const 1595cdf0e10cSrcweir { 1596cdf0e10cSrcweir if( !nPos ) 1597cdf0e10cSrcweir return sal_False; 1598cdf0e10cSrcweir 1599cdf0e10cSrcweir xub_StrLen nEnde = nPos; 1600cdf0e10cSrcweir 1601cdf0e10cSrcweir // dahinter muss ein Blank oder Tab folgen! 1602cdf0e10cSrcweir if( ( nPos < rTxt.Len() && 1603cdf0e10cSrcweir !IsWordDelim( rTxt.GetChar( nPos ))) || 1604cdf0e10cSrcweir IsWordDelim( rTxt.GetChar( --nPos ))) 1605cdf0e10cSrcweir return sal_False; 1606cdf0e10cSrcweir 1607cdf0e10cSrcweir while( nPos && !IsWordDelim( rTxt.GetChar( --nPos ))) 1608cdf0e10cSrcweir ; 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir // Absatz-Anfang oder ein Blank gefunden, suche nach dem Wort 1611cdf0e10cSrcweir // Kuerzel im Auto 1612cdf0e10cSrcweir xub_StrLen nCapLttrPos = nPos+1; // auf das 1. Zeichen 1613cdf0e10cSrcweir if( !nPos && !IsWordDelim( rTxt.GetChar( 0 ))) 1614cdf0e10cSrcweir --nCapLttrPos; // Absatz Anfang und kein Blank ! 1615cdf0e10cSrcweir 1616cdf0e10cSrcweir while( lcl_IsInAsciiArr( sImplSttSkipChars, rTxt.GetChar( nCapLttrPos )) ) 1617cdf0e10cSrcweir if( ++nCapLttrPos >= nEnde ) 1618cdf0e10cSrcweir return sal_False; 1619cdf0e10cSrcweir 1620cdf0e10cSrcweir // Bug 19285: Symbolzeichen nicht anfassen 1621cdf0e10cSrcweir // Interresant erst ab 3 Zeichen 1622cdf0e10cSrcweir if( 3 > nEnde - nCapLttrPos ) 1623cdf0e10cSrcweir return sal_False; 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir LanguageType eLang = rDoc.GetLanguage( nCapLttrPos, sal_False ); 1626cdf0e10cSrcweir if( LANGUAGE_SYSTEM == eLang ) 1627cdf0e10cSrcweir eLang = MsLangId::getSystemLanguage(); 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir SvxAutoCorrect* pThis = (SvxAutoCorrect*)this; 1630cdf0e10cSrcweir CharClass& rCC = pThis->GetCharClass( eLang ); 1631cdf0e10cSrcweir 1632cdf0e10cSrcweir if( lcl_IsSymbolChar( rCC, rTxt, nCapLttrPos, nEnde )) 1633cdf0e10cSrcweir return sal_False; 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir rWord = rTxt.Copy( nCapLttrPos, nEnde - nCapLttrPos ); 1636cdf0e10cSrcweir return sal_True; 1637cdf0e10cSrcweir } 1638cdf0e10cSrcweir 1639cdf0e10cSrcweir sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFile ) 1640cdf0e10cSrcweir { 1641cdf0e10cSrcweir DBG_ASSERT(!pLangTable->IsKeyValid(sal_uLong(eLang)), "Sprache ist bereits vorhanden"); 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir String sUserDirFile( GetAutoCorrFileName( eLang, sal_True, sal_False )), 1644cdf0e10cSrcweir sShareDirFile( sUserDirFile ); 1645cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = 0; 1646cdf0e10cSrcweir 1647cdf0e10cSrcweir Time nMinTime( 0, 2 ), nAktTime, nLastCheckTime; 1648cdf0e10cSrcweir sal_uLong nFndPos; 1649cdf0e10cSrcweir if( TABLE_ENTRY_NOTFOUND != 1650cdf0e10cSrcweir pLastFileTable->SearchKey( sal_uLong( eLang ), &nFndPos ) && 1651cdf0e10cSrcweir ( nLastCheckTime.SetTime( pLastFileTable->GetObject( nFndPos )), 1652cdf0e10cSrcweir nLastCheckTime < nAktTime ) && 1653cdf0e10cSrcweir ( nAktTime - nLastCheckTime ) < nMinTime ) 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir // no need to test the file, because the last check is not older then 1656cdf0e10cSrcweir // 2 minutes. 1657cdf0e10cSrcweir if( bNewFile ) 1658cdf0e10cSrcweir { 1659cdf0e10cSrcweir sShareDirFile = sUserDirFile; 1660cdf0e10cSrcweir pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile, 1661cdf0e10cSrcweir sUserDirFile, eLang ); 1662cdf0e10cSrcweir pLangTable->Insert( sal_uLong(eLang), pLists ); 1663cdf0e10cSrcweir pLastFileTable->Remove( sal_uLong( eLang ) ); 1664cdf0e10cSrcweir } 1665cdf0e10cSrcweir } 1666cdf0e10cSrcweir else if( ( FStatHelper::IsDocument( sUserDirFile ) || 1667cdf0e10cSrcweir FStatHelper::IsDocument( sShareDirFile = 1668cdf0e10cSrcweir GetAutoCorrFileName( eLang, sal_False, sal_False ) ) ) || 1669cdf0e10cSrcweir ( sShareDirFile = sUserDirFile, bNewFile )) 1670cdf0e10cSrcweir { 1671cdf0e10cSrcweir pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile, 1672cdf0e10cSrcweir sUserDirFile, eLang ); 1673cdf0e10cSrcweir pLangTable->Insert( sal_uLong(eLang), pLists ); 1674cdf0e10cSrcweir pLastFileTable->Remove( sal_uLong( eLang ) ); 1675cdf0e10cSrcweir } 1676cdf0e10cSrcweir else if( !bNewFile ) 1677cdf0e10cSrcweir { 1678cdf0e10cSrcweir if( !pLastFileTable->Insert( sal_uLong( eLang ), nAktTime.GetTime() )) 1679cdf0e10cSrcweir pLastFileTable->Replace( sal_uLong( eLang ), nAktTime.GetTime() ); 1680cdf0e10cSrcweir } 1681cdf0e10cSrcweir return pLists != 0; 1682cdf0e10cSrcweir } 1683cdf0e10cSrcweir 1684cdf0e10cSrcweir sal_Bool SvxAutoCorrect::PutText( const String& rShort, const String& rLong, 1685cdf0e10cSrcweir LanguageType eLang ) 1686cdf0e10cSrcweir { 1687cdf0e10cSrcweir sal_Bool bRet = sal_False; 1688cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong(eLang)) || CreateLanguageFile(eLang) ) 1689cdf0e10cSrcweir bRet = pLangTable->Seek( sal_uLong(eLang) )->PutText(rShort, rLong); 1690cdf0e10cSrcweir return bRet; 1691cdf0e10cSrcweir } 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir 1694cdf0e10cSrcweir // - loesche einen Eintrag 1695cdf0e10cSrcweir sal_Bool SvxAutoCorrect::DeleteText( const String& rShort, LanguageType eLang ) 1696cdf0e10cSrcweir { 1697cdf0e10cSrcweir sal_Bool bRet = sal_False; 1698cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( eLang )) ) 1699cdf0e10cSrcweir bRet = pLangTable->Seek( sal_uLong( eLang ))->DeleteText( rShort ); 1700cdf0e10cSrcweir return bRet; 1701cdf0e10cSrcweir } 1702cdf0e10cSrcweir 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen 1705cdf0e10cSrcweir // koennen aus der Wortliste herausgeholt werden!) 1706cdf0e10cSrcweir sal_Bool SvxAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String&, const String& , String& ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir return sal_False; 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir 1711cdf0e10cSrcweir // - Text mit Attributierung (kann nur der SWG - SWG-Format!) 1712cdf0e10cSrcweir sal_Bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String&, const String&, SfxObjectShell&, 1713cdf0e10cSrcweir String& ) 1714cdf0e10cSrcweir { 1715cdf0e10cSrcweir return sal_False; 1716cdf0e10cSrcweir } 1717cdf0e10cSrcweir 1718cdf0e10cSrcweir void EncryptBlockName_Imp( String& rName ) 1719cdf0e10cSrcweir { 1720cdf0e10cSrcweir xub_StrLen nLen, nPos = 1; 1721cdf0e10cSrcweir rName.Insert( '#', 0 ); 1722cdf0e10cSrcweir sal_Unicode* pName = rName.GetBufferAccess(); 1723cdf0e10cSrcweir for ( nLen = rName.Len(), ++pName; nPos < nLen; ++nPos, ++pName ) 1724cdf0e10cSrcweir { 1725cdf0e10cSrcweir if( lcl_IsInAsciiArr( "!/:.\\", *pName )) 1726cdf0e10cSrcweir *pName &= 0x0f; 1727cdf0e10cSrcweir } 1728cdf0e10cSrcweir } 1729cdf0e10cSrcweir 1730cdf0e10cSrcweir /* This code is copied from SwXMLTextBlocks::GeneratePackageName */ 1731cdf0e10cSrcweir void GeneratePackageName ( const String& rShort, String& rPackageName ) 1732cdf0e10cSrcweir { 1733cdf0e10cSrcweir rPackageName = rShort; 1734cdf0e10cSrcweir xub_StrLen nPos = 0; 1735cdf0e10cSrcweir sal_Unicode pDelims[] = { '!', '/', ':', '.', '\\', 0 }; 1736cdf0e10cSrcweir ByteString sByte ( rPackageName, RTL_TEXTENCODING_UTF7); 1737cdf0e10cSrcweir rPackageName = String (sByte, RTL_TEXTENCODING_ASCII_US); 1738cdf0e10cSrcweir while( STRING_NOTFOUND != ( nPos = rPackageName.SearchChar( pDelims, nPos ))) 1739cdf0e10cSrcweir { 1740cdf0e10cSrcweir rPackageName.SetChar( nPos, '_' ); 1741cdf0e10cSrcweir ++nPos; 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir } 1744cdf0e10cSrcweir 1745cdf0e10cSrcweir void DecryptBlockName_Imp( String& rName ) 1746cdf0e10cSrcweir { 1747cdf0e10cSrcweir if( '#' == rName.GetChar( 0 ) ) 1748cdf0e10cSrcweir { 1749cdf0e10cSrcweir rName.Erase( 0, 1 ); 1750cdf0e10cSrcweir sal_Unicode* pName = rName.GetBufferAccess(); 1751cdf0e10cSrcweir xub_StrLen nLen, nPos; 1752cdf0e10cSrcweir for ( nLen = rName.Len(), nPos = 0; nPos < nLen; ++nPos, ++pName ) 1753cdf0e10cSrcweir switch( *pName ) 1754cdf0e10cSrcweir { 1755cdf0e10cSrcweir case 0x01: *pName = '!'; break; 1756cdf0e10cSrcweir case 0x0A: *pName = ':'; break; 1757cdf0e10cSrcweir case 0x0C: *pName = '\\'; break; 1758cdf0e10cSrcweir case 0x0E: *pName = '.'; break; 1759cdf0e10cSrcweir case 0x0F: *pName = '/'; break; 1760cdf0e10cSrcweir } 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir } 1763cdf0e10cSrcweir 1764cdf0e10cSrcweir 1765cdf0e10cSrcweir /* -----------------18.11.98 16:00------------------- 1766cdf0e10cSrcweir * 1767cdf0e10cSrcweir * --------------------------------------------------*/ 1768cdf0e10cSrcweir const SvxAutocorrWord* lcl_SearchWordsInList( 1769cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList, const String& rTxt, 1770cdf0e10cSrcweir xub_StrLen& rStt, xub_StrLen nEndPos, SvxAutoCorrDoc& ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir const SvxAutocorrWordList* pAutoCorrWordList = pList->GetAutocorrWordList(); 1773cdf0e10cSrcweir TransliterationWrapper& rCmp = GetIgnoreTranslWrapper(); 1774cdf0e10cSrcweir for( xub_StrLen nPos = 0; nPos < pAutoCorrWordList->Count(); ++nPos ) 1775cdf0e10cSrcweir { 1776cdf0e10cSrcweir const SvxAutocorrWord* pFnd = (*pAutoCorrWordList)[ nPos ]; 1777cdf0e10cSrcweir const String& rChk = pFnd->GetShort(); 1778cdf0e10cSrcweir if( nEndPos >= rChk.Len() ) 1779cdf0e10cSrcweir { 1780cdf0e10cSrcweir xub_StrLen nCalcStt = nEndPos - rChk.Len(); 1781cdf0e10cSrcweir if( ( !nCalcStt || nCalcStt == rStt || 1782cdf0e10cSrcweir ( nCalcStt < rStt && 1783cdf0e10cSrcweir IsWordDelim( rTxt.GetChar(nCalcStt - 1 ) ))) ) 1784cdf0e10cSrcweir { 1785cdf0e10cSrcweir String sWord( rTxt.GetBuffer() + nCalcStt, rChk.Len() ); 1786cdf0e10cSrcweir if( rCmp.isEqual( rChk, sWord )) 1787cdf0e10cSrcweir { 1788cdf0e10cSrcweir rStt = nCalcStt; 1789cdf0e10cSrcweir return pFnd; 1790cdf0e10cSrcweir } 1791cdf0e10cSrcweir } 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir } 1794cdf0e10cSrcweir return 0; 1795cdf0e10cSrcweir } 1796cdf0e10cSrcweir 1797cdf0e10cSrcweir 1798cdf0e10cSrcweir // suche das oder die Worte in der ErsetzungsTabelle 1799cdf0e10cSrcweir const SvxAutocorrWord* SvxAutoCorrect::SearchWordsInList( 1800cdf0e10cSrcweir const String& rTxt, xub_StrLen& rStt, xub_StrLen nEndPos, 1801cdf0e10cSrcweir SvxAutoCorrDoc& rDoc, LanguageType& rLang ) 1802cdf0e10cSrcweir { 1803cdf0e10cSrcweir LanguageType eLang = rLang; 1804cdf0e10cSrcweir const SvxAutocorrWord* pRet = 0; 1805cdf0e10cSrcweir if( LANGUAGE_SYSTEM == eLang ) 1806cdf0e10cSrcweir eLang = MsLangId::getSystemLanguage(); 1807cdf0e10cSrcweir 1808cdf0e10cSrcweir // zuerst nach eLang suchen, dann nach der Obersprache 1809cdf0e10cSrcweir // US-Englisch -> Englisch und zuletzt in LANGUAGE_DONTKNOW 1810cdf0e10cSrcweir 1811cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( eLang ) ) || 1812cdf0e10cSrcweir CreateLanguageFile( eLang, sal_False )) 1813cdf0e10cSrcweir { 1814cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1815cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek(sal_uLong(eLang)); 1816cdf0e10cSrcweir pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos, rDoc ); 1817cdf0e10cSrcweir if( pRet ) 1818cdf0e10cSrcweir { 1819cdf0e10cSrcweir rLang = eLang; 1820cdf0e10cSrcweir return pRet; 1821cdf0e10cSrcweir } 1822cdf0e10cSrcweir } 1823cdf0e10cSrcweir 1824cdf0e10cSrcweir // wenn es hier noch nicht gefunden werden konnte, dann weitersuchen 1825cdf0e10cSrcweir sal_uLong nTmpKey1 = eLang & 0x7ff, // die Hauptsprache in vielen Faellen u.B. DE 1826cdf0e10cSrcweir nTmpKey2 = eLang & 0x3ff, // sonst z.B. EN 1827cdf0e10cSrcweir nTmp; 1828cdf0e10cSrcweir 1829cdf0e10cSrcweir if( ((nTmp = nTmpKey1) != (sal_uLong)eLang && 1830cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey1 ) || 1831cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey1 ), sal_False ) )) || 1832cdf0e10cSrcweir (( nTmp = nTmpKey2) != (sal_uLong)eLang && 1833cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey2 ) || 1834cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey2 ), sal_False ) )) ) 1835cdf0e10cSrcweir { 1836cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1837cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek( nTmp ); 1838cdf0e10cSrcweir pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos, rDoc); 1839cdf0e10cSrcweir if( pRet ) 1840cdf0e10cSrcweir { 1841cdf0e10cSrcweir rLang = LanguageType( nTmp ); 1842cdf0e10cSrcweir return pRet; 1843cdf0e10cSrcweir } 1844cdf0e10cSrcweir } 1845cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( LANGUAGE_DONTKNOW ) ) || 1846cdf0e10cSrcweir CreateLanguageFile( LANGUAGE_DONTKNOW, sal_False ) ) 1847cdf0e10cSrcweir { 1848cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1849cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek(sal_uLong(LANGUAGE_DONTKNOW)); 1850cdf0e10cSrcweir pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos, rDoc); 1851cdf0e10cSrcweir if( pRet ) 1852cdf0e10cSrcweir { 1853cdf0e10cSrcweir rLang = LANGUAGE_DONTKNOW; 1854cdf0e10cSrcweir return pRet; 1855cdf0e10cSrcweir } 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir return 0; 1858cdf0e10cSrcweir } 1859cdf0e10cSrcweir /* -----------------18.11.98 13:46------------------- 1860cdf0e10cSrcweir * 1861cdf0e10cSrcweir * --------------------------------------------------*/ 1862cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, 1863cdf0e10cSrcweir const String& sWord ) 1864cdf0e10cSrcweir { 1865cdf0e10cSrcweir //zuerst nach eLang suchen, dann nach der Obersprace US-Englisch -> Englisch 1866cdf0e10cSrcweir //und zuletzt in LANGUAGE_DONTKNOW 1867cdf0e10cSrcweir sal_uLong nTmpKey1 = eLang & 0x7ff; // die Hauptsprache in vielen Faellen u.B. DE 1868cdf0e10cSrcweir sal_uLong nTmpKey2 = eLang & 0x3ff; // sonst z.B. EN 1869cdf0e10cSrcweir String sTemp(sWord); 1870cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( eLang )) || 1871cdf0e10cSrcweir CreateLanguageFile( eLang, sal_False ) ) 1872cdf0e10cSrcweir { 1873cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1874cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek(sal_uLong(eLang)); 1875cdf0e10cSrcweir String _sTemp(sWord); 1876cdf0e10cSrcweir if(pList->GetWrdSttExceptList()->Seek_Entry(&_sTemp)) 1877cdf0e10cSrcweir return sal_True; 1878cdf0e10cSrcweir 1879cdf0e10cSrcweir } 1880cdf0e10cSrcweir // wenn es hier noch nicht gefunden werden konnte, dann weitersuchen 1881cdf0e10cSrcweir sal_uLong nTmp; 1882cdf0e10cSrcweir if( ((nTmp = nTmpKey1) != (sal_uLong)eLang && 1883cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey1 ) || 1884cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey1 ), sal_False ) )) || 1885cdf0e10cSrcweir (( nTmp = nTmpKey2) != (sal_uLong)eLang && 1886cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey2 ) || 1887cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey2 ), sal_False ) )) ) 1888cdf0e10cSrcweir { 1889cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1890cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek(nTmp); 1891cdf0e10cSrcweir if(pList->GetWrdSttExceptList()->Seek_Entry(&sTemp)) 1892cdf0e10cSrcweir return sal_True; 1893cdf0e10cSrcweir } 1894cdf0e10cSrcweir if(pLangTable->IsKeyValid(sal_uLong(LANGUAGE_DONTKNOW))|| CreateLanguageFile(LANGUAGE_DONTKNOW, sal_False)) 1895cdf0e10cSrcweir { 1896cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1897cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pList = pLangTable->Seek(sal_uLong(LANGUAGE_DONTKNOW)); 1898cdf0e10cSrcweir if(pList->GetWrdSttExceptList()->Seek_Entry(&sTemp)) 1899cdf0e10cSrcweir return sal_True; 1900cdf0e10cSrcweir } 1901cdf0e10cSrcweir return sal_False; 1902cdf0e10cSrcweir } 1903cdf0e10cSrcweir /* -----------------18.11.98 14:28------------------- 1904cdf0e10cSrcweir * 1905cdf0e10cSrcweir * --------------------------------------------------*/ 1906cdf0e10cSrcweir sal_Bool lcl_FindAbbreviation( const SvStringsISortDtor* pList, const String& sWord) 1907cdf0e10cSrcweir { 1908cdf0e10cSrcweir String sAbk( '~' ); 1909cdf0e10cSrcweir sal_uInt16 nPos; 1910cdf0e10cSrcweir pList->Seek_Entry( &sAbk, &nPos ); 1911cdf0e10cSrcweir if( nPos < pList->Count() ) 1912cdf0e10cSrcweir { 1913cdf0e10cSrcweir String sLowerWord( sWord ); sLowerWord.ToLowerAscii(); 1914cdf0e10cSrcweir const String* pAbk; 1915cdf0e10cSrcweir for( sal_uInt16 n = nPos; 1916cdf0e10cSrcweir n < pList->Count() && 1917cdf0e10cSrcweir '~' == ( pAbk = (*pList)[ n ])->GetChar( 0 ); 1918cdf0e10cSrcweir ++n ) 1919cdf0e10cSrcweir { 1920cdf0e10cSrcweir // ~ und ~. sind nicht erlaubt! 1921cdf0e10cSrcweir if( 2 < pAbk->Len() && pAbk->Len() - 1 <= sWord.Len() ) 1922cdf0e10cSrcweir { 1923cdf0e10cSrcweir String sLowerAbk( *pAbk ); sLowerAbk.ToLowerAscii(); 1924cdf0e10cSrcweir for( xub_StrLen i = sLowerAbk.Len(), ii = sLowerWord.Len(); i; ) 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir if( !--i ) // stimmt ueberein 1927cdf0e10cSrcweir return sal_True; 1928cdf0e10cSrcweir 1929cdf0e10cSrcweir if( sLowerAbk.GetChar( i ) != sLowerWord.GetChar( --ii )) 1930cdf0e10cSrcweir break; 1931cdf0e10cSrcweir } 1932cdf0e10cSrcweir } 1933cdf0e10cSrcweir } 1934cdf0e10cSrcweir } 1935cdf0e10cSrcweir DBG_ASSERT( !(nPos && '~' == (*pList)[ --nPos ]->GetChar( 0 ) ), 1936cdf0e10cSrcweir "falsch sortierte ExeptionListe?" ); 1937cdf0e10cSrcweir return sal_False; 1938cdf0e10cSrcweir } 1939cdf0e10cSrcweir /* -----------------18.11.98 14:49------------------- 1940cdf0e10cSrcweir * 1941cdf0e10cSrcweir * --------------------------------------------------*/ 1942cdf0e10cSrcweir sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, 1943cdf0e10cSrcweir const String& sWord, sal_Bool bAbbreviation) 1944cdf0e10cSrcweir { 1945cdf0e10cSrcweir //zuerst nach eLang suchen, dann nach der Obersprace US-Englisch -> Englisch 1946cdf0e10cSrcweir //und zuletzt in LANGUAGE_DONTKNOW 1947cdf0e10cSrcweir sal_uLong nTmpKey1 = eLang & 0x7ff; // die Hauptsprache in vielen Faellen u.B. DE 1948cdf0e10cSrcweir sal_uLong nTmpKey2 = eLang & 0x3ff; // sonst z.B. EN 1949cdf0e10cSrcweir String sTemp( sWord ); 1950cdf0e10cSrcweir if( pLangTable->IsKeyValid( sal_uLong( eLang )) || 1951cdf0e10cSrcweir CreateLanguageFile( eLang, sal_False )) 1952cdf0e10cSrcweir { 1953cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1954cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = pLangTable->Seek(sal_uLong(eLang)); 1955cdf0e10cSrcweir const SvStringsISortDtor* pList = pLists->GetCplSttExceptList(); 1956cdf0e10cSrcweir if(bAbbreviation ? lcl_FindAbbreviation( pList, sWord) 1957cdf0e10cSrcweir : pList->Seek_Entry( &sTemp ) ) 1958cdf0e10cSrcweir return sal_True; 1959cdf0e10cSrcweir } 1960cdf0e10cSrcweir // wenn es hier noch nicht gefunden werden konnte, dann weitersuchen 1961cdf0e10cSrcweir sal_uLong nTmp; 1962cdf0e10cSrcweir 1963cdf0e10cSrcweir if( ((nTmp = nTmpKey1) != (sal_uLong)eLang && 1964cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey1 ) || 1965cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey1 ), sal_False ) )) || 1966cdf0e10cSrcweir (( nTmp = nTmpKey2) != (sal_uLong)eLang && 1967cdf0e10cSrcweir ( pLangTable->IsKeyValid( nTmpKey2 ) || 1968cdf0e10cSrcweir CreateLanguageFile( LanguageType( nTmpKey2 ), sal_False ) )) ) 1969cdf0e10cSrcweir { 1970cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1971cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = pLangTable->Seek(nTmp); 1972cdf0e10cSrcweir const SvStringsISortDtor* pList = pLists->GetCplSttExceptList(); 1973cdf0e10cSrcweir if(bAbbreviation ? lcl_FindAbbreviation( pList, sWord) 1974cdf0e10cSrcweir : pList->Seek_Entry( &sTemp ) ) 1975cdf0e10cSrcweir return sal_True; 1976cdf0e10cSrcweir } 1977cdf0e10cSrcweir if(pLangTable->IsKeyValid(sal_uLong(LANGUAGE_DONTKNOW))|| CreateLanguageFile(LANGUAGE_DONTKNOW, sal_False)) 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir //die Sprache ist vorhanden - also her damit 1980cdf0e10cSrcweir SvxAutoCorrectLanguageListsPtr pLists = pLangTable->Seek(LANGUAGE_DONTKNOW); 1981cdf0e10cSrcweir const SvStringsISortDtor* pList = pLists->GetCplSttExceptList(); 1982cdf0e10cSrcweir if(bAbbreviation ? lcl_FindAbbreviation( pList, sWord) 1983cdf0e10cSrcweir : pList->Seek_Entry( &sTemp ) ) 1984cdf0e10cSrcweir return sal_True; 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir return sal_False; 1987cdf0e10cSrcweir 1988cdf0e10cSrcweir } 1989cdf0e10cSrcweir 1990cdf0e10cSrcweir /* -----------------20.11.98 11:53------------------- 1991cdf0e10cSrcweir * 1992cdf0e10cSrcweir * --------------------------------------------------*/ 1993cdf0e10cSrcweir String SvxAutoCorrect::GetAutoCorrFileName( LanguageType eLang, 1994cdf0e10cSrcweir sal_Bool bNewFile, sal_Bool bTst ) const 1995cdf0e10cSrcweir { 1996cdf0e10cSrcweir String sRet, sExt( MsLangId::convertLanguageToIsoString( eLang ) ); 1997cdf0e10cSrcweir sExt.Insert('_', 0); 1998cdf0e10cSrcweir sExt.AppendAscii( ".dat" ); 1999cdf0e10cSrcweir if( bNewFile ) 2000cdf0e10cSrcweir ( sRet = sUserAutoCorrFile ) += sExt; 2001cdf0e10cSrcweir else if( !bTst ) 2002cdf0e10cSrcweir ( sRet = sShareAutoCorrFile ) += sExt; 2003cdf0e10cSrcweir else 2004cdf0e10cSrcweir { 2005cdf0e10cSrcweir // test first in the user directory - if not exist, then 2006cdf0e10cSrcweir ( sRet = sUserAutoCorrFile ) += sExt; 2007cdf0e10cSrcweir if( !FStatHelper::IsDocument( sRet )) 2008cdf0e10cSrcweir ( sRet = sShareAutoCorrFile ) += sExt; 2009cdf0e10cSrcweir } 2010cdf0e10cSrcweir return sRet; 2011cdf0e10cSrcweir } 2012cdf0e10cSrcweir 2013cdf0e10cSrcweir /* -----------------18.11.98 11:16------------------- 2014cdf0e10cSrcweir * 2015cdf0e10cSrcweir * --------------------------------------------------*/ 2016cdf0e10cSrcweir SvxAutoCorrectLanguageLists::SvxAutoCorrectLanguageLists( 2017cdf0e10cSrcweir SvxAutoCorrect& rParent, 2018cdf0e10cSrcweir const String& rShareAutoCorrectFile, 2019cdf0e10cSrcweir const String& rUserAutoCorrectFile, 2020cdf0e10cSrcweir LanguageType eLang) 2021cdf0e10cSrcweir : sShareAutoCorrFile( rShareAutoCorrectFile ), 2022cdf0e10cSrcweir sUserAutoCorrFile( rUserAutoCorrectFile ), 2023cdf0e10cSrcweir eLanguage(eLang), 2024cdf0e10cSrcweir pCplStt_ExcptLst( 0 ), 2025cdf0e10cSrcweir pWrdStt_ExcptLst( 0 ), 2026cdf0e10cSrcweir pAutocorr_List( 0 ), 2027cdf0e10cSrcweir rAutoCorrect(rParent), 2028cdf0e10cSrcweir nFlags(0) 2029cdf0e10cSrcweir { 2030cdf0e10cSrcweir } 2031cdf0e10cSrcweir 2032cdf0e10cSrcweir /* -----------------18.11.98 11:16------------------- 2033cdf0e10cSrcweir * 2034cdf0e10cSrcweir * --------------------------------------------------*/ 2035cdf0e10cSrcweir SvxAutoCorrectLanguageLists::~SvxAutoCorrectLanguageLists() 2036cdf0e10cSrcweir { 2037cdf0e10cSrcweir delete pCplStt_ExcptLst; 2038cdf0e10cSrcweir delete pWrdStt_ExcptLst; 2039cdf0e10cSrcweir delete pAutocorr_List; 2040cdf0e10cSrcweir } 2041cdf0e10cSrcweir 2042cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2043cdf0e10cSrcweir * 2044cdf0e10cSrcweir * --------------------------------------------------*/ 2045cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::IsFileChanged_Imp() 2046cdf0e10cSrcweir { 2047cdf0e10cSrcweir // nur alle 2 Minuten aufs FileSystem zugreifen um den 2048cdf0e10cSrcweir // Dateistempel zu ueberpruefen 2049cdf0e10cSrcweir sal_Bool bRet = sal_False; 2050cdf0e10cSrcweir 2051cdf0e10cSrcweir Time nMinTime( 0, 2 ); 2052cdf0e10cSrcweir Time nAktTime; 2053cdf0e10cSrcweir if( aLastCheckTime > nAktTime || // ueberlauf ? 2054cdf0e10cSrcweir ( nAktTime -= aLastCheckTime ) > nMinTime ) // min Zeit vergangen 2055cdf0e10cSrcweir { 2056cdf0e10cSrcweir Date aTstDate; Time aTstTime; 2057cdf0e10cSrcweir if( FStatHelper::GetModifiedDateTimeOfFile( sShareAutoCorrFile, 2058cdf0e10cSrcweir &aTstDate, &aTstTime ) && 2059cdf0e10cSrcweir ( aModifiedDate != aTstDate || aModifiedTime != aTstTime )) 2060cdf0e10cSrcweir { 2061cdf0e10cSrcweir bRet = sal_True; 2062cdf0e10cSrcweir // dann mal schnell alle Listen entfernen! 2063cdf0e10cSrcweir if( CplSttLstLoad & nFlags && pCplStt_ExcptLst ) 2064cdf0e10cSrcweir delete pCplStt_ExcptLst, pCplStt_ExcptLst = 0; 2065cdf0e10cSrcweir if( WrdSttLstLoad & nFlags && pWrdStt_ExcptLst ) 2066cdf0e10cSrcweir delete pWrdStt_ExcptLst, pWrdStt_ExcptLst = 0; 2067cdf0e10cSrcweir if( ChgWordLstLoad & nFlags && pAutocorr_List ) 2068cdf0e10cSrcweir delete pAutocorr_List, pAutocorr_List = 0; 2069cdf0e10cSrcweir nFlags &= ~(CplSttLstLoad | WrdSttLstLoad | ChgWordLstLoad ); 2070cdf0e10cSrcweir } 2071cdf0e10cSrcweir aLastCheckTime = Time(); 2072cdf0e10cSrcweir } 2073cdf0e10cSrcweir return bRet; 2074cdf0e10cSrcweir } 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( 2077cdf0e10cSrcweir SvStringsISortDtor*& rpLst, 2078cdf0e10cSrcweir const sal_Char* pStrmName, 2079cdf0e10cSrcweir SotStorageRef& rStg) 2080cdf0e10cSrcweir { 2081cdf0e10cSrcweir if( rpLst ) 2082cdf0e10cSrcweir rpLst->DeleteAndDestroy( 0, rpLst->Count() ); 2083cdf0e10cSrcweir else 2084cdf0e10cSrcweir rpLst = new SvStringsISortDtor( 16, 16 ); 2085cdf0e10cSrcweir 2086cdf0e10cSrcweir { 2087cdf0e10cSrcweir String sStrmName( pStrmName, RTL_TEXTENCODING_MS_1252 ); 2088cdf0e10cSrcweir String sTmp( sStrmName ); 2089cdf0e10cSrcweir 2090cdf0e10cSrcweir if( rStg.Is() && rStg->IsStream( sStrmName ) ) 2091cdf0e10cSrcweir { 2092cdf0e10cSrcweir SvStorageStreamRef xStrm = rStg->OpenSotStream( sTmp, 2093cdf0e10cSrcweir ( STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE ) ); 2094cdf0e10cSrcweir if( SVSTREAM_OK != xStrm->GetError()) 2095cdf0e10cSrcweir { 2096cdf0e10cSrcweir xStrm.Clear(); 2097cdf0e10cSrcweir rStg.Clear(); 2098cdf0e10cSrcweir RemoveStream_Imp( sStrmName ); 2099cdf0e10cSrcweir } 2100cdf0e10cSrcweir else 2101cdf0e10cSrcweir { 2102cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xServiceFactory = 2103cdf0e10cSrcweir comphelper::getProcessServiceFactory(); 2104cdf0e10cSrcweir DBG_ASSERT( xServiceFactory.is(), 2105cdf0e10cSrcweir "XMLReader::Read: got no service manager" ); 2106cdf0e10cSrcweir if( !xServiceFactory.is() ) 2107cdf0e10cSrcweir { 2108cdf0e10cSrcweir // Throw an exception ? 2109cdf0e10cSrcweir } 2110cdf0e10cSrcweir 2111cdf0e10cSrcweir xml::sax::InputSource aParserInput; 2112cdf0e10cSrcweir aParserInput.sSystemId = sStrmName; 2113cdf0e10cSrcweir 2114cdf0e10cSrcweir xStrm->Seek( 0L ); 2115cdf0e10cSrcweir xStrm->SetBufferSize( 8 * 1024 ); 2116cdf0e10cSrcweir aParserInput.aInputStream = new utl::OInputStreamWrapper( *xStrm ); 2117cdf0e10cSrcweir 2118cdf0e10cSrcweir // get parser 2119cdf0e10cSrcweir uno::Reference< XInterface > xXMLParser = xServiceFactory->createInstance( 2120cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.xml.sax.Parser") ); 2121cdf0e10cSrcweir DBG_ASSERT( xXMLParser.is(), 2122cdf0e10cSrcweir "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" ); 2123cdf0e10cSrcweir if( !xXMLParser.is() ) 2124cdf0e10cSrcweir { 2125cdf0e10cSrcweir // Maybe throw an exception? 2126cdf0e10cSrcweir } 2127cdf0e10cSrcweir 2128cdf0e10cSrcweir // get filter 2129cdf0e10cSrcweir // #110680# 2130cdf0e10cSrcweir // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLExceptionListImport ( *rpLst ); 2131cdf0e10cSrcweir uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLExceptionListImport ( xServiceFactory, *rpLst ); 2132cdf0e10cSrcweir 2133cdf0e10cSrcweir // connect parser and filter 2134cdf0e10cSrcweir uno::Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY ); 2135cdf0e10cSrcweir xParser->setDocumentHandler( xFilter ); 2136cdf0e10cSrcweir 2137cdf0e10cSrcweir // parse 2138cdf0e10cSrcweir try 2139cdf0e10cSrcweir { 2140cdf0e10cSrcweir xParser->parseStream( aParserInput ); 2141cdf0e10cSrcweir } 2142cdf0e10cSrcweir catch( xml::sax::SAXParseException& ) 2143cdf0e10cSrcweir { 2144cdf0e10cSrcweir // re throw ? 2145cdf0e10cSrcweir } 2146cdf0e10cSrcweir catch( xml::sax::SAXException& ) 2147cdf0e10cSrcweir { 2148cdf0e10cSrcweir // re throw ? 2149cdf0e10cSrcweir } 2150cdf0e10cSrcweir catch( io::IOException& ) 2151cdf0e10cSrcweir { 2152cdf0e10cSrcweir // re throw ? 2153cdf0e10cSrcweir } 2154cdf0e10cSrcweir } 2155cdf0e10cSrcweir } 2156cdf0e10cSrcweir 2157cdf0e10cSrcweir // Zeitstempel noch setzen 2158cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sShareAutoCorrFile, 2159cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2160cdf0e10cSrcweir aLastCheckTime = Time(); 2161cdf0e10cSrcweir } 2162cdf0e10cSrcweir 2163cdf0e10cSrcweir } 2164cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2165cdf0e10cSrcweir * 2166cdf0e10cSrcweir * --------------------------------------------------*/ 2167cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SaveExceptList_Imp( 2168cdf0e10cSrcweir const SvStringsISortDtor& rLst, 2169cdf0e10cSrcweir const sal_Char* pStrmName, 2170cdf0e10cSrcweir SotStorageRef &rStg, 2171cdf0e10cSrcweir sal_Bool bConvert ) 2172cdf0e10cSrcweir { 2173cdf0e10cSrcweir if( rStg.Is() ) 2174cdf0e10cSrcweir { 2175cdf0e10cSrcweir String sStrmName( pStrmName, RTL_TEXTENCODING_MS_1252 ); 2176cdf0e10cSrcweir if( !rLst.Count() ) 2177cdf0e10cSrcweir { 2178cdf0e10cSrcweir rStg->Remove( sStrmName ); 2179cdf0e10cSrcweir rStg->Commit(); 2180cdf0e10cSrcweir } 2181cdf0e10cSrcweir else 2182cdf0e10cSrcweir { 2183cdf0e10cSrcweir SotStorageStreamRef xStrm = rStg->OpenSotStream( sStrmName, 2184cdf0e10cSrcweir ( STREAM_READ | STREAM_WRITE | STREAM_SHARE_DENYWRITE ) ); 2185cdf0e10cSrcweir if( xStrm.Is() ) 2186cdf0e10cSrcweir { 2187cdf0e10cSrcweir xStrm->SetSize( 0 ); 2188cdf0e10cSrcweir xStrm->SetBufferSize( 8192 ); 2189cdf0e10cSrcweir String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); 2190cdf0e10cSrcweir OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") ); 2191cdf0e10cSrcweir uno::Any aAny; 2192cdf0e10cSrcweir aAny <<= aMime; 2193cdf0e10cSrcweir xStrm->SetProperty( aPropName, aAny ); 2194cdf0e10cSrcweir 2195cdf0e10cSrcweir 2196cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xServiceFactory = 2197cdf0e10cSrcweir comphelper::getProcessServiceFactory(); 2198cdf0e10cSrcweir DBG_ASSERT( xServiceFactory.is(), 2199cdf0e10cSrcweir "XMLReader::Read: got no service manager" ); 2200cdf0e10cSrcweir if( !xServiceFactory.is() ) 2201cdf0e10cSrcweir { 2202cdf0e10cSrcweir // Throw an exception ? 2203cdf0e10cSrcweir } 2204cdf0e10cSrcweir 2205cdf0e10cSrcweir uno::Reference < XInterface > xWriter (xServiceFactory->createInstance( 2206cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer")))); 2207cdf0e10cSrcweir DBG_ASSERT(xWriter.is(),"com.sun.star.xml.sax.Writer service missing"); 2208cdf0e10cSrcweir uno::Reference < io::XOutputStream> xOut = new utl::OOutputStreamWrapper( *xStrm ); 2209cdf0e10cSrcweir uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); 2210cdf0e10cSrcweir xSrc->setOutputStream(xOut); 2211cdf0e10cSrcweir 2212cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); 2213cdf0e10cSrcweir 2214cdf0e10cSrcweir // #110680# 2215cdf0e10cSrcweir // SvXMLExceptionListExport aExp(rLst, sStrmName, xHandler); 2216cdf0e10cSrcweir SvXMLExceptionListExport aExp( xServiceFactory, rLst, sStrmName, xHandler ); 2217cdf0e10cSrcweir 2218cdf0e10cSrcweir aExp.exportDoc( XML_BLOCK_LIST ); 2219cdf0e10cSrcweir 2220cdf0e10cSrcweir xStrm->Commit(); 2221cdf0e10cSrcweir if( xStrm->GetError() == SVSTREAM_OK ) 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir xStrm.Clear(); 2224cdf0e10cSrcweir if (!bConvert) 2225cdf0e10cSrcweir { 2226cdf0e10cSrcweir rStg->Commit(); 2227cdf0e10cSrcweir if( SVSTREAM_OK != rStg->GetError() ) 2228cdf0e10cSrcweir { 2229cdf0e10cSrcweir rStg->Remove( sStrmName ); 2230cdf0e10cSrcweir rStg->Commit(); 2231cdf0e10cSrcweir } 2232cdf0e10cSrcweir } 2233cdf0e10cSrcweir } 2234cdf0e10cSrcweir } 2235cdf0e10cSrcweir } 2236cdf0e10cSrcweir } 2237cdf0e10cSrcweir } 2238cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2239cdf0e10cSrcweir * 2240cdf0e10cSrcweir * --------------------------------------------------*/ 2241cdf0e10cSrcweir SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() 2242cdf0e10cSrcweir { 2243cdf0e10cSrcweir if( pAutocorr_List ) 2244cdf0e10cSrcweir pAutocorr_List->DeleteAndDestroy( 0, pAutocorr_List->Count() ); 2245cdf0e10cSrcweir else 2246cdf0e10cSrcweir pAutocorr_List = new SvxAutocorrWordList( 16, 16 ); 2247cdf0e10cSrcweir 2248cdf0e10cSrcweir SvStringsDtor aRemoveArr; 2249cdf0e10cSrcweir try 2250cdf0e10cSrcweir { 2251cdf0e10cSrcweir uno::Reference < embed::XStorage > xStg = comphelper::OStorageHelper::GetStorageFromURL( sShareAutoCorrFile, embed::ElementModes::READ ); 2252cdf0e10cSrcweir String aXMLWordListName( pXMLImplAutocorr_ListStr, RTL_TEXTENCODING_MS_1252 ); 2253cdf0e10cSrcweir uno::Reference < io::XStream > xStrm = xStg->openStreamElement( aXMLWordListName, embed::ElementModes::READ ); 2254cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); 2255cdf0e10cSrcweir 2256cdf0e10cSrcweir xml::sax::InputSource aParserInput; 2257cdf0e10cSrcweir aParserInput.sSystemId = aXMLWordListName; 2258cdf0e10cSrcweir aParserInput.aInputStream = xStrm->getInputStream(); 2259cdf0e10cSrcweir 2260cdf0e10cSrcweir // get parser 2261cdf0e10cSrcweir uno::Reference< XInterface > xXMLParser = xServiceFactory->createInstance( OUString::createFromAscii("com.sun.star.xml.sax.Parser") ); 2262cdf0e10cSrcweir DBG_ASSERT( xXMLParser.is(), "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" ); 2263cdf0e10cSrcweir if( xXMLParser.is() ) 2264cdf0e10cSrcweir { 2265cdf0e10cSrcweir uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xServiceFactory, pAutocorr_List, rAutoCorrect, xStg ); 2266cdf0e10cSrcweir 2267cdf0e10cSrcweir // connect parser and filter 2268cdf0e10cSrcweir uno::Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY ); 2269cdf0e10cSrcweir xParser->setDocumentHandler( xFilter ); 2270cdf0e10cSrcweir 2271cdf0e10cSrcweir // parse 2272cdf0e10cSrcweir xParser->parseStream( aParserInput ); 2273cdf0e10cSrcweir } 2274cdf0e10cSrcweir } 2275cdf0e10cSrcweir catch ( uno::Exception& ) 2276cdf0e10cSrcweir { 2277cdf0e10cSrcweir } 2278cdf0e10cSrcweir 2279cdf0e10cSrcweir // Zeitstempel noch setzen 2280cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sShareAutoCorrFile, 2281cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2282cdf0e10cSrcweir aLastCheckTime = Time(); 2283cdf0e10cSrcweir 2284cdf0e10cSrcweir return pAutocorr_List; 2285cdf0e10cSrcweir } 2286cdf0e10cSrcweir 2287cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2288cdf0e10cSrcweir * 2289cdf0e10cSrcweir * --------------------------------------------------*/ 2290cdf0e10cSrcweir 2291cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SetAutocorrWordList( SvxAutocorrWordList* pList ) 2292cdf0e10cSrcweir { 2293cdf0e10cSrcweir if( pAutocorr_List && pList != pAutocorr_List ) 2294cdf0e10cSrcweir delete pAutocorr_List; 2295cdf0e10cSrcweir pAutocorr_List = pList; 2296cdf0e10cSrcweir if( !pAutocorr_List ) 2297cdf0e10cSrcweir { 2298cdf0e10cSrcweir DBG_ASSERT( !this, "keine gueltige Liste" ); 2299cdf0e10cSrcweir pAutocorr_List = new SvxAutocorrWordList( 16, 16 ); 2300cdf0e10cSrcweir } 2301cdf0e10cSrcweir nFlags |= ChgWordLstLoad; 2302cdf0e10cSrcweir } 2303cdf0e10cSrcweir 2304cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2305cdf0e10cSrcweir * 2306cdf0e10cSrcweir * --------------------------------------------------*/ 2307cdf0e10cSrcweir const SvxAutocorrWordList* SvxAutoCorrectLanguageLists::GetAutocorrWordList() 2308cdf0e10cSrcweir { 2309cdf0e10cSrcweir if( !( ChgWordLstLoad & nFlags ) || IsFileChanged_Imp() ) 2310cdf0e10cSrcweir SetAutocorrWordList( LoadAutocorrWordList() ); 2311cdf0e10cSrcweir return pAutocorr_List; 2312cdf0e10cSrcweir } 2313cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2314cdf0e10cSrcweir * 2315cdf0e10cSrcweir * --------------------------------------------------*/ 2316cdf0e10cSrcweir SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetCplSttExceptList() 2317cdf0e10cSrcweir { 2318cdf0e10cSrcweir if( !( CplSttLstLoad & nFlags ) || IsFileChanged_Imp() ) 2319cdf0e10cSrcweir SetCplSttExceptList( LoadCplSttExceptList() ); 2320cdf0e10cSrcweir return pCplStt_ExcptLst; 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2323cdf0e10cSrcweir * 2324cdf0e10cSrcweir * --------------------------------------------------*/ 2325cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::AddToCplSttExceptList(const String& rNew) 2326cdf0e10cSrcweir { 2327cdf0e10cSrcweir String* pNew = new String( rNew ); 2328cdf0e10cSrcweir if( rNew.Len() && GetCplSttExceptList()->Insert( pNew ) ) 2329cdf0e10cSrcweir { 2330cdf0e10cSrcweir MakeUserStorage_Impl(); 2331cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2332cdf0e10cSrcweir 2333cdf0e10cSrcweir SaveExceptList_Imp( *pCplStt_ExcptLst, pXMLImplCplStt_ExcptLstStr, xStg ); 2334cdf0e10cSrcweir 2335cdf0e10cSrcweir xStg = 0; 2336cdf0e10cSrcweir // Zeitstempel noch setzen 2337cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, 2338cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2339cdf0e10cSrcweir aLastCheckTime = Time(); 2340cdf0e10cSrcweir } 2341cdf0e10cSrcweir else 2342cdf0e10cSrcweir delete pNew, pNew = 0; 2343cdf0e10cSrcweir return 0 != pNew; 2344cdf0e10cSrcweir } 2345cdf0e10cSrcweir /* -----------------18.11.98 15:20------------------- 2346cdf0e10cSrcweir * 2347cdf0e10cSrcweir * --------------------------------------------------*/ 2348cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::AddToWrdSttExceptList(const String& rNew) 2349cdf0e10cSrcweir { 2350cdf0e10cSrcweir String* pNew = new String( rNew ); 2351cdf0e10cSrcweir SvStringsISortDtor* pExceptList = LoadWrdSttExceptList(); 2352cdf0e10cSrcweir if( rNew.Len() && pExceptList && pExceptList->Insert( pNew ) ) 2353cdf0e10cSrcweir { 2354cdf0e10cSrcweir MakeUserStorage_Impl(); 2355cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2356cdf0e10cSrcweir 2357cdf0e10cSrcweir SaveExceptList_Imp( *pWrdStt_ExcptLst, pXMLImplWrdStt_ExcptLstStr, xStg ); 2358cdf0e10cSrcweir 2359cdf0e10cSrcweir xStg = 0; 2360cdf0e10cSrcweir // Zeitstempel noch setzen 2361cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, 2362cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2363cdf0e10cSrcweir aLastCheckTime = Time(); 2364cdf0e10cSrcweir } 2365cdf0e10cSrcweir else 2366cdf0e10cSrcweir delete pNew, pNew = 0; 2367cdf0e10cSrcweir return 0 != pNew; 2368cdf0e10cSrcweir } 2369cdf0e10cSrcweir 2370cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2371cdf0e10cSrcweir * 2372cdf0e10cSrcweir * --------------------------------------------------*/ 2373cdf0e10cSrcweir SvStringsISortDtor* SvxAutoCorrectLanguageLists::LoadCplSttExceptList() 2374cdf0e10cSrcweir { 2375cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sShareAutoCorrFile, STREAM_READ | STREAM_SHARE_DENYNONE, sal_True ); 2376cdf0e10cSrcweir String sTemp ( RTL_CONSTASCII_USTRINGPARAM ( pXMLImplCplStt_ExcptLstStr ) ); 2377cdf0e10cSrcweir if( xStg.Is() && xStg->IsContained( sTemp ) ) 2378cdf0e10cSrcweir LoadXMLExceptList_Imp( pCplStt_ExcptLst, pXMLImplCplStt_ExcptLstStr, xStg ); 2379cdf0e10cSrcweir 2380cdf0e10cSrcweir return pCplStt_ExcptLst; 2381cdf0e10cSrcweir } 2382cdf0e10cSrcweir 2383cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2384cdf0e10cSrcweir * 2385cdf0e10cSrcweir * --------------------------------------------------*/ 2386cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SaveCplSttExceptList() 2387cdf0e10cSrcweir { 2388cdf0e10cSrcweir MakeUserStorage_Impl(); 2389cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2390cdf0e10cSrcweir 2391cdf0e10cSrcweir SaveExceptList_Imp( *pCplStt_ExcptLst, pXMLImplCplStt_ExcptLstStr, xStg ); 2392cdf0e10cSrcweir 2393cdf0e10cSrcweir xStg = 0; 2394cdf0e10cSrcweir 2395cdf0e10cSrcweir // Zeitstempel noch setzen 2396cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, 2397cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2398cdf0e10cSrcweir aLastCheckTime = Time(); 2399cdf0e10cSrcweir } 2400cdf0e10cSrcweir 2401cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2402cdf0e10cSrcweir * 2403cdf0e10cSrcweir * --------------------------------------------------*/ 2404cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SetCplSttExceptList( SvStringsISortDtor* pList ) 2405cdf0e10cSrcweir { 2406cdf0e10cSrcweir if( pCplStt_ExcptLst && pList != pCplStt_ExcptLst ) 2407cdf0e10cSrcweir delete pCplStt_ExcptLst; 2408cdf0e10cSrcweir 2409cdf0e10cSrcweir pCplStt_ExcptLst = pList; 2410cdf0e10cSrcweir if( !pCplStt_ExcptLst ) 2411cdf0e10cSrcweir { 2412cdf0e10cSrcweir DBG_ASSERT( !this, "keine gueltige Liste" ); 2413cdf0e10cSrcweir pCplStt_ExcptLst = new SvStringsISortDtor( 16, 16 ); 2414cdf0e10cSrcweir } 2415cdf0e10cSrcweir nFlags |= CplSttLstLoad; 2416cdf0e10cSrcweir } 2417cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2418cdf0e10cSrcweir * 2419cdf0e10cSrcweir * --------------------------------------------------*/ 2420cdf0e10cSrcweir SvStringsISortDtor* SvxAutoCorrectLanguageLists::LoadWrdSttExceptList() 2421cdf0e10cSrcweir { 2422cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sShareAutoCorrFile, STREAM_READ | STREAM_SHARE_DENYNONE, sal_True ); 2423cdf0e10cSrcweir String sTemp ( RTL_CONSTASCII_USTRINGPARAM ( pXMLImplWrdStt_ExcptLstStr ) ); 2424cdf0e10cSrcweir if( xStg.Is() && xStg->IsContained( sTemp ) ) 2425cdf0e10cSrcweir LoadXMLExceptList_Imp( pWrdStt_ExcptLst, pXMLImplWrdStt_ExcptLstStr, xStg ); 2426cdf0e10cSrcweir return pWrdStt_ExcptLst; 2427cdf0e10cSrcweir } 2428cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2429cdf0e10cSrcweir * 2430cdf0e10cSrcweir * --------------------------------------------------*/ 2431cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SaveWrdSttExceptList() 2432cdf0e10cSrcweir { 2433cdf0e10cSrcweir MakeUserStorage_Impl(); 2434cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2435cdf0e10cSrcweir 2436cdf0e10cSrcweir SaveExceptList_Imp( *pWrdStt_ExcptLst, pXMLImplWrdStt_ExcptLstStr, xStg ); 2437cdf0e10cSrcweir 2438cdf0e10cSrcweir xStg = 0; 2439cdf0e10cSrcweir // Zeitstempel noch setzen 2440cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, 2441cdf0e10cSrcweir &aModifiedDate, &aModifiedTime ); 2442cdf0e10cSrcweir aLastCheckTime = Time(); 2443cdf0e10cSrcweir } 2444cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2445cdf0e10cSrcweir * 2446cdf0e10cSrcweir * --------------------------------------------------*/ 2447cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::SetWrdSttExceptList( SvStringsISortDtor* pList ) 2448cdf0e10cSrcweir { 2449cdf0e10cSrcweir if( pWrdStt_ExcptLst && pList != pWrdStt_ExcptLst ) 2450cdf0e10cSrcweir delete pWrdStt_ExcptLst; 2451cdf0e10cSrcweir pWrdStt_ExcptLst = pList; 2452cdf0e10cSrcweir if( !pWrdStt_ExcptLst ) 2453cdf0e10cSrcweir { 2454cdf0e10cSrcweir DBG_ASSERT( !this, "keine gueltige Liste" ); 2455cdf0e10cSrcweir pWrdStt_ExcptLst = new SvStringsISortDtor( 16, 16 ); 2456cdf0e10cSrcweir } 2457cdf0e10cSrcweir nFlags |= WrdSttLstLoad; 2458cdf0e10cSrcweir } 2459cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2460cdf0e10cSrcweir * 2461cdf0e10cSrcweir * --------------------------------------------------*/ 2462cdf0e10cSrcweir SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetWrdSttExceptList() 2463cdf0e10cSrcweir { 2464cdf0e10cSrcweir if( !( WrdSttLstLoad & nFlags ) || IsFileChanged_Imp() ) 2465cdf0e10cSrcweir SetWrdSttExceptList( LoadWrdSttExceptList() ); 2466cdf0e10cSrcweir return pWrdStt_ExcptLst; 2467cdf0e10cSrcweir } 2468cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2469cdf0e10cSrcweir * 2470cdf0e10cSrcweir * --------------------------------------------------*/ 2471cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::RemoveStream_Imp( const String& rName ) 2472cdf0e10cSrcweir { 2473cdf0e10cSrcweir if( sShareAutoCorrFile != sUserAutoCorrFile ) 2474cdf0e10cSrcweir { 2475cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2476cdf0e10cSrcweir if( xStg.Is() && SVSTREAM_OK == xStg->GetError() && 2477cdf0e10cSrcweir xStg->IsStream( rName ) ) 2478cdf0e10cSrcweir { 2479cdf0e10cSrcweir xStg->Remove( rName ); 2480cdf0e10cSrcweir xStg->Commit(); 2481cdf0e10cSrcweir 2482cdf0e10cSrcweir xStg = 0; 2483cdf0e10cSrcweir } 2484cdf0e10cSrcweir } 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir 2487cdf0e10cSrcweir void SvxAutoCorrectLanguageLists::MakeUserStorage_Impl() 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir // The conversion needs to happen if the file is already in the user 2490cdf0e10cSrcweir // directory and is in the old format. Additionally it needs to 2491cdf0e10cSrcweir // happen when the file is being copied from share to user. 2492cdf0e10cSrcweir 2493cdf0e10cSrcweir sal_Bool bError = sal_False, bConvert = sal_False, bCopy = sal_False; 2494cdf0e10cSrcweir INetURLObject aDest; 2495cdf0e10cSrcweir INetURLObject aSource; 2496cdf0e10cSrcweir 2497cdf0e10cSrcweir // String sDestPath = sUserAutoCorrFile.Copy ( 0, sUserAutoCorrFile.Len()-3); 2498cdf0e10cSrcweir // sDestPath.AppendAscii ("bak"); 2499cdf0e10cSrcweir 2500cdf0e10cSrcweir 2501cdf0e10cSrcweir if (sUserAutoCorrFile != sShareAutoCorrFile ) 2502cdf0e10cSrcweir { 2503cdf0e10cSrcweir aSource = INetURLObject ( sShareAutoCorrFile ); //aSource.setFSysPath ( sShareAutoCorrFile, INetURLObject::FSYS_DETECT ); 2504cdf0e10cSrcweir aDest = INetURLObject ( sUserAutoCorrFile ); 2505cdf0e10cSrcweir if ( SotStorage::IsOLEStorage ( sShareAutoCorrFile ) ) 2506cdf0e10cSrcweir { 2507cdf0e10cSrcweir aDest.SetExtension ( String::CreateFromAscii ( "bak" ) ); 2508cdf0e10cSrcweir bConvert = sal_True; 2509cdf0e10cSrcweir } 2510cdf0e10cSrcweir bCopy = sal_True; 2511cdf0e10cSrcweir } 2512cdf0e10cSrcweir else if ( SotStorage::IsOLEStorage ( sUserAutoCorrFile ) ) 2513cdf0e10cSrcweir { 2514cdf0e10cSrcweir aSource = INetURLObject ( sUserAutoCorrFile ); 2515cdf0e10cSrcweir aDest = INetURLObject ( sUserAutoCorrFile ); 2516cdf0e10cSrcweir aDest.SetExtension ( String::CreateFromAscii ( "bak" ) ); 2517cdf0e10cSrcweir bCopy = bConvert = sal_True; 2518cdf0e10cSrcweir } 2519cdf0e10cSrcweir if (bCopy) 2520cdf0e10cSrcweir { 2521cdf0e10cSrcweir try 2522cdf0e10cSrcweir { 2523cdf0e10cSrcweir String sMain(aDest.GetMainURL( INetURLObject::DECODE_TO_IURI )); 2524cdf0e10cSrcweir sal_Unicode cSlash = '/'; 2525cdf0e10cSrcweir xub_StrLen nSlashPos = sMain.SearchBackward(cSlash); 2526cdf0e10cSrcweir sMain.Erase(nSlashPos); 2527cdf0e10cSrcweir ::ucbhelper::Content aNewContent( sMain, uno::Reference< XCommandEnvironment > ()); 2528cdf0e10cSrcweir Any aAny; 2529cdf0e10cSrcweir TransferInfo aInfo; 2530cdf0e10cSrcweir aInfo.NameClash = NameClash::OVERWRITE; 2531cdf0e10cSrcweir aInfo.NewTitle = aDest.GetName(); 2532cdf0e10cSrcweir aInfo.SourceURL = aSource.GetMainURL( INetURLObject::DECODE_TO_IURI ); 2533cdf0e10cSrcweir aInfo.MoveData = sal_False; 2534cdf0e10cSrcweir aAny <<= aInfo; 2535cdf0e10cSrcweir aNewContent.executeCommand( OUString ( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), aAny); 2536cdf0e10cSrcweir } 2537cdf0e10cSrcweir catch (...) 2538cdf0e10cSrcweir { 2539cdf0e10cSrcweir bError = sal_True; 2540cdf0e10cSrcweir } 2541cdf0e10cSrcweir } 2542cdf0e10cSrcweir if (bConvert && !bError) 2543cdf0e10cSrcweir { 2544cdf0e10cSrcweir SotStorageRef xSrcStg = new SotStorage( aDest.GetMainURL( INetURLObject::DECODE_TO_IURI ), STREAM_READ, sal_True ); 2545cdf0e10cSrcweir SotStorageRef xDstStg = new SotStorage( sUserAutoCorrFile, STREAM_WRITE, sal_True ); 2546cdf0e10cSrcweir 2547cdf0e10cSrcweir if( xSrcStg.Is() && xDstStg.Is() ) 2548cdf0e10cSrcweir { 2549cdf0e10cSrcweir String sWord ( RTL_CONSTASCII_USTRINGPARAM ( pImplWrdStt_ExcptLstStr ) ); 2550cdf0e10cSrcweir String sSentence ( RTL_CONSTASCII_USTRINGPARAM ( pImplCplStt_ExcptLstStr ) ); 2551cdf0e10cSrcweir String sXMLWord ( RTL_CONSTASCII_USTRINGPARAM ( pXMLImplWrdStt_ExcptLstStr ) ); 2552cdf0e10cSrcweir String sXMLSentence ( RTL_CONSTASCII_USTRINGPARAM ( pXMLImplCplStt_ExcptLstStr ) ); 2553cdf0e10cSrcweir SvStringsISortDtor *pTmpWordList = NULL; 2554cdf0e10cSrcweir 2555cdf0e10cSrcweir if (xSrcStg->IsContained( sXMLWord ) ) 2556cdf0e10cSrcweir LoadXMLExceptList_Imp( pTmpWordList, pXMLImplWrdStt_ExcptLstStr, xSrcStg ); 2557cdf0e10cSrcweir 2558cdf0e10cSrcweir if (pTmpWordList) 2559cdf0e10cSrcweir { 2560cdf0e10cSrcweir SaveExceptList_Imp( *pTmpWordList, pXMLImplWrdStt_ExcptLstStr, xDstStg, sal_True ); 2561cdf0e10cSrcweir pTmpWordList->DeleteAndDestroy( 0, pTmpWordList->Count() ); 2562cdf0e10cSrcweir pTmpWordList = NULL; 2563cdf0e10cSrcweir } 2564cdf0e10cSrcweir 2565cdf0e10cSrcweir 2566cdf0e10cSrcweir if (xSrcStg->IsContained( sXMLSentence ) ) 2567cdf0e10cSrcweir LoadXMLExceptList_Imp( pTmpWordList, pXMLImplCplStt_ExcptLstStr, xSrcStg ); 2568cdf0e10cSrcweir 2569cdf0e10cSrcweir if (pTmpWordList) 2570cdf0e10cSrcweir { 2571cdf0e10cSrcweir SaveExceptList_Imp( *pTmpWordList, pXMLImplCplStt_ExcptLstStr, xDstStg, sal_True ); 2572cdf0e10cSrcweir pTmpWordList->DeleteAndDestroy( 0, pTmpWordList->Count() ); 2573cdf0e10cSrcweir } 2574cdf0e10cSrcweir 2575cdf0e10cSrcweir GetAutocorrWordList(); 2576cdf0e10cSrcweir MakeBlocklist_Imp( *xDstStg ); 2577cdf0e10cSrcweir // xDstStg is committed in MakeBlocklist_Imp 2578cdf0e10cSrcweir /*xSrcStg->CopyTo( &xDstStg );*/ 2579cdf0e10cSrcweir sShareAutoCorrFile = sUserAutoCorrFile; 2580cdf0e10cSrcweir xDstStg = 0; 2581cdf0e10cSrcweir try 2582cdf0e10cSrcweir { 2583cdf0e10cSrcweir ::ucbhelper::Content aContent ( aDest.GetMainURL( INetURLObject::DECODE_TO_IURI ), uno::Reference < XCommandEnvironment > ()); 2584cdf0e10cSrcweir aContent.executeCommand ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "delete" ) ), makeAny ( sal_Bool (sal_True ) ) ); 2585cdf0e10cSrcweir } 2586cdf0e10cSrcweir catch (...) 2587cdf0e10cSrcweir { 2588cdf0e10cSrcweir } 2589cdf0e10cSrcweir } 2590cdf0e10cSrcweir } 2591cdf0e10cSrcweir else if( bCopy && !bError ) 2592cdf0e10cSrcweir sShareAutoCorrFile = sUserAutoCorrFile; 2593cdf0e10cSrcweir } 2594cdf0e10cSrcweir 2595cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2596cdf0e10cSrcweir * 2597cdf0e10cSrcweir * --------------------------------------------------*/ 2598cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::MakeBlocklist_Imp( SvStorage& rStg ) 2599cdf0e10cSrcweir { 2600cdf0e10cSrcweir String sStrmName( pXMLImplAutocorr_ListStr, RTL_TEXTENCODING_MS_1252 ); 2601cdf0e10cSrcweir sal_Bool bRet = sal_True, bRemove = !pAutocorr_List || !pAutocorr_List->Count(); 2602cdf0e10cSrcweir if( !bRemove ) 2603cdf0e10cSrcweir { 2604cdf0e10cSrcweir /* 2605cdf0e10cSrcweir if ( rStg.IsContained( sStrmName) ) 2606cdf0e10cSrcweir { 2607cdf0e10cSrcweir rStg.Remove ( sStrmName ); 2608cdf0e10cSrcweir rStg.Commit(); 2609cdf0e10cSrcweir } 2610cdf0e10cSrcweir */ 2611cdf0e10cSrcweir SvStorageStreamRef refList = rStg.OpenSotStream( sStrmName, 2612cdf0e10cSrcweir ( STREAM_READ | STREAM_WRITE | STREAM_SHARE_DENYWRITE ) ); 2613cdf0e10cSrcweir if( refList.Is() ) 2614cdf0e10cSrcweir { 2615cdf0e10cSrcweir refList->SetSize( 0 ); 2616cdf0e10cSrcweir refList->SetBufferSize( 8192 ); 2617cdf0e10cSrcweir String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); 2618cdf0e10cSrcweir OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") ); 2619cdf0e10cSrcweir uno::Any aAny; 2620cdf0e10cSrcweir aAny <<= aMime; 2621cdf0e10cSrcweir refList->SetProperty( aPropName, aAny ); 2622cdf0e10cSrcweir 2623cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xServiceFactory = 2624cdf0e10cSrcweir comphelper::getProcessServiceFactory(); 2625cdf0e10cSrcweir DBG_ASSERT( xServiceFactory.is(), 2626cdf0e10cSrcweir "XMLReader::Read: got no service manager" ); 2627cdf0e10cSrcweir if( !xServiceFactory.is() ) 2628cdf0e10cSrcweir { 2629cdf0e10cSrcweir // Throw an exception ? 2630cdf0e10cSrcweir } 2631cdf0e10cSrcweir 2632cdf0e10cSrcweir uno::Reference < XInterface > xWriter (xServiceFactory->createInstance( 2633cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer")))); 2634cdf0e10cSrcweir DBG_ASSERT(xWriter.is(),"com.sun.star.xml.sax.Writer service missing"); 2635cdf0e10cSrcweir uno::Reference < io::XOutputStream> xOut = new utl::OOutputStreamWrapper( *refList ); 2636cdf0e10cSrcweir uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); 2637cdf0e10cSrcweir xSrc->setOutputStream(xOut); 2638cdf0e10cSrcweir 2639cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); 2640cdf0e10cSrcweir 2641cdf0e10cSrcweir // #110680# 2642cdf0e10cSrcweir // SvXMLAutoCorrectExport aExp(pAutocorr_List, sStrmName, xHandler); 2643cdf0e10cSrcweir SvXMLAutoCorrectExport aExp( xServiceFactory, pAutocorr_List, sStrmName, xHandler ); 2644cdf0e10cSrcweir 2645cdf0e10cSrcweir aExp.exportDoc( XML_BLOCK_LIST ); 2646cdf0e10cSrcweir 2647cdf0e10cSrcweir refList->Commit(); 2648cdf0e10cSrcweir bRet = SVSTREAM_OK == refList->GetError(); 2649cdf0e10cSrcweir if( bRet ) 2650cdf0e10cSrcweir { 2651cdf0e10cSrcweir refList.Clear(); 2652cdf0e10cSrcweir rStg.Commit(); 2653cdf0e10cSrcweir if( SVSTREAM_OK != rStg.GetError() ) 2654cdf0e10cSrcweir { 2655cdf0e10cSrcweir bRemove = sal_True; 2656cdf0e10cSrcweir bRet = sal_False; 2657cdf0e10cSrcweir } 2658cdf0e10cSrcweir } 2659cdf0e10cSrcweir 2660cdf0e10cSrcweir /* 2661cdf0e10cSrcweir refList->SetSize( 0 ); 2662cdf0e10cSrcweir refList->SetBufferSize( 8192 ); 2663cdf0e10cSrcweir rtl_TextEncoding eEncoding = gsl_getSystemTextEncoding(); 2664cdf0e10cSrcweir 2665cdf0e10cSrcweir String aDummy; // Erkennungszeichen fuer neue Streams 2666cdf0e10cSrcweir refList->WriteByteString( aDummy, RTL_TEXTENCODING_MS_1252 ) 2667cdf0e10cSrcweir << (sal_uInt8) 4 // Laenge des Headers (ohne den Leerstring) 2668cdf0e10cSrcweir << (sal_uInt16)WORDLIST_VERSION_358 // Version des Streams 2669cdf0e10cSrcweir << (sal_uInt8)eEncoding; // der Zeichensatz 2670cdf0e10cSrcweir 2671cdf0e10cSrcweir for( sal_uInt16 i = 0; i < pAutocorr_List->Count() && 2672cdf0e10cSrcweir SVSTREAM_OK == refList->GetError(); ++i ) 2673cdf0e10cSrcweir { 2674cdf0e10cSrcweir SvxAutocorrWord* p = pAutocorr_List->GetObject( i ); 2675cdf0e10cSrcweir refList->WriteByteString( p->GetShort(), eEncoding ). 2676cdf0e10cSrcweir WriteByteString( p->IsTextOnly() 2677cdf0e10cSrcweir ? p->GetLong() 2678cdf0e10cSrcweir : p->GetShort(), eEncoding ); 2679cdf0e10cSrcweir } 2680cdf0e10cSrcweir refList->Commit(); 2681cdf0e10cSrcweir bRet = SVSTREAM_OK == refList->GetError(); 2682cdf0e10cSrcweir if( bRet ) 2683cdf0e10cSrcweir { 2684cdf0e10cSrcweir refList.Clear(); 2685cdf0e10cSrcweir rStg.Commit(); 2686cdf0e10cSrcweir if( SVSTREAM_OK != rStg.GetError() ) 2687cdf0e10cSrcweir { 2688cdf0e10cSrcweir bRemove = sal_True; 2689cdf0e10cSrcweir bRet = sal_False; 2690cdf0e10cSrcweir } 2691cdf0e10cSrcweir } 2692cdf0e10cSrcweir */ 2693cdf0e10cSrcweir } 2694cdf0e10cSrcweir else 2695cdf0e10cSrcweir bRet = sal_False; 2696cdf0e10cSrcweir } 2697cdf0e10cSrcweir 2698cdf0e10cSrcweir if( bRemove ) 2699cdf0e10cSrcweir { 2700cdf0e10cSrcweir rStg.Remove( sStrmName ); 2701cdf0e10cSrcweir rStg.Commit(); 2702cdf0e10cSrcweir } 2703cdf0e10cSrcweir 2704cdf0e10cSrcweir return bRet; 2705cdf0e10cSrcweir } 2706cdf0e10cSrcweir 2707cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2708cdf0e10cSrcweir * 2709cdf0e10cSrcweir * --------------------------------------------------*/ 2710cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort, 2711cdf0e10cSrcweir const String& rLong ) 2712cdf0e10cSrcweir { 2713cdf0e10cSrcweir // erstmal akt. Liste besorgen! 2714cdf0e10cSrcweir GetAutocorrWordList(); 2715cdf0e10cSrcweir 2716cdf0e10cSrcweir MakeUserStorage_Impl(); 2717cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2718cdf0e10cSrcweir 2719cdf0e10cSrcweir sal_Bool bRet = xStg.Is() && SVSTREAM_OK == xStg->GetError(); 2720cdf0e10cSrcweir 2721cdf0e10cSrcweir /* if( bRet ) 2722cdf0e10cSrcweir { 2723cdf0e10cSrcweir // PutText( *xStg, rShort ); 2724cdf0e10cSrcweir } 2725cdf0e10cSrcweir */ 2726cdf0e10cSrcweir // die Wortliste aktualisieren 2727cdf0e10cSrcweir if( bRet ) 2728cdf0e10cSrcweir { 2729cdf0e10cSrcweir sal_uInt16 nPos; 2730cdf0e10cSrcweir SvxAutocorrWord* pNew = new SvxAutocorrWord( rShort, rLong, sal_True ); 2731cdf0e10cSrcweir if( pAutocorr_List->Seek_Entry( pNew, &nPos ) ) 2732cdf0e10cSrcweir { 2733cdf0e10cSrcweir if( !(*pAutocorr_List)[ nPos ]->IsTextOnly() ) 2734cdf0e10cSrcweir { 2735cdf0e10cSrcweir // dann ist der Storage noch zu entfernen 2736cdf0e10cSrcweir String sStgNm( rShort ); 2737cdf0e10cSrcweir if (xStg->IsOLEStorage()) 2738cdf0e10cSrcweir EncryptBlockName_Imp( sStgNm ); 2739cdf0e10cSrcweir else 2740cdf0e10cSrcweir GeneratePackageName ( rShort, sStgNm); 2741cdf0e10cSrcweir 2742cdf0e10cSrcweir if( xStg->IsContained( sStgNm ) ) 2743cdf0e10cSrcweir xStg->Remove( sStgNm ); 2744cdf0e10cSrcweir } 2745cdf0e10cSrcweir pAutocorr_List->DeleteAndDestroy( nPos ); 2746cdf0e10cSrcweir } 2747cdf0e10cSrcweir 2748cdf0e10cSrcweir if( pAutocorr_List->Insert( pNew ) ) 2749cdf0e10cSrcweir { 2750cdf0e10cSrcweir bRet = MakeBlocklist_Imp( *xStg ); 2751cdf0e10cSrcweir xStg = 0; 2752cdf0e10cSrcweir } 2753cdf0e10cSrcweir else 2754cdf0e10cSrcweir { 2755cdf0e10cSrcweir delete pNew; 2756cdf0e10cSrcweir bRet = sal_False; 2757cdf0e10cSrcweir } 2758cdf0e10cSrcweir } 2759cdf0e10cSrcweir return bRet; 2760cdf0e10cSrcweir } 2761cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2762cdf0e10cSrcweir * 2763cdf0e10cSrcweir * --------------------------------------------------*/ 2764cdf0e10cSrcweir // - Text mit Attributierung (kann nur der SWG - SWG-Format!) 2765cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort, 2766cdf0e10cSrcweir SfxObjectShell& rShell ) 2767cdf0e10cSrcweir { 2768cdf0e10cSrcweir // erstmal akt. Liste besorgen! 2769cdf0e10cSrcweir GetAutocorrWordList(); 2770cdf0e10cSrcweir 2771cdf0e10cSrcweir MakeUserStorage_Impl(); 2772cdf0e10cSrcweir 2773cdf0e10cSrcweir sal_Bool bRet = sal_False; 2774cdf0e10cSrcweir String sLong; 2775cdf0e10cSrcweir try 2776cdf0e10cSrcweir { 2777cdf0e10cSrcweir uno::Reference < embed::XStorage > xStg = comphelper::OStorageHelper::GetStorageFromURL( sUserAutoCorrFile, embed::ElementModes::READWRITE ); 2778cdf0e10cSrcweir // String aName( rShort ); 2779cdf0e10cSrcweir // EncryptBlockName_Imp( aName ); 2780cdf0e10cSrcweir // bRet = PutText( *xStg, aName, rShell, sLong ); 2781cdf0e10cSrcweir bRet = rAutoCorrect.PutText( xStg, sUserAutoCorrFile, rShort, rShell, sLong ); 2782cdf0e10cSrcweir xStg = 0; 2783cdf0e10cSrcweir 2784cdf0e10cSrcweir // die Wortliste aktualisieren 2785cdf0e10cSrcweir if( bRet ) 2786cdf0e10cSrcweir { 2787cdf0e10cSrcweir SvxAutocorrWord* pNew = new SvxAutocorrWord( rShort, sLong, sal_False ); 2788cdf0e10cSrcweir if( pAutocorr_List->Insert( pNew ) ) 2789cdf0e10cSrcweir { 2790cdf0e10cSrcweir SotStorageRef xStor = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2791cdf0e10cSrcweir MakeBlocklist_Imp( *xStor ); 2792cdf0e10cSrcweir } 2793cdf0e10cSrcweir else 2794cdf0e10cSrcweir delete pNew; 2795cdf0e10cSrcweir } 2796cdf0e10cSrcweir } 2797cdf0e10cSrcweir catch ( uno::Exception& ) 2798cdf0e10cSrcweir { 2799cdf0e10cSrcweir } 2800cdf0e10cSrcweir 2801cdf0e10cSrcweir return bRet; 2802cdf0e10cSrcweir } 2803cdf0e10cSrcweir 2804cdf0e10cSrcweir /* -----------------18.11.98 11:26------------------- 2805cdf0e10cSrcweir * 2806cdf0e10cSrcweir * --------------------------------------------------*/ 2807cdf0e10cSrcweir // - loesche einen Eintrag 2808cdf0e10cSrcweir sal_Bool SvxAutoCorrectLanguageLists::DeleteText( const String& rShort ) 2809cdf0e10cSrcweir { 2810cdf0e10cSrcweir // erstmal akt. Liste besorgen! 2811cdf0e10cSrcweir GetAutocorrWordList(); 2812cdf0e10cSrcweir 2813cdf0e10cSrcweir MakeUserStorage_Impl(); 2814cdf0e10cSrcweir 2815cdf0e10cSrcweir SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); 2816cdf0e10cSrcweir sal_Bool bRet = xStg.Is() && SVSTREAM_OK == xStg->GetError(); 2817cdf0e10cSrcweir if( bRet ) 2818cdf0e10cSrcweir { 2819cdf0e10cSrcweir sal_uInt16 nPos; 2820cdf0e10cSrcweir SvxAutocorrWord aTmp( rShort, rShort ); 2821cdf0e10cSrcweir if( pAutocorr_List->Seek_Entry( &aTmp, &nPos ) ) 2822cdf0e10cSrcweir { 2823cdf0e10cSrcweir SvxAutocorrWord* pFnd = (*pAutocorr_List)[ nPos ]; 2824cdf0e10cSrcweir if( !pFnd->IsTextOnly() ) 2825cdf0e10cSrcweir { 2826cdf0e10cSrcweir String aName( rShort ); 2827cdf0e10cSrcweir if (xStg->IsOLEStorage()) 2828cdf0e10cSrcweir EncryptBlockName_Imp( aName ); 2829cdf0e10cSrcweir else 2830cdf0e10cSrcweir GeneratePackageName ( rShort, aName ); 2831cdf0e10cSrcweir if( xStg->IsContained( aName ) ) 2832cdf0e10cSrcweir { 2833cdf0e10cSrcweir xStg->Remove( aName ); 2834cdf0e10cSrcweir bRet = xStg->Commit(); 2835cdf0e10cSrcweir } 2836cdf0e10cSrcweir 2837cdf0e10cSrcweir } 2838cdf0e10cSrcweir // die Wortliste aktualisieren 2839cdf0e10cSrcweir pAutocorr_List->DeleteAndDestroy( nPos ); 2840cdf0e10cSrcweir MakeBlocklist_Imp( *xStg ); 2841cdf0e10cSrcweir xStg = 0; 2842cdf0e10cSrcweir } 2843cdf0e10cSrcweir else 2844cdf0e10cSrcweir bRet = sal_False; 2845cdf0e10cSrcweir } 2846cdf0e10cSrcweir return bRet; 2847cdf0e10cSrcweir } 2848