LCOV - code coverage report
Current view: top level - libreoffice/cui/source/dialogs - thesdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 290 0.0 %
Date: 2012-12-27 Functions: 0 52 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "thesdlg.hxx"
      21             : #include "thesdlg_impl.hxx"
      22             : #include "cuires.hrc"
      23             : #include "dialmgr.hxx"
      24             : 
      25             : #include <tools/shl.hxx>
      26             : #include <svl/lngmisc.hxx>
      27             : #include <svtools/filter.hxx>
      28             : #include <svtools/svlbitm.hxx>
      29             : #include <svtools/treelistbox.hxx>
      30             : #include "svtools/treelistentry.hxx"
      31             : #include "svtools/viewdataentry.hxx"
      32             : #include <vcl/wrkwin.hxx>
      33             : #include <vcl/msgbox.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : #include <thesdlg.hxx>
      36             : #include <svx/dlgutil.hxx>
      37             : #include <svx/dialmgr.hxx>
      38             : #include <svx/svxerr.hxx>
      39             : #include <editeng/unolingu.hxx>
      40             : #include <svx/langbox.hxx>
      41             : #include <svtools/langtab.hxx>
      42             : #include <unotools/lingucfg.hxx>
      43             : #include <i18npool/mslangid.hxx>
      44             : #include <comphelper/processfactory.hxx>
      45             : #include <comphelper/string.hxx>
      46             : #include <osl/file.hxx>
      47             : 
      48             : #include <stack>
      49             : #include <algorithm>
      50             : 
      51             : #include <com/sun/star/linguistic2/XThesaurus.hpp>
      52             : #include <com/sun/star/linguistic2/XMeaning.hpp>
      53             : #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
      54             : 
      55             : using namespace ::com::sun::star;
      56             : using ::rtl::OUString;
      57             : 
      58             : // class LookUpComboBox --------------------------------------------------
      59             : 
      60           0 : LookUpComboBox::LookUpComboBox(Window *pParent)
      61           0 :     : ComboBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP)
      62             : {
      63           0 :     EnableAutoSize(true);
      64             : 
      65           0 :     m_aModifyTimer.SetTimeoutHdl( LINK( this, LookUpComboBox, ModifyTimer_Hdl ) );
      66           0 :     m_aModifyTimer.SetTimeout( 500 );
      67             : 
      68           0 :     EnableAutocomplete( sal_False );
      69           0 : }
      70             : 
      71           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLookUpComboBox(Window *pParent, VclBuilder::stringmap &)
      72             : {
      73           0 :     return new LookUpComboBox(pParent);
      74             : }
      75             : 
      76           0 : void LookUpComboBox::init(SvxThesaurusDialog *pDialog)
      77             : {
      78           0 :     m_pDialog = pDialog;
      79           0 : }
      80             : 
      81           0 : LookUpComboBox::~LookUpComboBox()
      82             : {
      83           0 : }
      84             : 
      85           0 : void LookUpComboBox::Modify()
      86             : {
      87           0 :     m_aModifyTimer.Start();
      88           0 : }
      89             : 
      90           0 : IMPL_LINK( LookUpComboBox, ModifyTimer_Hdl, Timer *, EMPTYARG /*pTimer*/ )
      91             : {
      92           0 :     m_pDialog->LookUp( GetText() );
      93           0 :     m_aModifyTimer.Stop();
      94           0 :     return 0;
      95             : }
      96             : 
      97             : // class ReplaceEdit --------------------------------------------------
      98             : 
      99           0 : ReplaceEdit::ReplaceEdit(Window *pParent)
     100           0 :     : Edit(pParent, WB_BORDER | WB_TABSTOP)
     101             : {
     102           0 : }
     103             : 
     104           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReplaceEdit(Window *pParent, VclBuilder::stringmap &)
     105             : {
     106           0 :     return new ReplaceEdit(pParent);
     107             : }
     108             : 
     109           0 : ReplaceEdit::~ReplaceEdit()
     110             : {
     111           0 : }
     112             : 
     113           0 : void ReplaceEdit::Modify()
     114             : {
     115           0 :     if (m_pBtn)
     116           0 :         m_pBtn->Enable( GetText().Len() > 0 );
     117           0 : }
     118             : 
     119           0 : void ReplaceEdit::SetText( const XubString& rStr )
     120             : {
     121           0 :     Edit::SetText( rStr );
     122           0 :     Modify();
     123           0 : }
     124             : 
     125           0 : void ReplaceEdit::SetText( const XubString& rStr, const Selection& rNewSelection )
     126             : {
     127           0 :     Edit::SetText( rStr, rNewSelection );
     128           0 :     Modify();
     129           0 : }
     130             : 
     131             : // class ThesaurusAlternativesCtrl ----------------------------------
     132             : 
     133           0 : AlternativesString::AlternativesString(
     134             :     ThesaurusAlternativesCtrl &rControl,
     135             :     SvTreeListEntry* pEntry, sal_uInt16 nFlags, const String& rStr ) :
     136             : 
     137             :     SvLBoxString( pEntry, nFlags, rStr ),
     138           0 :     m_rControlImpl( rControl )
     139             : {
     140           0 : }
     141             : 
     142           0 : void AlternativesString::Paint(
     143             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     144             :     const SvTreeListEntry* pEntry)
     145             : {
     146           0 :     AlternativesExtraData* pData = m_rControlImpl.GetExtraData( pEntry );
     147           0 :     Point aPos( rPos );
     148           0 :     Font aOldFont( rDev.GetFont());
     149           0 :     if (pData && pData->IsHeader())
     150             :     {
     151           0 :         Font aFont( aOldFont );
     152           0 :         aFont.SetWeight( WEIGHT_BOLD );
     153           0 :         rDev.SetFont( aFont );
     154           0 :         aPos.X() = 0;
     155             :     }
     156             :     else
     157           0 :         aPos.X() += 5;
     158           0 :     rDev.DrawText( aPos, GetText() );
     159           0 :     rDev.SetFont( aOldFont );
     160           0 : }
     161             : 
     162           0 : ThesaurusAlternativesCtrl::ThesaurusAlternativesCtrl(Window* pParent)
     163           0 :     : SvxCheckListBox(pParent)
     164             : {
     165           0 :     SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE );
     166           0 :     SetHighlightRange();
     167           0 : }
     168             : 
     169           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeThesaurusAlternativesCtrl(Window *pParent, VclBuilder::stringmap &)
     170             : {
     171           0 :     return new ThesaurusAlternativesCtrl(pParent);
     172             : }
     173             : 
     174           0 : void ThesaurusAlternativesCtrl::init(SvxThesaurusDialog *pDialog)
     175             : {
     176           0 :     m_pDialog = pDialog;
     177           0 : }
     178             : 
     179           0 : ThesaurusAlternativesCtrl::~ThesaurusAlternativesCtrl()
     180             : {
     181           0 :     ClearExtraData();
     182           0 : }
     183             : 
     184           0 : void ThesaurusAlternativesCtrl::ClearExtraData()
     185             : {
     186           0 :     UserDataMap_t   aEmpty;
     187           0 :     m_aUserData.swap( aEmpty );
     188           0 : }
     189             : 
     190           0 : void ThesaurusAlternativesCtrl::SetExtraData(
     191             :     const SvTreeListEntry *pEntry,
     192             :     const AlternativesExtraData &rData )
     193             : {
     194           0 :     if (!pEntry)
     195           0 :         return;
     196             : 
     197           0 :     UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) );
     198           0 :     if (aIt != m_aUserData.end())
     199           0 :         aIt->second = rData;
     200             :     else
     201           0 :         m_aUserData[ pEntry ] = rData;
     202             : }
     203             : 
     204           0 : AlternativesExtraData * ThesaurusAlternativesCtrl::GetExtraData(
     205             :     const SvTreeListEntry *pEntry )
     206             : {
     207           0 :     AlternativesExtraData *pRes = NULL;
     208           0 :     UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) );
     209           0 :     if (aIt != m_aUserData.end())
     210           0 :         pRes = &aIt->second;
     211           0 :     return pRes;
     212             : }
     213             : 
     214           0 : SvTreeListEntry * ThesaurusAlternativesCtrl::AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader )
     215             : {
     216           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     217           0 :     String aText;
     218           0 :     if (bIsHeader && nVal >= 0)
     219             :     {
     220           0 :         aText = String::CreateFromInt32( nVal );
     221           0 :         aText += rtl::OUString(". ");
     222             :     }
     223           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) ); // add empty column
     224           0 :     aText += rText;
     225           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );  // otherwise crash
     226           0 :     pEntry->AddItem( new AlternativesString( *this, pEntry, 0, aText ) );
     227             : 
     228           0 :     SetExtraData( pEntry, AlternativesExtraData( rText, bIsHeader ) );
     229           0 :     GetModel()->Insert( pEntry );
     230             : 
     231           0 :     if (bIsHeader)
     232           0 :         GetViewDataEntry( pEntry )->SetSelectable( false );
     233             : 
     234           0 :     return pEntry;
     235             : }
     236             : 
     237           0 : void ThesaurusAlternativesCtrl::KeyInput( const KeyEvent& rKEvt )
     238             : {
     239           0 :     const KeyCode& rKey = rKEvt.GetKeyCode();
     240             : 
     241           0 :     if (rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_ESCAPE)
     242           0 :         GetParent()->KeyInput( rKEvt ); // parent will close dialog...
     243           0 :     else if (rKey.GetCode() == KEY_SPACE)
     244           0 :         m_pDialog->AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry
     245           0 :     else if (GetEntryCount())
     246           0 :         SvxCheckListBox::KeyInput( rKEvt );
     247           0 : }
     248             : 
     249           0 : void ThesaurusAlternativesCtrl::Paint( const Rectangle& rRect )
     250             : {
     251           0 :     if (!m_pDialog->WordFound())
     252             :     {
     253           0 :         Size aTextSize( GetTextWidth( m_pDialog->getErrStr() ), GetTextHeight() );
     254           0 :         aTextSize  = LogicToPixel( aTextSize );
     255           0 :         Point aPos;
     256           0 :         aPos.X() += GetSizePixel().Width() / 2  - aTextSize.Width() / 2;
     257           0 :         aPos.Y() += GetSizePixel().Height() / 2;
     258           0 :         aPos = PixelToLogic( aPos );
     259           0 :         DrawText( aPos, m_pDialog->getErrStr() );
     260             : 
     261             :     }
     262             :     else
     263           0 :         SvxCheckListBox::Paint( rRect );
     264           0 : }
     265             : 
     266           0 : uno::Sequence< uno::Reference< linguistic2::XMeaning > > SvxThesaurusDialog::queryMeanings_Impl(
     267             :         OUString& rTerm,
     268             :         const lang::Locale& rLocale,
     269             :         const beans::PropertyValues& rProperties )
     270             :     throw(lang::IllegalArgumentException, uno::RuntimeException)
     271             : {
     272             :     uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings(
     273           0 :             xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) );
     274             : 
     275             :     // text with '.' at the end?
     276           0 :     if ( 0 == aMeanings.getLength() && !rTerm.isEmpty() &&
     277           0 :         rTerm.getStr()[ rTerm.getLength() - 1 ] == '.')
     278             :     {
     279             :         // try again without trailing '.' chars. It may be a word at the
     280             :         // end of a sentence and not an abbreviation...
     281           0 :         String aTxt(comphelper::string::stripEnd(rTerm, '.'));
     282           0 :         aMeanings = xThesaurus->queryMeanings( aTxt, rLocale, rProperties );
     283           0 :         if (aMeanings.getLength())
     284             :         {
     285           0 :             rTerm = aTxt;
     286           0 :         }
     287             :     }
     288             : 
     289           0 :     return aMeanings;
     290             : }
     291             : 
     292           0 : bool SvxThesaurusDialog::UpdateAlternativesBox_Impl()
     293             : {
     294           0 :     lang::Locale aLocale( LanguageTag( nLookUpLanguage ).getLocale() );
     295             :     uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings = queryMeanings_Impl(
     296           0 :             aLookUpText, aLocale, uno::Sequence< beans::PropertyValue >() );
     297           0 :     const sal_Int32 nMeanings = aMeanings.getLength();
     298           0 :     const uno::Reference< linguistic2::XMeaning > *pMeanings = aMeanings.getConstArray();
     299             : 
     300           0 :     m_pAlternativesCT->SetUpdateMode( sal_False );
     301             : 
     302             :     // clear old user data of control before creating new ones via AddEntry below
     303           0 :     m_pAlternativesCT->ClearExtraData();
     304             : 
     305           0 :     m_pAlternativesCT->Clear();
     306           0 :     for (sal_Int32 i = 0;  i < nMeanings;  ++i)
     307             :     {
     308           0 :         OUString rMeaningTxt = pMeanings[i]->getMeaning();
     309           0 :         uno::Sequence< OUString > aSynonyms( pMeanings[i]->querySynonyms() );
     310           0 :         const sal_Int32 nSynonyms = aSynonyms.getLength();
     311           0 :         const OUString *pSynonyms = aSynonyms.getConstArray();
     312             :         DBG_ASSERT( !rMeaningTxt.isEmpty(), "meaning with empty text" );
     313             :         DBG_ASSERT( nSynonyms > 0, "meaning without synonym" );
     314             : 
     315           0 :         m_pAlternativesCT->AddEntry( i + 1, rMeaningTxt, true );
     316           0 :         for (sal_Int32 k = 0;  k < nSynonyms;  ++k)
     317           0 :             m_pAlternativesCT->AddEntry( -1, pSynonyms[k], false );
     318           0 :     }
     319             : 
     320           0 :     m_pAlternativesCT->SetUpdateMode( sal_True );
     321             : 
     322           0 :     return nMeanings > 0;
     323             : }
     324             : 
     325           0 : void SvxThesaurusDialog::LookUp( const String &rText )
     326             : {
     327           0 :     if (rText != m_pWordCB->GetText()) // avoid moving of the cursor if the text is the same
     328           0 :         m_pWordCB->SetText( rText );
     329           0 :     LookUp_Impl();
     330           0 : }
     331             : 
     332           0 : IMPL_LINK( SvxThesaurusDialog, LeftBtnHdl_Impl, Button *, pBtn )
     333             : {
     334           0 :     if (pBtn && aLookUpHistory.size() >= 2)
     335             :     {
     336           0 :         aLookUpHistory.pop();                       // remove current look up word from stack
     337           0 :         m_pWordCB->SetText( aLookUpHistory.top() );    // retrieve previous look up word
     338           0 :         aLookUpHistory.pop();
     339           0 :         LookUp_Impl();
     340             :     }
     341           0 :     return 0;
     342             : }
     343             : 
     344           0 : IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, ListBox*, pLB )
     345             : {
     346           0 :     String aLangText( pLB->GetSelectEntry() );
     347           0 :     LanguageType nLang = SvtLanguageTable().GetType( aLangText );
     348             :     DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" );
     349           0 :     if (xThesaurus->hasLocale( LanguageTag( nLang ).getLocale() ))
     350           0 :         nLookUpLanguage = nLang;
     351           0 :     SetWindowTitle( nLang );
     352           0 :     LookUp_Impl();
     353           0 :     return 0;
     354             : }
     355             : 
     356           0 : void SvxThesaurusDialog::LookUp_Impl()
     357             : {
     358           0 :     String aText( m_pWordCB->GetText() );
     359             : 
     360           0 :     aLookUpText = OUString( aText );
     361           0 :     if (!aLookUpText.isEmpty() &&
     362           0 :             (aLookUpHistory.empty() || aLookUpText != aLookUpHistory.top()))
     363           0 :         aLookUpHistory.push( aLookUpText );
     364             : 
     365           0 :     m_bWordFound = UpdateAlternativesBox_Impl();
     366           0 :     m_pAlternativesCT->Enable( m_bWordFound );
     367             : 
     368           0 :     if ( m_pWordCB->GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND )
     369           0 :         m_pWordCB->InsertEntry( aText );
     370             : 
     371           0 :     m_pReplaceEdit->SetText( String() );
     372           0 :     m_pLeftBtn->Enable( aLookUpHistory.size() > 1 );
     373           0 : }
     374             : 
     375           0 : IMPL_LINK( SvxThesaurusDialog, WordSelectHdl_Impl, ComboBox *, pBox )
     376             : {
     377           0 :     if (pBox && !m_pWordCB->IsTravelSelect())  // act only upon return key and not when traveling with cursor keys
     378             :     {
     379           0 :         sal_uInt16 nPos = pBox->GetSelectEntryPos();
     380           0 :         String aStr( pBox->GetEntry( nPos ) );
     381           0 :         aStr = linguistic::GetThesaurusReplaceText( aStr );
     382           0 :         m_pWordCB->SetText( aStr );
     383           0 :         LookUp_Impl();
     384             :     }
     385             : 
     386           0 :     return 0;
     387             : }
     388             : 
     389           0 : IMPL_LINK( SvxThesaurusDialog, AlternativesSelectHdl_Impl, SvxCheckListBox *, pBox )
     390             : {
     391           0 :     SvTreeListEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL;
     392           0 :     if (pEntry)
     393             :     {
     394           0 :         AlternativesExtraData * pData = m_pAlternativesCT->GetExtraData( pEntry );
     395           0 :         String aStr;
     396           0 :         if (pData && !pData->IsHeader())
     397             :         {
     398           0 :             aStr = pData->GetText();
     399           0 :             aStr = linguistic::GetThesaurusReplaceText( aStr );
     400             :         }
     401           0 :         m_pReplaceEdit->SetText( aStr );
     402             :     }
     403           0 :     return 0;
     404             : }
     405             : 
     406           0 : IMPL_LINK( SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl, SvxCheckListBox *, pBox )
     407             : {
     408           0 :     SvTreeListEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL;
     409           0 :     if (pEntry)
     410             :     {
     411           0 :         AlternativesExtraData * pData = m_pAlternativesCT->GetExtraData( pEntry );
     412           0 :         String aStr;
     413           0 :         if (pData && !pData->IsHeader())
     414             :         {
     415           0 :             aStr = pData->GetText();
     416           0 :             aStr = linguistic::GetThesaurusReplaceText( aStr );
     417             :         }
     418             : 
     419           0 :         m_pWordCB->SetText( aStr );
     420           0 :         if (aStr.Len() > 0)
     421           0 :             LookUp_Impl();
     422             :     }
     423             : 
     424             :     //! workaround to set the selection since calling SelectEntryPos within
     425             :     //! the double click handler does not work
     426           0 :     Application::PostUserEvent( STATIC_LINK( this, SvxThesaurusDialog, SelectFirstHdl_Impl ), pBox );
     427           0 :     return 0;
     428             : }
     429             : 
     430           0 : IMPL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox *, pBox )
     431             : {
     432             :     (void) pThis;
     433           0 :     if (pBox && pBox->GetEntryCount() >= 2)
     434           0 :         pBox->SelectEntryPos( 1 );  // pos 0 is a 'header' that is not selectable
     435           0 :     return 0;
     436             : }
     437             : 
     438             : // class SvxThesaurusDialog ----------------------------------------------
     439             : 
     440           0 : SvxThesaurusDialog::SvxThesaurusDialog(
     441             :     Window* pParent,
     442             :     uno::Reference< linguistic2::XThesaurus >  xThes,
     443             :     const String &rWord,
     444             :     LanguageType nLanguage)
     445             :     : SvxStandardDialog(pParent, "ThesaurusDialog", "cui/ui/thesaurus.ui")
     446           0 :     , m_aErrStr(CUI_RESSTR(RID_SVXSTR_ERR_TEXTNOTFOUND))
     447             :     , xThesaurus(NULL)
     448             :     , aLookUpText()
     449             :     , nLookUpLanguage(LANGUAGE_NONE)
     450           0 :     , m_bWordFound(false)
     451             : {
     452           0 :     get(m_pLeftBtn, "left");
     453             : 
     454           0 :     get(m_pWordCB, "wordcb");
     455           0 :     m_pWordCB->init(this);
     456             : 
     457           0 :     get(m_pAlternativesCT, "alternatives");
     458           0 :     m_pAlternativesCT->init(this);
     459             : 
     460           0 :     get(m_pReplaceEdit, "replaceed");
     461           0 :     PushButton *pReplaceBtn = get<PushButton>("replace");
     462           0 :     m_pReplaceEdit->init(pReplaceBtn);
     463             : 
     464           0 :     get(m_pLangLB, "langcb");
     465             : 
     466           0 :     pReplaceBtn->SetClickHdl( LINK( this, SvxThesaurusDialog, ReplaceBtnHdl_Impl ) );
     467           0 :     m_pLeftBtn->SetClickHdl( LINK( this, SvxThesaurusDialog, LeftBtnHdl_Impl ) );
     468           0 :     m_pWordCB->SetSelectHdl( LINK( this, SvxThesaurusDialog, WordSelectHdl_Impl ) );
     469           0 :     m_pLangLB->SetSelectHdl( LINK( this, SvxThesaurusDialog, LanguageHdl_Impl ) );
     470           0 :     m_pAlternativesCT->SetSelectHdl( LINK( this, SvxThesaurusDialog, AlternativesSelectHdl_Impl ));
     471           0 :     m_pAlternativesCT->SetDoubleClickHdl( LINK( this, SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl ));
     472             : 
     473           0 :     xThesaurus = xThes;
     474           0 :     aLookUpText = OUString( rWord );
     475           0 :     nLookUpLanguage = nLanguage;
     476           0 :     if (rWord.Len() > 0)
     477           0 :         aLookUpHistory.push( rWord );
     478             : 
     479           0 :     OUString aTmp( rWord );
     480           0 :     linguistic::RemoveHyphens( aTmp );
     481           0 :     linguistic::ReplaceControlChars( aTmp );
     482           0 :     String aTmp2( aTmp );
     483           0 :     m_pReplaceEdit->SetText( aTmp2 );
     484           0 :     m_pWordCB->InsertEntry( aTmp2 );
     485             : 
     486           0 :     LookUp( aTmp2 );
     487           0 :     m_pAlternativesCT->GrabFocus();
     488           0 :     m_pLeftBtn->Enable( sal_False );
     489             : 
     490             :     // fill language menu button list
     491           0 :     SvtLanguageTable aLangTab;
     492           0 :     uno::Sequence< lang::Locale > aLocales;
     493           0 :     if (xThesaurus.is())
     494           0 :         aLocales = xThesaurus->getLocales();
     495           0 :     const sal_Int32 nLocales = aLocales.getLength();
     496           0 :     const lang::Locale *pLocales = aLocales.getConstArray();
     497           0 :     m_pLangLB->Clear();
     498           0 :     std::vector< OUString > aLangVec;
     499           0 :     for (sal_Int32 i = 0;  i < nLocales; ++i)
     500             :     {
     501           0 :         const LanguageType nLang = LanguageTag( pLocales[i] ).getLanguageType();
     502             :         DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" );
     503           0 :         aLangVec.push_back( aLangTab.GetString( nLang ) );
     504             :     }
     505           0 :     std::sort( aLangVec.begin(), aLangVec.end() );
     506           0 :     for (size_t i = 0;  i < aLangVec.size();  ++i)
     507           0 :         m_pLangLB->InsertEntry( aLangVec[i] );
     508             : 
     509           0 :     std::vector< OUString >::iterator aI = std::find(aLangVec.begin(), aLangVec.end(), aLangTab.GetString(nLanguage));
     510           0 :     if (aI != aLangVec.end())
     511             :     {
     512           0 :         m_pLangLB->SelectEntry(*aI);
     513             :     }
     514             : 
     515           0 :     SetWindowTitle(nLanguage);
     516             : 
     517             :     // disable controls if service is missing
     518           0 :     if (!xThesaurus.is())
     519           0 :         Enable( sal_False );
     520           0 : }
     521             : 
     522           0 : IMPL_LINK( SvxThesaurusDialog, ReplaceBtnHdl_Impl, Button *, EMPTYARG /*pBtn*/ )
     523             : {
     524           0 :     EndDialog(true);
     525           0 :     return 0;
     526             : }
     527             : 
     528           0 : SvxThesaurusDialog::~SvxThesaurusDialog()
     529             : {
     530           0 : }
     531             : 
     532           0 : void SvxThesaurusDialog::SetWindowTitle( LanguageType nLanguage )
     533             : {
     534             :     // adjust language
     535           0 :     String aStr( GetText() );
     536           0 :     aStr.Erase( aStr.Search( sal_Unicode( '(' ) ) - 1 );
     537           0 :     aStr.Append( rtl::OUString(" (") );
     538           0 :     aStr += SvtLanguageTable().GetLanguageString( nLanguage );
     539           0 :     aStr.Append( sal_Unicode( ')' ) );
     540           0 :     SetText( aStr );    // set window title
     541           0 : }
     542             : 
     543           0 : String SvxThesaurusDialog::GetWord()
     544             : {
     545           0 :     return m_pReplaceEdit->GetText();
     546             : }
     547             : 
     548           0 : sal_uInt16 SvxThesaurusDialog::GetLanguage() const
     549             : {
     550           0 :     return nLookUpLanguage;
     551             : }
     552             : 
     553           0 : void SvxThesaurusDialog::Apply()
     554             : {
     555           0 : }
     556             : 
     557             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10