summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 15:49:47 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 22:50:13 -0400
commitcc7bacc506d3613ad45b0443df1151eb92b1f9b4 (patch)
treed442b8a226b12dfa7c86bfc7935ef7c2e38a320f /editeng
parent86647a187371f03a05a329f24366b0ac2e6c7fbf (diff)
template over 3 different types of casts all in one line.
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.hxx7
-rw-r--r--editeng/source/editeng/editdoc2.cxx19
2 files changed, 13 insertions, 13 deletions
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 7f760f396082..9474ee92a002 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -298,8 +298,7 @@ SV_DECL_PTRARR( DummyContentList, ContentNodePtr, 0 )
class ContentList : public DummyContentList
{
- sal_uInt16 nLastCache;
-
+ mutable sal_uInt16 nLastCache;
public:
ContentList();
sal_uInt16 GetPos(ContentNode* p) const;
@@ -631,7 +630,7 @@ SV_DECL_PTRARR( DummyParaPortionList, ParaPortionPtr, 0 )
// -------------------------------------------------------------------------
class ParaPortionList : public DummyParaPortionList
{
- sal_uInt16 nLastCache;
+ mutable sal_uInt16 nLastCache;
public:
ParaPortionList();
~ParaPortionList();
@@ -643,7 +642,7 @@ public:
inline ParaPortion* SaveGetObject( sal_uInt16 nPos ) const
{ return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
- sal_uInt16 GetPos( const ParaPortionPtr &rPtr ) const;
+ sal_uInt16 GetPos(ParaPortion* p) const;
#if OSL_DEBUG_LEVEL > 2
// temporary:
void DbgCheck( EditDoc& rDoc );
diff --git a/editeng/source/editeng/editdoc2.cxx b/editeng/source/editeng/editdoc2.cxx
index 68da6aa6f799..51a22f3e6aa6 100644
--- a/editeng/source/editeng/editdoc2.cxx
+++ b/editeng/source/editeng/editdoc2.cxx
@@ -291,8 +291,11 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormatte
// Shared reverse lookup acceleration pieces ...
-static sal_uInt16 FastGetPos( const VoidPtr *pPtrArray, sal_uInt16 nPtrArrayLen,
- VoidPtr pPtr, sal_uInt16 &rLastPos )
+namespace {
+
+template<typename T>
+sal_uInt16 FastGetPos(
+ T const* pPtrArray, sal_uInt16 nPtrArrayLen, T pPtr, sal_uInt16 &rLastPos)
{
// Through certain filter code-paths we do a lot of appends, which in
// turn call GetPos - creating some N^2 nightmares. If we have a
@@ -321,6 +324,8 @@ static sal_uInt16 FastGetPos( const VoidPtr *pPtrArray, sal_uInt16 nPtrArrayLen,
return USHRT_MAX;
}
+}
+
ParaPortionList::ParaPortionList() : nLastCache( 0 )
{
}
@@ -330,20 +335,16 @@ ParaPortionList::~ParaPortionList()
Reset();
}
-sal_uInt16 ParaPortionList::GetPos( const ParaPortionPtr &rPtr ) const
+sal_uInt16 ParaPortionList::GetPos(ParaPortion* p) const
{
- return FastGetPos( reinterpret_cast<const VoidPtr *>( GetData() ),
- Count(), static_cast<VoidPtr>( rPtr ),
- ((ParaPortionList *)this)->nLastCache );
+ return FastGetPos(GetData(), Count(), p, nLastCache);
}
ContentList::ContentList() : DummyContentList( 0 ), nLastCache(0) {}
sal_uInt16 ContentList::GetPos(ContentNode* p) const
{
- return FastGetPos( reinterpret_cast<const VoidPtr *>( GetData() ),
- Count(), static_cast<VoidPtr>(p),
- ((ContentList *)this)->nLastCache );
+ return FastGetPos(GetData(), Count(), p, nLastCache);
}
void ParaPortionList::Reset()