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

Generated by: LCOV version 1.10