LCOV - code coverage report
Current view: top level - cui/source/dialogs - thesdlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 290 0.0 %
Date: 2014-04-14 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 <vcl/graphicfilter.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 <i18nlangtag/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             : 
      57             : // class LookUpComboBox --------------------------------------------------
      58             : 
      59           0 : LookUpComboBox::LookUpComboBox(Window *pParent)
      60             :     : ComboBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP)
      61           0 :     , m_pDialog(NULL)
      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( 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             :     : Edit(pParent, WB_BORDER | WB_TABSTOP)
     101           0 :     , m_pBtn(NULL)
     102             : {
     103           0 : }
     104             : 
     105           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReplaceEdit(Window *pParent, VclBuilder::stringmap &)
     106             : {
     107           0 :     return new ReplaceEdit(pParent);
     108             : }
     109             : 
     110           0 : ReplaceEdit::~ReplaceEdit()
     111             : {
     112           0 : }
     113             : 
     114           0 : void ReplaceEdit::Modify()
     115             : {
     116           0 :     if (m_pBtn)
     117           0 :         m_pBtn->Enable( !GetText().isEmpty() );
     118           0 : }
     119             : 
     120           0 : void ReplaceEdit::SetText( const OUString& rStr )
     121             : {
     122           0 :     Edit::SetText( rStr );
     123           0 :     Modify();
     124           0 : }
     125             : 
     126           0 : void ReplaceEdit::SetText( const OUString& rStr, const Selection& rNewSelection )
     127             : {
     128           0 :     Edit::SetText( rStr, rNewSelection );
     129           0 :     Modify();
     130           0 : }
     131             : 
     132             : // class ThesaurusAlternativesCtrl ----------------------------------
     133             : 
     134           0 : AlternativesString::AlternativesString(
     135             :     ThesaurusAlternativesCtrl &rControl,
     136             :     SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rStr ) :
     137             : 
     138             :     SvLBoxString( pEntry, nFlags, rStr ),
     139           0 :     m_rControlImpl( rControl )
     140             : {
     141           0 : }
     142             : 
     143           0 : void AlternativesString::Paint(
     144             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     145             :     const SvTreeListEntry* pEntry)
     146             : {
     147           0 :     AlternativesExtraData* pData = m_rControlImpl.GetExtraData( pEntry );
     148           0 :     Point aPos( rPos );
     149           0 :     Font aOldFont( rDev.GetFont());
     150           0 :     if (pData && pData->IsHeader())
     151             :     {
     152           0 :         Font aFont( aOldFont );
     153           0 :         aFont.SetWeight( WEIGHT_BOLD );
     154           0 :         rDev.SetFont( aFont );
     155           0 :         aPos.X() = 0;
     156             :     }
     157             :     else
     158           0 :         aPos.X() += 5;
     159           0 :     rDev.DrawText( aPos, GetText() );
     160           0 :     rDev.SetFont( aOldFont );
     161           0 : }
     162             : 
     163           0 : ThesaurusAlternativesCtrl::ThesaurusAlternativesCtrl(Window* pParent)
     164             :     : SvxCheckListBox(pParent)
     165           0 :     , m_pDialog(NULL)
     166             : {
     167           0 :     SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE );
     168           0 :     SetHighlightRange();
     169           0 : }
     170             : 
     171           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeThesaurusAlternativesCtrl(Window *pParent, VclBuilder::stringmap &)
     172             : {
     173           0 :     return new ThesaurusAlternativesCtrl(pParent);
     174             : }
     175             : 
     176           0 : void ThesaurusAlternativesCtrl::init(SvxThesaurusDialog *pDialog)
     177             : {
     178           0 :     m_pDialog = pDialog;
     179           0 : }
     180             : 
     181           0 : ThesaurusAlternativesCtrl::~ThesaurusAlternativesCtrl()
     182             : {
     183           0 :     ClearExtraData();
     184           0 : }
     185             : 
     186           0 : void ThesaurusAlternativesCtrl::ClearExtraData()
     187             : {
     188           0 :     UserDataMap_t   aEmpty;
     189           0 :     m_aUserData.swap( aEmpty );
     190           0 : }
     191             : 
     192           0 : void ThesaurusAlternativesCtrl::SetExtraData(
     193             :     const SvTreeListEntry *pEntry,
     194             :     const AlternativesExtraData &rData )
     195             : {
     196           0 :     if (!pEntry)
     197           0 :         return;
     198             : 
     199           0 :     UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) );
     200           0 :     if (aIt != m_aUserData.end())
     201           0 :         aIt->second = rData;
     202             :     else
     203           0 :         m_aUserData[ pEntry ] = rData;
     204             : }
     205             : 
     206           0 : AlternativesExtraData * ThesaurusAlternativesCtrl::GetExtraData(
     207             :     const SvTreeListEntry *pEntry )
     208             : {
     209           0 :     AlternativesExtraData *pRes = NULL;
     210           0 :     UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) );
     211           0 :     if (aIt != m_aUserData.end())
     212           0 :         pRes = &aIt->second;
     213           0 :     return pRes;
     214             : }
     215             : 
     216           0 : SvTreeListEntry * ThesaurusAlternativesCtrl::AddEntry( sal_Int32 nVal, const OUString &rText, bool bIsHeader )
     217             : {
     218           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     219           0 :     OUString aText;
     220           0 :     if (bIsHeader && nVal >= 0)
     221             :     {
     222           0 :         aText = OUString::number( nVal ) + ". ";
     223             :     }
     224           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, OUString() ) ); // add empty column
     225           0 :     aText += rText;
     226           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), false ) );  // otherwise crash
     227           0 :     pEntry->AddItem( new AlternativesString( *this, pEntry, 0, aText ) );
     228             : 
     229           0 :     SetExtraData( pEntry, AlternativesExtraData( rText, bIsHeader ) );
     230           0 :     GetModel()->Insert( pEntry );
     231             : 
     232           0 :     if (bIsHeader)
     233           0 :         GetViewDataEntry( pEntry )->SetSelectable( false );
     234             : 
     235           0 :     return pEntry;
     236             : }
     237             : 
     238           0 : void ThesaurusAlternativesCtrl::KeyInput( const KeyEvent& rKEvt )
     239             : {
     240           0 :     const KeyCode& rKey = rKEvt.GetKeyCode();
     241             : 
     242           0 :     if (rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_ESCAPE)
     243           0 :         GetParent()->KeyInput( rKEvt ); // parent will close dialog...
     244           0 :     else if (rKey.GetCode() == KEY_SPACE)
     245           0 :         m_pDialog->AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry
     246           0 :     else if (GetEntryCount())
     247           0 :         SvxCheckListBox::KeyInput( rKEvt );
     248           0 : }
     249             : 
     250           0 : void ThesaurusAlternativesCtrl::Paint( const Rectangle& rRect )
     251             : {
     252           0 :     if (!m_pDialog->WordFound())
     253             :     {
     254           0 :         Size aTextSize( GetTextWidth( m_pDialog->getErrStr() ), GetTextHeight() );
     255           0 :         aTextSize  = LogicToPixel( aTextSize );
     256           0 :         Point aPos;
     257           0 :         aPos.X() += GetSizePixel().Width() / 2  - aTextSize.Width() / 2;
     258           0 :         aPos.Y() += GetSizePixel().Height() / 2;
     259           0 :         aPos = PixelToLogic( aPos );
     260           0 :         DrawText( aPos, m_pDialog->getErrStr() );
     261             : 
     262             :     }
     263             :     else
     264           0 :         SvxCheckListBox::Paint( rRect );
     265           0 : }
     266             : 
     267           0 : uno::Sequence< uno::Reference< linguistic2::XMeaning > > SvxThesaurusDialog::queryMeanings_Impl(
     268             :         OUString& rTerm,
     269             :         const lang::Locale& rLocale,
     270             :         const beans::PropertyValues& rProperties )
     271             :     throw(lang::IllegalArgumentException, uno::RuntimeException)
     272             : {
     273             :     uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings(
     274           0 :             xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) );
     275             : 
     276             :     // text with '.' at the end?
     277           0 :     if ( 0 == aMeanings.getLength() && rTerm.endsWith(".") )
     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 :         OUString 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::convertToLocale( nLookUpLanguage ) );
     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( 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( true );
     321             : 
     322           0 :     return nMeanings > 0;
     323             : }
     324             : 
     325           0 : void SvxThesaurusDialog::LookUp( const OUString &rText )
     326             : {
     327           0 :     if (OUString(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 :     OUString 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::convertToLocale( nLang ) ))
     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 :     OUString 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( OUString() );
     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 :         OUString 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 :         OUString 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 :         OUString 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.isEmpty())
     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 OUString &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.isEmpty())
     477           0 :         aLookUpHistory.push( rWord );
     478             : 
     479           0 :     OUString aTmp( rWord );
     480           0 :     linguistic::RemoveHyphens( aTmp );
     481           0 :     linguistic::ReplaceControlChars( aTmp );
     482           0 :     OUString 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( 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::convertToLanguageType( pLocales[i] );
     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( false );
     520           0 : }
     521             : 
     522           0 : IMPL_LINK( SvxThesaurusDialog, ReplaceBtnHdl_Impl, Button *, EMPTYARG /*pBtn*/ )
     523             : {
     524           0 :     EndDialog(RET_OK);
     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 :     OUString aStr( GetText() );
     536           0 :     sal_Int32 nIndex = aStr.indexOf( '(' );
     537           0 :     if( nIndex != -1 )
     538           0 :         aStr = aStr.copy( 0, nIndex - 1 );
     539           0 :     aStr += " (";
     540           0 :     aStr += SvtLanguageTable().GetLanguageString( nLanguage );
     541           0 :     aStr += ")";
     542           0 :     SetText( aStr );    // set window title
     543           0 : }
     544             : 
     545           0 : OUString SvxThesaurusDialog::GetWord()
     546             : {
     547           0 :     return m_pReplaceEdit->GetText();
     548             : }
     549             : 
     550           0 : sal_uInt16 SvxThesaurusDialog::GetLanguage() const
     551             : {
     552           0 :     return nLookUpLanguage;
     553             : }
     554             : 
     555           0 : void SvxThesaurusDialog::Apply()
     556             : {
     557           0 : }
     558             : 
     559             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10