diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-04 11:31:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-04 12:49:27 +0100 |
commit | 77407d7ad0cece76eed9e7767765b12229e6449d (patch) | |
tree | 2d03934bd883b64567d8f6a5f9e4630f4ba94a64 /cui/source/dialogs/thesdlg.cxx | |
parent | c5850f4b25d2b735ea59bb0ac8c2bc58527ac17e (diff) |
convert thesaurus dialog to .ui format
Change-Id: I58c128b78f19b1141b82c2cecb37ed390a5db82b
Diffstat (limited to 'cui/source/dialogs/thesdlg.cxx')
-rw-r--r-- | cui/source/dialogs/thesdlg.cxx | 347 |
1 files changed, 121 insertions, 226 deletions
diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index c794b2a9512d..7be748a60f6b 100644 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include "thesdlg.hrc" #include "thesdlg.hxx" #include "thesdlg_impl.hxx" #include "cuires.hrc" @@ -63,69 +62,83 @@ using namespace ::com::sun::star; using ::rtl::OUString; -// class LookUpComboBox_Impl -------------------------------------------------- +// class LookUpComboBox -------------------------------------------------- -LookUpComboBox_Impl::LookUpComboBox_Impl( - Window *pParent, const ResId &rResId, SvxThesaurusDialog &rImpl ) : - ComboBox (pParent, rResId), - m_rDialogImpl( rImpl ) +LookUpComboBox::LookUpComboBox(Window *pParent) + : ComboBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK) { - m_aModifyTimer.SetTimeoutHdl( LINK( this, LookUpComboBox_Impl, ModifyTimer_Hdl ) ); + SetBestDropDownLineCount(); + + m_aModifyTimer.SetTimeoutHdl( LINK( this, LookUpComboBox, ModifyTimer_Hdl ) ); m_aModifyTimer.SetTimeout( 500 ); EnableAutocomplete( sal_False ); } -LookUpComboBox_Impl::~LookUpComboBox_Impl() +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLookUpComboBox(Window *pParent, VclBuilder::stringmap &) { + return new LookUpComboBox(pParent); } -void LookUpComboBox_Impl::Modify() +void LookUpComboBox::init(SvxThesaurusDialog *pDialog) +{ + m_pDialog = pDialog; +} + +LookUpComboBox::~LookUpComboBox() +{ +} + +void LookUpComboBox::Modify() { m_aModifyTimer.Start(); } -IMPL_LINK( LookUpComboBox_Impl, ModifyTimer_Hdl, Timer *, EMPTYARG /*pTimer*/ ) +IMPL_LINK( LookUpComboBox, ModifyTimer_Hdl, Timer *, EMPTYARG /*pTimer*/ ) { - m_rDialogImpl.LookUp( GetText() ); + m_pDialog->LookUp( GetText() ); m_aModifyTimer.Stop(); return 0; } -// class ReplaceEdit_Impl -------------------------------------------------- +// class ReplaceEdit -------------------------------------------------- -ReplaceEdit_Impl::ReplaceEdit_Impl( Window *pParent, const ResId &rResId ) - : Edit(pParent, rResId) - , m_pBtn(NULL) +ReplaceEdit::ReplaceEdit(Window *pParent) + : Edit(pParent) { } -ReplaceEdit_Impl::~ReplaceEdit_Impl() +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReplaceEdit(Window *pParent, VclBuilder::stringmap &) { + return new ReplaceEdit(pParent); } -void ReplaceEdit_Impl::Modify() +ReplaceEdit::~ReplaceEdit() +{ +} + +void ReplaceEdit::Modify() { if (m_pBtn) m_pBtn->Enable( GetText().Len() > 0 ); } -void ReplaceEdit_Impl::SetText( const XubString& rStr ) +void ReplaceEdit::SetText( const XubString& rStr ) { Edit::SetText( rStr ); Modify(); } -void ReplaceEdit_Impl::SetText( const XubString& rStr, const Selection& rNewSelection ) +void ReplaceEdit::SetText( const XubString& rStr, const Selection& rNewSelection ) { Edit::SetText( rStr, rNewSelection ); Modify(); } -// class ThesaurusAlternativesCtrl_Impl ---------------------------------- +// class ThesaurusAlternativesCtrl ---------------------------------- -AlternativesString_Impl::AlternativesString_Impl( - ThesaurusAlternativesCtrl_Impl &rControl, +AlternativesString::AlternativesString( + ThesaurusAlternativesCtrl &rControl, SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr ) : SvLBoxString( pEntry, nFlags, rStr ), @@ -133,7 +146,7 @@ AlternativesString_Impl::AlternativesString_Impl( { } -void AlternativesString_Impl::Paint( +void AlternativesString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* pEntry ) @@ -154,28 +167,35 @@ void AlternativesString_Impl::Paint( rDev.SetFont( aOldFont ); } -ThesaurusAlternativesCtrl_Impl::ThesaurusAlternativesCtrl_Impl( - Window* pParent, - SvxThesaurusDialog &rImpl ) : - SvxCheckListBox( pParent, CUI_RES( CT_THES_ALTERNATIVES ) ), - m_rDialogImpl( rImpl ) +ThesaurusAlternativesCtrl::ThesaurusAlternativesCtrl(Window* pParent) + : SvxCheckListBox(pParent) { SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE ); SetHighlightRange(); } -ThesaurusAlternativesCtrl_Impl::~ThesaurusAlternativesCtrl_Impl() +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeThesaurusAlternativesCtrl(Window *pParent, VclBuilder::stringmap &) +{ + return new ThesaurusAlternativesCtrl(pParent); +} + +void ThesaurusAlternativesCtrl::init(SvxThesaurusDialog *pDialog) +{ + m_pDialog = pDialog; +} + +ThesaurusAlternativesCtrl::~ThesaurusAlternativesCtrl() { ClearExtraData(); } -void ThesaurusAlternativesCtrl_Impl::ClearExtraData() +void ThesaurusAlternativesCtrl::ClearExtraData() { UserDataMap_t aEmpty; m_aUserData.swap( aEmpty ); } -void ThesaurusAlternativesCtrl_Impl::SetExtraData( +void ThesaurusAlternativesCtrl::SetExtraData( const SvLBoxEntry *pEntry, const AlternativesExtraData &rData ) { @@ -189,7 +209,7 @@ void ThesaurusAlternativesCtrl_Impl::SetExtraData( m_aUserData[ pEntry ] = rData; } -AlternativesExtraData * ThesaurusAlternativesCtrl_Impl::GetExtraData( +AlternativesExtraData * ThesaurusAlternativesCtrl::GetExtraData( const SvLBoxEntry *pEntry ) { AlternativesExtraData *pRes = NULL; @@ -199,7 +219,7 @@ AlternativesExtraData * ThesaurusAlternativesCtrl_Impl::GetExtraData( return pRes; } -SvLBoxEntry * ThesaurusAlternativesCtrl_Impl::AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader ) +SvLBoxEntry * ThesaurusAlternativesCtrl::AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader ) { SvLBoxEntry* pEntry = new SvLBoxEntry; String aText; @@ -211,7 +231,7 @@ SvLBoxEntry * ThesaurusAlternativesCtrl_Impl::AddEntry( sal_Int32 nVal, const St pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) ); // add empty column aText += rText; pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) ); // otherwise crash - pEntry->AddItem( new AlternativesString_Impl( *this, pEntry, 0, aText ) ); + pEntry->AddItem( new AlternativesString( *this, pEntry, 0, aText ) ); SetExtraData( pEntry, AlternativesExtraData( rText, bIsHeader ) ); GetModel()->Insert( pEntry ); @@ -222,29 +242,29 @@ SvLBoxEntry * ThesaurusAlternativesCtrl_Impl::AddEntry( sal_Int32 nVal, const St return pEntry; } -void ThesaurusAlternativesCtrl_Impl::KeyInput( const KeyEvent& rKEvt ) +void ThesaurusAlternativesCtrl::KeyInput( const KeyEvent& rKEvt ) { const KeyCode& rKey = rKEvt.GetKeyCode(); if (rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_ESCAPE) GetParent()->KeyInput( rKEvt ); // parent will close dialog... else if (rKey.GetCode() == KEY_SPACE) - m_rDialogImpl.AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry + m_pDialog->AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry else if (GetEntryCount()) SvxCheckListBox::KeyInput( rKEvt ); } -void ThesaurusAlternativesCtrl_Impl::Paint( const Rectangle& rRect ) +void ThesaurusAlternativesCtrl::Paint( const Rectangle& rRect ) { - if (!m_rDialogImpl.WordFound()) + if (!m_pDialog->WordFound()) { - Size aTextSize( GetTextWidth( m_rDialogImpl.getErrStr() ), GetTextHeight() ); + Size aTextSize( GetTextWidth( m_pDialog->getErrStr() ), GetTextHeight() ); aTextSize = LogicToPixel( aTextSize ); Point aPos; aPos.X() += GetSizePixel().Width() / 2 - aTextSize.Width() / 2; aPos.Y() += GetSizePixel().Height() / 2; aPos = PixelToLogic( aPos ); - DrawText( aPos, m_rDialogImpl.getErrStr() ); + DrawText( aPos, m_pDialog->getErrStr() ); } else @@ -312,8 +332,8 @@ bool SvxThesaurusDialog::UpdateAlternativesBox_Impl() void SvxThesaurusDialog::LookUp( const String &rText ) { - if (rText != aWordCB.GetText()) // avoid moving of the cursor if the text is the same - aWordCB.SetText( rText ); + if (rText != m_pWordCB->GetText()) // avoid moving of the cursor if the text is the same + m_pWordCB->SetText( rText ); LookUp_Impl(); } @@ -322,16 +342,16 @@ IMPL_LINK( SvxThesaurusDialog, LeftBtnHdl_Impl, Button *, pBtn ) if (pBtn && aLookUpHistory.size() >= 2) { aLookUpHistory.pop(); // remove current look up word from stack - aWordCB.SetText( aLookUpHistory.top() ); // retrieve previous look up word + m_pWordCB->SetText( aLookUpHistory.top() ); // retrieve previous look up word aLookUpHistory.pop(); LookUp_Impl(); } return 0; } -IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, MenuButton *, pBtn ) +IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, MenuButton*, pBtn ) { - PopupMenu *pMenu = aLangMBtn.GetPopupMenu(); + PopupMenu *pMenu = m_pLangMBtn->GetPopupMenu(); if (pMenu && pBtn) { sal_uInt16 nItem = pBtn->GetCurItemId(); @@ -341,7 +361,6 @@ IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, MenuButton *, pBtn ) if (xThesaurus->hasLocale( SvxCreateLocale( nLang ) )) nLookUpLanguage = nLang; SetWindowTitle( nLang ); - UpdateVendorImage(); LookUp_Impl(); } return 0; @@ -349,7 +368,7 @@ IMPL_LINK( SvxThesaurusDialog, LanguageHdl_Impl, MenuButton *, pBtn ) void SvxThesaurusDialog::LookUp_Impl() { - String aText( aWordCB.GetText() ); + String aText( m_pWordCB->GetText() ); aLookUpText = OUString( aText ); if (!aLookUpText.isEmpty() && @@ -359,21 +378,21 @@ void SvxThesaurusDialog::LookUp_Impl() m_bWordFound = UpdateAlternativesBox_Impl(); m_pAlternativesCT->Enable( m_bWordFound ); - if ( aWordCB.GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND ) - aWordCB.InsertEntry( aText ); + if ( m_pWordCB->GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND ) + m_pWordCB->InsertEntry( aText ); - aReplaceEdit.SetText( String() ); - aLeftBtn.Enable( aLookUpHistory.size() > 1 ); + m_pReplaceEdit->SetText( String() ); + m_pLeftBtn->Enable( aLookUpHistory.size() > 1 ); } IMPL_LINK( SvxThesaurusDialog, WordSelectHdl_Impl, ComboBox *, pBox ) { - if (pBox && !aWordCB.IsTravelSelect()) // act only upon return key and not when traveling with cursor keys + if (pBox && !m_pWordCB->IsTravelSelect()) // act only upon return key and not when traveling with cursor keys { sal_uInt16 nPos = pBox->GetSelectEntryPos(); String aStr( pBox->GetEntry( nPos ) ); aStr = linguistic::GetThesaurusReplaceText( aStr ); - aWordCB.SetText( aStr ); + m_pWordCB->SetText( aStr ); LookUp_Impl(); } @@ -392,7 +411,7 @@ IMPL_LINK( SvxThesaurusDialog, AlternativesSelectHdl_Impl, SvxCheckListBox *, pB aStr = pData->GetText(); aStr = linguistic::GetThesaurusReplaceText( aStr ); } - aReplaceEdit.SetText( aStr ); + m_pReplaceEdit->SetText( aStr ); } return 0; } @@ -410,7 +429,7 @@ IMPL_LINK( SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl, SvxCheckListBox aStr = linguistic::GetThesaurusReplaceText( aStr ); } - aWordCB.SetText( aStr ); + m_pWordCB->SetText( aStr ); if (aStr.Len() > 0) LookUp_Impl(); } @@ -429,192 +448,57 @@ IMPL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox *, pB return 0; } -//////////////////////////////////////////////////////////// - -static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl ) -{ - Image aRes; - - OUString aTmp; - osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp ); - - Graphic aGraphic; - const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) ); - if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic, NULL, NULL ) ) - { - aRes = Image( aGraphic.GetBitmapEx() ); - } - return aRes; -} - -static String lcl_GetThesImplName( const lang::Locale &rLocale ) -{ - String aRes; - - uno::Reference< linguistic2::XLinguServiceManager > xLngMgr; - try - { - uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - xLngMgr = uno::Reference< linguistic2::XLinguServiceManager >( xMSF->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.linguistic2.LinguServiceManager" ))), uno::UNO_QUERY_THROW ); - - DBG_ASSERT( xLngMgr.is(), "LinguServiceManager missing" ); - if (xLngMgr.is()) - { - uno::Sequence< OUString > aServiceNames = xLngMgr->getConfiguredServices( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.Thesaurus")), rLocale ); - // there should be at most one thesaurus configured for each language - DBG_ASSERT( aServiceNames.getLength() <= 1, "more than one thesaurus found. Should not be possible" ); - if (aServiceNames.getLength() == 1) - aRes = aServiceNames[0]; - } - } - catch (uno::Exception &e) - { - (void) e; - DBG_ASSERT( 0, "failed to get thesaurus" ); - } - - return aRes; -} - -void SvxThesaurusDialog::UpdateVendorImage() -{ - SetUpdateMode( sal_False ); - - SvtLinguConfig aCfg; - if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) - { - Image aImage; - String sThesImplName( lcl_GetThesImplName( SvxCreateLocale( nLookUpLanguage ) ) ); - OUString aThesDialogImageUrl( aCfg.GetThesaurusDialogImage( sThesImplName ) ); - if (sThesImplName.Len() > 0 && !aThesDialogImageUrl.isEmpty()) - aImage = Image( lcl_GetImageFromPngUrl( aThesDialogImageUrl ) ); - else - aImage = aVendorDefaultImage; - aVendorImageFI.SetImage( aImage ); - } - - SetUpdateMode( sal_True ); -} +// class SvxThesaurusDialog ---------------------------------------------- -IMPL_STATIC_LINK( SvxThesaurusDialog, VendorImageInitHdl, SvxThesaurusDialog*, EMPTYARG ) +SvxThesaurusDialog::SvxThesaurusDialog( + Window* pParent, + uno::Reference< linguistic2::XThesaurus > xThes, + const String &rWord, + LanguageType nLanguage) + : SvxStandardDialog(pParent, "ThesaurusDialog", "cui/ui/thesaurus.ui") + , m_aErrStr(CUI_RESSTR(RID_SVXSTR_ERR_TEXTNOTFOUND)) + , xThesaurus(NULL) + , aLookUpText() + , nLookUpLanguage(LANGUAGE_NONE) + , m_bWordFound(false) { - pThis->SetUpdateMode( sal_False ); + get(m_pLeftBtn, "left"); - SvtLinguConfig aCfg; - if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) - { - Image aImage( pThis->aVendorDefaultImage ); - pThis->aVendorImageFI.SetImage( aImage ); - pThis->aVendorImageFI.Show(); - - // move down visible controls according to the vendor images height - Size aVendorSize = pThis->aVendorImageFI.GetSizePixel(); - Size aImageSize = pThis->aVendorImageFI.GetImage().GetSizePixel(); - if (aImageSize.Height()) - { - aVendorSize.Height() = aImageSize.Height(); - if(aVendorSize.Width() < aImageSize.Width()) - aVendorSize.Width() = aImageSize.Width(); - pThis->aVendorImageFI.SetSizePixel( aVendorSize ); - } - const sal_Int32 nDiff = aVendorSize.Height(); - pThis->aVendorImageFI.SetSizePixel( aVendorSize ); - Control* aControls[] = { - &pThis->aLeftBtn, - &pThis->aWordText, - &pThis->aWordCB, - &pThis->m_aAlternativesText, - pThis->m_pAlternativesCT.get(), - &pThis->aReplaceText, - &pThis->aReplaceEdit, - &pThis->aFL, - &pThis->aHelpBtn, - &pThis->aLangMBtn, - &pThis->aReplaceBtn, - &pThis->aCancelBtn, - 0 - }; - sal_Int32 nControl = 0; - while (aControls[nControl]) - { - Point aPos = aControls[nControl]->GetPosPixel(); - aPos.Y() += nDiff; - aControls[nControl]->SetPosPixel(aPos); - ++nControl; - } - Size aDlgSize = pThis->GetSizePixel(); - aDlgSize.Height() += nDiff; - pThis->SetSizePixel( aDlgSize ); - pThis->Invalidate(); - } + get(m_pWordCB, "wordcb"); + m_pWordCB->init(this); - pThis->UpdateVendorImage(); - pThis->SetUpdateMode( sal_True ); + get(m_pAlternativesCT, "alternatives"); + m_pAlternativesCT->init(this); - return 0; -}; + get(m_pReplaceEdit, "replaceed"); + PushButton *pReplaceBtn = get<PushButton>("replace"); + m_pReplaceEdit->init(pReplaceBtn); -// class SvxThesaurusDialog ---------------------------------------------- + get(m_pLangMBtn, "langcb"); -SvxThesaurusDialog::SvxThesaurusDialog( - Window* pParent, - uno::Reference< linguistic2::XThesaurus > xThes, - const String &rWord, - LanguageType nLanguage ) : - - SvxStandardDialog( pParent, CUI_RES( RID_SVXDLG_THESAURUS ) ), - - aVendorImageFI ( this, CUI_RES( IMG_VENDOR ) ), - aLeftBtn ( this, CUI_RES( BTN_LEFT ) ), - aWordText ( this, CUI_RES( FT_WORD ) ), - aWordCB ( this, CUI_RES( CB_WORD ), *this ), - m_aAlternativesText ( this, CUI_RES( FT_THES_ALTERNATIVES ) ), - m_pAlternativesCT ( new ThesaurusAlternativesCtrl_Impl( this, *this ) ), - aReplaceText ( this, CUI_RES( FT_REPL ) ), - aReplaceEdit ( this, CUI_RES( ED_REPL ) ), - aFL ( this, CUI_RES( FL_VAR ) ), - aHelpBtn ( this, CUI_RES( BTN_THES_HELP ) ), - aLangMBtn ( this, CUI_RES( MB_LANGUAGE ) ), - aReplaceBtn ( this, CUI_RES( BTN_THES_OK ) ), - aCancelBtn ( this, CUI_RES( BTN_THES_CANCEL ) ), - aErrStr ( CUI_RES( STR_ERR_TEXTNOTFOUND ) ), - aVendorDefaultImage ( CUI_RES( IMG_DEFAULT_VENDOR ) ), - xThesaurus ( NULL ), - aLookUpText (), - nLookUpLanguage ( LANGUAGE_NONE ), - m_bWordFound( false ) -{ - aReplaceEdit.SetButton( &aReplaceBtn ); - - aLeftBtn.SetClickHdl( LINK( this, SvxThesaurusDialog, LeftBtnHdl_Impl ) ); - aWordCB.SetSelectHdl( LINK( this, SvxThesaurusDialog, WordSelectHdl_Impl ) ); - aLangMBtn.SetSelectHdl( LINK( this, SvxThesaurusDialog, LanguageHdl_Impl ) ); + pReplaceBtn->SetClickHdl( LINK( this, SvxThesaurusDialog, ReplaceBtnHdl_Impl ) ); + m_pLeftBtn->SetClickHdl( LINK( this, SvxThesaurusDialog, LeftBtnHdl_Impl ) ); + m_pWordCB->SetSelectHdl( LINK( this, SvxThesaurusDialog, WordSelectHdl_Impl ) ); + m_pLangMBtn->SetSelectHdl( LINK( this, SvxThesaurusDialog, LanguageHdl_Impl ) ); m_pAlternativesCT->SetSelectHdl( LINK( this, SvxThesaurusDialog, AlternativesSelectHdl_Impl )); m_pAlternativesCT->SetDoubleClickHdl( LINK( this, SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl )); - Application::PostUserEvent( STATIC_LINK( this, SvxThesaurusDialog, VendorImageInitHdl ) ); - xThesaurus = xThes; aLookUpText = OUString( rWord ); nLookUpLanguage = nLanguage; if (rWord.Len() > 0) aLookUpHistory.push( rWord ); - FreeResource(); - OUString aTmp( rWord ); linguistic::RemoveHyphens( aTmp ); linguistic::ReplaceControlChars( aTmp ); String aTmp2( aTmp ); - aReplaceEdit.SetText( aTmp2 ); - aWordCB.InsertEntry( aTmp2 ); + m_pReplaceEdit->SetText( aTmp2 ); + m_pWordCB->InsertEntry( aTmp2 ); LookUp( aTmp2 ); m_pAlternativesCT->GrabFocus(); - aLeftBtn.Enable( sal_False ); + m_pLeftBtn->Enable( sal_False ); // fill language menu button list SvtLanguageTable aLangTab; @@ -623,11 +507,11 @@ SvxThesaurusDialog::SvxThesaurusDialog( aLocales = xThesaurus->getLocales(); const sal_Int32 nLocales = aLocales.getLength(); const lang::Locale *pLocales = aLocales.getConstArray(); - delete aLangMBtn.GetPopupMenu(); - PopupMenu* pMenu = new PopupMenu; - pMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS ); + PopupMenu* pMenu = m_pLangMBtn->GetPopupMenu(); + pMenu->Clear(); + pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); std::vector< OUString > aLangVec; - for (sal_Int32 i = 0; i < nLocales; ++i ) + for (sal_Int32 i = 0; i < nLocales; ++i) { const LanguageType nLang = SvxLocaleToLanguage( pLocales[i] ); DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" ); @@ -636,18 +520,29 @@ SvxThesaurusDialog::SvxThesaurusDialog( std::sort( aLangVec.begin(), aLangVec.end() ); for (size_t i = 0; i < aLangVec.size(); ++i) pMenu->InsertItem( (sal_uInt16)i+1, aLangVec[i] ); // menu items should be enumerated from 1 and not 0 - aLangMBtn.SetPopupMenu( pMenu ); - SetWindowTitle( nLanguage ); + std::vector< OUString >::iterator aI = std::find(aLangVec.begin(), aLangVec.end(), aLangTab.GetString(nLanguage)); + if (aI != aLangVec.end()) + { + pMenu->SetSelectedEntry(std::distance(aLangVec.begin(), aI) + 1); + pMenu->Select(); + } + + SetWindowTitle(nLanguage); // disable controls if service is missing if (!xThesaurus.is()) Enable( sal_False ); } +IMPL_LINK( SvxThesaurusDialog, ReplaceBtnHdl_Impl, Button *, EMPTYARG /*pBtn*/ ) +{ + EndDialog(true); + return 0; +} + SvxThesaurusDialog::~SvxThesaurusDialog() { - delete aLangMBtn.GetPopupMenu(); } void SvxThesaurusDialog::SetWindowTitle( LanguageType nLanguage ) @@ -663,7 +558,7 @@ void SvxThesaurusDialog::SetWindowTitle( LanguageType nLanguage ) String SvxThesaurusDialog::GetWord() { - return aReplaceEdit.GetText(); + return m_pReplaceEdit->GetText(); } sal_uInt16 SvxThesaurusDialog::GetLanguage() const |