From aa3eeb28bcba10d603c15ee850620bed638514f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sun, 15 Jul 2012 21:59:04 +0100 Subject: [PATCH] Resolves: fdo#37279 and #i78701# startEditingAtNode does nothing inherit class UnoTreeListItem from SvLBoxString instead of SvLBoxItem so that it really isa SvLBoxString and can be edited with startEditingAtNode a) remove the unused SvLBoxEntry argument to SvLBoxString's SetText b) used rtl::OUString instead of XubString c) rename aStr to maText d) inherit UnoTreeListItem from SvLBoxString and drop its maText in favour of that of SvLBoxEntry Change-Id: Id78f43ae5be8cd6f581e6c2fd2bd6f46de9144ba --- dbaccess/source/ui/control/dbtreelistbox.cxx | 2 +- svtools/inc/svtools/svlbitm.hxx | 11 +++---- svtools/source/contnr/svlbitm.cxx | 20 +++++-------- svtools/source/contnr/svtabbx.cxx | 4 +-- svtools/source/contnr/svtreebx.cxx | 7 ++--- svtools/source/uno/treecontrolpeer.cxx | 31 ++------------------ svx/source/dialog/ctredlin.cxx | 2 +- svx/source/dialog/fontlb.cxx | 2 +- 8 files changed, 24 insertions(+), 55 deletions(-) diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx index 7e593f00759d..d73a435fe9e5 100644 --- a/dbaccess/source/ui/control/dbtreelistbox.cxx +++ b/dbaccess/source/ui/control/dbtreelistbox.cxx @@ -120,7 +120,7 @@ SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvLBoxEntry* { pEntry = static_cast((*pChildren)[ i ]); SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); - if ( pItem->GetText().Equals(aName) ) + if ( pItem->GetText().equals(aName) ) { if ( !_pFilter || _pFilter->includeEntry( pEntry ) ) // found diff --git a/svtools/inc/svtools/svlbitm.hxx b/svtools/inc/svtools/svlbitm.hxx index 7299ec7dcf6c..ae259acd1790 100644 --- a/svtools/inc/svtools/svlbitm.hxx +++ b/svtools/inc/svtools/svlbitm.hxx @@ -122,15 +122,16 @@ inline SvButtonState SvLBoxButtonData::GetActButtonState() const class SVT_DLLPUBLIC SvLBoxString : public SvLBoxItem { - XubString aStr; +protected: + rtl::OUString maText; public: - SvLBoxString( SvLBoxEntry*,sal_uInt16 nFlags,const XubString& rStr); + SvLBoxString(SvLBoxEntry*, sal_uInt16 nFlags, const rtl::OUString& rStr); SvLBoxString(); virtual ~SvLBoxString(); virtual sal_uInt16 IsA(); - virtual void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* ); - XubString GetText() const { return aStr; } - void SetText( SvLBoxEntry*, const XubString& rStr ); + virtual void InitViewData(SvLBox*, SvLBoxEntry*, SvViewDataItem*); + rtl::OUString GetText() const { return maText; } + void SetText( const rtl::OUString& rText ) { maText = rText; } virtual void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* ); virtual SvLBoxItem* Create() const; virtual void Clone( SvLBoxItem* pSource ); diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index f3a669fdc26f..509654adac96 100644 --- a/svtools/source/contnr/svlbitm.cxx +++ b/svtools/source/contnr/svlbitm.cxx @@ -197,11 +197,11 @@ sal_Bool SvLBoxButtonData::IsRadio() { DBG_NAME(SvLBoxString); -SvLBoxString::SvLBoxString( SvLBoxEntry* pEntry,sal_uInt16 nFlags,const XubString& rStr) : - SvLBoxItem( pEntry, nFlags ) +SvLBoxString::SvLBoxString(SvLBoxEntry* pEntry, sal_uInt16 nFlags, const rtl::OUString& rStr) + : SvLBoxItem(pEntry, nFlags) { DBG_CTOR(SvLBoxString,0); - SetText( pEntry, rStr ); + SetText(rStr); } SvLBoxString::SvLBoxString() : SvLBoxItem() @@ -229,10 +229,10 @@ void SvLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE; if ( rDev.IsEntryMnemonicsEnabled() ) nStyle |= TEXT_DRAW_MNEMONIC; - rDev.DrawText( Rectangle(rPos,GetSize(&rDev,_pEntry)),aStr,nStyle); + rDev.DrawText(Rectangle(rPos, GetSize(&rDev,_pEntry)), maText, nStyle); } else - rDev.DrawText( rPos, aStr); + rDev.DrawText(rPos, maText); } @@ -245,13 +245,7 @@ SvLBoxItem* SvLBoxString::Create() const void SvLBoxString::Clone( SvLBoxItem* pSource ) { DBG_CHKTHIS(SvLBoxString,0); - aStr = ((SvLBoxString*)pSource)->aStr; -} - -void SvLBoxString::SetText( SvLBoxEntry*, const XubString& rStr ) -{ - DBG_CHKTHIS(SvLBoxString,0); - aStr = rStr; + maText = ((SvLBoxString*)pSource)->maText; } void SvLBoxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, @@ -260,7 +254,7 @@ void SvLBoxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, DBG_CHKTHIS(SvLBoxString,0); if( !pViewData ) pViewData = pView->GetViewDataItem( pEntry, this ); - pViewData->aSize = Size(pView->GetTextWidth( aStr ), pView->GetTextHeight()); + pViewData->aSize = Size(pView->GetTextWidth(maText), pView->GetTextHeight()); } // *************************************************************** diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index ad019f4c9202..13850f2b4c57 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -341,7 +341,7 @@ void SvTabListBox::SetEntryText( const XubString& rStr, SvLBoxEntry* pEntry, sal aTemp = rtl::OUString(pCurToken, nCurTokenLen); else aTemp.Erase(); // delete all columns without a token - ((SvLBoxString*)pStr)->SetText( pEntry, aTemp ); + ((SvLBoxString*)pStr)->SetText( aTemp ); pCurToken = pNextToken; pNextToken = GetToken( pCurToken, nCurTokenLen ); } @@ -350,7 +350,7 @@ void SvTabListBox::SetEntryText( const XubString& rStr, SvLBoxEntry* pEntry, sal if( !nCol ) { aTemp = rtl::OUString(pCurToken, nCurTokenLen); - ((SvLBoxString*)pStr)->SetText( pEntry, aTemp ); + ((SvLBoxString*)pStr)->SetText( aTemp ); if( !pNextToken ) break; pCurToken = pNextToken; diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index 7e6475e4571f..9cb396631060 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -339,8 +339,7 @@ String SvTreeListBox::SearchEntryText( SvLBoxEntry* pEntry ) const while( nCur < nCount ) { pItem = pEntry->GetItem( nCur ); - if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && - static_cast( pItem )->GetText().Len() > 0 ) + if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && !static_cast( pItem )->GetText().isEmpty() ) { sRet = static_cast( pItem )->GetText(); break; @@ -447,7 +446,7 @@ void SvTreeListBox::SetEntryText( SvLBoxEntry* pEntry, const XubString& aStr) DBG_CHKTHIS(SvTreeListBox,0); SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); DBG_ASSERT(pItem,"SetText:Item not found"); - pItem->SetText( pEntry, aStr ); + pItem->SetText( aStr ); pItem->InitViewData( this, pEntry, 0 ); GetModel()->InvalidateEntry( pEntry ); } @@ -1345,7 +1344,7 @@ void SvTreeListBox::EditedText( const XubString& rStr ) { if( EditedEntry( pEdEntry, rStr ) ) { - ((SvLBoxString*)pEdItem)->SetText( pEdEntry, rStr ); + ((SvLBoxString*)pEdItem)->SetText( rStr ); pModel->InvalidateEntry( pEdEntry ); } if( GetSelectionCount() == 0 ) diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 15bb2da3720c..12fd892910e4 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -112,16 +112,13 @@ private: // -------------------------------------------------------------------- -class UnoTreeListItem : public SvLBoxItem +class UnoTreeListItem : public SvLBoxString { public: UnoTreeListItem( SvLBoxEntry* ); UnoTreeListItem(); virtual ~UnoTreeListItem(); - virtual sal_uInt16 IsA(); void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* ); - OUString GetText() const; - void SetText( const OUString& rText ); Image GetImage() const; void SetImage( const Image& rImage ); OUString GetGraphicURL() const; @@ -131,7 +128,6 @@ public: void Clone( SvLBoxItem* pSource ); private: - OUString maText; OUString maGraphicURL; Image maImage; }; @@ -1601,14 +1597,14 @@ sal_Bool UnoTreeListBoxImpl::EditedEntry( SvLBoxEntry* pEntry, const rtl::OUStri // ==================================================================== UnoTreeListItem::UnoTreeListItem( SvLBoxEntry* pEntry ) -: SvLBoxItem( pEntry, 0 ) +: SvLBoxString(pEntry, 0, rtl::OUString()) { } // -------------------------------------------------------------------- UnoTreeListItem::UnoTreeListItem() -: SvLBoxItem() +: SvLBoxString() { } @@ -1620,13 +1616,6 @@ UnoTreeListItem::~UnoTreeListItem() // -------------------------------------------------------------------- -sal_uInt16 UnoTreeListItem::IsA() -{ - return 0; -} - -// -------------------------------------------------------------------- - void UnoTreeListItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */, SvLBoxEntry* _pEntry) { Point aPos( rPos ); @@ -1674,20 +1663,6 @@ void UnoTreeListItem::Clone( SvLBoxItem* pSource ) // -------------------------------------------------------------------- -OUString UnoTreeListItem::GetText() const -{ - return maText; -} - -// -------------------------------------------------------------------- - -void UnoTreeListItem::SetText( const OUString& rText ) -{ - maText = rText; -} - -// -------------------------------------------------------------------- - void UnoTreeListItem::SetImage( const Image& rImage ) { maImage = rImage; diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx index 620ce3949da4..01e1c4cdf174 100644 --- a/svx/source/dialog/ctredlin.cxx +++ b/svx/source/dialog/ctredlin.cxx @@ -100,7 +100,7 @@ SvLBoxColorString::SvLBoxColorString( SvLBoxEntry*pEntry,sal_uInt16 nFlags,const { DBG_CTOR(SvLBoxColorString,0); aPrivColor=rCol; - SetText( pEntry, rStr ); + SetText( rStr ); } SvLBoxColorString::SvLBoxColorString() diff --git a/svx/source/dialog/fontlb.cxx b/svx/source/dialog/fontlb.cxx index 94edf0a55c56..b697a66061c8 100644 --- a/svx/source/dialog/fontlb.cxx +++ b/svx/source/dialog/fontlb.cxx @@ -47,7 +47,7 @@ SvLBoxFontString::SvLBoxFontString( mbUseColor( pColor != NULL ) { DBG_CTOR( SvLBoxFontString, 0 ); - SetText( pEntry, rString ); + SetText( rString ); if( pColor ) maFont.SetColor( *pColor ); }