LCOV - code coverage report
Current view: top level - cui/source/options - optdict.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 400 0.0 %
Date: 2012-08-25 Functions: 0 27 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1082 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/shl.hxx>
      30                 :            : #include <editeng/unolingu.hxx>
      31                 :            : #include <svx/dlgutil.hxx>
      32                 :            : #include <sfx2/sfxuno.hxx>
      33                 :            : #include <svl/eitem.hxx>
      34                 :            : #include <com/sun/star/frame/XStorable.hpp>
      35                 :            : #include <comphelper/processfactory.hxx>
      36                 :            : #include <comphelper/string.hxx>
      37                 :            : #include <unotools/intlwrapper.hxx>
      38                 :            : #include <vcl/svapp.hxx>
      39                 :            : #include <vcl/msgbox.hxx>
      40                 :            : #include <svx/dialogs.hrc>
      41                 :            : 
      42                 :            : #define _SVX_OPTDICT_CXX
      43                 :            : 
      44                 :            : #include <linguistic/misc.hxx>
      45                 :            : #include <cuires.hrc>
      46                 :            : #include "optdict.hrc"
      47                 :            : #include "optdict.hxx"
      48                 :            : #include <dialmgr.hxx>
      49                 :            : #include <svx/svxerr.hxx>
      50                 :            : 
      51                 :            : using namespace ::com::sun::star;
      52                 :            : using namespace ::com::sun::star::uno;
      53                 :            : using namespace ::com::sun::star::linguistic2;
      54                 :            : 
      55                 :            : // static ----------------------------------------------------------------
      56                 :            : 
      57                 :            : static const short  NOACTDICT   = -1;
      58                 :            : 
      59                 :            : static long nStaticTabs[]=
      60                 :            : {
      61                 :            :     2,10,71,120
      62                 :            : };
      63                 :            : 
      64                 :            : // static function -------------------------------------------------------
      65                 :            : 
      66                 :          0 : static String getNormDicEntry_Impl(const rtl::OUString &rText)
      67                 :            : {
      68         [ #  # ]:          0 :     rtl::OUString aTmp(comphelper::string::stripEnd(rText, '.'));
      69         [ #  # ]:          0 :     return comphelper::string::remove(aTmp, '=');
      70                 :            : }
      71                 :            : 
      72                 :            : // Compare Dictionary Entry  result
      73                 :            : enum CDE_RESULT { CDE_EQUAL, CDE_SIMILAR, CDE_DIFFERENT };
      74                 :            : 
      75                 :          0 : static CDE_RESULT cmpDicEntry_Impl( const String &rText1, const String &rText2 )
      76                 :            : {
      77                 :          0 :     CDE_RESULT eRes = CDE_DIFFERENT;
      78                 :            : 
      79         [ #  # ]:          0 :     if (rText1 == rText2)
      80                 :          0 :         eRes = CDE_EQUAL;
      81                 :            :     else
      82                 :            :     {   // similar = equal up to trailing '.' and hyphenation positions
      83                 :            :         // marked with '='
      84 [ #  # ][ #  # ]:          0 :         if (getNormDicEntry_Impl( rText1 ) == getNormDicEntry_Impl( rText2 ))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      85                 :          0 :             eRes = CDE_SIMILAR;
      86                 :            :     }
      87                 :            : 
      88                 :          0 :     return eRes;
      89                 :            : }
      90                 :            : 
      91                 :            : // class SvxNewDictionaryDialog -------------------------------------------
      92                 :            : 
      93                 :          0 : SvxNewDictionaryDialog::SvxNewDictionaryDialog( Window* pParent,
      94                 :            :         Reference< XSpellChecker1 >  &xSpl ) :
      95                 :            : 
      96                 :          0 :     ModalDialog( pParent, CUI_RES( RID_SFXDLG_NEWDICT ) ),
      97                 :            : 
      98         [ #  # ]:          0 :     aNewDictBox     ( this, CUI_RES( GB_NEWDICT ) ),
      99         [ #  # ]:          0 :     aNameText       ( this, CUI_RES( FT_DICTNAME ) ),
     100         [ #  # ]:          0 :     aNameEdit       ( this, CUI_RES( ED_DICTNAME ) ),
     101         [ #  # ]:          0 :     aLanguageText   ( this, CUI_RES( FT_DICTLANG ) ),
     102         [ #  # ]:          0 :     aLanguageLB     ( this, CUI_RES( LB_DICTLANG ) ),
     103         [ #  # ]:          0 :     aExceptBtn      ( this, CUI_RES( BTN_EXCEPT ) ),
     104         [ #  # ]:          0 :     aOKBtn          ( this, CUI_RES( BTN_NEWDICT_OK ) ),
     105         [ #  # ]:          0 :     aCancelBtn      ( this, CUI_RES( BTN_NEWDICT_ESC ) ),
     106         [ #  # ]:          0 :     aHelpBtn        ( this, CUI_RES( BTN_NEWDICT_HLP ) ),
     107 [ #  # ][ #  # ]:          0 :     xSpell( xSpl )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     108                 :            : {
     109                 :            :     // install handler
     110                 :            :     aNameEdit.SetModifyHdl(
     111         [ #  # ]:          0 :         LINK( this, SvxNewDictionaryDialog, ModifyHdl_Impl ) );
     112         [ #  # ]:          0 :     aOKBtn.SetClickHdl( LINK( this, SvxNewDictionaryDialog, OKHdl_Impl ) );
     113                 :            : 
     114                 :            :     // display languages
     115         [ #  # ]:          0 :     aLanguageLB.SetLanguageList( LANG_LIST_ALL, sal_True, sal_True );
     116         [ #  # ]:          0 :     aLanguageLB.SelectEntryPos(0);
     117                 :            : 
     118         [ #  # ]:          0 :     aNameText.SetAccessibleRelationMemberOf( &aNewDictBox );
     119         [ #  # ]:          0 :     aNameEdit.SetAccessibleRelationMemberOf( &aNewDictBox );
     120         [ #  # ]:          0 :     aLanguageText.SetAccessibleRelationMemberOf( &aNewDictBox );
     121         [ #  # ]:          0 :     aLanguageLB.SetAccessibleRelationMemberOf( &aNewDictBox );
     122                 :            : 
     123         [ #  # ]:          0 :     FreeResource();
     124                 :          0 : }
     125                 :            : 
     126                 :            : // -----------------------------------------------------------------------
     127                 :            : 
     128                 :          0 : IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl)
     129                 :            : {
     130 [ #  # ][ #  # ]:          0 :     String sDict = comphelper::string::stripEnd(aNameEdit.GetText(), ' ');
         [ #  # ][ #  # ]
                 [ #  # ]
     131                 :            :     // add extension for personal dictionaries
     132         [ #  # ]:          0 :     sDict.AppendAscii(".dic");
     133                 :            : 
     134         [ #  # ]:          0 :     Reference< XDictionaryList >  xDicList( SvxGetDictionaryList() );
     135                 :            : 
     136         [ #  # ]:          0 :     Sequence< Reference< XDictionary >  > aDics;
     137         [ #  # ]:          0 :     if (xDicList.is())
     138 [ #  # ][ #  # ]:          0 :         aDics = xDicList->getDictionaries();
         [ #  # ][ #  # ]
     139                 :          0 :     const Reference< XDictionary >  *pDic = aDics.getConstArray();
     140                 :          0 :     sal_Int32 nCount = (sal_uInt16) aDics.getLength();
     141                 :            : 
     142                 :          0 :     sal_Bool bFound = sal_False;
     143                 :            :     sal_uInt16 i;
     144 [ #  # ][ #  # ]:          0 :     for (i = 0; !bFound && i < nCount; ++i )
                 [ #  # ]
     145 [ #  # ][ #  # ]:          0 :         if ( sDict.EqualsIgnoreCaseAscii( String(pDic[i]->getName()) ))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     146                 :          0 :             bFound = sal_True;
     147                 :            : 
     148         [ #  # ]:          0 :     if ( bFound )
     149                 :            :     {
     150                 :            :         // duplicate names?
     151 [ #  # ][ #  # ]:          0 :         InfoBox( this, CUI_RESSTR( RID_SVXSTR_OPT_DOUBLE_DICTS ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     152         [ #  # ]:          0 :         aNameEdit.GrabFocus();
     153                 :          0 :         return 0;
     154                 :            :     }
     155                 :            : 
     156                 :            :     // create and add
     157         [ #  # ]:          0 :     sal_uInt16 nLang = aLanguageLB.GetSelectLanguage();
     158                 :            :     try
     159                 :            :     {
     160                 :            :         // create new dictionary
     161         [ #  # ]:          0 :         DictionaryType eType = aExceptBtn.IsChecked() ?
     162         [ #  # ]:          0 :                 DictionaryType_NEGATIVE : DictionaryType_POSITIVE;
     163         [ #  # ]:          0 :         if (xDicList.is())
     164                 :            :         {
     165         [ #  # ]:          0 :             lang::Locale aLocale( SvxCreateLocale(nLang) );
     166         [ #  # ]:          0 :             String aURL( linguistic::GetWritableDictionaryURL( sDict ) );
     167                 :            :             xNewDic = Reference< XDictionary > (
     168 [ #  # ][ #  # ]:          0 :                     xDicList->createDictionary( sDict, aLocale, eType, aURL ) , UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     169 [ #  # ][ #  # ]:          0 :             xNewDic->setActive( sal_True );
                 [ #  # ]
     170                 :            :         }
     171                 :            :         DBG_ASSERT(xNewDic.is(), "NULL pointer");
     172                 :            :     }
     173         [ #  # ]:          0 :     catch(...)
     174                 :            :     {
     175         [ #  # ]:          0 :         xNewDic = NULL;
     176                 :            : 
     177                 :            :         // error: couldn't create new dictionary
     178                 :            :         SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, String(),
     179   [ #  #  #  #  :          0 :             this, RID_SVXERRCTX, &CUI_MGR() );
             #  #  #  # ]
     180                 :            :         ErrorHandler::HandleError( *new StringErrorInfo(
     181   [ #  #  #  #  :          0 :                 ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) );
             #  #  #  # ]
     182                 :            : 
     183   [ #  #  #  # ]:          0 :         EndDialog( RET_CANCEL );
     184                 :            :     }
     185                 :            : 
     186 [ #  # ][ #  # ]:          0 :     if (xDicList.is() && xNewDic.is())
                 [ #  # ]
     187                 :            :     {
     188 [ #  # ][ #  # ]:          0 :         xDicList->addDictionary( Reference< XDictionary > ( xNewDic, UNO_QUERY ) );
                 [ #  # ]
     189                 :            : 
     190                 :            :         // refresh list of dictionaries
     191                 :            :         //! dictionaries may have been added/removed elsewhere too.
     192 [ #  # ][ #  # ]:          0 :         aDics = xDicList->getDictionaries();
         [ #  # ][ #  # ]
     193                 :            :     }
     194                 :          0 :     pDic = aDics.getConstArray();
     195                 :          0 :     nCount = (sal_uInt16) aDics.getLength();
     196                 :            : 
     197                 :            : 
     198         [ #  # ]:          0 :     EndDialog( RET_OK );
     199 [ #  # ][ #  # ]:          0 :     return 0;
     200                 :            : }
     201                 :            : 
     202                 :            : // -----------------------------------------------------------------------
     203                 :            : 
     204                 :          0 : IMPL_LINK_NOARG_INLINE_START(SvxNewDictionaryDialog, ModifyHdl_Impl)
     205                 :            : {
     206         [ #  # ]:          0 :     if ( aNameEdit.GetText().Len() )
     207                 :          0 :         aOKBtn.Enable();
     208                 :            :     else
     209                 :          0 :         aOKBtn.Disable();
     210                 :          0 :     return 0;
     211                 :            : }
     212                 :          0 : IMPL_LINK_NOARG_INLINE_END(SvxNewDictionaryDialog, ModifyHdl_Impl)
     213                 :            : 
     214                 :            : //==========================================================================
     215                 :            : //
     216                 :            : // class SvxEditDictionaryDialog -------------------------------------------
     217                 :            : //
     218                 :            : //==========================================================================
     219                 :            : 
     220                 :          0 : SvxEditDictionaryDialog::SvxEditDictionaryDialog(
     221                 :            :             Window* pParent,
     222                 :            :             const String& rName,
     223                 :            :             Reference< XSpellChecker1 >  &xSpl ) :
     224                 :            : 
     225                 :          0 :     ModalDialog( pParent, CUI_RES( RID_SFXDLG_EDITDICT ) ),
     226                 :            : 
     227         [ #  # ]:          0 :     aBookFT         ( this, CUI_RES( FT_BOOK ) ),
     228         [ #  # ]:          0 :     aAllDictsLB     ( this, CUI_RES( LB_ALLDICTS ) ),
     229         [ #  # ]:          0 :     aLangFT         ( this, CUI_RES( FT_DICTLANG ) ),
     230         [ #  # ]:          0 :     aLangLB         ( this, CUI_RES( LB_DICTLANG ) ),
     231                 :            : 
     232         [ #  # ]:          0 :     aWordFT         ( this, CUI_RES( FT_WORD ) ),
     233         [ #  # ]:          0 :     aWordED         ( this, CUI_RES( ED_WORD ) ),
     234         [ #  # ]:          0 :     aReplaceFT      ( this, CUI_RES( FT_REPLACE ) ),
     235         [ #  # ]:          0 :     aReplaceED      ( this, CUI_RES( ED_REPLACE ) ),
     236         [ #  # ]:          0 :     aWordsLB        ( this, CUI_RES( TLB_REPLACE ) ),
     237         [ #  # ]:          0 :     aNewReplacePB   ( this, CUI_RES( PB_NEW_REPLACE ) ),
     238         [ #  # ]:          0 :     aDeletePB       ( this, CUI_RES( PB_DELETE_REPLACE ) ),
     239         [ #  # ]:          0 :     aEditDictsBox   ( this, CUI_RES( GB_EDITDICTS ) ),
     240         [ #  # ]:          0 :     aHelpBtn        ( this, CUI_RES( BTN_EDITHELP ) ),
     241         [ #  # ]:          0 :     aCloseBtn       ( this, CUI_RES( BTN_EDITCLOSE ) ),
     242         [ #  # ]:          0 :     sModify         (CUI_RES(STR_MODIFY)),
     243                 :            :     sNew            (aNewReplacePB.GetText()),
     244                 :            :     aDecoView       ( this),
     245                 :            :     xSpell          ( xSpl ),
     246                 :            :     nOld            ( NOACTDICT ),
     247                 :            :     bFirstSelect    (sal_True),
     248 [ #  # ][ #  # ]:          0 :     bDoNothing      (sal_False)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     249                 :            : 
     250                 :            : {
     251 [ #  # ][ #  # ]:          0 :     if (SvxGetDictionaryList().is())
     252 [ #  # ][ #  # ]:          0 :         aDics = SvxGetDictionaryList()->getDictionaries();
         [ #  # ][ #  # ]
                 [ #  # ]
     253                 :            : 
     254         [ #  # ]:          0 :     aWordsLB.SetSelectHdl(LINK(this, SvxEditDictionaryDialog, SelectHdl));
     255         [ #  # ]:          0 :     aWordsLB.SetTabs(nStaticTabs);
     256                 :            : 
     257                 :            :     //! we use an algorithm of our own to insert elements sorted
     258 [ #  # ][ #  # ]:          0 :     aWordsLB.SetStyle(aWordsLB.GetStyle()|/*WB_SORT|*/WB_HSCROLL|WB_CLIPCHILDREN);
     259                 :            : 
     260                 :            : 
     261         [ #  # ]:          0 :     nWidth=aWordED.GetSizePixel().Width();
     262                 :            :     // install handler
     263                 :            :     aNewReplacePB.SetClickHdl(
     264         [ #  # ]:          0 :         LINK( this, SvxEditDictionaryDialog, NewDelHdl));
     265                 :            :     aDeletePB.SetClickHdl(
     266         [ #  # ]:          0 :         LINK( this, SvxEditDictionaryDialog, NewDelHdl));
     267                 :            : 
     268                 :            :     aLangLB.SetSelectHdl(
     269         [ #  # ]:          0 :         LINK( this, SvxEditDictionaryDialog, SelectLangHdl_Impl ) );
     270                 :            :     aAllDictsLB.SetSelectHdl(
     271         [ #  # ]:          0 :         LINK( this, SvxEditDictionaryDialog, SelectBookHdl_Impl ) );
     272                 :            : 
     273         [ #  # ]:          0 :     aWordED.SetModifyHdl(LINK(this, SvxEditDictionaryDialog, ModifyHdl));
     274         [ #  # ]:          0 :     aReplaceED.SetModifyHdl(LINK(this, SvxEditDictionaryDialog, ModifyHdl));
     275         [ #  # ]:          0 :     aWordED.SetActionHdl(LINK(this, SvxEditDictionaryDialog, NewDelHdl));
     276         [ #  # ]:          0 :     aReplaceED.SetActionHdl(LINK(this, SvxEditDictionaryDialog, NewDelHdl));
     277                 :            : 
     278                 :            :     // fill listbox with all available WB's
     279                 :          0 :     const Reference< XDictionary >  *pDic = aDics.getConstArray();
     280                 :          0 :     sal_Int32 nCount = aDics.getLength();
     281                 :            : 
     282         [ #  # ]:          0 :     String aLookUpEntry;
     283         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < nCount; ++i )
     284                 :            :     {
     285         [ #  # ]:          0 :         Reference< XDictionary >  xDic( pDic[i], UNO_QUERY );
     286         [ #  # ]:          0 :         if (xDic.is())
     287                 :            :         {
     288 [ #  # ][ #  # ]:          0 :             sal_Bool bNegative = xDic->getDictionaryType() == DictionaryType_NEGATIVE ?
     289         [ #  # ]:          0 :                                 sal_True : sal_False;
     290 [ #  # ][ #  # ]:          0 :             String aDicName( xDic->getName() );
                 [ #  # ]
     291 [ #  # ][ #  # ]:          0 :             const String aTxt( ::GetDicInfoStr( aDicName, SvxLocaleToLanguage( xDic->getLocale() ),
                 [ #  # ]
     292         [ #  # ]:          0 :                                                  bNegative ) );
     293         [ #  # ]:          0 :             aAllDictsLB.InsertEntry( aTxt );
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :             if (rName == aDicName)
     296 [ #  # ][ #  # ]:          0 :                 aLookUpEntry = aTxt;
                 [ #  # ]
     297                 :            :         }
     298                 :          0 :     }
     299                 :            : 
     300         [ #  # ]:          0 :     aLangLB.SetLanguageList( LANG_LIST_ALL, sal_True, sal_True );
     301                 :            : 
     302                 :          0 :     aReplaceED.SetSpaces(sal_True);
     303                 :          0 :     aWordED.SetSpaces(sal_True);
     304                 :            : 
     305         [ #  # ]:          0 :     if ( nCount > 0 )
     306                 :            :     {
     307         [ #  # ]:          0 :         aAllDictsLB.SelectEntry( aLookUpEntry );
     308         [ #  # ]:          0 :         sal_uInt16 nPos = aAllDictsLB.GetSelectEntryPos();
     309                 :            : 
     310         [ #  # ]:          0 :         if ( nPos == LISTBOX_ENTRY_NOTFOUND )
     311                 :            :         {
     312                 :          0 :             nPos = 0;
     313         [ #  # ]:          0 :             aAllDictsLB.SelectEntryPos( nPos );
     314                 :            :         }
     315                 :          0 :         Reference< XDictionary >  xDic;
     316         [ #  # ]:          0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
     317 [ #  # ][ #  # ]:          0 :             xDic = Reference< XDictionary > ( aDics.getConstArray()[ nPos ], UNO_QUERY );
     318         [ #  # ]:          0 :         if (xDic.is())
     319 [ #  # ][ #  # ]:          0 :             SetLanguage_Impl( SvxLocaleToLanguage( xDic->getLocale() ) );
         [ #  # ][ #  # ]
     320                 :            : 
     321                 :            :         // check if dictionary is read-only
     322         [ #  # ]:          0 :         SetDicReadonly_Impl(xDic);
     323                 :          0 :         sal_Bool bEnable = !IsDicReadonly_Impl();
     324         [ #  # ]:          0 :         aNewReplacePB   .Enable( sal_False );
     325         [ #  # ]:          0 :         aDeletePB       .Enable( sal_False );
     326         [ #  # ]:          0 :         aLangFT.Enable( bEnable );
     327         [ #  # ]:          0 :         aLangLB.Enable( bEnable );
     328         [ #  # ]:          0 :         ShowWords_Impl( nPos );
     329                 :            : 
     330                 :            :     }
     331                 :            :     else
     332                 :            :     {
     333         [ #  # ]:          0 :         aNewReplacePB.Disable();
     334         [ #  # ]:          0 :         aDeletePB    .Disable();
     335                 :            :     }
     336 [ #  # ][ #  # ]:          0 :     FreeResource();
     337                 :          0 : }
     338                 :            : 
     339                 :            : // -----------------------------------------------------------------------
     340                 :            : 
     341 [ #  # ][ #  # ]:          0 : SvxEditDictionaryDialog::~SvxEditDictionaryDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     342                 :            : {
     343         [ #  # ]:          0 : }
     344                 :            : 
     345                 :            : // -----------------------------------------------------------------------
     346                 :            : 
     347                 :          0 : void SvxEditDictionaryDialog::Paint( const Rectangle& rRect )
     348                 :            : {
     349         [ #  # ]:          0 :     ModalDialog::Paint(rRect );
     350                 :            : 
     351 [ #  # ][ #  # ]:          0 :     Rectangle aRect(aEditDictsBox.GetPosPixel(),aEditDictsBox.GetSizePixel());
                 [ #  # ]
     352                 :            : 
     353                 :          0 :     sal_uInt16 nStyle=BUTTON_DRAW_NOFILL;
     354         [ #  # ]:          0 :     aDecoView.DrawButton( aRect, nStyle);
     355                 :          0 : }
     356                 :            : 
     357                 :            : // -----------------------------------------------------------------------
     358                 :            : 
     359                 :          0 : void SvxEditDictionaryDialog::SetDicReadonly_Impl(
     360                 :            :             Reference< XDictionary >  &xDic )
     361                 :            : {
     362                 :            :     // enable or disable new and delete button according to file attributes
     363                 :          0 :     bDicIsReadonly = sal_True;
     364         [ #  # ]:          0 :     if (xDic.is())
     365                 :            :     {
     366         [ #  # ]:          0 :         Reference< frame::XStorable >  xStor( xDic, UNO_QUERY );
     367 [ #  # ][ #  # ]:          0 :         if (   !xStor.is()              // non persistent dictionary
         [ #  # ][ #  # ]
     368 [ #  # ][ #  # ]:          0 :             || !xStor->hasLocation()    // not yet persistent
     369 [ #  # ][ #  # ]:          0 :             || !xStor->isReadonly() )
     370                 :            :         {
     371                 :          0 :             bDicIsReadonly = sal_False;
     372                 :          0 :         }
     373                 :            :     }
     374                 :          0 : }
     375                 :            : 
     376                 :            : // -----------------------------------------------------------------------
     377                 :            : 
     378                 :          0 : void SvxEditDictionaryDialog::SetLanguage_Impl( util::Language nLanguage )
     379                 :            : {
     380                 :            :     // select language
     381                 :          0 :     aLangLB.SelectLanguage( nLanguage );
     382                 :          0 : }
     383                 :            : 
     384                 :          0 : sal_uInt16 SvxEditDictionaryDialog::GetLBInsertPos(const String &rDicWord)
     385                 :            : {
     386                 :          0 :     sal_uInt16 nPos = USHRT_MAX;
     387                 :            : 
     388 [ #  # ][ #  # ]:          0 :     IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     389         [ #  # ]:          0 :     const CollatorWrapper* pCollator = aIntlWrapper.getCollator();
     390                 :            :     sal_uInt16 j;
     391         [ #  # ]:          0 :     for( j = 0; j < aWordsLB.GetEntryCount(); j++ )
     392                 :            :     {
     393         [ #  # ]:          0 :         SvLBoxEntry* pEntry = aWordsLB.GetEntry(j);
     394                 :            :         DBG_ASSERT( pEntry, "NULL pointer");
     395 [ #  # ][ #  # ]:          0 :         String aNormEntry( getNormDicEntry_Impl( rDicWord ) );
     396                 :            :         StringCompare eCmpRes = (StringCompare)pCollator->
     397 [ #  # ][ #  # ]:          0 :             compareString( aNormEntry, getNormDicEntry_Impl( aWordsLB.GetEntryText(pEntry, 0) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     398         [ #  # ]:          0 :         if( COMPARE_LESS == eCmpRes )
     399                 :            :             break;
     400 [ #  # ][ #  # ]:          0 :     }
     401         [ #  # ]:          0 :     if (j < aWordsLB.GetEntryCount())   // entry found?
     402                 :          0 :         nPos = j;
     403                 :            : 
     404         [ #  # ]:          0 :     return nPos;
     405                 :            : }
     406                 :            : 
     407                 :          0 : void SvxEditDictionaryDialog::RemoveDictEntry(SvLBoxEntry* pEntry)
     408                 :            : {
     409                 :          0 :     sal_uInt16 nLBPos = aAllDictsLB.GetSelectEntryPos();
     410                 :            : 
     411 [ #  # ][ #  # ]:          0 :     if ( pEntry != NULL && nLBPos != LISTBOX_ENTRY_NOTFOUND )
     412                 :            :     {
     413         [ #  # ]:          0 :         String sTmpShort(aWordsLB.GetEntryText(pEntry, 0));
     414                 :            : 
     415                 :          0 :         Reference< XDictionary >  xDic = aDics.getConstArray()[ nLBPos ];
     416 [ #  # ][ #  # ]:          0 :         if (xDic->remove( sTmpShort ))  // sal_True on success
         [ #  # ][ #  # ]
     417                 :            :         {
     418         [ #  # ]:          0 :             aWordsLB.GetModel()->Remove(pEntry);
     419         [ #  # ]:          0 :         }
     420                 :            :     }
     421                 :          0 : }
     422                 :            : 
     423                 :            : // -----------------------------------------------------------------------
     424                 :            : 
     425                 :          0 : IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectBookHdl_Impl)
     426                 :            : {
     427                 :          0 :     sal_uInt16 nPos = aAllDictsLB.GetSelectEntryPos();
     428                 :            : 
     429         [ #  # ]:          0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     430                 :            :     {
     431         [ #  # ]:          0 :         aNewReplacePB.Enable( sal_False );
     432         [ #  # ]:          0 :         aDeletePB    .Enable( sal_False );
     433                 :            :         // display dictionary
     434         [ #  # ]:          0 :         ShowWords_Impl( nPos );
     435                 :            :         // enable or disable new and delete button according to file attributes
     436         [ #  # ]:          0 :         Reference< XDictionary >  xDic( aDics.getConstArray()[ nPos ], UNO_QUERY );
     437         [ #  # ]:          0 :         if (xDic.is())
     438 [ #  # ][ #  # ]:          0 :             SetLanguage_Impl( SvxLocaleToLanguage( xDic->getLocale() ) );
         [ #  # ][ #  # ]
     439                 :            : 
     440         [ #  # ]:          0 :         SetDicReadonly_Impl(xDic);
     441                 :          0 :         sal_Bool bEnable = !IsDicReadonly_Impl();
     442         [ #  # ]:          0 :         aLangFT.Enable( bEnable );
     443         [ #  # ]:          0 :         aLangLB.Enable( bEnable );
     444                 :            :     }
     445                 :          0 :     return 0;
     446                 :            : }
     447                 :            : 
     448                 :            : // -----------------------------------------------------------------------
     449                 :            : 
     450                 :          0 : IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl)
     451                 :            : {
     452         [ #  # ]:          0 :     sal_uInt16 nDicPos = aAllDictsLB.GetSelectEntryPos();
     453         [ #  # ]:          0 :     sal_uInt16 nLang = aLangLB.GetSelectLanguage();
     454         [ #  # ]:          0 :     Reference< XDictionary >  xDic( aDics.getConstArray()[ nDicPos ], UNO_QUERY );
     455 [ #  # ][ #  # ]:          0 :     sal_Int16 nOldLang = SvxLocaleToLanguage( xDic->getLocale() );
                 [ #  # ]
     456                 :            : 
     457         [ #  # ]:          0 :     if ( nLang != nOldLang )
     458                 :            :     {
     459 [ #  # ][ #  # ]:          0 :         QueryBox aBox( this, CUI_RES( RID_SFXQB_SET_LANGUAGE ) );
     460         [ #  # ]:          0 :         String sTxt( aBox.GetMessText() );
     461 [ #  # ][ #  # ]:          0 :         sTxt.SearchAndReplaceAscii( "%1", aAllDictsLB.GetSelectEntry() );
                 [ #  # ]
     462         [ #  # ]:          0 :         aBox.SetMessText( sTxt );
     463                 :            : 
     464 [ #  # ][ #  # ]:          0 :         if ( aBox.Execute() == RET_YES )
     465                 :            :         {
     466 [ #  # ][ #  # ]:          0 :             xDic->setLocale( SvxCreateLocale( nLang ) );
                 [ #  # ]
     467 [ #  # ][ #  # ]:          0 :             sal_Bool bNegativ = xDic->getDictionaryType() == DictionaryType_NEGATIVE;
     468                 :            : 
     469                 :            :             const String sName(
     470         [ #  # ]:          0 :                 ::GetDicInfoStr( xDic->getName(),
     471 [ #  # ][ #  # ]:          0 :                                  SvxLocaleToLanguage( xDic->getLocale() ),
                 [ #  # ]
     472 [ #  # ][ #  # ]:          0 :                                  bNegativ ) );
         [ #  # ][ #  # ]
     473         [ #  # ]:          0 :             aAllDictsLB.RemoveEntry( nDicPos );
     474         [ #  # ]:          0 :             aAllDictsLB.InsertEntry( sName, nDicPos );
     475 [ #  # ][ #  # ]:          0 :             aAllDictsLB.SelectEntryPos( nDicPos );
     476                 :            :         }
     477                 :            :         else
     478 [ #  # ][ #  # ]:          0 :             SetLanguage_Impl( nOldLang );
                 [ #  # ]
     479                 :            :     }
     480                 :          0 :     return 1;
     481                 :            : }
     482                 :            : 
     483                 :            : // -----------------------------------------------------------------------
     484                 :            : 
     485                 :          0 : void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId )
     486                 :            : {
     487                 :          0 :     Reference< XDictionary >  xDic = aDics.getConstArray()[ nId ];
     488                 :            : 
     489                 :          0 :     nOld = nId;
     490         [ #  # ]:          0 :     EnterWait();
     491                 :            : 
     492         [ #  # ]:          0 :     String aStr;
     493                 :            : 
     494         [ #  # ]:          0 :     aWordED.SetText(aStr);
     495         [ #  # ]:          0 :     aReplaceED.SetText(aStr);
     496                 :            : 
     497 [ #  # ][ #  # ]:          0 :     if(xDic->getDictionaryType() != DictionaryType_POSITIVE)
                 [ #  # ]
     498                 :            :     {
     499                 :          0 :         nStaticTabs[0]=2;
     500                 :            : 
     501                 :            :         // make controls for replacement text active
     502 [ #  # ][ #  # ]:          0 :         if(!aReplaceFT.IsVisible())
     503                 :            :         {
     504         [ #  # ]:          0 :             Size aSize=aWordED.GetSizePixel();
     505                 :          0 :             aSize.Width()=nWidth;
     506         [ #  # ]:          0 :             aWordED.SetSizePixel(aSize);
     507         [ #  # ]:          0 :             aReplaceFT.Show();
     508         [ #  # ]:          0 :             aReplaceED.Show();
     509                 :            :         }
     510                 :            :     }
     511                 :            :     else
     512                 :            :     {
     513                 :          0 :         nStaticTabs[0]=1;
     514                 :            : 
     515                 :            :         // deactivate controls for replacement text
     516 [ #  # ][ #  # ]:          0 :         if(aReplaceFT.IsVisible())
     517                 :            :         {
     518         [ #  # ]:          0 :             Size aSize=aWordED.GetSizePixel();
     519         [ #  # ]:          0 :             aSize.Width()=aWordsLB.GetSizePixel().Width();
     520         [ #  # ]:          0 :             aWordED.SetSizePixel(aSize);
     521         [ #  # ]:          0 :             aReplaceFT.Hide();
     522         [ #  # ]:          0 :             aReplaceED.Hide();
     523                 :            :         }
     524                 :            : 
     525                 :            :     }
     526                 :            : 
     527         [ #  # ]:          0 :     aWordsLB.SetTabs(nStaticTabs);
     528         [ #  # ]:          0 :     aWordsLB.Clear();
     529                 :            : 
     530 [ #  # ][ #  # ]:          0 :     Sequence< Reference< XDictionaryEntry >  > aEntries( xDic->getEntries() );
     531                 :          0 :     const Reference< XDictionaryEntry >  *pEntry = aEntries.getConstArray();
     532                 :          0 :     sal_Int32 nCount = aEntries.getLength();
     533                 :            : 
     534         [ #  # ]:          0 :     for (sal_Int32 i = 0;  i < nCount;  i++)
     535                 :            :     {
     536 [ #  # ][ #  # ]:          0 :         aStr = String(pEntry[i]->getDictionaryWord());
         [ #  # ][ #  # ]
                 [ #  # ]
     537         [ #  # ]:          0 :         sal_uInt16 nPos = GetLBInsertPos( aStr );
     538 [ #  # ][ #  # ]:          0 :         if(pEntry[i]->isNegative())
                 [ #  # ]
     539                 :            :         {
     540         [ #  # ]:          0 :             aStr += '\t';
     541 [ #  # ][ #  # ]:          0 :             aStr += String(pEntry[i]->getReplacementText());
         [ #  # ][ #  # ]
                 [ #  # ]
     542                 :            :         }
     543 [ #  # ][ #  # ]:          0 :         aWordsLB.InsertEntry(aStr, 0, sal_False, nPos == USHRT_MAX ?  LIST_APPEND : nPos);
     544                 :            :     }
     545                 :            : 
     546         [ #  # ]:          0 :     if (aWordsLB.GetEntryCount())
     547                 :            :     {
     548 [ #  # ][ #  # ]:          0 :         aWordED   .SetText( aWordsLB.GetEntryText((sal_uLong)0, 0) );
                 [ #  # ]
     549 [ #  # ][ #  # ]:          0 :         aReplaceED.SetText( aWordsLB.GetEntryText((sal_uLong)0, 1) );
                 [ #  # ]
     550                 :            :     }
     551                 :            : 
     552 [ #  # ][ #  # ]:          0 :     LeaveWait();
                 [ #  # ]
     553                 :          0 : }
     554                 :            : 
     555                 :            : // -----------------------------------------------------------------------
     556                 :            : 
     557                 :          0 : IMPL_LINK(SvxEditDictionaryDialog, SelectHdl, SvTabListBox*, pBox)
     558                 :            : {
     559         [ #  # ]:          0 :     if(!bDoNothing)
     560                 :            :     {
     561         [ #  # ]:          0 :         if(!bFirstSelect)
     562                 :            :         {
     563         [ #  # ]:          0 :             SvLBoxEntry* pEntry = pBox->FirstSelected();
     564         [ #  # ]:          0 :             String sTmpShort(pBox->GetEntryText(pEntry, 0));
     565                 :            :             // without this the curser is always at the beginning of a word, if the text
     566                 :            :             // is set over the ModifyHdl, although you're editing there at the moment
     567 [ #  # ][ #  # ]:          0 :             if(aWordED.GetText() != sTmpShort)
         [ #  # ][ #  # ]
     568         [ #  # ]:          0 :                 aWordED.SetText(sTmpShort);
     569 [ #  # ][ #  # ]:          0 :             aReplaceED.SetText(pBox->GetEntryText(pEntry, 1));
         [ #  # ][ #  # ]
     570                 :            :         }
     571                 :            :         else
     572                 :          0 :             bFirstSelect = sal_False;
     573                 :            : 
     574                 :            :         // entries in the list box should exactly correspond to those from the
     575                 :            :         // dictionary. Thus:
     576                 :          0 :         aNewReplacePB.Enable(sal_False);
     577                 :          0 :         aDeletePB    .Enable( sal_True && !IsDicReadonly_Impl() );
     578                 :            :     }
     579                 :          0 :     return 0;
     580                 :            : };
     581                 :            : 
     582                 :            : // -----------------------------------------------------------------------
     583                 :            : 
     584                 :          0 : IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn)
     585                 :            : {
     586                 :          0 :     SvLBoxEntry* pEntry = aWordsLB.FirstSelected();
     587                 :            : 
     588         [ #  # ]:          0 :     if(pBtn == &aDeletePB)
     589                 :            :     {
     590                 :            :         DBG_ASSERT(pEntry, "keine Eintrag selektiert");
     591         [ #  # ]:          0 :         String aStr;
     592                 :            : 
     593         [ #  # ]:          0 :         aWordED.SetText(aStr);
     594         [ #  # ]:          0 :         aReplaceED.SetText(aStr);
     595         [ #  # ]:          0 :         aDeletePB.Disable();
     596                 :            : 
     597 [ #  # ][ #  # ]:          0 :         RemoveDictEntry(pEntry);    // remove entry from dic and list-box
     598                 :            :     }
     599 [ #  # ][ #  # ]:          0 :     if(pBtn == &aNewReplacePB || aNewReplacePB.IsEnabled())
                 [ #  # ]
     600                 :            :     {
     601         [ #  # ]:          0 :         SvLBoxEntry* _pEntry = aWordsLB.FirstSelected();
     602         [ #  # ]:          0 :         XubString aNewWord(aWordED.GetText());
     603         [ #  # ]:          0 :         String sEntry(aNewWord);
     604         [ #  # ]:          0 :         XubString aReplaceStr(aReplaceED.GetText());
     605                 :            : 
     606                 :          0 :         sal_Int16 nAddRes = DIC_ERR_UNKNOWN;
     607         [ #  # ]:          0 :         sal_uInt16 nPos = aAllDictsLB.GetSelectEntryPos();
     608 [ #  # ][ #  # ]:          0 :         if ( nPos != LISTBOX_ENTRY_NOTFOUND && aNewWord.Len() > 0)
                 [ #  # ]
     609                 :            :         {
     610                 :            :             DBG_ASSERT(nPos < aDics.getLength(), "invalid dictionary index");
     611         [ #  # ]:          0 :             Reference< XDictionary >  xDic( aDics.getConstArray()[ nPos ], UNO_QUERY );
     612         [ #  # ]:          0 :             if (xDic.is())
     613                 :            :             {
     614                 :            :                 // make changes in dic
     615                 :            : 
     616                 :            :                 //! ...IsVisible should reflect whether the dictionary is a negativ
     617                 :            :                 //! or not (hopefully...)
     618         [ #  # ]:          0 :                 sal_Bool bIsNegEntry = aReplaceFT.IsVisible();
     619                 :          0 :                 ::rtl::OUString aRplcText;
     620         [ #  # ]:          0 :                 if(bIsNegEntry)
     621         [ #  # ]:          0 :                     aRplcText = aReplaceStr;
     622                 :            : 
     623         [ #  # ]:          0 :                 if (_pEntry) // entry selected in aWordsLB ie action = modify entry
     624 [ #  # ][ #  # ]:          0 :                     xDic->remove( aWordsLB.GetEntryText( _pEntry, 0 ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     625                 :            :                 // if remove has failed the following add should fail too
     626                 :            :                 // and thus a warning message should be triggered...
     627                 :            : 
     628         [ #  # ]:          0 :                 Reference<XDictionary> aXDictionary(xDic, UNO_QUERY);
     629                 :            :                 nAddRes = linguistic::AddEntryToDic( aXDictionary,
     630                 :            :                             aNewWord, bIsNegEntry,
     631 [ #  # ][ #  # ]:          0 :                             aRplcText, SvxLocaleToLanguage( xDic->getLocale() ), sal_False );
         [ #  # ][ #  # ]
                 [ #  # ]
     632                 :          0 :              }
     633                 :            :         }
     634         [ #  # ]:          0 :         if (DIC_ERR_NONE != nAddRes)
     635         [ #  # ]:          0 :             SvxDicError( this, nAddRes );
     636                 :            : 
     637 [ #  # ][ #  # ]:          0 :         if(DIC_ERR_NONE == nAddRes && sEntry.Len())
                 [ #  # ]
     638                 :            :         {
     639                 :            :             // insert new entry in list-box etc...
     640                 :            : 
     641         [ #  # ]:          0 :             aWordsLB.SetUpdateMode(sal_False);
     642                 :          0 :             sal_uInt16 _nPos = USHRT_MAX;
     643                 :            : 
     644 [ #  # ][ #  # ]:          0 :             if(aReplaceFT.IsVisible())
     645                 :            :             {
     646         [ #  # ]:          0 :                 sEntry += '\t';
     647         [ #  # ]:          0 :                 sEntry += aReplaceStr;
     648                 :            :             }
     649                 :            : 
     650                 :          0 :             SvLBoxEntry* pNewEntry = NULL;
     651         [ #  # ]:          0 :             if(_pEntry) // entry selected in aWordsLB ie action = modify entry
     652                 :            :             {
     653         [ #  # ]:          0 :                 aWordsLB.SetEntryText( sEntry, _pEntry );
     654                 :          0 :                 pNewEntry = _pEntry;
     655                 :            :             }
     656                 :            :             else
     657                 :            :             {
     658         [ #  # ]:          0 :                 _nPos = GetLBInsertPos( aNewWord );
     659                 :            :                 SvLBoxEntry* pInsEntry = aWordsLB.InsertEntry(sEntry, 0, sal_False,
     660 [ #  # ][ #  # ]:          0 :                             _nPos == USHRT_MAX ? LIST_APPEND : (sal_uInt32)_nPos);
     661                 :          0 :                 pNewEntry = pInsEntry;
     662                 :            :             }
     663                 :            : 
     664         [ #  # ]:          0 :             aWordsLB.MakeVisible( pNewEntry );
     665         [ #  # ]:          0 :             aWordsLB.SetUpdateMode(sal_True);
     666                 :            :             // if the request came from the ReplaceEdit, give focus to the ShortEdit
     667 [ #  # ][ #  # ]:          0 :             if(aReplaceED.HasFocus())
     668         [ #  # ]:          0 :                 aWordED.GrabFocus();
     669 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     670                 :            :     }
     671                 :            :     else
     672                 :            :     {
     673                 :            :         // this can only be an enter in one of the two edit fields
     674                 :            :         // which means EndDialog() - has to be evaluated in KeyInput
     675                 :          0 :         return 0;
     676                 :            :     }
     677                 :          0 :     ModifyHdl(&aWordED);
     678                 :          0 :     return 1;
     679                 :            : }
     680                 :            : 
     681                 :            : // -----------------------------------------------------------------------
     682                 :            : 
     683                 :          0 : IMPL_LINK(SvxEditDictionaryDialog, ModifyHdl, Edit*, pEdt)
     684                 :            : {
     685         [ #  # ]:          0 :     SvLBoxEntry* pFirstSel = aWordsLB.FirstSelected();
     686         [ #  # ]:          0 :     String rEntry = pEdt->GetText();
     687                 :            : 
     688                 :          0 :     xub_StrLen nWordLen=rEntry.Len();
     689         [ #  # ]:          0 :     const String& rRepString = aReplaceED.GetText();
     690                 :            : 
     691                 :          0 :     sal_Bool bEnableNewReplace  = sal_False;
     692                 :          0 :     sal_Bool bEnableDelete      = sal_False;
     693         [ #  # ]:          0 :     String aNewReplaceText  = sNew;
     694                 :            : 
     695         [ #  # ]:          0 :     if(pEdt == &aWordED)
     696                 :            :     {
     697         [ #  # ]:          0 :         if(nWordLen>0)
     698                 :            :         {
     699                 :          0 :             sal_Bool bFound = sal_False;
     700                 :          0 :             sal_Bool bTmpSelEntry=sal_False;
     701                 :          0 :             CDE_RESULT eCmpRes = CDE_DIFFERENT;
     702                 :            : 
     703         [ #  # ]:          0 :             for(sal_uInt16 i = 0; i < aWordsLB.GetEntryCount(); i++)
     704                 :            :             {
     705         [ #  # ]:          0 :                 SvLBoxEntry*  pEntry = aWordsLB.GetEntry( i );
     706         [ #  # ]:          0 :                 String aTestStr( aWordsLB.GetEntryText(pEntry, 0) );
     707         [ #  # ]:          0 :                 eCmpRes = cmpDicEntry_Impl( rEntry, aTestStr );
     708         [ #  # ]:          0 :                 if(CDE_DIFFERENT != eCmpRes)
     709                 :            :                 {
     710         [ #  # ]:          0 :                     if(rRepString.Len())
     711                 :          0 :                         bFirstSelect = sal_True;
     712                 :          0 :                     bDoNothing=sal_True;
     713         [ #  # ]:          0 :                     aWordsLB.SetCurEntry(pEntry);
     714                 :          0 :                     bDoNothing=sal_False;
     715                 :          0 :                     pFirstSel = pEntry;
     716 [ #  # ][ #  # ]:          0 :                     aReplaceED.SetText(aWordsLB.GetEntryText(pEntry, 1));
                 [ #  # ]
     717                 :            : 
     718         [ #  # ]:          0 :                     if (CDE_SIMILAR == eCmpRes)
     719                 :            :                     {
     720         [ #  # ]:          0 :                         aNewReplaceText = sModify;
     721                 :          0 :                         bEnableNewReplace = sal_True;
     722                 :            :                     }
     723                 :          0 :                     bFound= sal_True;
     724                 :            :                     break;
     725                 :            :                 }
     726 [ #  # ][ #  # ]:          0 :                 else if(getNormDicEntry_Impl(aTestStr).Search(
                 [ #  # ]
     727 [ #  # ][ #  # ]:          0 :                             getNormDicEntry_Impl( rEntry ) ) == 0
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     728                 :            :                         && !bTmpSelEntry)
     729                 :            :                 {
     730                 :          0 :                     bDoNothing=sal_True;
     731         [ #  # ]:          0 :                     aWordsLB.MakeVisible(pEntry);
     732                 :          0 :                     bDoNothing=sal_False;
     733                 :          0 :                     bTmpSelEntry=sal_True;
     734                 :            : 
     735         [ #  # ]:          0 :                     aNewReplaceText = sNew;
     736                 :          0 :                     bEnableNewReplace = sal_True;
     737                 :            :                 }
     738 [ #  # ][ #  # ]:          0 :             }
     739                 :            : 
     740         [ #  # ]:          0 :             if(!bFound)
     741                 :            :             {
     742         [ #  # ]:          0 :                 aWordsLB.SelectAll(sal_False);
     743                 :          0 :                 pFirstSel = 0;
     744                 :            : 
     745         [ #  # ]:          0 :                 aNewReplaceText = sNew;
     746                 :          0 :                 bEnableNewReplace = sal_True;
     747                 :            :             }
     748                 :          0 :             bEnableDelete = CDE_DIFFERENT != eCmpRes;
     749                 :            :         }
     750         [ #  # ]:          0 :         else if(aWordsLB.GetEntryCount()>0)
     751                 :            :         {
     752         [ #  # ]:          0 :             SvLBoxEntry*  pEntry = aWordsLB.GetEntry( 0 );
     753                 :          0 :             bDoNothing=sal_True;
     754         [ #  # ]:          0 :             aWordsLB.MakeVisible(pEntry);
     755                 :          0 :             bDoNothing=sal_False;
     756                 :            :         }
     757                 :            :     }
     758         [ #  # ]:          0 :     else if(pEdt == &aReplaceED)
     759                 :            :     {
     760         [ #  # ]:          0 :         String aReplaceText;
     761         [ #  # ]:          0 :         String aWordText;
     762         [ #  # ]:          0 :         if (pFirstSel)  // a aWordsLB entry is selected
     763                 :            :         {
     764 [ #  # ][ #  # ]:          0 :             aWordText    = aWordsLB.GetEntryText( pFirstSel, 0 );
                 [ #  # ]
     765 [ #  # ][ #  # ]:          0 :              aReplaceText = aWordsLB.GetEntryText( pFirstSel, 1 );
                 [ #  # ]
     766                 :            : 
     767         [ #  # ]:          0 :             aNewReplaceText = sModify;
     768                 :          0 :             bEnableDelete = sal_True;
     769                 :            :         }
     770                 :            :         sal_Bool bIsChange =
     771 [ #  # ][ #  # ]:          0 :                 CDE_EQUAL != cmpDicEntry_Impl(aWordED.GetText(), aWordText)
         [ #  # ][ #  # ]
                 [ #  # ]
     772 [ #  # ][ #  # ]:          0 :              || CDE_EQUAL != cmpDicEntry_Impl(aReplaceED.GetText(), aReplaceText);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     773 [ #  # ][ #  # ]:          0 :         if (aWordED.GetText().Len()  &&  bIsChange)
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     774 [ #  # ][ #  # ]:          0 :             bEnableNewReplace = sal_True;
     775                 :            :     }
     776                 :            : 
     777         [ #  # ]:          0 :     aNewReplacePB.SetText( aNewReplaceText );
     778 [ #  # ][ #  # ]:          0 :     aNewReplacePB.Enable( bEnableNewReplace && !IsDicReadonly_Impl() );
                 [ #  # ]
     779 [ #  # ][ #  # ]:          0 :     aDeletePB    .Enable( bEnableDelete     && !IsDicReadonly_Impl() );
                 [ #  # ]
     780                 :            : 
     781 [ #  # ][ #  # ]:          0 :     return 0;
                 [ #  # ]
     782                 :            : }
     783                 :            : 
     784                 :            : //=========================================================
     785                 :            : //SvxDictEdit
     786                 :            : //=========================================================
     787                 :          0 : void SvxDictEdit::KeyInput( const KeyEvent& rKEvt )
     788                 :            : {
     789                 :          0 :     const KeyCode aKeyCode = rKEvt.GetKeyCode();
     790                 :          0 :     const sal_uInt16 nModifier = aKeyCode.GetModifier();
     791         [ #  # ]:          0 :     if( aKeyCode.GetCode() == KEY_RETURN )
     792                 :            :     {
     793                 :            :         // if there's nothing done on enter, call the
     794                 :            :         // base class after all to close the dialog
     795 [ #  # ][ #  # ]:          0 :         if(!nModifier && !aActionLink.Call(this))
         [ #  # ][ #  # ]
     796         [ #  # ]:          0 :                  Edit::KeyInput(rKEvt);
     797                 :            :     }
     798 [ #  # ][ #  # ]:          0 :     else if(bSpaces || aKeyCode.GetCode() != KEY_SPACE)
                 [ #  # ]
     799         [ #  # ]:          0 :         Edit::KeyInput(rKEvt);
     800                 :          0 : }
     801                 :            : 
     802                 :            : 
     803                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10