diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-07-22 13:00:15 +0200 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-07-22 13:00:15 +0200 |
commit | 7ca1af93428fb82f98b6f30af8a85b7faf11ae1d (patch) | |
tree | 3e183ff5cee9abf04e20d99a97ef02ee5cdf8fe3 /cui/source/dialogs/thesdlg.cxx | |
parent | 53c2830488b066d962c2ea65f070406de89c89cf (diff) | |
parent | 5914f1a08b1ca5d0b9fe59b8a12403d9a65d3430 (diff) |
CWS-TOOLING: integrate CWS tl81_OOO330
Diffstat (limited to 'cui/source/dialogs/thesdlg.cxx')
-rwxr-xr-x | cui/source/dialogs/thesdlg.cxx | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index bf617b126747..ec04362b488d 100755 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -172,12 +172,21 @@ void ReplaceEdit_Impl::SetText( const XubString& rStr, const Selection& rNewSele // class ThesaurusAlternativesCtrl_Impl ---------------------------------- +AlternativesString_Impl::AlternativesString_Impl( + ThesaurusAlternativesCtrl_Impl &rControl, + SvLBoxEntry* pEntry, USHORT nFlags, const String& rStr ) : + // + SvLBoxString( pEntry, nFlags, rStr ), + m_rControlImpl( rControl ) +{ +} + void AlternativesString_Impl::Paint( const Point& rPos, SvLBox& rDev, USHORT, SvLBoxEntry* pEntry ) { - AlternativesUserData_Impl* pData = (AlternativesUserData_Impl*)pEntry->GetUserData(); + AlternativesExtraData* pData = m_rControlImpl.GetExtraData( pEntry ); Point aPos( rPos ); Font aOldFont( rDev.GetFont()); if (pData && pData->IsHeader()) @@ -207,14 +216,40 @@ ThesaurusAlternativesCtrl_Impl::ThesaurusAlternativesCtrl_Impl( ThesaurusAlternativesCtrl_Impl::~ThesaurusAlternativesCtrl_Impl() { - ClearUserData(); + ClearExtraData(); +} + + +void ThesaurusAlternativesCtrl_Impl::ClearExtraData() +{ + UserDataMap_t aEmpty; + m_aUserData.swap( aEmpty ); +} + + +void ThesaurusAlternativesCtrl_Impl::SetExtraData( + const SvLBoxEntry *pEntry, + const AlternativesExtraData &rData ) +{ + if (!pEntry) + return; + + UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) ); + if (aIt != m_aUserData.end()) + aIt->second = rData; + else + m_aUserData[ pEntry ] = rData; } -void ThesaurusAlternativesCtrl_Impl::ClearUserData() +AlternativesExtraData * ThesaurusAlternativesCtrl_Impl::GetExtraData( + const SvLBoxEntry *pEntry ) { - for (USHORT i = 0; i < GetEntryCount(); ++i) - delete (AlternativesUserData_Impl*)GetEntry(i)->GetUserData(); + AlternativesExtraData *pRes = NULL; + UserDataMap_t::iterator aIt( m_aUserData.find( pEntry ) ); + if (aIt != m_aUserData.end()) + pRes = &aIt->second; + return pRes; } @@ -230,10 +265,9 @@ 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( pEntry, 0, aText ) ); + pEntry->AddItem( new AlternativesString_Impl( *this, pEntry, 0, aText ) ); - AlternativesUserData_Impl* pUserData = new AlternativesUserData_Impl( rText, bIsHeader ); - pEntry->SetUserData( pUserData ); + SetExtraData( pEntry, AlternativesExtraData( rText, bIsHeader ) ); GetModel()->Insert( pEntry ); if (bIsHeader) @@ -365,7 +399,7 @@ bool SvxThesaurusDialog_Impl::UpdateAlternativesBox_Impl() m_pAlternativesCT->SetUpdateMode( FALSE ); // clear old user data of control before creating new ones via AddEntry below - m_pAlternativesCT->ClearUserData(); + m_pAlternativesCT->ClearExtraData(); m_pAlternativesCT->Clear(); for (sal_Int32 i = 0; i < nMeanings; ++i) @@ -468,9 +502,9 @@ IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesSelectHdl_Impl, SvxCheckListBox SvLBoxEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL; if (pEntry) { - AlternativesUserData_Impl * pData = (AlternativesUserData_Impl *) pEntry->GetUserData(); + AlternativesExtraData * pData = m_pAlternativesCT->GetExtraData( pEntry ); String aStr; - if (!pData->IsHeader()) + if (pData && !pData->IsHeader()) { aStr = pData->GetText(); GetReplaceEditString( aStr ); @@ -486,9 +520,9 @@ IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesDoubleClickHdl_Impl, SvxCheckLis SvLBoxEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL; if (pEntry) { - AlternativesUserData_Impl * pData = (AlternativesUserData_Impl *) pEntry->GetUserData(); + AlternativesExtraData * pData = m_pAlternativesCT->GetExtraData( pEntry ); String aStr; - if (!pData->IsHeader()) + if (pData && !pData->IsHeader()) { aStr = pData->GetText(); GetReplaceEditString( aStr ); @@ -509,8 +543,8 @@ IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesDoubleClickHdl_Impl, SvxCheckLis IMPL_STATIC_LINK( SvxThesaurusDialog_Impl, SelectFirstHdl_Impl, SvxCheckListBox *, pBox ) { (void) pThis; - if (pBox && pBox->GetEntryCount() > 0) - pBox->SelectEntryPos( 0 ); + if (pBox && pBox->GetEntryCount() >= 2) + pBox->SelectEntryPos( 1 ); // pos 0 is a 'header' that is not selectable return 0; } |