1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <editeng/unolingu.hxx>
22 #include <svx/dlgutil.hxx>
23 #include <sfx2/sfxuno.hxx>
24 #include <svl/eitem.hxx>
25 #include <com/sun/star/frame/XStorable.hpp>
26 #include <comphelper/processfactory.hxx>
27 #include <comphelper/string.hxx>
28 #include <unotools/intlwrapper.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/msgbox.hxx>
31 #include <vcl/settings.hxx>
32 #include <svx/dialogs.hrc>
34 #include <linguistic/misc.hxx>
36 #include "optdict.hxx"
37 #include <dialmgr.hxx>
38 #include <svx/svxerr.hxx>
40 using namespace ::com::sun::star
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::linguistic2
;
44 // static ----------------------------------------------------------------
46 static const short NOACTDICT
= -1;
48 static long nStaticTabs
[]=
53 // static function -------------------------------------------------------
55 static OUString
getNormDicEntry_Impl(const OUString
&rText
)
57 OUString
aTmp(comphelper::string::stripEnd(rText
, '.'));
58 // non-standard hyphenation
59 if (aTmp
.indexOf('[') > -1)
61 OUStringBuffer
aTmp2 ( aTmp
.getLength() );
63 for (sal_Int32 i
= 0; i
< aTmp
.getLength(); i
++)
65 sal_Unicode cTmp
= aTmp
[i
];
73 aTmp
= aTmp2
.makeStringAndClear();
75 return comphelper::string::remove(aTmp
, '=');
78 // Compare Dictionary Entry result
79 enum CDE_RESULT
{ CDE_EQUAL
, CDE_SIMILAR
, CDE_DIFFERENT
};
81 static CDE_RESULT
cmpDicEntry_Impl( const OUString
&rText1
, const OUString
&rText2
)
83 CDE_RESULT eRes
= CDE_DIFFERENT
;
88 { // similar = equal up to trailing '.' and hyphenation positions
89 // marked with '=' and '[' + alternative spelling pattern + ']'
90 if (getNormDicEntry_Impl( rText1
) == getNormDicEntry_Impl( rText2
))
97 // class SvxNewDictionaryDialog -------------------------------------------
99 SvxNewDictionaryDialog::SvxNewDictionaryDialog( Window
* pParent
,
100 Reference
< XSpellChecker1
> &xSpl
) :
102 ModalDialog( pParent
, "OptNewDictionaryDialog" , "cui/ui/optnewdictionarydialog.ui" ),
106 get(pNameEdit
,"nameedit");
107 get(pLanguageLB
,"language");
108 get(pExceptBtn
,"except");
111 pNameEdit
->SetModifyHdl(
112 LINK( this, SvxNewDictionaryDialog
, ModifyHdl_Impl
) );
113 pOKBtn
->SetClickHdl( LINK( this, SvxNewDictionaryDialog
, OKHdl_Impl
) );
116 pLanguageLB
->SetLanguageList( LANG_LIST_ALL
, true, true );
117 pLanguageLB
->SelectEntryPos(0);
122 IMPL_LINK_NOARG(SvxNewDictionaryDialog
, OKHdl_Impl
)
124 OUString sDict
= comphelper::string::stripEnd(pNameEdit
->GetText(), ' ');
125 // add extension for personal dictionaries
128 Reference
< XSearchableDictionaryList
> xDicList( SvxGetDictionaryList() );
130 Sequence
< Reference
< XDictionary
> > aDics
;
132 aDics
= xDicList
->getDictionaries();
133 const Reference
< XDictionary
> *pDic
= aDics
.getConstArray();
134 sal_Int32 nCount
= aDics
.getLength();
138 for (i
= 0; !bFound
&& i
< nCount
; ++i
)
139 if ( sDict
.equalsIgnoreAsciiCase( pDic
[i
]->getName()) )
145 InfoBox( this, CUI_RESSTR( RID_SVXSTR_OPT_DOUBLE_DICTS
) ).Execute();
146 pNameEdit
->GrabFocus();
151 sal_uInt16 nLang
= pLanguageLB
->GetSelectLanguage();
154 // create new dictionary
155 DictionaryType eType
= pExceptBtn
->IsChecked() ?
156 DictionaryType_NEGATIVE
: DictionaryType_POSITIVE
;
159 lang::Locale
aLocale( LanguageTag::convertToLocale(nLang
) );
160 OUString
aURL( linguistic::GetWritableDictionaryURL( sDict
) );
161 xNewDic
= Reference
< XDictionary
> (
162 xDicList
->createDictionary( sDict
, aLocale
, eType
, aURL
) , UNO_QUERY
);
163 xNewDic
->setActive( sal_True
);
165 DBG_ASSERT(xNewDic
.is(), "NULL pointer");
171 // error: couldn't create new dictionary
172 SfxErrorContext
aContext( ERRCTX_SVX_LINGU_DICTIONARY
, OUString(),
173 this, RID_SVXERRCTX
, &CUI_MGR() );
174 ErrorHandler::HandleError( *new StringErrorInfo(
175 ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE
, sDict
) );
177 EndDialog( RET_CANCEL
);
180 if (xDicList
.is() && xNewDic
.is())
182 xDicList
->addDictionary( Reference
< XDictionary
> ( xNewDic
, UNO_QUERY
) );
184 // refresh list of dictionaries
185 //! dictionaries may have been added/removed elsewhere too.
186 aDics
= xDicList
->getDictionaries();
196 IMPL_LINK_NOARG_INLINE_START(SvxNewDictionaryDialog
, ModifyHdl_Impl
)
198 if ( !pNameEdit
->GetText().isEmpty() )
204 IMPL_LINK_NOARG_INLINE_END(SvxNewDictionaryDialog
, ModifyHdl_Impl
)
208 // class SvxEditDictionaryDialog -------------------------------------------
212 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeSvxDictEdit(Window
*pParent
, VclBuilder::stringmap
&)
214 WinBits nWinStyle
= WB_LEFT
|WB_VCENTER
|WB_BORDER
|WB_3DLOOK
;
215 SvxDictEdit
*pEdit
= new SvxDictEdit(pParent
, nWinStyle
);
219 SvxEditDictionaryDialog::SvxEditDictionaryDialog(
221 const OUString
& rName
,
222 Reference
< XSpellChecker1
> &xSpl
) :
224 ModalDialog( pParent
, "EditDictionaryDialog" ,"cui/ui/editdictionarydialog.ui" ),
226 sModify (CUI_RESSTR(STR_MODIFY
)),
232 bDicIsReadonly (false)
235 get(pAllDictsLB
,"book");
236 get(pLangFT
,"lang_label");
240 get(pReplaceFT
,"replace_label");
241 get(pReplaceED
,"replace");
242 get(pWordsLB
,"words");
243 pWordsLB
->set_height_request(pWordsLB
->GetTextHeight() * 8);
244 get(pNewReplacePB
,"newreplace");
245 get(pDeletePB
,"delete");
247 sNew
=pNewReplacePB
->GetText();
248 if (SvxGetDictionaryList().is())
249 aDics
= SvxGetDictionaryList()->getDictionaries();
251 pWordsLB
->SetSelectHdl(LINK(this, SvxEditDictionaryDialog
, SelectHdl
));
252 pWordsLB
->SetTabs(nStaticTabs
);
254 //! we use an algorithm of our own to insert elements sorted
255 pWordsLB
->SetStyle(pWordsLB
->GetStyle()|/*WB_SORT|*/WB_HSCROLL
|WB_CLIPCHILDREN
);
258 nWidth
=pWordED
->GetSizePixel().Width();
260 pNewReplacePB
->SetClickHdl(
261 LINK( this, SvxEditDictionaryDialog
, NewDelHdl
));
262 pDeletePB
->SetClickHdl(
263 LINK( this, SvxEditDictionaryDialog
, NewDelHdl
));
265 pLangLB
->SetSelectHdl(
266 LINK( this, SvxEditDictionaryDialog
, SelectLangHdl_Impl
) );
267 pAllDictsLB
->SetSelectHdl(
268 LINK( this, SvxEditDictionaryDialog
, SelectBookHdl_Impl
) );
270 pWordED
->SetModifyHdl(LINK(this, SvxEditDictionaryDialog
, ModifyHdl
));
271 pReplaceED
->SetModifyHdl(LINK(this, SvxEditDictionaryDialog
, ModifyHdl
));
272 pWordED
->SetActionHdl(LINK(this, SvxEditDictionaryDialog
, NewDelHdl
));
273 pReplaceED
->SetActionHdl(LINK(this, SvxEditDictionaryDialog
, NewDelHdl
));
275 // fill listbox with all available WB's
276 const Reference
< XDictionary
> *pDic
= aDics
.getConstArray();
277 sal_Int32 nCount
= aDics
.getLength();
279 OUString aLookUpEntry
;
280 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
282 Reference
< XDictionary
> xDic( pDic
[i
], UNO_QUERY
);
285 bool bNegative
= xDic
->getDictionaryType() == DictionaryType_NEGATIVE
;
286 OUString
aDicName( xDic
->getName() );
287 const OUString
aTxt( ::GetDicInfoStr( aDicName
,
288 LanguageTag( xDic
->getLocale() ).getLanguageType(), bNegative
) );
289 pAllDictsLB
->InsertEntry( aTxt
);
291 if (rName
== aDicName
)
296 pLangLB
->SetLanguageList( LANG_LIST_ALL
, true, true );
298 pReplaceED
->SetSpaces(true);
299 pWordED
->SetSpaces(true);
303 pAllDictsLB
->SelectEntry( aLookUpEntry
);
304 sal_Int32 nPos
= pAllDictsLB
->GetSelectEntryPos();
306 if ( nPos
== LISTBOX_ENTRY_NOTFOUND
)
309 pAllDictsLB
->SelectEntryPos( nPos
);
311 Reference
< XDictionary
> xDic
;
312 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
313 xDic
= Reference
< XDictionary
> ( aDics
.getConstArray()[ nPos
], UNO_QUERY
);
315 SetLanguage_Impl( LanguageTag( xDic
->getLocale() ).getLanguageType() );
317 // check if dictionary is read-only
318 SetDicReadonly_Impl(xDic
);
319 bool bEnable
= !IsDicReadonly_Impl();
320 pNewReplacePB
->Enable( false );
321 pDeletePB
->Enable( false );
322 pLangFT
->Enable( bEnable
);
323 pLangLB
->Enable( bEnable
);
324 ShowWords_Impl( nPos
);
329 pNewReplacePB
->Disable();
330 pDeletePB
->Disable();
336 SvxEditDictionaryDialog::~SvxEditDictionaryDialog()
342 void SvxEditDictionaryDialog::Paint( const Rectangle& rRect )
344 ModalDialog::Paint(rRect );
346 //Rectangle aRect(aEditDictsBox.GetPosPixel(),aEditDictsBox.GetSizePixel());
348 sal_uInt16 nStyle=BUTTON_DRAW_NOFILL;
349 // aDecoView.DrawButton( aRect, nStyle);
354 void SvxEditDictionaryDialog::SetDicReadonly_Impl(
355 Reference
< XDictionary
> &xDic
)
357 // enable or disable new and delete button according to file attributes
358 bDicIsReadonly
= true;
361 Reference
< frame::XStorable
> xStor( xDic
, UNO_QUERY
);
362 if ( !xStor
.is() // non persistent dictionary
363 || !xStor
->hasLocation() // not yet persistent
364 || !xStor
->isReadonly() )
366 bDicIsReadonly
= false;
373 void SvxEditDictionaryDialog::SetLanguage_Impl( util::Language nLanguage
)
376 pLangLB
->SelectLanguage( nLanguage
);
379 sal_uLong
SvxEditDictionaryDialog::GetLBInsertPos(const OUString
&rDicWord
)
381 sal_uLong nPos
= TREELIST_ENTRY_NOTFOUND
;
383 IntlWrapper
aIntlWrapper( Application::GetSettings().GetLanguageTag() );
384 const CollatorWrapper
* pCollator
= aIntlWrapper
.getCollator();
386 for( j
= 0; j
< pWordsLB
->GetEntryCount(); j
++ )
388 SvTreeListEntry
* pEntry
= pWordsLB
->GetEntry(j
);
389 DBG_ASSERT( pEntry
, "NULL pointer");
390 OUString
aNormEntry( getNormDicEntry_Impl( rDicWord
) );
391 sal_Int32 nCmpRes
= pCollator
->
392 compareString( aNormEntry
, getNormDicEntry_Impl( pWordsLB
->GetEntryText(pEntry
, 0) ) );
396 if (j
< pWordsLB
->GetEntryCount()) // entry found?
402 void SvxEditDictionaryDialog::RemoveDictEntry(SvTreeListEntry
* pEntry
)
404 sal_Int32 nLBPos
= pAllDictsLB
->GetSelectEntryPos();
406 if ( pEntry
!= NULL
&& nLBPos
!= LISTBOX_ENTRY_NOTFOUND
)
408 OUString
sTmpShort(pWordsLB
->GetEntryText(pEntry
, 0));
410 Reference
< XDictionary
> xDic
= aDics
.getConstArray()[ nLBPos
];
411 if (xDic
->remove( sTmpShort
)) // sal_True on success
413 pWordsLB
->GetModel()->Remove(pEntry
);
420 IMPL_LINK_NOARG(SvxEditDictionaryDialog
, SelectBookHdl_Impl
)
422 sal_Int32 nPos
= pAllDictsLB
->GetSelectEntryPos();
424 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
426 pNewReplacePB
->Enable( false );
427 pDeletePB
->Enable( false );
428 // display dictionary
429 ShowWords_Impl( nPos
);
430 // enable or disable new and delete button according to file attributes
431 Reference
< XDictionary
> xDic( aDics
.getConstArray()[ nPos
], UNO_QUERY
);
433 SetLanguage_Impl( LanguageTag( xDic
->getLocale() ).getLanguageType() );
435 SetDicReadonly_Impl(xDic
);
436 bool bEnable
= !IsDicReadonly_Impl();
437 pLangFT
->Enable( bEnable
);
438 pLangLB
->Enable( bEnable
);
445 IMPL_LINK_NOARG(SvxEditDictionaryDialog
, SelectLangHdl_Impl
)
447 sal_Int32 nDicPos
= pAllDictsLB
->GetSelectEntryPos();
448 sal_Int32 nLang
= pLangLB
->GetSelectLanguage();
449 Reference
< XDictionary
> xDic( aDics
.getConstArray()[ nDicPos
], UNO_QUERY
);
450 sal_Int16 nOldLang
= LanguageTag( xDic
->getLocale() ).getLanguageType();
452 if ( nLang
!= nOldLang
)
454 QueryBox
aBox( this, CUI_RES( RID_SFXQB_SET_LANGUAGE
) );
455 OUString
sTxt( aBox
.GetMessText() );
456 sTxt
= sTxt
.replaceFirst( "%1", pAllDictsLB
->GetSelectEntry() );
457 aBox
.SetMessText( sTxt
);
459 if ( aBox
.Execute() == RET_YES
)
461 xDic
->setLocale( LanguageTag::convertToLocale( nLang
) );
462 bool bNegativ
= xDic
->getDictionaryType() == DictionaryType_NEGATIVE
;
464 const OUString
sName(
465 ::GetDicInfoStr( xDic
->getName(),
466 LanguageTag( xDic
->getLocale() ).getLanguageType(),
468 pAllDictsLB
->RemoveEntry( nDicPos
);
469 pAllDictsLB
->InsertEntry( sName
, nDicPos
);
470 pAllDictsLB
->SelectEntryPos( nDicPos
);
473 SetLanguage_Impl( nOldLang
);
480 void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId
)
482 Reference
< XDictionary
> xDic
= aDics
.getConstArray()[ nId
];
489 pWordED
->SetText(aStr
);
490 pReplaceED
->SetText(aStr
);
492 if(xDic
->getDictionaryType() != DictionaryType_POSITIVE
)
496 // make controls for replacement text active
497 if(!pReplaceFT
->IsVisible())
499 Size aSize
=pWordED
->GetSizePixel();
500 aSize
.Width()=nWidth
;
501 pWordED
->SetSizePixel(aSize
);
510 // deactivate controls for replacement text
511 if(pReplaceFT
->IsVisible())
513 Size aSize
=pWordED
->GetSizePixel();
514 aSize
.Width()=pWordsLB
->GetSizePixel().Width();
515 pWordED
->SetSizePixel(aSize
);
522 pWordsLB
->SetTabs(nStaticTabs
);
525 Sequence
< Reference
< XDictionaryEntry
> > aEntries( xDic
->getEntries() );
526 const Reference
< XDictionaryEntry
> *pEntry
= aEntries
.getConstArray();
527 sal_Int32 nCount
= aEntries
.getLength();
529 for (sal_Int32 i
= 0; i
< nCount
; i
++)
531 aStr
= pEntry
[i
]->getDictionaryWord();
532 sal_uLong nPos
= GetLBInsertPos( aStr
);
533 if(pEntry
[i
]->isNegative())
536 aStr
+= pEntry
[i
]->getReplacementText();
538 pWordsLB
->InsertEntry(aStr
, 0, false, nPos
== TREELIST_ENTRY_NOTFOUND
? TREELIST_APPEND
: nPos
);
541 if (pWordsLB
->GetEntryCount())
543 pWordED
->SetText( pWordsLB
->GetEntryText((sal_uLong
)0, 0) );
544 pReplaceED
->SetText( pWordsLB
->GetEntryText((sal_uLong
)0, 1) );
552 IMPL_LINK(SvxEditDictionaryDialog
, SelectHdl
, SvTabListBox
*, pBox
)
558 SvTreeListEntry
* pEntry
= pBox
->FirstSelected();
559 OUString
sTmpShort(pBox
->GetEntryText(pEntry
, 0));
560 // without this the curser is always at the beginning of a word, if the text
561 // is set over the ModifyHdl, although you're editing there at the moment
562 if(pWordED
->GetText() != sTmpShort
)
563 pWordED
->SetText(sTmpShort
);
564 pReplaceED
->SetText(pBox
->GetEntryText(pEntry
, 1));
567 bFirstSelect
= false;
569 // entries in the list box should exactly correspond to those from the
571 pNewReplacePB
->Enable(false);
572 pDeletePB
->Enable( true && !IsDicReadonly_Impl() );
579 IMPL_LINK(SvxEditDictionaryDialog
, NewDelHdl
, PushButton
*, pBtn
)
581 SvTreeListEntry
* pEntry
= pWordsLB
->FirstSelected();
583 if(pBtn
== pDeletePB
)
585 DBG_ASSERT(pEntry
, "keine Eintrag selektiert");
588 pWordED
->SetText(aStr
);
589 pReplaceED
->SetText(aStr
);
590 pDeletePB
->Disable();
592 RemoveDictEntry(pEntry
); // remove entry from dic and list-box
594 if(pBtn
== pNewReplacePB
|| pNewReplacePB
->IsEnabled())
596 SvTreeListEntry
* _pEntry
= pWordsLB
->FirstSelected();
597 OUString
aNewWord(pWordED
->GetText());
598 OUString
sEntry(aNewWord
);
599 OUString
aReplaceStr(pReplaceED
->GetText());
601 sal_Int16 nAddRes
= DIC_ERR_UNKNOWN
;
602 sal_Int32 nPos
= pAllDictsLB
->GetSelectEntryPos();
603 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
&& !aNewWord
.isEmpty())
605 DBG_ASSERT(nPos
< aDics
.getLength(), "invalid dictionary index");
606 Reference
< XDictionary
> xDic( aDics
.getConstArray()[ nPos
], UNO_QUERY
);
609 // make changes in dic
611 //! ...IsVisible should reflect whether the dictionary is a negativ
612 //! or not (hopefully...)
613 bool bIsNegEntry
= pReplaceFT
->IsVisible();
616 aRplcText
= aReplaceStr
;
618 if (_pEntry
) // entry selected in pWordsLB ie action = modify entry
619 xDic
->remove( pWordsLB
->GetEntryText( _pEntry
, 0 ) );
620 // if remove has failed the following add should fail too
621 // and thus a warning message should be triggered...
623 nAddRes
= linguistic::AddEntryToDic( xDic
,
624 aNewWord
, bIsNegEntry
,
625 aRplcText
, LanguageTag( xDic
->getLocale() ).getLanguageType(), false );
628 if (DIC_ERR_NONE
!= nAddRes
)
629 SvxDicError( this, nAddRes
);
631 if(DIC_ERR_NONE
== nAddRes
&& !sEntry
.isEmpty())
633 // insert new entry in list-box etc...
635 pWordsLB
->SetUpdateMode(false);
636 sal_uLong _nPos
= TREELIST_ENTRY_NOTFOUND
;
638 if(pReplaceFT
->IsVisible())
641 sEntry
+= aReplaceStr
;
644 SvTreeListEntry
* pNewEntry
= NULL
;
645 if(_pEntry
) // entry selected in pWordsLB ie action = modify entry
647 pWordsLB
->SetEntryText( sEntry
, _pEntry
);
652 _nPos
= GetLBInsertPos( aNewWord
);
653 SvTreeListEntry
* pInsEntry
= pWordsLB
->InsertEntry(sEntry
, 0, false,
654 _nPos
== TREELIST_ENTRY_NOTFOUND
? TREELIST_APPEND
: _nPos
);
655 pNewEntry
= pInsEntry
;
658 pWordsLB
->MakeVisible( pNewEntry
);
659 pWordsLB
->SetUpdateMode(true);
660 // if the request came from the ReplaceEdit, give focus to the ShortEdit
661 if(pReplaceED
->HasFocus())
662 pWordED
->GrabFocus();
667 // this can only be an enter in one of the two edit fields
668 // which means EndDialog() - has to be evaluated in KeyInput
677 IMPL_LINK(SvxEditDictionaryDialog
, ModifyHdl
, Edit
*, pEdt
)
679 SvTreeListEntry
* pFirstSel
= pWordsLB
->FirstSelected();
680 OUString rEntry
= pEdt
->GetText();
682 sal_Int32 nWordLen
= rEntry
.getLength();
683 const OUString
& rRepString
= pReplaceED
->GetText();
685 bool bEnableNewReplace
= false;
686 bool bEnableDelete
= false;
687 OUString aNewReplaceText
= sNew
;
694 bool bTmpSelEntry
=false;
695 CDE_RESULT eCmpRes
= CDE_DIFFERENT
;
697 for(sal_uLong i
= 0; i
< pWordsLB
->GetEntryCount(); i
++)
699 SvTreeListEntry
* pEntry
= pWordsLB
->GetEntry( i
);
700 OUString
aTestStr( pWordsLB
->GetEntryText(pEntry
, 0) );
701 eCmpRes
= cmpDicEntry_Impl( rEntry
, aTestStr
);
702 if(CDE_DIFFERENT
!= eCmpRes
)
704 if(!rRepString
.isEmpty())
707 pWordsLB
->SetCurEntry(pEntry
);
710 pReplaceED
->SetText(pWordsLB
->GetEntryText(pEntry
, 1));
712 if (CDE_SIMILAR
== eCmpRes
)
714 aNewReplaceText
= sModify
;
715 bEnableNewReplace
= true;
720 else if(getNormDicEntry_Impl(aTestStr
).indexOf(
721 getNormDicEntry_Impl( rEntry
) ) == 0
725 pWordsLB
->MakeVisible(pEntry
);
729 aNewReplaceText
= sNew
;
730 bEnableNewReplace
= true;
736 pWordsLB
->SelectAll(false);
739 aNewReplaceText
= sNew
;
740 bEnableNewReplace
= true;
742 bEnableDelete
= CDE_DIFFERENT
!= eCmpRes
;
744 else if(pWordsLB
->GetEntryCount()>0)
746 SvTreeListEntry
* pEntry
= pWordsLB
->GetEntry( 0 );
748 pWordsLB
->MakeVisible(pEntry
);
752 else if(pEdt
== pReplaceED
)
754 OUString aReplaceText
;
756 if (pFirstSel
) // a pWordsLB entry is selected
758 aWordText
= pWordsLB
->GetEntryText( pFirstSel
, 0 );
759 aReplaceText
= pWordsLB
->GetEntryText( pFirstSel
, 1 );
761 aNewReplaceText
= sModify
;
762 bEnableDelete
= true;
765 CDE_EQUAL
!= cmpDicEntry_Impl(pWordED
->GetText(), aWordText
)
766 || CDE_EQUAL
!= cmpDicEntry_Impl(pReplaceED
->GetText(), aReplaceText
);
767 if (!pWordED
->GetText().isEmpty() && bIsChange
)
768 bEnableNewReplace
= true;
771 pNewReplacePB
->SetText( aNewReplaceText
);
772 pNewReplacePB
->Enable( bEnableNewReplace
&& !IsDicReadonly_Impl() );
773 pDeletePB
->Enable( bEnableDelete
&& !IsDicReadonly_Impl() );
781 void SvxDictEdit::KeyInput( const KeyEvent
& rKEvt
)
783 const KeyCode aKeyCode
= rKEvt
.GetKeyCode();
784 const sal_uInt16 nModifier
= aKeyCode
.GetModifier();
785 if( aKeyCode
.GetCode() == KEY_RETURN
)
787 // if there's nothing done on enter, call the
788 // base class after all to close the dialog
789 if(!nModifier
&& !aActionLink
.Call(this))
790 Edit::KeyInput(rKEvt
);
792 else if(bSpaces
|| aKeyCode
.GetCode() != KEY_SPACE
)
793 Edit::KeyInput(rKEvt
);
797 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */