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

Generated by: LCOV version 1.11