1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_cui.hxx" 30 31 #define _SVSTDARR_STRINGSISORTDTOR 32 #define _SVSTDARR_STRINGSDTOR 33 #include <svl/svstdarr.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <vcl/field.hxx> 36 #include <vcl/keycodes.hxx> 37 #include <sot/exchange.hxx> 38 #include <svtools/transfer.hxx> 39 #include <unotools/syslocale.hxx> 40 #include <sfx2/objsh.hxx> 41 #include <sfx2/viewsh.hxx> 42 #include <unotools/charclass.hxx> 43 #include <unotools/collatorwrapper.hxx> 44 #include <com/sun/star/i18n/CollatorOptions.hpp> 45 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 46 #include <comphelper/processfactory.hxx> 47 #include <vcl/svapp.hxx> 48 #include <sfx2/module.hxx> 49 #include <sfx2/request.hxx> 50 #include <sfx2/sfxsids.hrc> 51 #include <svl/eitem.hxx> 52 #include <svl/languageoptions.hxx> 53 #include <svx/SmartTagMgr.hxx> 54 #include <com/sun/star/smarttags/XSmartTagRecognizer.hpp> 55 #include <com/sun/star/smarttags/XSmartTagAction.hpp> 56 57 #define _OFA_AUTOCDLG_CXX 58 #include "autocdlg.hxx" 59 #include "autocdlg.hrc" 60 #include "helpid.hrc" 61 #include <editeng/acorrcfg.hxx> 62 #include <editeng/svxacorr.hxx> 63 #include "cuicharmap.hxx" 64 #include <editeng/unolingu.hxx> 65 #include <dialmgr.hxx> 66 #include <svx/svxids.hrc> // SID_OPEN_SMARTTAGSOPTIONS 67 68 static LanguageType eLastDialogLanguage = LANGUAGE_SYSTEM; 69 70 using namespace ::com::sun::star::util; 71 using namespace ::com::sun::star; 72 using namespace ::rtl; 73 74 static ::com::sun::star::uno::Reference< 75 ::com::sun::star::lang::XMultiServiceFactory >& GetProcessFact() 76 { 77 static ::com::sun::star::uno::Reference< 78 ::com::sun::star::lang::XMultiServiceFactory > xMSF = 79 ::comphelper::getProcessServiceFactory(); 80 return xMSF; 81 } 82 83 /*-----------------14.10.96 15.47------------------- 84 85 --------------------------------------------------*/ 86 87 OfaAutoCorrDlg::OfaAutoCorrDlg(Window* pParent, const SfxItemSet* _pSet ) : 88 SfxTabDialog(pParent, CUI_RES( RID_OFA_AUTOCORR_DLG ), _pSet), 89 aLanguageFT( this, CUI_RES(FT_LANG )), 90 aLanguageLB( this, CUI_RES(LB_LANG )) 91 { 92 sal_Bool bShowSWOptions = sal_False; 93 sal_Bool bOpenSmartTagOptions = sal_False; 94 95 if ( _pSet ) 96 { 97 SFX_ITEMSET_ARG( _pSet, pItem, SfxBoolItem, SID_AUTO_CORRECT_DLG, sal_False ); 98 if ( pItem && pItem->GetValue() ) 99 bShowSWOptions = sal_True; 100 101 SFX_ITEMSET_ARG( _pSet, pItem2, SfxBoolItem, SID_OPEN_SMARTTAGOPTIONS, sal_False ); 102 if ( pItem2 && pItem2->GetValue() ) 103 bOpenSmartTagOptions = sal_True; 104 } 105 106 aLanguageFT.SetZOrder(0, WINDOW_ZORDER_FIRST); 107 aLanguageLB.SetZOrder(&aLanguageFT, WINDOW_ZORDER_BEHIND); 108 aLanguageLB.SetHelpId(HID_AUTOCORR_LANGUAGE); 109 FreeResource(); 110 111 AddTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS, OfaAutocorrOptionsPage::Create, 0); 112 AddTabPage(RID_OFAPAGE_AUTOFMT_APPLY, OfaSwAutoFmtOptionsPage::Create, 0); 113 AddTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS, OfaAutoCompleteTabPage::Create, 0); 114 AddTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS, OfaSmartTagOptionsTabPage::Create, 0); 115 116 if (!bShowSWOptions) 117 { 118 RemoveTabPage(RID_OFAPAGE_AUTOFMT_APPLY); 119 RemoveTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS); 120 RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS); 121 } 122 else 123 { 124 // remove smart tag tab page if no extensions are installed 125 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 126 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 127 if ( !pOpt || !pOpt->pSmartTagMgr || 0 == pOpt->pSmartTagMgr->NumberOfRecognizers() ) 128 RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS); 129 130 RemoveTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS); 131 } 132 133 AddTabPage(RID_OFAPAGE_AUTOCORR_REPLACE, OfaAutocorrReplacePage::Create, 0); 134 AddTabPage(RID_OFAPAGE_AUTOCORR_EXCEPT, OfaAutocorrExceptPage::Create, 0); 135 AddTabPage(RID_OFAPAGE_AUTOCORR_QUOTE, OfaQuoteTabPage::Create, 0); 136 137 // initialize languages 138 //! LANGUAGE_NONE is displayed as '[All]' and the LanguageType 139 //! will be set to LANGUAGE_DONTKNOW 140 sal_Int16 nLangList = LANG_LIST_WESTERN; 141 142 if( SvtLanguageOptions().IsCTLFontEnabled() ) 143 nLangList |= LANG_LIST_CTL; 144 aLanguageLB.SetLanguageList( nLangList, sal_True, sal_True ); 145 aLanguageLB.SelectLanguage( LANGUAGE_NONE ); 146 sal_uInt16 nPos = aLanguageLB.GetSelectEntryPos(); 147 DBG_ASSERT( LISTBOX_ENTRY_NOTFOUND != nPos, "listbox entry missing" ); 148 aLanguageLB.SetEntryData( nPos, (void*)(long) LANGUAGE_DONTKNOW ); 149 150 // Initialisierung funktionier fuer static nicht unter Linux - deswegen hier 151 if( LANGUAGE_SYSTEM == eLastDialogLanguage ) 152 eLastDialogLanguage = Application::GetSettings().GetLanguage(); 153 154 LanguageType nSelectLang = LANGUAGE_DONTKNOW; 155 nPos = aLanguageLB.GetEntryPos( (void*)(long) eLastDialogLanguage ); 156 if (LISTBOX_ENTRY_NOTFOUND != nPos) 157 nSelectLang = eLastDialogLanguage; 158 aLanguageLB.SelectLanguage( nSelectLang ); 159 160 aLanguageLB.SetSelectHdl(LINK(this, OfaAutoCorrDlg, SelectLanguageHdl)); 161 162 Size aMinSize(aLanguageFT.CalcMinimumSize()); 163 //reserve some extra space for CJK accelerators that are possible inserted 164 //later (like '(A)') 165 aLanguageFT.SetPosSizePixel( 0, 0, aMinSize.Width() + 20, 0, WINDOW_POSSIZE_WIDTH ); 166 167 if ( bOpenSmartTagOptions ) 168 SetCurPageId( RID_OFAPAGE_SMARTTAG_OPTIONS ); 169 } 170 /*-----------------16.10.96 14.06------------------- 171 172 --------------------------------------------------*/ 173 174 sal_Bool lcl_FindEntry( ListBox& rLB, const String& rEntry, 175 CollatorWrapper& rCmpClass ) 176 { 177 sal_uInt16 nCount = rLB.GetEntryCount(); 178 sal_uInt16 nSelPos = rLB.GetSelectEntryPos(); 179 sal_uInt16 i; 180 for(i = 0; i < nCount; i++) 181 { 182 if( 0 == rCmpClass.compareString(rEntry, rLB.GetEntry(i) )) 183 { 184 rLB.SelectEntryPos(i, sal_True); 185 return sal_True; 186 } 187 } 188 if(LISTBOX_ENTRY_NOTFOUND != nSelPos) 189 rLB.SelectEntryPos(nSelPos, sal_False); 190 return sal_False; 191 } 192 193 /* -----------------23.11.98 10:46------------------- 194 * 195 * --------------------------------------------------*/ 196 IMPL_LINK(OfaAutoCorrDlg, SelectLanguageHdl, ListBox*, pBox) 197 { 198 sal_uInt16 nPos = pBox->GetSelectEntryPos(); 199 void* pVoid = pBox->GetEntryData(nPos); 200 LanguageType eNewLang = (LanguageType)(long)pVoid; 201 //alte Einstellungen speichern und neu fuellen 202 if(eNewLang != eLastDialogLanguage) 203 { 204 sal_uInt16 nPageId = GetCurPageId(); 205 if(RID_OFAPAGE_AUTOCORR_REPLACE == nPageId) 206 ((OfaAutocorrReplacePage*)GetTabPage( nPageId ))->SetLanguage(eNewLang); 207 else if(RID_OFAPAGE_AUTOCORR_EXCEPT == nPageId) 208 ((OfaAutocorrExceptPage*)GetTabPage( nPageId ))->SetLanguage(eNewLang); 209 } 210 return 0; 211 } 212 /*-----------------14.10.96 15.57------------------- 213 214 --------------------------------------------------*/ 215 216 OfaAutocorrOptionsPage::OfaAutocorrOptionsPage( Window* pParent, 217 const SfxItemSet& rSet ) : 218 SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_OPTIONS ), rSet), 219 aCheckLB (this, CUI_RES(CLB_SETTINGS )), 220 221 sInput (CUI_RES(ST_USE_REPLACE )), 222 sDoubleCaps (CUI_RES(ST_CPTL_STT_WORD )), 223 sStartCap (CUI_RES(ST_CPTL_STT_SENT )), 224 sBoldUnderline (CUI_RES(ST_BOLD_UNDER )), 225 sURL (CUI_RES(ST_DETECT_URL )), 226 sNoDblSpaces (CUI_RES(STR_NO_DBL_SPACES )), 227 sDash (CUI_RES(ST_DASH )) 228 { 229 FreeResource(); 230 231 aCheckLB.SetHelpId(HID_OFAPAGE_AUTOCORR_CLB); 232 } 233 234 /*-----------------14.10.96 15.58------------------- 235 236 --------------------------------------------------*/ 237 238 239 OfaAutocorrOptionsPage::~OfaAutocorrOptionsPage() 240 { 241 } 242 243 /*-----------------14.10.96 15.58------------------- 244 245 --------------------------------------------------*/ 246 247 248 SfxTabPage* OfaAutocorrOptionsPage::Create( Window* pParent, 249 const SfxItemSet& rSet) 250 { 251 return new OfaAutocorrOptionsPage(pParent, rSet); 252 } 253 /*-----------------14.10.96 15.58------------------- 254 255 --------------------------------------------------*/ 256 257 258 sal_Bool OfaAutocorrOptionsPage::FillItemSet( SfxItemSet& ) 259 { 260 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 261 long nFlags = pAutoCorrect->GetFlags(); 262 263 sal_uInt16 nPos = 0; 264 pAutoCorrect->SetAutoCorrFlag(Autocorrect, aCheckLB.IsChecked(nPos++)); 265 pAutoCorrect->SetAutoCorrFlag(CptlSttWrd, aCheckLB.IsChecked(nPos++)); 266 pAutoCorrect->SetAutoCorrFlag(CptlSttSntnc, aCheckLB.IsChecked(nPos++)); 267 pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl, aCheckLB.IsChecked(nPos++)); 268 pAutoCorrect->SetAutoCorrFlag(SetINetAttr, aCheckLB.IsChecked(nPos++)); 269 pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, aCheckLB.IsChecked(nPos++)); 270 pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace, aCheckLB.IsChecked(nPos++)); 271 272 sal_Bool bReturn = nFlags != pAutoCorrect->GetFlags(); 273 if(bReturn ) 274 { 275 SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get(); 276 pCfg->SetModified(); 277 pCfg->Commit(); 278 } 279 return bReturn; 280 } 281 282 /* -----------------23.11.98 16:15------------------- 283 * 284 * --------------------------------------------------*/ 285 void OfaAutocorrOptionsPage::ActivatePage( const SfxItemSet& ) 286 { 287 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False); 288 } 289 290 /*-----------------14.10.96 15.58------------------- 291 292 --------------------------------------------------*/ 293 294 295 void OfaAutocorrOptionsPage::Reset( const SfxItemSet& ) 296 { 297 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 298 const long nFlags = pAutoCorrect->GetFlags(); 299 300 aCheckLB.SetUpdateMode(sal_False); 301 aCheckLB.Clear(); 302 303 aCheckLB.InsertEntry(sInput); 304 aCheckLB.InsertEntry(sDoubleCaps); 305 aCheckLB.InsertEntry(sStartCap); 306 aCheckLB.InsertEntry(sBoldUnderline); 307 aCheckLB.InsertEntry(sURL); 308 aCheckLB.InsertEntry(sDash); 309 aCheckLB.InsertEntry(sNoDblSpaces); 310 311 sal_uInt16 nPos = 0; 312 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & Autocorrect) ); 313 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CptlSttWrd) ); 314 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CptlSttSntnc) ); 315 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgWeightUnderl) ); 316 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & SetINetAttr) ); 317 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgToEnEmDash) ); 318 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & IgnoreDoubleSpace) ); 319 320 aCheckLB.SetUpdateMode(sal_True); 321 } 322 323 /*********************************************************************/ 324 /* */ 325 /* Hilfs-struct fuer dUserDaten der Checklistbox */ 326 /* */ 327 /*********************************************************************/ 328 329 struct ImpUserData 330 { 331 String *pString; 332 Font* pFont; 333 334 ImpUserData(String* pText, Font* pFnt) 335 { pString = pText; pFont = pFnt;} 336 }; 337 338 339 /*********************************************************************/ 340 /* */ 341 /* Dialog fuer Prozenteinstellung */ 342 /* */ 343 /*********************************************************************/ 344 345 class OfaAutoFmtPrcntSet : public ModalDialog 346 { 347 OKButton aOKPB; 348 CancelButton aCancelPB; 349 FixedLine aPrcntFL; 350 MetricField aPrcntMF; 351 352 public: 353 OfaAutoFmtPrcntSet(Window* pParent) : 354 ModalDialog(pParent, CUI_RES(RID_OFADLG_PRCNT_SET)), 355 aOKPB(this, CUI_RES(BT_OK)), 356 aCancelPB(this, CUI_RES(BT_CANCEL)), 357 aPrcntFL(this, CUI_RES(FL_PRCNT)), 358 aPrcntMF(this, CUI_RES(ED_RIGHT_MARGIN)) 359 { 360 FreeResource(); 361 } 362 MetricField& GetPrcntFld(){return aPrcntMF;} 363 }; 364 365 366 /*********************************************************************/ 367 /* */ 368 /* veraenderter LBoxString */ 369 /* */ 370 /*********************************************************************/ 371 372 class OfaImpBrwString : public SvLBoxString 373 { 374 public: 375 376 OfaImpBrwString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, 377 const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr){} 378 379 virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 380 SvLBoxEntry* pEntry); 381 }; 382 383 /*********************************************************************/ 384 /* */ 385 /*********************************************************************/ 386 387 388 void __EXPORT OfaImpBrwString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, 389 SvLBoxEntry* pEntry ) 390 { 391 rDev.DrawText( rPos, GetText() ); 392 if(pEntry->GetUserData()) 393 { 394 ImpUserData* pUserData = (ImpUserData* )pEntry->GetUserData(); 395 Point aNewPos(rPos); 396 aNewPos.X() += rDev.GetTextWidth(GetText()); 397 Font aOldFont( rDev.GetFont()); 398 Font aFont( aOldFont ); 399 if(pUserData->pFont) 400 { 401 aFont = *pUserData->pFont; 402 aFont.SetColor(aOldFont.GetColor()); 403 aFont.SetSize(aOldFont.GetSize()); 404 } 405 aFont.SetWeight( WEIGHT_BOLD ); 406 407 sal_Bool bFett = sal_True; 408 sal_uInt16 nPos = 0; 409 do { 410 String sTxt( pUserData->pString->GetToken( 0, 1, nPos )); 411 412 if( bFett ) 413 rDev.SetFont( aFont ); 414 415 rDev.DrawText( aNewPos, sTxt ); 416 417 if( STRING_NOTFOUND != nPos ) 418 aNewPos.X() += rDev.GetTextWidth( sTxt ); 419 420 if( bFett ) 421 rDev.SetFont( aOldFont ); 422 423 bFett = !bFett; 424 } while( STRING_NOTFOUND != nPos ); 425 } 426 } 427 428 /*********************************************************************/ 429 /* */ 430 /* TabPage Autoformat anwenden */ 431 /* */ 432 /*********************************************************************/ 433 434 #define CBCOL_FIRST 0 435 #define CBCOL_SECOND 1 436 #define CBCOL_BOTH 2 437 438 enum OfaAutoFmtOptions 439 { 440 USE_REPLACE_TABLE, 441 CORR_UPPER, 442 BEGIN_UPPER, 443 BOLD_UNDERLINE, 444 DETECT_URL, 445 REPLACE_DASHES, 446 DEL_SPACES_AT_STT_END, 447 DEL_SPACES_BETWEEN_LINES, 448 IGNORE_DBLSPACE, 449 APPLY_NUMBERING, 450 INSERT_BORDER, 451 CREATE_TABLE, 452 REPLACE_STYLES, 453 DEL_EMPTY_NODE, 454 REPLACE_USER_COLL, 455 REPLACE_BULLETS, 456 MERGE_SINGLE_LINE_PARA 457 }; 458 459 OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage( Window* pParent, 460 const SfxItemSet& rSet ) : 461 SfxTabPage(pParent, CUI_RES(RID_OFAPAGE_AUTOFMT_APPLY), rSet), 462 aCheckLB (this, CUI_RES(CLB_SETTINGS)), 463 aEditPB (this, CUI_RES(PB_EDIT)), 464 aHeader1Expl (this, CUI_RES(FT_HEADER1_EXPLANATION)), 465 aHeader2Expl (this, CUI_RES(FT_HEADER2_EXPLANATION)), 466 sHeader1 (CUI_RES( STR_HEADER1 )), 467 sHeader2 (CUI_RES( STR_HEADER2 )), 468 sDeleteEmptyPara (CUI_RES( ST_DEL_EMPTY_PARA)), 469 sUseReplaceTbl (CUI_RES( ST_USE_REPLACE )), 470 sCptlSttWord (CUI_RES( ST_CPTL_STT_WORD)), 471 sCptlSttSent (CUI_RES( ST_CPTL_STT_SENT)), 472 sUserStyle (CUI_RES( ST_USER_STYLE )), 473 sBullet (CUI_RES( ST_BULLET )), 474 sBoldUnder (CUI_RES( ST_BOLD_UNDER )), 475 sNoDblSpaces (CUI_RES( STR_NO_DBL_SPACES)), 476 sDetectURL (CUI_RES( ST_DETECT_URL )), 477 sDash (CUI_RES( ST_DASH )), 478 sRightMargin (CUI_RES( ST_RIGHT_MARGIN )), 479 sNum (CUI_RES( STR_NUM )), 480 sBorder (CUI_RES( STR_BORDER )), 481 sTable (CUI_RES( STR_TABLE )), 482 sReplaceTemplates (CUI_RES( STR_REPLACE_TEMPLATES)), 483 sDelSpaceAtSttEnd (CUI_RES( STR_DEL_SPACES_AT_STT_END)), 484 sDelSpaceBetweenLines(CUI_RES(STR_DEL_SPACES_BETWEEN_LINES)), 485 486 nPercent ( 50 ), 487 pCheckButtonData( NULL ) 488 489 { 490 FreeResource(); 491 492 //typ. Anfuehrungszeichen einsetzen 493 SvtSysLocale aSysLcl; 494 495 aCheckLB.SetHelpId(HID_OFAPAGE_AUTOFORMAT_CLB); 496 aCheckLB.SetStyle(aCheckLB.GetStyle()|WB_HSCROLL| WB_VSCROLL); 497 498 aCheckLB.SetSelectHdl(LINK(this, OfaSwAutoFmtOptionsPage, SelectHdl)); 499 aCheckLB.SetDoubleClickHdl(LINK(this, OfaSwAutoFmtOptionsPage, EditHdl)); 500 501 static long aStaticTabs[]= 502 { 503 3, 0, 20, 40 504 }; 505 506 aCheckLB.SvxSimpleTable::SetTabs(aStaticTabs); 507 String sHeader( sHeader1 ); 508 sHeader += '\t'; 509 sHeader += sHeader2; 510 sHeader += '\t'; 511 aCheckLB.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, 512 HIB_CENTER | HIB_VCENTER | HIB_FIXEDPOS | HIB_FIXED); 513 514 aEditPB.SetClickHdl(LINK(this, OfaSwAutoFmtOptionsPage, EditHdl)); 515 } 516 517 /*********************************************************************/ 518 /* */ 519 /*********************************************************************/ 520 521 SvLBoxEntry* OfaSwAutoFmtOptionsPage::CreateEntry(String& rTxt, sal_uInt16 nCol) 522 { 523 SvLBoxEntry* pEntry = new SvLBoxEntry; 524 525 if ( !pCheckButtonData ) 526 { 527 pCheckButtonData = new SvLBoxButtonData( &aCheckLB ); 528 aCheckLB.SetCheckButtonData( pCheckButtonData ); 529 } 530 531 pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); // Sonst Puff! 532 533 String sEmpty; 534 if (nCol == CBCOL_SECOND) 535 pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte 536 else 537 pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) ); 538 539 if (nCol == CBCOL_FIRST) 540 pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte 541 else 542 pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) ); 543 pEntry->AddItem( new OfaImpBrwString( pEntry, 0, rTxt ) ); 544 545 return pEntry; 546 } 547 548 /*********************************************************************/ 549 /* */ 550 /*********************************************************************/ 551 552 553 __EXPORT OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage() 554 { 555 delete (ImpUserData*) aCheckLB.GetUserData( REPLACE_BULLETS ); 556 delete (ImpUserData*) aCheckLB.GetUserData( APPLY_NUMBERING ); 557 delete (ImpUserData*) aCheckLB.GetUserData( MERGE_SINGLE_LINE_PARA ); 558 delete pCheckButtonData; 559 } 560 561 /*********************************************************************/ 562 /* */ 563 /*********************************************************************/ 564 565 SfxTabPage* __EXPORT OfaSwAutoFmtOptionsPage::Create( Window* pParent, 566 const SfxItemSet& rAttrSet) 567 { 568 return new OfaSwAutoFmtOptionsPage(pParent, rAttrSet); 569 } 570 571 /*********************************************************************/ 572 /* */ 573 /*********************************************************************/ 574 575 sal_Bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet& ) 576 { 577 sal_Bool bModified = sal_False; 578 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 579 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 580 long nFlags = pAutoCorrect->GetFlags(); 581 582 sal_Bool bCheck = aCheckLB.IsChecked(USE_REPLACE_TABLE, CBCOL_FIRST); 583 bModified |= pOpt->bAutoCorrect != bCheck; 584 pOpt->bAutoCorrect = bCheck; 585 pAutoCorrect->SetAutoCorrFlag(Autocorrect, 586 aCheckLB.IsChecked(USE_REPLACE_TABLE, CBCOL_SECOND)); 587 588 bCheck = aCheckLB.IsChecked(CORR_UPPER, CBCOL_FIRST); 589 bModified |= pOpt->bCptlSttWrd != bCheck; 590 pOpt->bCptlSttWrd = bCheck; 591 pAutoCorrect->SetAutoCorrFlag(CptlSttWrd, 592 aCheckLB.IsChecked(CORR_UPPER, CBCOL_SECOND)); 593 594 bCheck = aCheckLB.IsChecked(BEGIN_UPPER, CBCOL_FIRST); 595 bModified |= pOpt->bCptlSttSntnc != bCheck; 596 pOpt->bCptlSttSntnc = bCheck; 597 pAutoCorrect->SetAutoCorrFlag(CptlSttSntnc, 598 aCheckLB.IsChecked(BEGIN_UPPER, CBCOL_SECOND)); 599 600 bCheck = aCheckLB.IsChecked(BOLD_UNDERLINE, CBCOL_FIRST); 601 bModified |= pOpt->bChgWeightUnderl != bCheck; 602 pOpt->bChgWeightUnderl = bCheck; 603 pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl, 604 aCheckLB.IsChecked(BOLD_UNDERLINE, CBCOL_SECOND)); 605 606 pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace, 607 aCheckLB.IsChecked(IGNORE_DBLSPACE, CBCOL_SECOND)); 608 609 bCheck = aCheckLB.IsChecked(DETECT_URL, CBCOL_FIRST); 610 bModified |= pOpt->bSetINetAttr != bCheck; 611 pOpt->bSetINetAttr = bCheck; 612 pAutoCorrect->SetAutoCorrFlag(SetINetAttr, 613 aCheckLB.IsChecked(DETECT_URL, CBCOL_SECOND)); 614 615 bCheck = aCheckLB.IsChecked(DEL_EMPTY_NODE, CBCOL_FIRST); 616 bModified |= pOpt->bDelEmptyNode != bCheck; 617 pOpt->bDelEmptyNode = bCheck; 618 619 bCheck = aCheckLB.IsChecked(REPLACE_USER_COLL, CBCOL_FIRST); 620 bModified |= pOpt->bChgUserColl != bCheck; 621 pOpt->bChgUserColl = bCheck; 622 623 bCheck = aCheckLB.IsChecked(REPLACE_BULLETS, CBCOL_FIRST); 624 bModified |= pOpt->bChgEnumNum != bCheck; 625 pOpt->bChgEnumNum = bCheck; 626 bModified |= aBulletFont != pOpt->aBulletFont; 627 pOpt->aBulletFont = aBulletFont; 628 bModified |= String(pOpt->cBullet) != sBulletChar; 629 pOpt->cBullet = sBulletChar.GetChar(0); 630 631 bModified |= aByInputBulletFont != pOpt->aByInputBulletFont; 632 bModified |= String(pOpt->cByInputBullet) != sByInputBulletChar; 633 pOpt->aByInputBulletFont = aByInputBulletFont; 634 pOpt->cByInputBullet = sByInputBulletChar.GetChar(0); 635 636 bCheck = aCheckLB.IsChecked(MERGE_SINGLE_LINE_PARA, CBCOL_FIRST); 637 bModified |= pOpt->bRightMargin != bCheck; 638 pOpt->bRightMargin = bCheck; 639 bModified |= nPercent != pOpt->nRightMargin; 640 pOpt->nRightMargin = (sal_uInt8)nPercent; 641 642 bCheck = aCheckLB.IsChecked(APPLY_NUMBERING, CBCOL_SECOND); 643 bModified |= pOpt->bSetNumRule != bCheck; 644 pOpt->bSetNumRule = bCheck; 645 646 bCheck = aCheckLB.IsChecked(INSERT_BORDER, CBCOL_SECOND); 647 bModified |= pOpt->bSetBorder != bCheck; 648 pOpt->bSetBorder = bCheck; 649 650 bCheck = aCheckLB.IsChecked(CREATE_TABLE, CBCOL_SECOND); 651 bModified |= pOpt->bCreateTable != bCheck; 652 pOpt->bCreateTable = bCheck; 653 654 bCheck = aCheckLB.IsChecked(REPLACE_STYLES, CBCOL_SECOND); 655 bModified |= pOpt->bReplaceStyles != bCheck; 656 pOpt->bReplaceStyles = bCheck; 657 658 bCheck = aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_FIRST); 659 bModified |= pOpt->bChgToEnEmDash != bCheck; 660 pOpt->bChgToEnEmDash = bCheck; 661 pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, 662 aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_SECOND)); 663 664 bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_FIRST); 665 bModified |= pOpt->bAFmtDelSpacesAtSttEnd != bCheck; 666 pOpt->bAFmtDelSpacesAtSttEnd = bCheck; 667 bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_SECOND); 668 bModified |= pOpt->bAFmtByInpDelSpacesAtSttEnd != bCheck; 669 pOpt->bAFmtByInpDelSpacesAtSttEnd = bCheck; 670 671 bCheck = aCheckLB.IsChecked(DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST); 672 bModified |= pOpt->bAFmtDelSpacesBetweenLines != bCheck; 673 pOpt->bAFmtDelSpacesBetweenLines = bCheck; 674 bCheck = aCheckLB.IsChecked(DEL_SPACES_BETWEEN_LINES, CBCOL_SECOND); 675 bModified |= pOpt->bAFmtByInpDelSpacesBetweenLines != bCheck; 676 pOpt->bAFmtByInpDelSpacesBetweenLines = bCheck; 677 678 if(bModified || nFlags != pAutoCorrect->GetFlags()) 679 { 680 SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get(); 681 pCfg->SetModified(); 682 pCfg->Commit(); 683 } 684 685 return sal_True; 686 } 687 688 /* -----------------23.11.98 16:15------------------- 689 * 690 * --------------------------------------------------*/ 691 void OfaSwAutoFmtOptionsPage::ActivatePage( const SfxItemSet& ) 692 { 693 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False); 694 } 695 696 /*********************************************************************/ 697 /* */ 698 /*********************************************************************/ 699 700 701 void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& ) 702 { 703 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 704 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 705 const long nFlags = pAutoCorrect->GetFlags(); 706 707 aCheckLB.SetUpdateMode(sal_False); 708 aCheckLB.Clear(); 709 710 // Die folgenden Eintraege muessen in der selben Reihenfolge, wie im 711 // OfaAutoFmtOptions-enum eingefuegt werden! 712 aCheckLB.GetModel()->Insert(CreateEntry(sUseReplaceTbl, CBCOL_BOTH )); 713 aCheckLB.GetModel()->Insert(CreateEntry(sCptlSttWord, CBCOL_BOTH )); 714 aCheckLB.GetModel()->Insert(CreateEntry(sCptlSttSent, CBCOL_BOTH )); 715 aCheckLB.GetModel()->Insert(CreateEntry(sBoldUnder, CBCOL_BOTH )); 716 aCheckLB.GetModel()->Insert(CreateEntry(sDetectURL, CBCOL_BOTH )); 717 aCheckLB.GetModel()->Insert(CreateEntry(sDash, CBCOL_BOTH )); 718 aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH )); 719 aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH )); 720 721 aCheckLB.GetModel()->Insert(CreateEntry(sNoDblSpaces, CBCOL_SECOND)); 722 aCheckLB.GetModel()->Insert(CreateEntry(sNum, CBCOL_SECOND)); 723 aCheckLB.GetModel()->Insert(CreateEntry(sBorder, CBCOL_SECOND)); 724 aCheckLB.GetModel()->Insert(CreateEntry(sTable, CBCOL_SECOND)); 725 aCheckLB.GetModel()->Insert(CreateEntry(sReplaceTemplates, CBCOL_SECOND)); 726 aCheckLB.GetModel()->Insert(CreateEntry(sDeleteEmptyPara, CBCOL_FIRST )); 727 aCheckLB.GetModel()->Insert(CreateEntry(sUserStyle, CBCOL_FIRST )); 728 aCheckLB.GetModel()->Insert(CreateEntry(sBullet, CBCOL_FIRST )); 729 aCheckLB.GetModel()->Insert(CreateEntry(sRightMargin, CBCOL_FIRST )); 730 731 aCheckLB.CheckEntryPos( USE_REPLACE_TABLE, CBCOL_FIRST, pOpt->bAutoCorrect ); 732 aCheckLB.CheckEntryPos( USE_REPLACE_TABLE, CBCOL_SECOND, 0 != (nFlags & Autocorrect)); 733 aCheckLB.CheckEntryPos( CORR_UPPER, CBCOL_FIRST, pOpt->bCptlSttWrd ); 734 aCheckLB.CheckEntryPos( CORR_UPPER, CBCOL_SECOND, 0 != (nFlags & CptlSttWrd) ); 735 aCheckLB.CheckEntryPos( BEGIN_UPPER, CBCOL_FIRST, pOpt->bCptlSttSntnc ); 736 aCheckLB.CheckEntryPos( BEGIN_UPPER, CBCOL_SECOND, 0 != (nFlags & CptlSttSntnc) ); 737 aCheckLB.CheckEntryPos( BOLD_UNDERLINE, CBCOL_FIRST, pOpt->bChgWeightUnderl ); 738 aCheckLB.CheckEntryPos( BOLD_UNDERLINE, CBCOL_SECOND, 0 != (nFlags & ChgWeightUnderl) ); 739 aCheckLB.CheckEntryPos( IGNORE_DBLSPACE, CBCOL_SECOND, 0 != (nFlags & IgnoreDoubleSpace) ); 740 aCheckLB.CheckEntryPos( DETECT_URL, CBCOL_FIRST, pOpt->bSetINetAttr ); 741 aCheckLB.CheckEntryPos( DETECT_URL, CBCOL_SECOND, 0 != (nFlags & SetINetAttr) ); 742 aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_FIRST, pOpt->bChgToEnEmDash ); 743 aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, 0 != (nFlags & ChgToEnEmDash) ); 744 aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_FIRST, pOpt->bAFmtDelSpacesAtSttEnd ); 745 aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesAtSttEnd ); 746 aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST, pOpt->bAFmtDelSpacesBetweenLines ); 747 aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesBetweenLines ); 748 aCheckLB.CheckEntryPos( DEL_EMPTY_NODE, CBCOL_FIRST, pOpt->bDelEmptyNode ); 749 aCheckLB.CheckEntryPos( REPLACE_USER_COLL, CBCOL_FIRST, pOpt->bChgUserColl ); 750 aCheckLB.CheckEntryPos( REPLACE_BULLETS, CBCOL_FIRST, pOpt->bChgEnumNum ); 751 752 aBulletFont = pOpt->aBulletFont; 753 sBulletChar = pOpt->cBullet; 754 ImpUserData* pUserData = new ImpUserData(&sBulletChar, &aBulletFont); 755 aCheckLB.SetUserData( REPLACE_BULLETS, pUserData ); 756 757 nPercent = pOpt->nRightMargin; 758 sMargin = ' '; 759 sMargin += String::CreateFromInt32( nPercent ); 760 sMargin += '%'; 761 pUserData = new ImpUserData(&sMargin, 0); 762 aCheckLB.SetUserData( MERGE_SINGLE_LINE_PARA, pUserData ); 763 764 aCheckLB.CheckEntryPos( APPLY_NUMBERING, CBCOL_SECOND, pOpt->bSetNumRule ); 765 766 aByInputBulletFont = pOpt->aByInputBulletFont; 767 sByInputBulletChar = pOpt->cByInputBullet; 768 ImpUserData* pUserData2 = new ImpUserData(&sByInputBulletChar, &aByInputBulletFont); 769 aCheckLB.SetUserData( APPLY_NUMBERING , pUserData2 ); 770 771 aCheckLB.CheckEntryPos( MERGE_SINGLE_LINE_PARA, CBCOL_FIRST, pOpt->bRightMargin ); 772 aCheckLB.CheckEntryPos( INSERT_BORDER, CBCOL_SECOND, pOpt->bSetBorder ); 773 aCheckLB.CheckEntryPos( CREATE_TABLE, CBCOL_SECOND, pOpt->bCreateTable ); 774 aCheckLB.CheckEntryPos( REPLACE_STYLES, CBCOL_SECOND, pOpt->bReplaceStyles ); 775 776 aCheckLB.SetUpdateMode(sal_True); 777 } 778 779 /*********************************************************************/ 780 /* */ 781 /*********************************************************************/ 782 783 IMPL_LINK(OfaSwAutoFmtOptionsPage, SelectHdl, OfaACorrCheckListBox*, pBox) 784 { 785 aEditPB.Enable(0 != pBox->FirstSelected()->GetUserData()); 786 return 0; 787 } 788 789 /*********************************************************************/ 790 /* */ 791 /*********************************************************************/ 792 793 IMPL_LINK(OfaSwAutoFmtOptionsPage, EditHdl, PushButton*, EMPTYARG) 794 { 795 sal_uLong nSelEntryPos = aCheckLB.GetSelectEntryPos(); 796 if( nSelEntryPos == REPLACE_BULLETS || 797 nSelEntryPos == APPLY_NUMBERING) 798 { 799 SvxCharacterMap *pMapDlg = new SvxCharacterMap(this); 800 ImpUserData* pUserData = (ImpUserData*)aCheckLB.FirstSelected()->GetUserData(); 801 pMapDlg->SetCharFont(*pUserData->pFont); 802 pMapDlg->SetChar( pUserData->pString->GetChar(0) ); 803 if(RET_OK == pMapDlg->Execute()) 804 { 805 Font aFont(pMapDlg->GetCharFont()); 806 *pUserData->pFont = aFont; 807 sal_UCS4 aChar = pMapDlg->GetChar(); 808 // using the UCS4 constructor 809 rtl::OUString aOUStr( &aChar, 1 ); 810 *pUserData->pString = aOUStr; 811 } 812 delete pMapDlg; 813 } 814 else if( MERGE_SINGLE_LINE_PARA == nSelEntryPos ) 815 { 816 // Dialog fuer Prozenteinstellung 817 OfaAutoFmtPrcntSet aDlg(this); 818 aDlg.GetPrcntFld().SetValue(nPercent); 819 if(RET_OK == aDlg.Execute()) 820 { 821 nPercent = (sal_uInt16)aDlg.GetPrcntFld().GetValue(); 822 sMargin = ' '; 823 sMargin += String::CreateFromInt32( nPercent ); 824 sMargin += '%'; 825 } 826 } 827 aCheckLB.Invalidate(); 828 return 0; 829 } 830 831 /*********************************************************************/ 832 /* */ 833 /*********************************************************************/ 834 835 void OfaACorrCheckListBox::SetTabs() 836 { 837 SvxSimpleTable::SetTabs(); 838 sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE; 839 840 if( aTabs.Count() > 1 ) 841 { 842 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(1); 843 pTab->nFlags &= ~nAdjust; 844 pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; 845 } 846 if( aTabs.Count() > 2 ) 847 { 848 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(2); 849 pTab->nFlags &= ~nAdjust; 850 pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; 851 } 852 } 853 854 /*********************************************************************/ 855 /* */ 856 /*********************************************************************/ 857 858 void OfaACorrCheckListBox::CheckEntryPos(sal_uLong nPos, sal_uInt16 nCol, sal_Bool bChecked) 859 { 860 if ( nPos < GetEntryCount() ) 861 SetCheckButtonState( 862 GetEntry(nPos), 863 nCol, 864 bChecked ? SvButtonState( SV_BUTTON_CHECKED ) : 865 SvButtonState( SV_BUTTON_UNCHECKED ) ); 866 } 867 868 /*********************************************************************/ 869 /* */ 870 /*********************************************************************/ 871 872 sal_Bool OfaACorrCheckListBox::IsChecked(sal_uLong nPos, sal_uInt16 nCol) 873 { 874 return GetCheckButtonState( GetEntry(nPos), nCol ) == SV_BUTTON_CHECKED; 875 } 876 877 /*********************************************************************/ 878 /* */ 879 /*********************************************************************/ 880 881 void OfaACorrCheckListBox::SetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol, SvButtonState eState) 882 { 883 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1)); 884 885 DBG_ASSERT(pItem,"SetCheckButton:Item not found"); 886 if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON) 887 { 888 switch( eState ) 889 { 890 case SV_BUTTON_CHECKED: 891 pItem->SetStateChecked(); 892 break; 893 894 case SV_BUTTON_UNCHECKED: 895 pItem->SetStateUnchecked(); 896 break; 897 898 case SV_BUTTON_TRISTATE: 899 pItem->SetStateTristate(); 900 break; 901 } 902 InvalidateEntry( pEntry ); 903 } 904 } 905 906 /*********************************************************************/ 907 /* */ 908 /*********************************************************************/ 909 910 SvButtonState OfaACorrCheckListBox::GetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const 911 { 912 SvButtonState eState = SV_BUTTON_UNCHECKED; 913 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1)); 914 DBG_ASSERT(pItem,"GetChButnState:Item not found"); 915 916 if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON) 917 { 918 sal_uInt16 nButtonFlags = pItem->GetButtonFlags(); 919 eState = pCheckButtonData->ConvertToButtonState( nButtonFlags ); 920 } 921 922 return eState; 923 } 924 925 void OfaACorrCheckListBox::HBarClick() 926 { 927 // Sortierung durch diese Ueberladung abgeklemmt 928 } 929 /* -----------------------------22.05.2002 11:06------------------------------ 930 931 ---------------------------------------------------------------------------*/ 932 void OfaACorrCheckListBox::KeyInput( const KeyEvent& rKEvt ) 933 { 934 if(!rKEvt.GetKeyCode().GetModifier() && 935 KEY_SPACE == rKEvt.GetKeyCode().GetCode()) 936 { 937 sal_uLong nSelPos = GetSelectEntryPos(); 938 sal_uInt16 nCol = GetCurrentTabPos() - 1; 939 if ( nCol < 2 ) 940 { 941 CheckEntryPos( nSelPos, nCol, !IsChecked( nSelPos, nCol ) ); 942 CallImplEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)GetEntry( nSelPos ) ); 943 } 944 else 945 { 946 sal_uInt16 nCheck = IsChecked(nSelPos, 1) ? 1 : 0; 947 if(IsChecked(nSelPos, 0)) 948 nCheck += 2; 949 nCheck--; 950 nCheck &= 3; 951 CheckEntryPos(nSelPos, 1, 0 != (nCheck & 1)); 952 CheckEntryPos(nSelPos, 0, 0 != (nCheck & 2)); 953 } 954 } 955 else 956 SvxSimpleTable::KeyInput(rKEvt); 957 } 958 /* -----------------19.11.98 15:57------------------- 959 * 960 * --------------------------------------------------*/ 961 struct DoubleString 962 { 963 String sShort; 964 String sLong; 965 void* pUserData; // CheckBox -> form. Text Bool -> Selektionstext 966 }; 967 typedef DoubleString* DoubleStringPtr; 968 SV_DECL_PTRARR_DEL(DoubleStringArray, DoubleStringPtr, 4, 4) 969 SV_IMPL_PTRARR(DoubleStringArray, DoubleStringPtr); 970 971 /* -----------------19.11.98 16:07------------------- 972 * 973 * --------------------------------------------------*/ 974 void lcl_ClearTable(DoubleStringTable& rTable) 975 { 976 DoubleStringArrayPtr pArray = rTable.Last(); 977 while(pArray) 978 { 979 pArray->DeleteAndDestroy(0, pArray->Count()); 980 delete pArray; 981 pArray = rTable.Prev(); 982 } 983 rTable.Clear(); 984 } 985 986 /*-----------------14.10.96 15.57------------------- 987 988 --------------------------------------------------*/ 989 990 OfaAutocorrReplacePage::OfaAutocorrReplacePage( Window* pParent, 991 const SfxItemSet& rSet ) : 992 SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_REPLACE ), rSet), 993 aTextOnlyCB( this, CUI_RES(CB_TEXT_ONLY )), 994 aShortFT ( this, CUI_RES(FT_SHORT )), 995 aShortED ( this, CUI_RES(ED_SHORT )), 996 aReplaceFT( this, CUI_RES(FT_REPLACE )), 997 aReplaceED( this, CUI_RES(ED_REPLACE )), 998 aReplaceTLB( this, CUI_RES(TLB_REPLACE )), 999 aNewReplacePB( this, CUI_RES(PB_NEW_REPLACE )), 1000 aDeleteReplacePB(this,CUI_RES(PB_DELETE_REPLACE )), 1001 sModify(CUI_RES(STR_MODIFY)), 1002 sNew(aNewReplacePB.GetText()), 1003 pFormatText(0), 1004 eLang(eLastDialogLanguage), 1005 bHasSelectionText(sal_False), 1006 bFirstSelect(sal_True), 1007 bReplaceEditChanged(sal_False), 1008 bSWriter(sal_True) 1009 { 1010 FreeResource(); 1011 SfxModule *pMod = *(SfxModule**)GetAppData(SHL_WRITER); 1012 bSWriter = pMod == SfxModule::GetActiveModule(); 1013 1014 ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage )); 1015 pCompareClass = new CollatorWrapper( GetProcessFact() ); 1016 pCompareCaseClass = new CollatorWrapper( GetProcessFact() ); 1017 pCompareClass->loadDefaultCollator( aLcl, ::com::sun::star::i18n:: 1018 CollatorOptions::CollatorOptions_IGNORE_CASE ); 1019 pCompareCaseClass->loadDefaultCollator( aLcl, 0 ); 1020 pCharClass = new CharClass( aLcl ); 1021 1022 static long nTabs[] = { 2 /* Tab-Count */, 1, 61 }; 1023 aReplaceTLB.SetTabs( &nTabs[0], MAP_APPFONT ); 1024 1025 aReplaceTLB.SetStyle(aReplaceTLB.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN); 1026 aReplaceTLB.SetSelectHdl(LINK(this, OfaAutocorrReplacePage, SelectHdl)); 1027 aNewReplacePB.SetClickHdl( LINK(this, OfaAutocorrReplacePage, NewDelHdl)); 1028 aDeleteReplacePB.SetClickHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl)); 1029 aShortED.SetModifyHdl(LINK(this, OfaAutocorrReplacePage, ModifyHdl)); 1030 aReplaceED.SetModifyHdl(LINK(this, OfaAutocorrReplacePage, ModifyHdl)); 1031 aShortED.SetActionHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl)); 1032 aReplaceED.SetActionHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl)); 1033 1034 aReplaceED.SetSpaces(sal_True); 1035 aShortED.SetSpaces(sal_True); 1036 aShortED.SetMaxTextLen(30); 1037 } 1038 1039 /*-----------------14.10.96 15.58------------------- 1040 1041 --------------------------------------------------*/ 1042 1043 1044 OfaAutocorrReplacePage::~OfaAutocorrReplacePage() 1045 { 1046 delete pFormatText; 1047 lcl_ClearTable(aDoubleStringTable); 1048 delete pCompareClass; 1049 delete pCompareCaseClass; 1050 delete pCharClass; 1051 } 1052 /*-----------------14.10.96 15.58------------------- 1053 1054 --------------------------------------------------*/ 1055 1056 SfxTabPage* OfaAutocorrReplacePage::Create( Window* pParent, 1057 const SfxItemSet& rSet) 1058 { 1059 return new OfaAutocorrReplacePage(pParent, rSet); 1060 } 1061 /* -----------------20.11.98 13:26------------------- 1062 * 1063 * --------------------------------------------------*/ 1064 void OfaAutocorrReplacePage::ActivatePage( const SfxItemSet& ) 1065 { 1066 if(eLang != eLastDialogLanguage) 1067 SetLanguage(eLastDialogLanguage); 1068 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_True); 1069 } 1070 /* -----------------20.11.98 13:26------------------- 1071 * 1072 * --------------------------------------------------*/ 1073 int OfaAutocorrReplacePage::DeactivatePage( SfxItemSet* ) 1074 { 1075 return LEAVE_PAGE; 1076 } 1077 /*-----------------14.10.96 15.58------------------- 1078 1079 --------------------------------------------------*/ 1080 1081 sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& ) 1082 { 1083 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 1084 DoubleStringArrayPtr pDoubleStringArray = aDoubleStringTable.Last(); 1085 while(pDoubleStringArray) 1086 { 1087 LanguageType eCurLang = (LanguageType)aDoubleStringTable.GetCurKey(); 1088 if(eCurLang != eLang) // die aktuelle Sprache wird weiter hinten behandelt 1089 { 1090 SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eCurLang); 1091 sal_uInt16 nWordListCount = pWordList->Count(); 1092 sal_uInt16 nDoubleStringArrayCount = pDoubleStringArray->Count(); 1093 sal_uInt16 nPos = nDoubleStringArrayCount; 1094 sal_uInt16 nLastPos = nPos; 1095 // 1. Durchlauf: Eintraege loeschen oder veraendern: 1096 1097 1098 for( sal_uInt16 nWordListPos = nWordListCount; nWordListPos; nWordListPos-- ) 1099 { 1100 SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(nWordListPos - 1); 1101 String sEntry(pWordPtr->GetShort()); 1102 // formatierter Text steht nur im Writer 1103 sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly(); 1104 while(!bFound && nPos) 1105 { 1106 DoubleString* pDouble = pDoubleStringArray->GetObject( nPos - 1); 1107 1108 if( 0 == pCompareClass->compareString( 1109 sEntry, pDouble->sShort )) 1110 { 1111 nLastPos = nPos - 1; 1112 bFound = sal_True; 1113 if( !(pWordPtr->IsTextOnly() == (0 == pDouble->pUserData) 1114 && 0 == pCompareCaseClass->compareString( 1115 pWordPtr->GetLong(), pDouble->sLong ) ) ) 1116 { 1117 pAutoCorrect->PutText(sEntry, pDouble->sLong, eCurLang); 1118 } 1119 pDoubleStringArray->DeleteAndDestroy(nPos - 1, 1); 1120 break; 1121 } 1122 nPos--; 1123 } 1124 nPos = nLastPos; 1125 if(!bFound) 1126 { 1127 pAutoCorrect->DeleteText(sEntry, eCurLang); 1128 } 1129 } 1130 nDoubleStringArrayCount = pDoubleStringArray->Count(); 1131 for(sal_uInt16 nDoubleStringArrayPos = 0; nDoubleStringArrayPos < nDoubleStringArrayCount; nDoubleStringArrayPos++ ) 1132 { 1133 //jetzt sollte es nur noch neue Eintraege geben 1134 DoubleString* pDouble = pDoubleStringArray->GetObject( nDoubleStringArrayPos ); 1135 if(pDouble->pUserData == &bHasSelectionText) 1136 pAutoCorrect->PutText( pDouble->sShort, 1137 *SfxObjectShell::Current(), eCurLang ); 1138 else 1139 { 1140 pAutoCorrect->PutText( pDouble->sShort, pDouble->sLong, 1141 eCurLang); 1142 } 1143 } 1144 } 1145 pDoubleStringArray->DeleteAndDestroy(0, pDoubleStringArray->Count()); 1146 delete pDoubleStringArray; 1147 pDoubleStringArray = aDoubleStringTable.Prev(); 1148 } 1149 aDoubleStringTable.Clear(); 1150 // jetzt noch die aktuelle Selektion 1151 SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang); 1152 sal_uInt16 nWordListCount = pWordList->Count(); 1153 sal_uInt16 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount(); 1154 1155 aReplaceTLB.SetUpdateMode(sal_False); 1156 sal_uInt16 nListBoxPos = nListBoxCount; 1157 sal_uInt16 nLastListBoxPos = nListBoxPos; 1158 // 1. Durchlauf: Eintraege loeschen oder veraendern: 1159 1160 sal_uInt16 i; 1161 for( i = nWordListCount; i; i-- ) 1162 { 1163 SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(i- 1); 1164 String sEntry(pWordPtr->GetShort()); 1165 // formatierter Text steht nur im Writer 1166 sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly(); 1167 while(!bFound && nListBoxPos) 1168 { 1169 SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( nListBoxPos - 1); 1170 if( 0 == pCompareClass->compareString( sEntry, 1171 aReplaceTLB.GetEntryText(pEntry, 0))) 1172 { 1173 nLastListBoxPos = nListBoxPos - 1; 1174 bFound = sal_True; 1175 String sLong = aReplaceTLB.GetEntryText(pEntry, 1); 1176 if( !(pWordPtr->IsTextOnly() == (0 == pEntry->GetUserData()) 1177 && 0 == pCompareCaseClass->compareString( 1178 pWordPtr->GetLong(), sLong ))) 1179 { 1180 pAutoCorrect->PutText(sEntry, sLong, eLang); 1181 } 1182 aReplaceTLB.GetModel()->Remove(pEntry); 1183 break; 1184 1185 } 1186 nListBoxPos --; 1187 } 1188 nListBoxPos = nLastListBoxPos; 1189 if(!bFound) 1190 { 1191 pAutoCorrect->DeleteText(sEntry, eLang); 1192 } 1193 1194 } 1195 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount(); 1196 for(i = 0; i < nListBoxCount; i++ ) 1197 { 1198 //jetzt sollte es nur noch neue Eintraege geben 1199 SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i ); 1200 String sShort = aReplaceTLB.GetEntryText(pEntry, 0); 1201 if(pEntry->GetUserData() == &bHasSelectionText) 1202 pAutoCorrect->PutText(sShort, *SfxObjectShell::Current(), eLang); 1203 else 1204 { 1205 String sLong = aReplaceTLB.GetEntryText(pEntry, 1); 1206 pAutoCorrect->PutText(sShort, sLong, eLang); 1207 } 1208 } 1209 1210 return sal_False; 1211 } 1212 1213 /* -----------------19.11.98 13:16------------------- 1214 * 1215 * --------------------------------------------------*/ 1216 void OfaAutocorrReplacePage::RefillReplaceBox(sal_Bool bFromReset, 1217 LanguageType eOldLanguage, 1218 LanguageType eNewLanguage) 1219 { 1220 eLang = eNewLanguage; 1221 if(bFromReset) 1222 lcl_ClearTable(aDoubleStringTable); 1223 else 1224 { 1225 DoubleStringArray* pArray = 0; 1226 if(aDoubleStringTable.IsKeyValid(eOldLanguage)) 1227 { 1228 pArray = aDoubleStringTable.Seek(sal_uLong(eOldLanguage)); 1229 pArray->DeleteAndDestroy(0, pArray->Count()); 1230 } 1231 else 1232 { 1233 pArray = new DoubleStringArray; 1234 aDoubleStringTable.Insert(sal_uLong(eOldLanguage), pArray); 1235 } 1236 1237 sal_uInt16 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount(); 1238 sal_uInt16 i; 1239 for(i = 0; i < nListBoxCount; i++) 1240 { 1241 DoubleString* pDouble = new DoubleString(); 1242 SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i ); 1243 pDouble->sShort = aReplaceTLB.GetEntryText(pEntry, 0); 1244 pDouble->sLong = aReplaceTLB.GetEntryText(pEntry, 1); 1245 pDouble->pUserData = pEntry->GetUserData(); 1246 pArray->Insert(pDouble, i); 1247 } 1248 } 1249 1250 aReplaceTLB.Clear(); 1251 if(!bSWriter) 1252 { 1253 if(pFormatText) 1254 pFormatText->DeleteAndDestroy(0, pFormatText->Count()); 1255 else 1256 pFormatText = new SvStringsISortDtor(); 1257 } 1258 1259 if(aDoubleStringTable.IsKeyValid(eLang)) 1260 { 1261 DoubleStringArray* pArray = aDoubleStringTable.Seek(sal_uLong(eNewLanguage)); 1262 for(sal_uInt16 i = 0; i < pArray->Count(); i++) 1263 { 1264 DoubleString* pDouble = pArray->GetObject(i); 1265 sal_Bool bTextOnly = 0 == pDouble->pUserData; 1266 // formatierter Text wird nur im Writer angeboten 1267 if(bSWriter || bTextOnly) 1268 { 1269 String sEntry(pDouble->sShort); 1270 sEntry += '\t'; 1271 sEntry += pDouble->sLong; 1272 SvLBoxEntry* pEntry = aReplaceTLB.InsertEntry(sEntry); 1273 aTextOnlyCB.Check(bTextOnly); 1274 if(!bTextOnly) 1275 pEntry->SetUserData(pDouble->pUserData); // Das heisst: mit Formatinfo oder sogar mit Selektionstext 1276 } 1277 else 1278 { 1279 pFormatText->Insert(new String(pDouble->sShort)); 1280 } 1281 } 1282 } 1283 else 1284 { 1285 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 1286 SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang); 1287 1288 for(sal_uInt16 i = 0; i < pWordList->Count(); i++) 1289 { 1290 SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(i); 1291 sal_Bool bTextOnly = pWordPtr->IsTextOnly(); 1292 // formatierter Text wird nur im Writer angeboten 1293 if(bSWriter || bTextOnly) 1294 { 1295 String sEntry(pWordPtr->GetShort()); 1296 sEntry += '\t'; 1297 sEntry += pWordPtr->GetLong(); 1298 SvLBoxEntry* pEntry = aReplaceTLB.InsertEntry(sEntry); 1299 aTextOnlyCB.Check(pWordPtr->IsTextOnly()); 1300 if(!bTextOnly) 1301 pEntry->SetUserData(&aTextOnlyCB); // Das heisst: mit Formatinfo 1302 } 1303 else 1304 { 1305 pFormatText->Insert(new String(pWordPtr->GetShort())); 1306 } 1307 } 1308 aNewReplacePB.Enable(sal_False); 1309 aDeleteReplacePB.Enable(sal_False); 1310 1311 } 1312 1313 SfxViewShell* pViewShell = SfxViewShell::Current(); 1314 if( pViewShell && pViewShell->HasSelection( sal_True ) ) 1315 { 1316 bHasSelectionText = sal_True; 1317 const String sSelection( pViewShell->GetSelectionText() ); 1318 aReplaceED.SetText( sSelection ); 1319 aTextOnlyCB.Check( !bSWriter ); 1320 aTextOnlyCB.Enable( bSWriter && sSelection.Len() ); 1321 } 1322 else 1323 aTextOnlyCB.Enable( sal_False ); 1324 } 1325 /*-----------------14.10.96 15.58------------------- 1326 1327 --------------------------------------------------*/ 1328 1329 void OfaAutocorrReplacePage::Reset( const SfxItemSet& ) 1330 { 1331 RefillReplaceBox(sal_True, eLang, eLang); 1332 aShortED.GrabFocus(); 1333 } 1334 1335 /* -----------------23.11.98 10:33------------------- 1336 * 1337 * --------------------------------------------------*/ 1338 void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet) 1339 { 1340 //save old settings an refill 1341 if(eSet != eLang) 1342 { 1343 RefillReplaceBox(sal_False, eLang, eSet); 1344 eLastDialogLanguage = eSet; 1345 delete pCompareClass; 1346 delete pCompareCaseClass; 1347 delete pCharClass; 1348 1349 ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage )); 1350 pCompareClass = new CollatorWrapper( GetProcessFact() ); 1351 pCompareCaseClass = new CollatorWrapper( GetProcessFact() ); 1352 pCompareClass->loadDefaultCollator( aLcl, ::com::sun::star::i18n:: 1353 CollatorOptions::CollatorOptions_IGNORE_CASE ); 1354 pCompareCaseClass->loadDefaultCollator( aLcl, 0 ); 1355 pCharClass = new CharClass( aLcl ); 1356 ModifyHdl(&aShortED); 1357 } 1358 } 1359 /*-----------------14.10.96 15.58------------------- 1360 1361 --------------------------------------------------*/ 1362 1363 1364 IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, SvTabListBox*, pBox) 1365 { 1366 if(!bFirstSelect || !bHasSelectionText) 1367 { 1368 SvLBoxEntry* pEntry = pBox->FirstSelected(); 1369 String sTmpShort(pBox->GetEntryText(pEntry, 0)); 1370 // wird der Text ueber den ModifyHdl gesetzt, dann steht der Cursor sonst immer am Wortanfang, 1371 // obwohl man gerade hier editiert 1372 sal_Bool bSameContent = 0 == pCompareClass->compareString( 1373 sTmpShort, aShortED.GetText() ); 1374 Selection aSel = aShortED.GetSelection(); 1375 if(aShortED.GetText() != sTmpShort) 1376 { 1377 aShortED.SetText(sTmpShort); 1378 //war es nur eine andere Schreibweise, dann muss die Selektion auch wieder gesetzt werden 1379 if(bSameContent) 1380 aShortED.SetSelection(aSel); 1381 } 1382 aReplaceED.SetText(pBox->GetEntryText(pEntry, 1)); 1383 // mit UserData gibt es eine Formatinfo 1384 aTextOnlyCB.Check(0 == pEntry->GetUserData()); 1385 } 1386 else 1387 bFirstSelect = sal_False; 1388 1389 aNewReplacePB.Enable(sal_False); 1390 aDeleteReplacePB.Enable(); 1391 return 0; 1392 }; 1393 1394 /*-----------------14.10.96 15.58------------------- 1395 1396 --------------------------------------------------*/ 1397 1398 1399 IMPL_LINK(OfaAutocorrReplacePage, NewDelHdl, PushButton*, pBtn) 1400 { 1401 SvLBoxEntry* _pEntry = aReplaceTLB.FirstSelected(); 1402 if(pBtn == &aDeleteReplacePB) 1403 { 1404 DBG_ASSERT(_pEntry, "keine Eintrag selektiert"); 1405 if(_pEntry) 1406 { 1407 aReplaceTLB.GetModel()->Remove(_pEntry); 1408 ModifyHdl(&aShortED); 1409 return 0; 1410 } 1411 } 1412 if(pBtn == &aNewReplacePB || aNewReplacePB.IsEnabled()) 1413 { 1414 SvLBoxEntry* _pNewEntry = aReplaceTLB.FirstSelected(); 1415 String sEntry(aShortED.GetText()); 1416 if(sEntry.Len() && ( aReplaceED.GetText().Len() || 1417 ( bHasSelectionText && bSWriter ) )) 1418 { 1419 aReplaceTLB.SetUpdateMode(sal_False); 1420 sal_uInt16 nPos = USHRT_MAX; 1421 sEntry += '\t'; 1422 sEntry += aReplaceED.GetText(); 1423 if(_pNewEntry) 1424 { 1425 nPos = (sal_uInt16)aReplaceTLB.GetModel()->GetAbsPos(_pNewEntry); 1426 aReplaceTLB.GetModel()->Remove(_pNewEntry); 1427 } 1428 else 1429 { 1430 sal_uInt16 j; 1431 for( j = 0; j < aReplaceTLB.GetEntryCount(); j++ ) 1432 { 1433 SvLBoxEntry* pReplaceEntry = aReplaceTLB.GetEntry(j); 1434 if( 0 >= pCompareClass->compareString(sEntry, 1435 aReplaceTLB.GetEntryText(pReplaceEntry, 0) ) ) 1436 break; 1437 } 1438 nPos = j; 1439 } 1440 SvLBoxEntry* pInsEntry = 1441 aReplaceTLB.InsertEntry( 1442 sEntry, static_cast< SvLBoxEntry * >(NULL), false, 1443 nPos == USHRT_MAX ? LIST_APPEND : nPos); 1444 if( !bReplaceEditChanged && !aTextOnlyCB.IsChecked()) 1445 pInsEntry->SetUserData(&bHasSelectionText); // neuer formatierter Text 1446 1447 aReplaceTLB.MakeVisible( pInsEntry ); 1448 aReplaceTLB.SetUpdateMode(sal_True); 1449 // falls der Request aus dem ReplaceEdit kam, dann Focus in das ShortEdit setzen 1450 if(aReplaceED.HasFocus()) 1451 aShortED.GrabFocus(); 1452 1453 } 1454 } 1455 else 1456 { 1457 // das kann nur ein Enter in einem der beiden Edit-Felder sein und das 1458 // bedeutet EndDialog() - muss im KeyInput ausgewertet werden 1459 return 0; 1460 } 1461 ModifyHdl(&aShortED); 1462 return 1; 1463 } 1464 1465 /*-----------------17.10.96 07.49------------------- 1466 1467 --------------------------------------------------*/ 1468 IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, Edit*, pEdt) 1469 { 1470 SvLBoxEntry* pFirstSel = aReplaceTLB.FirstSelected(); 1471 sal_Bool bShort = pEdt == &aShortED; 1472 const String rEntry = pEdt->GetText(); 1473 const String rRepString = aReplaceED.GetText(); 1474 String aWordStr( pCharClass->lower( rEntry )); 1475 1476 if(bShort) 1477 { 1478 if(rEntry.Len()) 1479 { 1480 sal_Bool bFound = sal_False; 1481 sal_Bool bTmpSelEntry=sal_False; 1482 1483 for(sal_uInt16 i = 0; i < aReplaceTLB.GetEntryCount(); i++) 1484 { 1485 SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i ); 1486 String aTestStr=aReplaceTLB.GetEntryText(pEntry, 0); 1487 if( 0 == pCompareClass->compareString(rEntry, aTestStr )) 1488 { 1489 if(rRepString.Len()) 1490 bFirstSelect = sal_True; 1491 aReplaceTLB.SetCurEntry(pEntry); 1492 pFirstSel = pEntry; 1493 aNewReplacePB.SetText(sModify); 1494 bFound= sal_True; 1495 break; 1496 } 1497 else 1498 { 1499 pCharClass->toLower( aTestStr ); 1500 if(aTestStr.Search(aWordStr)==0 && !bTmpSelEntry) 1501 { 1502 aReplaceTLB.MakeVisible(pEntry); 1503 bTmpSelEntry=sal_True; 1504 } 1505 } 1506 } 1507 if(!bFound) 1508 { 1509 aReplaceTLB.SelectAll(sal_False); 1510 pFirstSel = 0; 1511 aNewReplacePB.SetText(sNew); 1512 if(bReplaceEditChanged) 1513 aTextOnlyCB.Enable(sal_False); 1514 } 1515 aDeleteReplacePB.Enable(bFound); 1516 } 1517 else if(aReplaceTLB.GetEntryCount()>0) 1518 { 1519 SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( 0 ); 1520 aReplaceTLB.MakeVisible(pEntry); 1521 } 1522 1523 } 1524 else if(!bShort) 1525 { 1526 bReplaceEditChanged = sal_True; 1527 if(pFirstSel) 1528 { 1529 aNewReplacePB.SetText(sModify); 1530 } 1531 } 1532 1533 const String& rShortTxt = aShortED.GetText(); 1534 sal_Bool bEnableNew = rShortTxt.Len() && 1535 ( rRepString.Len() || 1536 ( bHasSelectionText && bSWriter )) && 1537 ( !pFirstSel || rRepString != 1538 aReplaceTLB.GetEntryText( pFirstSel, 1 ) ); 1539 if(bEnableNew && pFormatText) 1540 { 1541 for(sal_uInt16 i = 0; i < pFormatText->Count(); i++) 1542 if(*pFormatText->GetObject(i) == rShortTxt) 1543 { 1544 bEnableNew = sal_False; 1545 break; 1546 } 1547 } 1548 aNewReplacePB.Enable(bEnableNew); 1549 1550 return 0; 1551 } 1552 1553 /* -----------------20.11.98 13:48------------------- 1554 * 1555 * --------------------------------------------------*/ 1556 1557 struct StringsArrays 1558 { 1559 1560 SvStringsDtor aAbbrevStrings; 1561 SvStringsDtor aDoubleCapsStrings; 1562 1563 StringsArrays() : 1564 aAbbrevStrings(5,5), aDoubleCapsStrings(5,5) {} 1565 }; 1566 typedef StringsArrays* StringsArraysPtr; 1567 /* -----------------19.11.98 16:07------------------- 1568 * 1569 * --------------------------------------------------*/ 1570 sal_Bool lcl_FindInArray(SvStringsDtor& rStrings, const String& rString) 1571 { 1572 for(sal_uInt16 i = 0; i < rStrings.Count(); i++) 1573 if(rString == *rStrings.GetObject(i)) 1574 return sal_True; 1575 return sal_False; 1576 } 1577 1578 void lcl_ClearTable(StringsTable& rTable) 1579 { 1580 StringsArraysPtr pArrays = rTable.Last(); 1581 while(pArrays) 1582 { 1583 delete pArrays; 1584 pArrays = rTable.Prev(); 1585 } 1586 rTable.Clear(); 1587 } 1588 1589 /*-----------------14.10.96 15.57------------------- 1590 1591 --------------------------------------------------*/ 1592 1593 OfaAutocorrExceptPage::OfaAutocorrExceptPage( Window* pParent, 1594 const SfxItemSet& rSet ) : 1595 SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_EXCEPT ), rSet), 1596 aAbbrevFL (this, CUI_RES(FL_ABBREV )), 1597 aAbbrevED (this, CUI_RES(ED_ABBREV )), 1598 aAbbrevLB (this, CUI_RES(LB_ABBREV )), 1599 aNewAbbrevPB (this, CUI_RES(PB_NEWABBREV )), 1600 aDelAbbrevPB (this, CUI_RES(PB_DELABBREV )), 1601 aAutoAbbrevCB (this, CUI_RES(CB_AUTOABBREV )), 1602 aDoubleCapsFL (this, CUI_RES(FL_DOUBLECAPS )), 1603 aDoubleCapsED (this, CUI_RES(ED_DOUBLE_CAPS )), 1604 aDoubleCapsLB (this, CUI_RES(LB_DOUBLE_CAPS )), 1605 aNewDoublePB (this, CUI_RES(PB_NEWDOUBLECAPS)), 1606 aDelDoublePB (this, CUI_RES(PB_DELDOUBLECAPS)), 1607 aAutoCapsCB (this, CUI_RES(CB_AUTOCAPS )), 1608 eLang(eLastDialogLanguage) 1609 { 1610 aNewAbbrevPB.SetAccessibleName(String(CUI_RES(STR_PB_NEWABBREV) ) ); 1611 aDelAbbrevPB.SetAccessibleName(String(CUI_RES(STR_PB_DELABBREV) ) ); 1612 aNewDoublePB.SetAccessibleName(String(CUI_RES(STR_PB_NEWDOUBLECAPS) ) ); 1613 aDelDoublePB.SetAccessibleName(String(CUI_RES(STR_PB_DELDOUBLECAPS) ) ); 1614 1615 FreeResource(); 1616 1617 ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage )); 1618 pCompareClass = new CollatorWrapper( GetProcessFact() ); 1619 pCompareClass->loadDefaultCollator( aLcl, ::com::sun::star::i18n:: 1620 CollatorOptions::CollatorOptions_IGNORE_CASE ); 1621 1622 aNewAbbrevPB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1623 aDelAbbrevPB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1624 aNewDoublePB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1625 aDelDoublePB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1626 1627 aAbbrevLB.SetSelectHdl(LINK(this, OfaAutocorrExceptPage, SelectHdl)); 1628 aDoubleCapsLB.SetSelectHdl(LINK(this, OfaAutocorrExceptPage, SelectHdl)); 1629 aAbbrevED.SetModifyHdl(LINK(this, OfaAutocorrExceptPage, ModifyHdl)); 1630 aDoubleCapsED.SetModifyHdl(LINK(this, OfaAutocorrExceptPage, ModifyHdl)); 1631 1632 aAbbrevED.SetActionHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1633 aDoubleCapsED.SetActionHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl)); 1634 1635 aNewAbbrevPB.SetAccessibleRelationMemberOf(&aAbbrevFL); 1636 aDelAbbrevPB.SetAccessibleRelationMemberOf(&aAbbrevFL); 1637 aNewDoublePB.SetAccessibleRelationMemberOf(&aDoubleCapsFL); 1638 aDelDoublePB.SetAccessibleRelationMemberOf(&aDoubleCapsFL); 1639 } 1640 1641 /*-----------------14.10.96 15.58------------------- 1642 1643 --------------------------------------------------*/ 1644 1645 OfaAutocorrExceptPage::~OfaAutocorrExceptPage() 1646 { 1647 lcl_ClearTable(aStringsTable); 1648 delete pCompareClass; 1649 } 1650 1651 /*-----------------14.10.96 15.58------------------- 1652 1653 --------------------------------------------------*/ 1654 1655 SfxTabPage* OfaAutocorrExceptPage::Create( Window* pParent, 1656 const SfxItemSet& rSet) 1657 { 1658 return new OfaAutocorrExceptPage(pParent, rSet); 1659 } 1660 /* -----------------20.11.98 13:26------------------- 1661 * 1662 * --------------------------------------------------*/ 1663 void OfaAutocorrExceptPage::ActivatePage( const SfxItemSet& ) 1664 { 1665 if(eLang != eLastDialogLanguage) 1666 SetLanguage(eLastDialogLanguage); 1667 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_True); 1668 } 1669 /* -----------------20.11.98 13:26------------------- 1670 * 1671 * --------------------------------------------------*/ 1672 int OfaAutocorrExceptPage::DeactivatePage( SfxItemSet* ) 1673 { 1674 return LEAVE_PAGE; 1675 } 1676 /*-----------------14.10.96 15.58------------------- 1677 1678 --------------------------------------------------*/ 1679 1680 sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& ) 1681 { 1682 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 1683 StringsArraysPtr pArrays = aStringsTable.Last(); 1684 while(pArrays) 1685 { 1686 LanguageType eCurLang = (LanguageType)aStringsTable.GetCurKey(); 1687 if(eCurLang != eLang) // die aktuelle Sprache wird weiter hinten behandelt 1688 { 1689 SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eCurLang); 1690 1691 if(pWrdList) 1692 { 1693 sal_uInt16 nCount = pWrdList->Count(); 1694 sal_uInt16 i; 1695 for( i = nCount; i; ) 1696 { 1697 String* pString = pWrdList->GetObject( --i ); 1698 //Eintrag finden u. gfs entfernen 1699 if( !lcl_FindInArray(pArrays->aDoubleCapsStrings, *pString)) 1700 pWrdList->DeleteAndDestroy( i ); 1701 } 1702 nCount = pArrays->aDoubleCapsStrings.Count(); 1703 for( i = 0; i < nCount; ++i ) 1704 { 1705 String* pEntry = new String( *pArrays->aDoubleCapsStrings.GetObject( i ) ); 1706 if( !pWrdList->Insert( pEntry )) 1707 delete pEntry; 1708 } 1709 pAutoCorrect->SaveWrdSttExceptList(eCurLang); 1710 } 1711 1712 SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eCurLang); 1713 1714 if(pCplList) 1715 { 1716 sal_uInt16 nCount = pCplList->Count(); 1717 sal_uInt16 i; 1718 for( i = nCount; i; ) 1719 { 1720 String* pString = pCplList->GetObject( --i ); 1721 if( !lcl_FindInArray(pArrays->aAbbrevStrings, *pString)) 1722 pCplList->DeleteAndDestroy( i ); 1723 } 1724 nCount = pArrays->aAbbrevStrings.Count(); 1725 for( i = 0; i < nCount; ++i ) 1726 { 1727 String* pEntry = new String( *pArrays->aAbbrevStrings.GetObject(i) ); 1728 if( !pCplList->Insert( pEntry )) 1729 delete pEntry; 1730 } 1731 pAutoCorrect->SaveCplSttExceptList(eCurLang); 1732 } 1733 } 1734 pArrays = aStringsTable.Prev(); 1735 } 1736 aStringsTable.Clear(); 1737 1738 SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eLang); 1739 1740 if(pWrdList) 1741 { 1742 sal_uInt16 nCount = pWrdList->Count(); 1743 sal_uInt16 i; 1744 for( i = nCount; i; ) 1745 { 1746 String* pString = pWrdList->GetObject( --i ); 1747 if( USHRT_MAX == aDoubleCapsLB.GetEntryPos(*pString) ) 1748 pWrdList->DeleteAndDestroy( i ); 1749 } 1750 nCount = aDoubleCapsLB.GetEntryCount(); 1751 for( i = 0; i < nCount; ++i ) 1752 { 1753 String* pEntry = new String( aDoubleCapsLB.GetEntry( i ) ); 1754 if( !pWrdList->Insert( pEntry )) 1755 delete pEntry; 1756 } 1757 pAutoCorrect->SaveWrdSttExceptList(eLang); 1758 } 1759 1760 SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eLang); 1761 1762 if(pCplList) 1763 { 1764 sal_uInt16 nCount = pCplList->Count(); 1765 sal_uInt16 i; 1766 for( i = nCount; i; ) 1767 { 1768 String* pString = pCplList->GetObject( --i ); 1769 if( USHRT_MAX == aAbbrevLB.GetEntryPos(*pString) ) 1770 pCplList->DeleteAndDestroy( i ); 1771 } 1772 nCount = aAbbrevLB.GetEntryCount(); 1773 for( i = 0; i < nCount; ++i ) 1774 { 1775 String* pEntry = new String( aAbbrevLB.GetEntry( i ) ); 1776 if( !pCplList->Insert( pEntry )) 1777 delete pEntry; 1778 } 1779 pAutoCorrect->SaveCplSttExceptList(eLang); 1780 } 1781 if(aAutoAbbrevCB.IsChecked() != aAutoAbbrevCB.GetSavedValue()) 1782 pAutoCorrect->SetAutoCorrFlag( SaveWordCplSttLst, aAutoAbbrevCB.IsChecked()); 1783 if(aAutoCapsCB.IsChecked() != aAutoCapsCB.GetSavedValue()) 1784 pAutoCorrect->SetAutoCorrFlag( SaveWordWrdSttLst, aAutoCapsCB.IsChecked()); 1785 return sal_False; 1786 } 1787 1788 /* -----------------23.11.98 10:33------------------- 1789 * 1790 * --------------------------------------------------*/ 1791 void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet) 1792 { 1793 if(eLang != eSet) 1794 { 1795 //alte Einstellungen speichern und neu fuellen 1796 RefillReplaceBoxes(sal_False, eLang, eSet); 1797 eLastDialogLanguage = eSet; 1798 delete pCompareClass; 1799 pCompareClass = new CollatorWrapper( GetProcessFact() ); 1800 pCompareClass->loadDefaultCollator( SvxCreateLocale( eLastDialogLanguage ), 1801 ::com::sun::star::i18n:: 1802 CollatorOptions::CollatorOptions_IGNORE_CASE ); 1803 ModifyHdl(&aAbbrevED); 1804 ModifyHdl(&aDoubleCapsED); 1805 } 1806 } 1807 /* -----------------20.11.98 14:06------------------- 1808 * 1809 * --------------------------------------------------*/ 1810 void OfaAutocorrExceptPage::RefillReplaceBoxes(sal_Bool bFromReset, 1811 LanguageType eOldLanguage, 1812 LanguageType eNewLanguage) 1813 { 1814 eLang = eNewLanguage; 1815 if(bFromReset) 1816 lcl_ClearTable(aStringsTable); 1817 else 1818 { 1819 StringsArraysPtr pArrays = 0; 1820 if(aStringsTable.IsKeyValid(eOldLanguage)) 1821 { 1822 pArrays = aStringsTable.Seek(sal_uLong(eOldLanguage)); 1823 pArrays->aAbbrevStrings.DeleteAndDestroy( 1824 0, pArrays->aAbbrevStrings.Count()); 1825 pArrays->aDoubleCapsStrings.DeleteAndDestroy( 1826 0, pArrays->aDoubleCapsStrings.Count()); 1827 } 1828 else 1829 { 1830 pArrays = new StringsArrays; 1831 aStringsTable.Insert(sal_uLong(eOldLanguage), pArrays); 1832 } 1833 1834 sal_uInt16 i; 1835 for(i = 0; i < aAbbrevLB.GetEntryCount(); i++) 1836 { 1837 pArrays->aAbbrevStrings.Insert( 1838 new String(aAbbrevLB.GetEntry(i)), i); 1839 1840 } 1841 for(i = 0; i < aDoubleCapsLB.GetEntryCount(); i++) 1842 { 1843 pArrays->aDoubleCapsStrings.Insert( 1844 new String(aDoubleCapsLB.GetEntry(i)), i); 1845 } 1846 } 1847 aDoubleCapsLB.Clear(); 1848 aAbbrevLB.Clear(); 1849 String sTemp; 1850 aAbbrevED.SetText(sTemp); 1851 aDoubleCapsED.SetText(sTemp); 1852 1853 if(aStringsTable.IsKeyValid(eLang)) 1854 { 1855 StringsArraysPtr pArrays = aStringsTable.Seek(sal_uLong(eLang)); 1856 sal_uInt16 i; 1857 for(i = 0; i < pArrays->aAbbrevStrings.Count(); i++ ) 1858 { 1859 aAbbrevLB.InsertEntry(*pArrays->aAbbrevStrings.GetObject(i)); 1860 } 1861 for( i = 0; i < pArrays->aDoubleCapsStrings.Count(); i++ ) 1862 { 1863 aDoubleCapsLB.InsertEntry(*pArrays->aDoubleCapsStrings.GetObject(i)); 1864 } 1865 } 1866 else 1867 { 1868 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 1869 const SvStringsISortDtor* pCplList = pAutoCorrect->GetCplSttExceptList(eLang); 1870 const SvStringsISortDtor* pWrdList = pAutoCorrect->GetWrdSttExceptList(eLang); 1871 sal_uInt16 i; 1872 for( i = 0; i < pCplList->Count(); i++ ) 1873 { 1874 aAbbrevLB.InsertEntry(*pCplList->GetObject(i)); 1875 } 1876 for( i = 0; i < pWrdList->Count(); i++ ) 1877 { 1878 aDoubleCapsLB.InsertEntry(*pWrdList->GetObject(i)); 1879 } 1880 } 1881 } 1882 1883 /*-----------------14.10.96 15.58------------------- 1884 1885 --------------------------------------------------*/ 1886 1887 void OfaAutocorrExceptPage::Reset( const SfxItemSet& ) 1888 { 1889 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 1890 RefillReplaceBoxes(sal_True, eLang, eLang); 1891 aAutoAbbrevCB. Check( pAutoCorrect->IsAutoCorrFlag( SaveWordCplSttLst )); 1892 aAutoCapsCB. Check( pAutoCorrect->IsAutoCorrFlag( SaveWordWrdSttLst )); 1893 aAutoAbbrevCB.SaveValue(); 1894 aAutoCapsCB.SaveValue(); 1895 } 1896 1897 /*-----------------16.10.96 12.27------------------- 1898 1899 --------------------------------------------------*/ 1900 1901 1902 IMPL_LINK(OfaAutocorrExceptPage, NewDelHdl, PushButton*, pBtn) 1903 { 1904 if((pBtn == &aNewAbbrevPB || pBtn == (PushButton*)&aAbbrevED ) 1905 && aAbbrevED.GetText().Len()) 1906 { 1907 aAbbrevLB.InsertEntry(aAbbrevED.GetText()); 1908 ModifyHdl(&aAbbrevED); 1909 } 1910 else if(pBtn == &aDelAbbrevPB) 1911 { 1912 aAbbrevLB.RemoveEntry(aAbbrevED.GetText()); 1913 ModifyHdl(&aAbbrevED); 1914 } 1915 else if((pBtn == &aNewDoublePB || pBtn == (PushButton*)&aDoubleCapsED ) 1916 && aDoubleCapsED.GetText().Len()) 1917 { 1918 aDoubleCapsLB.InsertEntry(aDoubleCapsED.GetText()); 1919 ModifyHdl(&aDoubleCapsED); 1920 } 1921 else if(pBtn == &aDelDoublePB) 1922 { 1923 aDoubleCapsLB.RemoveEntry(aDoubleCapsED.GetText()); 1924 ModifyHdl(&aDoubleCapsED); 1925 } 1926 return 0; 1927 } 1928 1929 /*-----------------16.10.96 12.57------------------- 1930 1931 --------------------------------------------------*/ 1932 1933 IMPL_LINK(OfaAutocorrExceptPage, SelectHdl, ListBox*, pBox) 1934 { 1935 if(pBox == &aAbbrevLB) 1936 { 1937 aAbbrevED.SetText(pBox->GetSelectEntry()); 1938 aNewAbbrevPB.Enable(sal_False); 1939 aDelAbbrevPB.Enable(); 1940 } 1941 else 1942 { 1943 aDoubleCapsED.SetText(pBox->GetSelectEntry()); 1944 aNewDoublePB.Enable(sal_False); 1945 aDelDoublePB.Enable(); 1946 } 1947 return 0; 1948 } 1949 1950 /*-----------------16.10.96 13.02------------------- 1951 1952 --------------------------------------------------*/ 1953 1954 IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, Edit*, pEdt) 1955 { 1956 // sal_Bool bSame = pEdt->GetText() == ->GetSelectEntry(); 1957 const String& sEntry = pEdt->GetText(); 1958 sal_Bool bEntryLen = 0!= sEntry.Len(); 1959 if(pEdt == &aAbbrevED) 1960 { 1961 sal_Bool bSame = lcl_FindEntry(aAbbrevLB, sEntry, *pCompareClass); 1962 if(bSame && sEntry != aAbbrevLB.GetSelectEntry()) 1963 pEdt->SetText(aAbbrevLB.GetSelectEntry()); 1964 aNewAbbrevPB.Enable(!bSame && bEntryLen); 1965 aDelAbbrevPB.Enable(bSame && bEntryLen); 1966 } 1967 else 1968 { 1969 sal_Bool bSame = lcl_FindEntry(aDoubleCapsLB, sEntry, *pCompareClass); 1970 if(bSame && sEntry != aDoubleCapsLB.GetSelectEntry()) 1971 pEdt->SetText(aDoubleCapsLB.GetSelectEntry()); 1972 aNewDoublePB.Enable(!bSame && bEntryLen); 1973 aDelDoublePB.Enable(bSame && bEntryLen); 1974 } 1975 return 0; 1976 } 1977 1978 /*-----------------16.10.96 15.03------------------- 1979 1980 --------------------------------------------------*/ 1981 1982 void AutoCorrEdit::KeyInput( const KeyEvent& rKEvt ) 1983 { 1984 const KeyCode aKeyCode = rKEvt.GetKeyCode(); 1985 const sal_uInt16 nModifier = aKeyCode.GetModifier(); 1986 if( aKeyCode.GetCode() == KEY_RETURN ) 1987 { 1988 //wird bei Enter nichts getan, dann doch die Basisklasse rufen 1989 // um den Dialog zu schliessen 1990 if(!nModifier && !aActionLink.Call(this)) 1991 Edit::KeyInput(rKEvt); 1992 } 1993 else if(bSpaces || aKeyCode.GetCode() != KEY_SPACE) 1994 Edit::KeyInput(rKEvt); 1995 } 1996 1997 /*-----------------03.07.97 13:17------------------- 1998 1999 --------------------------------------------------*/ 2000 2001 enum OfaQuoteOptions 2002 { 2003 ADD_NONBRK_SPACE, 2004 REPLACE_1ST 2005 }; 2006 2007 SvLBoxEntry* OfaQuoteTabPage::CreateEntry(String& rTxt, sal_uInt16 nCol) 2008 { 2009 SvLBoxEntry* pEntry = new SvLBoxEntry; 2010 2011 if ( !pCheckButtonData ) 2012 { 2013 pCheckButtonData = new SvLBoxButtonData( &aSwCheckLB ); 2014 aSwCheckLB.SetCheckButtonData( pCheckButtonData ); 2015 } 2016 2017 pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); // Sonst Puff! 2018 2019 String sEmpty; 2020 if (nCol == CBCOL_SECOND) 2021 pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte 2022 else 2023 pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) ); 2024 2025 if (nCol == CBCOL_FIRST) 2026 pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte 2027 else 2028 pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) ); 2029 2030 pEntry->AddItem( new OfaImpBrwString( pEntry, 0, rTxt ) ); 2031 2032 return pEntry; 2033 } 2034 2035 OfaQuoteTabPage::OfaQuoteTabPage( Window* pParent, const SfxItemSet& rSet ) : 2036 SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_QUOTE ), rSet), 2037 aCheckLB (this, CUI_RES(CLB_SETTINGS )), 2038 aSwCheckLB (this, CUI_RES(CLB_SETTINGS )), 2039 sHeader1 (CUI_RES( STR_HEADER1 )), 2040 sHeader2 (CUI_RES( STR_HEADER2 )), 2041 sNonBrkSpace (CUI_RES( ST_NON_BREAK_SPACE )), 2042 sOrdinal (CUI_RES( ST_ORDINAL )), 2043 pCheckButtonData ( NULL ), 2044 2045 aSingleFL (this, CUI_RES(FL_SINGLE )), 2046 aSingleTypoCB (this, CUI_RES(CB_SGL_TYPO )), 2047 aSglStartQuoteFT (this, CUI_RES(FT_SGL_STARTQUOTE )), 2048 aSglStartQuotePB (this, CUI_RES(PB_SGL_STARTQUOTE )), 2049 aSglStartExFT (this, CUI_RES(FT_SGSTEX )), 2050 aSglEndQuoteFT (this, CUI_RES(FT_SGL_ENDQUOTE )), 2051 aSglEndQuotePB (this, CUI_RES(PB_SGL_ENDQUOTE )), 2052 aSglEndExFT (this, CUI_RES(FT_SGENEX )), 2053 aSglStandardPB (this, CUI_RES(PB_SGL_STD )), 2054 2055 aDoubleFL (this, CUI_RES(FL_DOUBLE )), 2056 aTypoCB (this, CUI_RES(CB_TYPO )), 2057 aStartQuoteFT (this, CUI_RES(FT_STARTQUOTE )), 2058 aStartQuotePB (this, CUI_RES(PB_STARTQUOTE )), 2059 aDblStartExFT (this, CUI_RES(FT_DBSTEX )), 2060 aEndQuoteFT (this, CUI_RES(FT_ENDQUOTE )), 2061 aEndQuotePB (this, CUI_RES(PB_ENDQUOTE )), 2062 aDblEndExFT (this, CUI_RES(FT_DBECEX )), 2063 aDblStandardPB (this, CUI_RES(PB_DBL_STD )), 2064 2065 sStartQuoteDlg (CUI_RES(STR_CHANGE_START)), 2066 sEndQuoteDlg (CUI_RES(STR_CHANGE_END)), 2067 2068 sStandard(CUI_RES(ST_STANDARD)) 2069 { 2070 aSglStandardPB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_STD) ) ); 2071 aDblStandardPB.SetAccessibleName(String(CUI_RES(STR_PB_DBL_STD) ) ); 2072 aStartQuotePB.SetAccessibleName( String(CUI_RES(STR_PB_DBL_START) )); 2073 aEndQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_DBL_END) )); 2074 aSglStartQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_START) )); 2075 aSglEndQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_END) ) ); 2076 2077 FreeResource(); 2078 2079 sal_Bool bShowSWOptions = sal_False; 2080 2081 aCheckLB.SetHelpId( HID_OFAPAGE_QUOTE_CLB ); 2082 aSwCheckLB.SetHelpId( HID_OFAPAGE_QUOTE_SW_CLB ); 2083 2084 SFX_ITEMSET_ARG( &rSet, pItem, SfxBoolItem, SID_AUTO_CORRECT_DLG, sal_False ); 2085 if ( pItem && pItem->GetValue() ) 2086 bShowSWOptions = sal_True; 2087 2088 if ( bShowSWOptions ) 2089 { 2090 static long aStaticTabs[]= 2091 { 2092 3, 0, 20, 40 2093 }; 2094 2095 aSwCheckLB.SetStyle(aSwCheckLB.GetStyle() | WB_HSCROLL| WB_VSCROLL); 2096 2097 aSwCheckLB.SvxSimpleTable::SetTabs(aStaticTabs); 2098 String sHeader( sHeader1 ); 2099 sHeader += '\t'; 2100 sHeader += sHeader2; 2101 sHeader += '\t'; 2102 aSwCheckLB.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, 2103 HIB_CENTER | HIB_VCENTER | HIB_FIXEDPOS | HIB_FIXED); 2104 aCheckLB.Hide( sal_True ); 2105 } 2106 else 2107 { 2108 aSwCheckLB.HideTable( ); 2109 } 2110 2111 aStartQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl)); 2112 aEndQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl)); 2113 aSglStartQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl)); 2114 aSglEndQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl)); 2115 aDblStandardPB.SetClickHdl(LINK(this, OfaQuoteTabPage, StdQuoteHdl)); 2116 aSglStandardPB.SetClickHdl(LINK(this, OfaQuoteTabPage, StdQuoteHdl)); 2117 2118 aSglStartQuotePB.SetAccessibleRelationLabeledBy( &aSglStartQuoteFT ); 2119 aSglEndQuotePB.SetAccessibleRelationLabeledBy( &aSglEndQuoteFT ); 2120 aSglStartQuotePB.SetAccessibleRelationMemberOf( &aSingleFL ); 2121 aSglEndQuotePB.SetAccessibleRelationMemberOf( &aSingleFL ); 2122 aStartQuotePB.SetAccessibleRelationLabeledBy( &aStartQuoteFT ); 2123 aEndQuotePB.SetAccessibleRelationLabeledBy( &aEndQuoteFT ); 2124 aStartQuotePB.SetAccessibleRelationMemberOf( &aDoubleFL ); 2125 aEndQuotePB.SetAccessibleRelationMemberOf( &aDoubleFL ); 2126 aSglStandardPB.SetAccessibleRelationMemberOf(&aSingleFL); 2127 aDblStandardPB.SetAccessibleRelationMemberOf(&aDoubleFL); 2128 } 2129 /*-----------------03.07.97 13:17------------------- 2130 2131 --------------------------------------------------*/ 2132 OfaQuoteTabPage::~OfaQuoteTabPage() 2133 { 2134 delete( pCheckButtonData ); 2135 } 2136 /*-----------------03.07.97 13:17------------------- 2137 2138 --------------------------------------------------*/ 2139 SfxTabPage* OfaQuoteTabPage::Create( Window* pParent, 2140 const SfxItemSet& rAttrSet) 2141 { 2142 return new OfaQuoteTabPage(pParent, rAttrSet); 2143 } 2144 /*-----------------03.07.97 13:18------------------- 2145 2146 --------------------------------------------------*/ 2147 sal_Bool OfaQuoteTabPage::FillItemSet( SfxItemSet& ) 2148 { 2149 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2150 2151 long nFlags = pAutoCorrect->GetFlags(); 2152 2153 if ( aCheckLB.IsVisible( ) ) 2154 { 2155 sal_uInt16 nPos = 0; 2156 pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, aCheckLB.IsChecked(nPos++)); 2157 pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, aCheckLB.IsChecked(nPos++)); 2158 } 2159 2160 sal_Bool bModified = sal_False; 2161 if ( aSwCheckLB.IsVisible( ) ) 2162 { 2163 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2164 2165 sal_Bool bCheck = aSwCheckLB.IsChecked(ADD_NONBRK_SPACE, CBCOL_FIRST); 2166 bModified |= pOpt->bAddNonBrkSpace != bCheck; 2167 pOpt->bAddNonBrkSpace = bCheck; 2168 pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, 2169 aSwCheckLB.IsChecked(ADD_NONBRK_SPACE, CBCOL_SECOND)); 2170 2171 bCheck = aSwCheckLB.IsChecked(REPLACE_1ST, CBCOL_FIRST); 2172 bModified |= pOpt->bChgOrdinalNumber != bCheck; 2173 pOpt->bChgOrdinalNumber = bCheck; 2174 pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, 2175 aSwCheckLB.IsChecked(REPLACE_1ST, CBCOL_SECOND)); 2176 } 2177 2178 pAutoCorrect->SetAutoCorrFlag(ChgQuotes, aTypoCB.IsChecked()); 2179 pAutoCorrect->SetAutoCorrFlag(ChgSglQuotes, aSingleTypoCB.IsChecked()); 2180 sal_Bool bReturn = nFlags != pAutoCorrect->GetFlags(); 2181 if(cStartQuote != pAutoCorrect->GetStartDoubleQuote()) 2182 { 2183 bReturn = sal_True; 2184 sal_Unicode cUCS2 = static_cast<sal_Unicode>(cStartQuote); //TODO 2185 pAutoCorrect->SetStartDoubleQuote(cUCS2); 2186 } 2187 if(cEndQuote != pAutoCorrect->GetEndDoubleQuote()) 2188 { 2189 bReturn = sal_True; 2190 sal_Unicode cUCS2 = static_cast<sal_Unicode>(cEndQuote); //TODO 2191 pAutoCorrect->SetEndDoubleQuote(cUCS2); 2192 } 2193 if(cSglStartQuote != pAutoCorrect->GetStartSingleQuote()) 2194 { 2195 bReturn = sal_True; 2196 sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglStartQuote); //TODO 2197 pAutoCorrect->SetStartSingleQuote(cUCS2); 2198 } 2199 if(cSglEndQuote != pAutoCorrect->GetEndSingleQuote()) 2200 { 2201 bReturn = sal_True; 2202 sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglEndQuote); //TODO 2203 pAutoCorrect->SetEndSingleQuote(cUCS2); 2204 } 2205 2206 if( bModified || bReturn ) 2207 { 2208 SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get(); 2209 pCfg->SetModified(); 2210 pCfg->Commit(); 2211 } 2212 return bReturn; 2213 } 2214 /* -----------------23.11.98 16:15------------------- 2215 * 2216 * --------------------------------------------------*/ 2217 void OfaQuoteTabPage::ActivatePage( const SfxItemSet& ) 2218 { 2219 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False); 2220 } 2221 /*-----------------03.07.97 13:18------------------- 2222 2223 --------------------------------------------------*/ 2224 void OfaQuoteTabPage::Reset( const SfxItemSet& ) 2225 { 2226 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2227 const long nFlags = pAutoCorrect->GetFlags(); 2228 2229 // Initialize the Sw options 2230 if ( aSwCheckLB.IsVisible( ) ) 2231 { 2232 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2233 2234 aSwCheckLB.SetUpdateMode( sal_False ); 2235 aSwCheckLB.Clear(); 2236 2237 aSwCheckLB.GetModel()->Insert(CreateEntry(sNonBrkSpace, CBCOL_BOTH )); 2238 aSwCheckLB.GetModel()->Insert(CreateEntry(sOrdinal, CBCOL_BOTH )); 2239 2240 aSwCheckLB.CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_FIRST, pOpt->bAddNonBrkSpace ); 2241 aSwCheckLB.CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_SECOND, 0 != (nFlags & AddNonBrkSpace) ); 2242 aSwCheckLB.CheckEntryPos( REPLACE_1ST, CBCOL_FIRST, pOpt->bChgOrdinalNumber ); 2243 aSwCheckLB.CheckEntryPos( REPLACE_1ST, CBCOL_SECOND, 0 != (nFlags & ChgOrdinalNumber) ); 2244 2245 aSwCheckLB.SetUpdateMode( sal_True ); 2246 } 2247 2248 // Initialize the non Sw options 2249 if ( aCheckLB.IsVisible( ) ) 2250 { 2251 aCheckLB.SetUpdateMode( sal_False ); 2252 aCheckLB.Clear( ); 2253 2254 aCheckLB.InsertEntry( sNonBrkSpace ); 2255 aCheckLB.InsertEntry( sOrdinal ); 2256 2257 sal_uInt16 nPos = 0; 2258 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & AddNonBrkSpace) ); 2259 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgOrdinalNumber) ); 2260 2261 aCheckLB.SetUpdateMode( sal_True ); 2262 } 2263 2264 // Initialize the quote stuffs 2265 aTypoCB .Check(0 != (nFlags & ChgQuotes)); 2266 aSingleTypoCB .Check(0 != (nFlags & ChgSglQuotes)); 2267 aTypoCB .SaveValue(); 2268 aSingleTypoCB .SaveValue(); 2269 2270 cStartQuote = pAutoCorrect->GetStartDoubleQuote(); 2271 cEndQuote = pAutoCorrect->GetEndDoubleQuote(); 2272 cSglStartQuote = pAutoCorrect->GetStartSingleQuote(); 2273 cSglEndQuote = pAutoCorrect->GetEndSingleQuote(); 2274 2275 aSglStartExFT .SetText(ChangeStringExt_Impl(cSglStartQuote)); 2276 aSglEndExFT .SetText(ChangeStringExt_Impl(cSglEndQuote)); 2277 aDblStartExFT .SetText(ChangeStringExt_Impl(cStartQuote)); 2278 aDblEndExFT .SetText(ChangeStringExt_Impl(cEndQuote)); 2279 } 2280 2281 2282 /*-----------------15.10.96 16.42------------------- 2283 2284 --------------------------------------------------*/ 2285 #define SGL_START 0 2286 #define DBL_START 1 2287 #define SGL_END 2 2288 #define DBL_END 3 2289 2290 2291 IMPL_LINK( OfaQuoteTabPage, QuoteHdl, PushButton*, pBtn ) 2292 { 2293 sal_uInt16 nMode = SGL_START; 2294 if(pBtn == &aSglEndQuotePB) 2295 nMode = SGL_END; 2296 else if(pBtn == &aStartQuotePB) 2297 nMode = DBL_START; 2298 else if(pBtn == &aEndQuotePB) 2299 nMode = DBL_END; 2300 // Zeichenauswahl-Dialog starten 2301 SvxCharacterMap* pMap = new SvxCharacterMap( this, sal_True ); 2302 pMap->SetCharFont( OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, 2303 LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE, 0 )); 2304 pMap->SetText(nMode < SGL_END ? sStartQuoteDlg : sEndQuoteDlg ); 2305 sal_UCS4 cDlg; 2306 //The two lines below are added by BerryJia for Bug95846 Time:2002-8-13 15:50 2307 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2308 LanguageType eLang = Application::GetSettings().GetLanguage(); 2309 switch( nMode ) 2310 { 2311 case SGL_START: 2312 cDlg = cSglStartQuote; 2313 if(cDlg == 0) 2314 cDlg = pAutoCorrect->GetQuote('\'',sal_True,eLang); //add by BerryJia for Bug95846 Time:2002-8-13 15:50 2315 break; 2316 case SGL_END: 2317 cDlg = cSglEndQuote; 2318 if(cDlg == 0) 2319 cDlg = pAutoCorrect->GetQuote('\'',sal_False,eLang); //add by BerryJia for Bug95846 Time:2002-8-13 15:50 2320 break; 2321 case DBL_START: 2322 cDlg = cStartQuote; 2323 if(cDlg == 0) 2324 cDlg = pAutoCorrect->GetQuote('\"',sal_True,eLang); //add by BerryJia for Bug95846 Time:2002-8-13 15:50 2325 break; 2326 case DBL_END: 2327 cDlg = cEndQuote; 2328 if(cDlg == 0) 2329 cDlg = pAutoCorrect->GetQuote('\"',sal_False,eLang); //add by BerryJia for Bug95846 Time:2002-8-13 15:50 2330 break; 2331 default: 2332 DBG_ERROR("svx::OfaQuoteTabPage::QuoteHdl(), how to initialize cDlg?" ); 2333 cDlg = 0; 2334 break; 2335 2336 } 2337 pMap->SetChar( cDlg ); 2338 pMap->DisableFontSelection(); 2339 if(pMap->Execute() == RET_OK) 2340 { 2341 sal_UCS4 cNewChar = pMap->GetChar(); 2342 switch( nMode ) 2343 { 2344 case SGL_START: 2345 cSglStartQuote = cNewChar; 2346 aSglStartExFT.SetText(ChangeStringExt_Impl(cNewChar)); 2347 break; 2348 case SGL_END: 2349 cSglEndQuote = cNewChar; 2350 aSglEndExFT.SetText(ChangeStringExt_Impl(cNewChar)); 2351 break; 2352 case DBL_START: 2353 cStartQuote = cNewChar; 2354 aDblStartExFT.SetText(ChangeStringExt_Impl(cNewChar)); 2355 break; 2356 case DBL_END: 2357 cEndQuote = cNewChar; 2358 aDblEndExFT.SetText(ChangeStringExt_Impl(cNewChar)); 2359 break; 2360 } 2361 } 2362 delete pMap; 2363 2364 return 0; 2365 } 2366 2367 /*-----------------27.06.97 09.55------------------- 2368 2369 --------------------------------------------------*/ 2370 IMPL_LINK( OfaQuoteTabPage, StdQuoteHdl, PushButton*, pBtn ) 2371 { 2372 if(pBtn == &aDblStandardPB) 2373 { 2374 cStartQuote = 0; 2375 aDblStartExFT.SetText(ChangeStringExt_Impl(0)); 2376 cEndQuote = 0; 2377 aDblEndExFT.SetText(ChangeStringExt_Impl(0)); 2378 2379 } 2380 else 2381 { 2382 cSglStartQuote = 0; 2383 aSglStartExFT.SetText(ChangeStringExt_Impl(0)); 2384 cSglEndQuote = 0; 2385 aSglEndExFT.SetText(ChangeStringExt_Impl(0)); 2386 } 2387 return 0; 2388 } 2389 2390 // -------------------------------------------------- 2391 2392 String OfaQuoteTabPage::ChangeStringExt_Impl( sal_UCS4 cChar ) 2393 { 2394 if( !cChar ) 2395 return sStandard; 2396 2397 // convert codepoint value to unicode-hex string 2398 sal_UCS4 aStrCodes[32] = { 0, ' ', '(', 'U', '+', '0' }; 2399 aStrCodes[0] = cChar; 2400 int nFullLen = 5; 2401 int nHexLen = 4; 2402 while( (cChar >> (4*nHexLen)) != 0 ) 2403 ++nHexLen; 2404 for( int i = nHexLen; --i >= 0;) 2405 { 2406 sal_UCS4 cHexDigit = ((cChar >> (4*i)) & 0x0f) + '0'; 2407 if( cHexDigit > '9' ) 2408 cHexDigit += 'A' - ('9' + 1); 2409 aStrCodes[ nFullLen++ ] = cHexDigit; 2410 } 2411 aStrCodes[ nFullLen++ ] = ')'; 2412 // using the new UCS4 constructor 2413 rtl::OUString aOUStr( aStrCodes, nFullLen ); 2414 return aOUStr; 2415 } 2416 2417 OfaAutoCompleteTabPage::OfaAutoCompleteTabPage( Window* pParent, 2418 const SfxItemSet& rSet ) 2419 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCOMPLETE_OPTIONS ), rSet), 2420 aCBActiv (this, CUI_RES(CB_ACTIV)), 2421 aCBAppendSpace (this, CUI_RES(CB_APPEND_SPACE)), 2422 aCBAsTip (this, CUI_RES(CB_AS_TIP)), 2423 aCBCollect (this, CUI_RES(CB_COLLECT)), 2424 aCBRemoveList (this, CUI_RES(CB_REMOVE_LIST)), 2425 aFTExpandKey (this, CUI_RES(FT_EXPAND_KEY)), 2426 aDCBExpandKey (this, CUI_RES(DCB_EXPAND_KEY)), 2427 aFTMinWordlen (this, CUI_RES(FT_MIN_WORDLEN)), 2428 aNFMinWordlen (this, CUI_RES(NF_MIN_WORDLEN)), 2429 aFTMaxEntries (this, CUI_RES(FT_MAX_ENTRIES)), 2430 aNFMaxEntries (this, CUI_RES(NF_MAX_ENTRIES)), 2431 aLBEntries (*this, CUI_RES(LB_ENTRIES)), 2432 aPBEntries (this, CUI_RES(PB_ENTRIES)), 2433 pAutoCmpltList( 0 ), 2434 nAutoCmpltListCnt( 0 ) 2435 { 2436 FreeResource(); 2437 2438 // the defined KEYs 2439 static const sal_uInt16 aKeyCodes[] = { 2440 KEY_END, 2441 KEY_RETURN, 2442 KEY_SPACE, 2443 KEY_RIGHT, 2444 KEY_TAB, 2445 0 2446 }; 2447 2448 for( const sal_uInt16* pKeys = aKeyCodes; *pKeys; ++pKeys ) 2449 { 2450 KeyCode aKCode( *pKeys ); 2451 sal_uInt16 nPos = aDCBExpandKey.InsertEntry( aKCode.GetName() ); 2452 aDCBExpandKey.SetEntryData( nPos, (void*)(sal_uLong)*pKeys ); 2453 if( KEY_RETURN == *pKeys ) // default to RETURN 2454 aDCBExpandKey.SelectEntryPos( nPos ); 2455 } 2456 2457 aPBEntries.SetClickHdl(LINK(this, OfaAutoCompleteTabPage, DeleteHdl)); 2458 aCBActiv.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage, CheckHdl)); 2459 aCBCollect.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage, CheckHdl)); 2460 aLBEntries.SetAccessibleRelationLabeledBy(&aLBEntries); 2461 } 2462 2463 OfaAutoCompleteTabPage::~OfaAutoCompleteTabPage() 2464 { 2465 } 2466 2467 SfxTabPage* OfaAutoCompleteTabPage::Create( Window* pParent, 2468 const SfxItemSet& rSet) 2469 { 2470 return new OfaAutoCompleteTabPage( pParent, rSet ); 2471 } 2472 2473 sal_Bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet& ) 2474 { 2475 sal_Bool bModified = sal_False, bCheck; 2476 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2477 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2478 sal_uInt16 nVal; 2479 2480 bCheck = aCBActiv.IsChecked(); 2481 bModified |= pOpt->bAutoCompleteWords != bCheck; 2482 pOpt->bAutoCompleteWords = bCheck; 2483 bCheck = aCBCollect.IsChecked(); 2484 bModified |= pOpt->bAutoCmpltCollectWords != bCheck; 2485 pOpt->bAutoCmpltCollectWords = bCheck; 2486 bCheck = !aCBRemoveList.IsChecked(); // inverted value! 2487 bModified |= pOpt->bAutoCmpltKeepList != bCheck; 2488 pOpt->bAutoCmpltKeepList = bCheck; 2489 bCheck = aCBAppendSpace.IsChecked(); 2490 bModified |= pOpt->bAutoCmpltAppendBlanc != bCheck; 2491 pOpt->bAutoCmpltAppendBlanc = bCheck; 2492 bCheck = aCBAsTip.IsChecked(); 2493 bModified |= pOpt->bAutoCmpltShowAsTip != bCheck; 2494 pOpt->bAutoCmpltShowAsTip = bCheck; 2495 2496 nVal = (sal_uInt16)aNFMinWordlen.GetValue(); 2497 bModified |= nVal != pOpt->nAutoCmpltWordLen; 2498 pOpt->nAutoCmpltWordLen = nVal; 2499 2500 nVal = (sal_uInt16)aNFMaxEntries.GetValue(); 2501 bModified |= nVal != pOpt->nAutoCmpltListLen; 2502 pOpt->nAutoCmpltListLen = nVal; 2503 2504 nVal = aDCBExpandKey.GetSelectEntryPos(); 2505 if( nVal < aDCBExpandKey.GetEntryCount() ) 2506 { 2507 sal_uLong nKey = (sal_uLong)aDCBExpandKey.GetEntryData( nVal ); 2508 bModified |= nKey != pOpt->nAutoCmpltExpandKey; 2509 pOpt->nAutoCmpltExpandKey = (sal_uInt16)nKey; 2510 } 2511 2512 if( pAutoCmpltList && nAutoCmpltListCnt != aLBEntries.GetEntryCount() ) 2513 { 2514 bModified = sal_True; 2515 pOpt->pAutoCmpltList = pAutoCmpltList; 2516 } 2517 if( bModified ) 2518 { 2519 SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get(); 2520 pCfg->SetModified(); 2521 pCfg->Commit(); 2522 } 2523 return sal_True; 2524 } 2525 2526 void OfaAutoCompleteTabPage::Reset( const SfxItemSet& ) 2527 { 2528 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2529 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2530 2531 aCBActiv.Check( 0 != pOpt->bAutoCompleteWords ); 2532 aCBCollect.Check( 0 != pOpt->bAutoCmpltCollectWords ); 2533 aCBRemoveList.Check( !pOpt->bAutoCmpltKeepList ); //inverted value! 2534 aCBAppendSpace.Check( 0 != pOpt->bAutoCmpltAppendBlanc ); 2535 aCBAsTip.Check( 0 != pOpt->bAutoCmpltShowAsTip ); 2536 2537 aNFMinWordlen.SetValue( pOpt->nAutoCmpltWordLen ); 2538 aNFMaxEntries.SetValue( pOpt->nAutoCmpltListLen ); 2539 2540 // select the specific KeyCode: 2541 { 2542 sal_uLong nKey = pOpt->nAutoCmpltExpandKey; 2543 for( sal_uInt16 n = 0, nCnt = aDCBExpandKey.GetEntryCount(); n < nCnt; ++n ) 2544 if( nKey == (sal_uLong)aDCBExpandKey.GetEntryData( n )) 2545 { 2546 aDCBExpandKey.SelectEntryPos( n ); 2547 break; 2548 } 2549 } 2550 2551 if( pOpt->pAutoCmpltList && pOpt->pAutoCmpltList->Count() ) 2552 { 2553 pAutoCmpltList = (SvStringsISortDtor*)pOpt->pAutoCmpltList; 2554 pOpt->pAutoCmpltList = 0; 2555 nAutoCmpltListCnt = pAutoCmpltList->Count(); 2556 for( sal_uInt16 n = 0; n < nAutoCmpltListCnt; ++n ) 2557 { 2558 const StringPtr pStr = pAutoCmpltList->GetObject( n ); 2559 sal_uInt16 nPos = aLBEntries.InsertEntry( *pStr ); 2560 aLBEntries.SetEntryData( nPos, (void*)pStr ); 2561 } 2562 } 2563 else 2564 { 2565 aLBEntries.Disable(); 2566 aPBEntries.Disable(); 2567 } 2568 2569 CheckHdl( &aCBActiv ); 2570 CheckHdl( &aCBCollect ); 2571 } 2572 2573 void OfaAutoCompleteTabPage::ActivatePage( const SfxItemSet& ) 2574 { 2575 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage( sal_False ); 2576 } 2577 2578 IMPL_LINK( OfaAutoCompleteTabPage, DeleteHdl, PushButton*, EMPTYARG ) 2579 { 2580 sal_uInt16 nSelCnt = pAutoCmpltList ? aLBEntries.GetSelectEntryCount() : 0; 2581 while( nSelCnt ) 2582 { 2583 sal_uInt16 nPos = aLBEntries.GetSelectEntryPos( --nSelCnt ); 2584 const StringPtr pStr = (StringPtr)aLBEntries.GetEntryData( nPos ); 2585 aLBEntries.RemoveEntry( nPos ); 2586 nPos = pAutoCmpltList->GetPos( pStr ); 2587 if( USHRT_MAX != nPos ) 2588 pAutoCmpltList->Remove( nPos ); 2589 } 2590 return 0; 2591 } 2592 2593 IMPL_LINK( OfaAutoCompleteTabPage, CheckHdl, CheckBox*, pBox ) 2594 { 2595 sal_Bool bEnable = pBox->IsChecked(); 2596 if( pBox == &aCBActiv ) 2597 { 2598 aCBAppendSpace.Enable( bEnable ); 2599 aCBAppendSpace.Enable( bEnable ); 2600 aCBAsTip.Enable( bEnable ); 2601 aDCBExpandKey.Enable( bEnable ); 2602 } 2603 else if(&aCBCollect == pBox) 2604 aCBRemoveList.Enable( bEnable ); 2605 return 0; 2606 } 2607 2608 void OfaAutoCompleteTabPage::CopyToClipboard() const 2609 { 2610 sal_uInt16 nSelCnt = aLBEntries.GetSelectEntryCount(); 2611 if( pAutoCmpltList && nSelCnt ) 2612 { 2613 TransferDataContainer* pCntnr = new TransferDataContainer; 2614 ::com::sun::star::uno::Reference< 2615 ::com::sun::star::datatransfer::XTransferable > xRef( pCntnr ); 2616 2617 ByteString sData; 2618 const sal_Char* pLineEnd = 2619 #if defined(UNX) 2620 "\012"; 2621 #else 2622 "\015\012"; 2623 #endif 2624 2625 rtl_TextEncoding nEncode = gsl_getSystemTextEncoding(); 2626 2627 for( sal_uInt16 n = 0; n < nSelCnt; ++n ) 2628 { 2629 sData += ByteString( aLBEntries.GetSelectEntry( n ), nEncode ); 2630 sData += pLineEnd; 2631 } 2632 pCntnr->CopyByteString( SOT_FORMAT_STRING, sData ); 2633 pCntnr->CopyToClipboard( (Window*)this ); 2634 } 2635 } 2636 2637 long OfaAutoCompleteTabPage::AutoCompleteMultiListBox::PreNotify( 2638 NotifyEvent& rNEvt ) 2639 { 2640 long nHandled = MultiListBox::PreNotify( rNEvt ); 2641 2642 if( !nHandled && EVENT_KEYUP == rNEvt.GetType() ) 2643 { 2644 const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 2645 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() ) 2646 { 2647 case KEY_DELETE: 2648 rPage.DeleteHdl( 0 ); 2649 nHandled = 1; 2650 break; 2651 2652 default: 2653 if( KEYFUNC_COPY == rKeyCode.GetFunction() ) 2654 { 2655 rPage.CopyToClipboard(); 2656 nHandled = 1; 2657 } 2658 break; 2659 } 2660 } 2661 return nHandled; 2662 } 2663 2664 // class OfaSmartTagOptionsTabPage --------------------------------------------- 2665 2666 OfaSmartTagOptionsTabPage::OfaSmartTagOptionsTabPage( Window* pParent, 2667 const SfxItemSet& rSet ) 2668 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_SMARTTAG_OPTIONS ), rSet), 2669 m_aMainCB( this, CUI_RES(CB_SMARTTAGS) ), 2670 m_aSmartTagTypesLB( this, CUI_RES(LB_SMARTTAGS) ), 2671 m_aPropertiesPB( this, CUI_RES(PB_SMARTTAGS) ), 2672 m_aTitleFT( this, CUI_RES(FT_SMARTTAGS) ) 2673 { 2674 FreeResource(); 2675 2676 // some options for the list box: 2677 m_aSmartTagTypesLB.SetStyle( m_aSmartTagTypesLB.GetStyle() | WB_HSCROLL | WB_HIDESELECTION ); 2678 m_aSmartTagTypesLB.SetHighlightRange(); 2679 2680 // set the handlers: 2681 m_aMainCB.SetToggleHdl(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl)); 2682 m_aPropertiesPB.SetClickHdl(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl)); 2683 m_aSmartTagTypesLB.SetSelectHdl(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl)); 2684 } 2685 2686 OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage() 2687 { 2688 2689 } 2690 2691 SfxTabPage* OfaSmartTagOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet) 2692 { 2693 return new OfaSmartTagOptionsTabPage( pParent, rSet ); 2694 } 2695 2696 /** This struct is used to associate list box entries with smart tag data 2697 */ 2698 struct ImplSmartTagLBUserData 2699 { 2700 rtl::OUString maSmartTagType; 2701 uno::Reference< smarttags::XSmartTagRecognizer > mxRec; 2702 sal_Int32 mnSmartTagIdx; 2703 2704 ImplSmartTagLBUserData( const rtl::OUString& rSmartTagType, 2705 uno::Reference< smarttags::XSmartTagRecognizer > xRec, 2706 sal_Int32 nSmartTagIdx ) : 2707 maSmartTagType( rSmartTagType ), 2708 mxRec( xRec ), 2709 mnSmartTagIdx( nSmartTagIdx ) {} 2710 }; 2711 2712 /** Clears m_aSmartTagTypesLB 2713 */ 2714 void OfaSmartTagOptionsTabPage::ClearListBox() 2715 { 2716 const sal_uLong nCount = m_aSmartTagTypesLB.GetEntryCount(); 2717 for ( sal_uInt16 i = 0; i < nCount; ++i ) 2718 { 2719 const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(i); 2720 const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData()); 2721 delete pUserData; 2722 } 2723 2724 m_aSmartTagTypesLB.Clear(); 2725 } 2726 2727 /** Inserts items into m_aSmartTagTypesLB 2728 */ 2729 void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) 2730 { 2731 // first we have to clear the list box: 2732 ClearListBox(); 2733 2734 // fill list box: 2735 const sal_uInt32 nNumberOfRecognizers = rSmartTagMgr.NumberOfRecognizers(); 2736 const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) ); 2737 std::vector< ActionReference > aActionReferences; 2738 2739 for ( sal_uInt32 i = 0; i < nNumberOfRecognizers; ++i ) 2740 { 2741 uno::Reference< smarttags::XSmartTagRecognizer > xRec = rSmartTagMgr.GetRecognizer(i); 2742 2743 const rtl::OUString aName = xRec->getName( aLocale ); 2744 const rtl::OUString aDesc = xRec->getDescription( aLocale ); 2745 const sal_Int32 nNumberOfSupportedSmartTags = xRec->getSmartTagCount(); 2746 2747 for ( sal_Int32 j = 0; j < nNumberOfSupportedSmartTags; ++j ) 2748 { 2749 const rtl::OUString aSmartTagType = xRec->getSmartTagName(j); 2750 rtl::OUString aSmartTagCaption = rSmartTagMgr.GetSmartTagCaption( aSmartTagType, aLocale ); 2751 2752 if ( !aSmartTagCaption.getLength() ) 2753 aSmartTagCaption = aSmartTagType; 2754 2755 const rtl::OUString aLBEntry = aSmartTagCaption + 2756 OUString::createFromAscii(" (") + 2757 aName + 2758 OUString::createFromAscii(")"); 2759 2760 SvLBoxEntry* pEntry = m_aSmartTagTypesLB.SvTreeListBox::InsertEntry( aLBEntry ); 2761 if ( pEntry ) 2762 { 2763 const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType ); 2764 m_aSmartTagTypesLB.SetCheckButtonState( pEntry, bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED ); 2765 pEntry->SetUserData(static_cast<void*>(new ImplSmartTagLBUserData( aSmartTagType, xRec, j ) ) ); 2766 } 2767 } 2768 } 2769 } 2770 2771 /** Handler for the push button 2772 */ 2773 IMPL_LINK( OfaSmartTagOptionsTabPage, ClickHdl, PushButton*, EMPTYARG ) 2774 { 2775 const sal_uInt16 nPos = m_aSmartTagTypesLB.GetSelectEntryPos(); 2776 const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(nPos); 2777 const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData()); 2778 uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; 2779 const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; 2780 2781 const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) ); 2782 if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) ) 2783 xRec->displayPropertyPage( nSmartTagIdx, aLocale ); 2784 2785 return 0; 2786 } 2787 2788 /** Handler for the check box 2789 */ 2790 IMPL_LINK( OfaSmartTagOptionsTabPage, CheckHdl, CheckBox*, EMPTYARG ) 2791 { 2792 const sal_Bool bEnable = m_aMainCB.IsChecked(); 2793 m_aSmartTagTypesLB.Enable( bEnable ); 2794 m_aSmartTagTypesLB.Invalidate(); 2795 m_aPropertiesPB.Enable( false ); 2796 2797 // if the controls are currently enabled, we still have to check 2798 // if the properties button should be disabled because the currently 2799 // seleted smart tag type does not have a properties dialog. 2800 // We do this by calling SelectHdl: 2801 if ( bEnable ) 2802 SelectHdl( &m_aSmartTagTypesLB ); 2803 2804 return 0; 2805 } 2806 2807 /** Handler for the list box 2808 */ 2809 IMPL_LINK(OfaSmartTagOptionsTabPage, SelectHdl, SvxCheckListBox*, EMPTYARG) 2810 { 2811 if ( m_aSmartTagTypesLB.GetEntryCount() < 1 ) 2812 return 0; 2813 2814 const sal_uInt16 nPos = m_aSmartTagTypesLB.GetSelectEntryPos(); 2815 const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(nPos); 2816 const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData()); 2817 uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; 2818 const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; 2819 2820 const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) ); 2821 if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) ) 2822 m_aPropertiesPB.Enable( sal_True ); 2823 else 2824 m_aPropertiesPB.Enable( sal_False ); 2825 2826 return 0; 2827 } 2828 2829 /** Propagates the current settings to the smart tag manager. 2830 */ 2831 sal_Bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet& ) 2832 { 2833 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2834 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2835 SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr; 2836 2837 // robust! 2838 if ( !pSmartTagMgr ) 2839 return sal_False; 2840 2841 sal_Bool bModifiedSmartTagTypes = sal_False; 2842 std::vector< rtl::OUString > aDisabledSmartTagTypes; 2843 2844 const sal_uLong nCount = m_aSmartTagTypesLB.GetEntryCount(); 2845 2846 for ( sal_uInt16 i = 0; i < nCount; ++i ) 2847 { 2848 const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(i); 2849 const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData()); 2850 const sal_Bool bChecked = m_aSmartTagTypesLB.IsChecked(i); 2851 const sal_Bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType ); 2852 2853 bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled ); 2854 2855 if ( !bChecked ) 2856 aDisabledSmartTagTypes.push_back( pUserData->maSmartTagType ); 2857 2858 delete pUserData; 2859 } 2860 2861 const sal_Bool bModifiedRecognize = ( !m_aMainCB.IsChecked() != !pSmartTagMgr->IsLabelTextWithSmartTags() ); 2862 if ( bModifiedSmartTagTypes || bModifiedRecognize ) 2863 { 2864 bool bLabelTextWithSmartTags = m_aMainCB.IsChecked() ? true : false; 2865 pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : 0, 2866 bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : 0 ); 2867 } 2868 2869 return sal_True; 2870 } 2871 2872 /** Sets the controls based on the current settings at SmartTagMgr. 2873 */ 2874 void OfaSmartTagOptionsTabPage::Reset( const SfxItemSet& ) 2875 { 2876 SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 2877 SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags(); 2878 const SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr; 2879 2880 // robust, should not happen! 2881 if ( !pSmartTagMgr ) 2882 return; 2883 2884 FillListBox( *pSmartTagMgr ); 2885 m_aSmartTagTypesLB.SelectEntryPos( 0 ); 2886 m_aMainCB.Check( pSmartTagMgr->IsLabelTextWithSmartTags() ); 2887 CheckHdl( &m_aMainCB ); 2888 } 2889 2890 void OfaSmartTagOptionsTabPage::ActivatePage( const SfxItemSet& ) 2891 { 2892 ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage( sal_False ); 2893 } 2894 2895