diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-29 14:17:48 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-29 16:34:43 -0500 |
commit | 251dab0145e15a372ff0fe41ce9647e9df8e9ffd (patch) | |
tree | 813037847c767cb8405b2bceef94356bb6bdd2e4 /svtools | |
parent | 764878deacb5018539ff5df71af8bf7e6677a93e (diff) |
Pass pointer to view data entry to Paint() instead of its raw flag value.
We need to hide these flags away.
Change-Id: I112003a88a92174f5012b3356ba261a039eeccc1
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/svlbitm.hxx | 14 | ||||
-rw-r--r-- | svtools/inc/svtools/treelistbox.hxx | 9 | ||||
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 48 | ||||
-rw-r--r-- | svtools/source/contnr/svlbitm.cxx | 30 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 10 | ||||
-rw-r--r-- | svtools/source/uno/treecontrolpeer.cxx | 10 |
6 files changed, 90 insertions, 31 deletions
diff --git a/svtools/inc/svtools/svlbitm.hxx b/svtools/inc/svtools/svlbitm.hxx index b0fcd73caa8f..c65d87ebd7b1 100644 --- a/svtools/inc/svtools/svlbitm.hxx +++ b/svtools/inc/svtools/svlbitm.hxx @@ -117,7 +117,10 @@ public: virtual void InitViewData(SvTreeListBox*, SvTreeListEntry*, SvViewDataItem*); rtl::OUString GetText() const { return maText; } void SetText( const rtl::OUString& rText ) { maText = rText; } - virtual void Paint( const Point&, SvTreeListBox& rDev, sal_uInt16 nFlags,SvTreeListEntry* ); + + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry); + virtual SvLBoxItem* Create() const; virtual void Clone( SvLBoxItem* pSource ); }; @@ -130,7 +133,8 @@ public: virtual ~SvLBoxBmp(); virtual sal_uInt16 GetType() const; virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ); - virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvTreeListEntry* ); + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry); virtual SvLBoxItem* Create() const; virtual void Clone( SvLBoxItem* pSource ); }; @@ -164,7 +168,8 @@ public: virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ); virtual sal_uInt16 GetType() const; virtual sal_Bool ClickHdl(SvTreeListBox* pView, SvTreeListEntry* ); - virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvTreeListEntry* ); + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry); virtual SvLBoxItem* Create() const; virtual void Clone( SvLBoxItem* pSource ); sal_uInt16 GetButtonFlags() const { return nItemFlags; } @@ -222,7 +227,8 @@ public: virtual ~SvLBoxContextBmp(); virtual sal_uInt16 GetType() const; virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ); - virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvTreeListEntry* ); + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry); virtual SvLBoxItem* Create() const; virtual void Clone( SvLBoxItem* pSource ); diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx index 23a55f4ffd9e..26476f4a0741 100644 --- a/svtools/inc/svtools/treelistbox.hxx +++ b/svtools/inc/svtools/treelistbox.hxx @@ -149,9 +149,8 @@ public: return pIData->maSize; } - virtual void Paint( const Point& rPos, SvTreeListBox& rOutDev, - sal_uInt16 nViewDataEntryFlags, - SvTreeListEntry* pEntry ) = 0; + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) = 0; virtual void InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry, // If != 0: this Pointer must be used! @@ -647,8 +646,8 @@ public: virtual String GetEntryText( SvTreeListEntry* pEntry ) const; String SearchEntryText( SvTreeListEntry* pEntry ) const; - const Image& GetExpandedEntryBmp(SvTreeListEntry* _pEntry ) const; - const Image& GetCollapsedEntryBmp(SvTreeListEntry* _pEntry ) const; + const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ) const; + const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ) const; void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; } Link GetCheckButtonHdl() const { return aCheckButtonHdl; } diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index 99612f92fb7a..d3c0eb76ff06 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -38,6 +38,48 @@ #define NODE_BMP_TABDIST_NOTVALID -2000000 #define FIRST_ENTRY_TAB 1 +#include <stdio.h> +#include <string> +#include <sys/time.h> + +namespace { + +class stack_printer +{ +public: + explicit stack_printer(const char *msg) : + msMsg(msg) + { + fprintf(stdout, "%s: --begin\n", msMsg.c_str()); + mfStartTime = getTime(); + } + + ~stack_printer() + { + double fEndTime = getTime(); + fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime - mfStartTime)); + } + + void printTime(int line) const + { + double fEndTime = getTime(); + fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime - mfStartTime)); + } + +private: + double getTime() const + { + timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1000000.0; + } + + ::std::string msMsg; + double mfStartTime; +}; + +} + // #i27063# (pl), #i32300# (pb) never access VCL after DeInitVCL - also no destructors Image* SvImpLBox::s_pDefCollapsed = NULL; Image* SvImpLBox::s_pDefExpanded = NULL; @@ -599,6 +641,7 @@ void SvImpLBox::RecalcFocusRect() void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) { + stack_printer __stack_printer__("SvImpLBox::SetCursor"); SvViewDataEntry* pViewDataNewCur = 0; if( pEntry ) pViewDataNewCur= pView->GetViewDataEntry(pEntry); @@ -607,6 +650,7 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) pViewDataNewCur->HasFocus() && pViewDataNewCur->IsSelected()) { + fprintf(stdout, "SvImpLBox::SetCursor: nothing to do\n"); return; } @@ -628,9 +672,11 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) pCursor = pEntry; if( pCursor ) { + fprintf(stdout, "SvImpLBox::SetCursor: cp (%d)\n", __LINE__); pViewDataNewCur->SetFocus( true ); if(!bForceNoSelect && bSimpleTravel && !(nFlags & F_DESEL_ALL) && GetUpdateMode()) { + fprintf(stdout, "SvImpLBox::SetCursor: cp (%d)\n", __LINE__); pView->Select( pCursor, true ); } // multiple selection: select in cursor move if we're not in @@ -640,10 +686,12 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) !(nFlags & F_DESEL_ALL) && !aSelEng.IsAddMode() && !bForceNoSelect ) { + fprintf(stdout, "SvImpLBox::SetCursor: cp (%d)\n", __LINE__); pView->Select( pCursor, true ); } else { + fprintf(stdout, "SvImpLBox::SetCursor: cp (%d)\n", __LINE__); ShowCursor( true ); } diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index 138ae3b5bef2..31ba9fe4a043 100644 --- a/svtools/source/contnr/svlbitm.cxx +++ b/svtools/source/contnr/svlbitm.cxx @@ -211,16 +211,17 @@ sal_uInt16 SvLBoxString::GetType() const return SV_ITEM_ID_LBOXSTRING; } -void SvLBoxString::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */, - SvTreeListEntry* _pEntry) +void SvLBoxString::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/, + const SvTreeListEntry* pEntry) { DBG_CHKTHIS(SvLBoxString,0); - if ( _pEntry ) + if (pEntry) { sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE; if ( rDev.IsEntryMnemonicsEnabled() ) nStyle |= TEXT_DRAW_MNEMONIC; - rDev.DrawText(Rectangle(rPos, GetSize(&rDev,_pEntry)), maText, nStyle); + rDev.DrawText(Rectangle(rPos, GetSize(&rDev, pEntry)), maText, nStyle); } else rDev.DrawText(rPos, maText); @@ -279,8 +280,9 @@ void SvLBoxBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, pViewData->maSize = aBmp.GetSizePixel(); } -void SvLBoxBmp::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */, - SvTreeListEntry* ) +void SvLBoxBmp::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/, + const SvTreeListEntry* /*pEntry*/) { DBG_CHKTHIS(SvLBoxBmp,0); sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE; @@ -351,8 +353,9 @@ sal_Bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvTreeListEntry* pEntry ) return sal_False; } -void SvLBoxButton::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */, - SvTreeListEntry* /*pEntry*/ ) +void SvLBoxButton::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/, + const SvTreeListEntry* /*pEntry*/) { DBG_CHKTHIS(SvLBoxButton,0); sal_uInt16 nIndex = eKind == SvLBoxButtonKind_staticImage @@ -528,15 +531,16 @@ void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntr pViewData->maSize = m_pImpl->m_aImage1.GetSizePixel(); } -void SvLBoxContextBmp::Paint( const Point& _rPos, SvTreeListBox& _rDev, - sal_uInt16 _nViewDataEntryFlags, SvTreeListEntry* _pEntry ) +void SvLBoxContextBmp::Paint( + const Point& _rPos, SvTreeListBox& _rDev, + const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) { DBG_CHKTHIS(SvLBoxContextBmp,0); - // get the image - const Image& rImage = implGetImageStore( 0 == ( _nViewDataEntryFlags & m_pImpl->m_nB2IndicatorFlags ) ); + // get the image (TODO: Avoid directly referencing the flags). + const Image& rImage = implGetImageStore( 0 == (pView->GetFlags() & m_pImpl->m_nB2IndicatorFlags ) ); - sal_Bool _bSemiTransparent = _pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT & _pEntry->GetFlags( ) ) ); + sal_Bool _bSemiTransparent = pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT & pEntry->GetFlags( ) ) ); // draw sal_uInt16 nStyle = _rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE; if ( _bSemiTransparent ) diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index 6c4eb5e3a230..c1d80f1f94a3 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -1782,20 +1782,20 @@ String SvTreeListBox::SearchEntryText( SvTreeListEntry* pEntry ) const return sRet; } -const Image& SvTreeListBox::GetExpandedEntryBmp(SvTreeListEntry* pEntry) const +const Image& SvTreeListBox::GetExpandedEntryBmp(const SvTreeListEntry* pEntry) const { DBG_CHKTHIS(SvTreeListBox,0); DBG_ASSERT(pEntry,"Entry?"); - SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); + const SvLBoxContextBmp* pItem = static_cast<const SvLBoxContextBmp*>(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); DBG_ASSERT(pItem,"GetContextBmp:Item not found"); return pItem->GetBitmap2( ); } -const Image& SvTreeListBox::GetCollapsedEntryBmp( SvTreeListEntry* pEntry ) const +const Image& SvTreeListBox::GetCollapsedEntryBmp( const SvTreeListEntry* pEntry ) const { DBG_CHKTHIS(SvTreeListBox,0); DBG_ASSERT(pEntry,"Entry?"); - SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); + const SvLBoxContextBmp* pItem = static_cast<const SvLBoxContextBmp*>(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); DBG_ASSERT(pItem,"GetContextBmp:Item not found"); return pItem->GetBitmap1( ); } @@ -3073,7 +3073,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry,long nLine,sal_uInt16 nT // draw item // center vertically aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2; - pItem->Paint( aEntryPos, *this, pViewDataEntry->GetFlags(), pEntry ); + pItem->Paint(aEntryPos, *this, pViewDataEntry, pEntry); // division line between tabs if (pNextTab && pItem->GetType() == SV_ITEM_ID_LBOXSTRING && diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 8a409090f500..15cdf99f56f6 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -115,7 +115,8 @@ public: void SetImage( const Image& rImage ); OUString GetGraphicURL() const; void SetGraphicURL( const OUString& rGraphicURL ); - void Paint( const Point&, SvTreeListBox& rDev, sal_uInt16 nFlags,SvTreeListEntry* ); + virtual void Paint( + const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry); SvLBoxItem* Create() const; void Clone( SvLBoxItem* pSource ); @@ -1600,12 +1601,13 @@ UnoTreeListItem::~UnoTreeListItem() // -------------------------------------------------------------------- -void UnoTreeListItem::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */, SvTreeListEntry* _pEntry) +void UnoTreeListItem::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/, const SvTreeListEntry* pEntry) { Point aPos( rPos ); - if( _pEntry ) + if (pEntry) { - Size aSize( GetSize(&rDev,_pEntry) ); + Size aSize( GetSize(&rDev, pEntry) ); if( !!maImage ) { rDev.DrawImage( aPos, maImage, rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE ); |