summaryrefslogtreecommitdiffstats
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-04-12 13:22:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-12 14:55:42 +0200
commitf6a1859704bf7f29d6cb55e37ac82affba9da1e5 (patch)
treebaab8996efd790e1f1e862b3ab841bb0609560c4 /editeng
parenttdf#105272: Add unittest (diff)
downloadcore-f6a1859704bf7f29d6cb55e37ac82affba9da1e5.tar.gz
core-f6a1859704bf7f29d6cb55e37ac82affba9da1e5.zip
small cleanups in TextRanger
- no need for mpPolyPolygon to be allocated out of line. - expand out LongDqPtr typedef, not much longer and makes the code easier to read - allocate mpBound inline using std::optional - rename RangeCache to RangeCacheItem Change-Id: I55032a31eaefa844059edb5f0ee599f1b813ac80 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92079 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit3.cxx2
-rw-r--r--editeng/source/misc/txtrange.cxx28
2 files changed, 15 insertions, 15 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 05ab3ccf6823..b9a33ceec64d 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -809,7 +809,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
long nTmpWidth = 0;
long nXWidth = nMaxLineWidth;
- LongDqPtr pTextRanges = nullptr;
+ std::deque<long>* pTextRanges = nullptr;
long nTextExtraYOffset = 0;
long nTextXOffset = 0;
long nTextLineHeight = 0;
diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index cc4417498721..42d674c42780 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -31,6 +31,7 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
const basegfx::B2DPolyPolygon* pLinePolyPolygon,
sal_uInt16 nCacheSz, sal_uInt16 nLft, sal_uInt16 nRght,
bool bSimpl, bool bInnr, bool bVert ) :
+ maPolyPolygon( rPolyPolygon.count() ),
nCacheSize( nCacheSz ),
nRight( nRght ),
nLeft( nLft ),
@@ -42,13 +43,12 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
bVertical( bVert )
{
sal_uInt32 nCount(rPolyPolygon.count());
- mpPolyPolygon.reset( new tools::PolyPolygon( static_cast<sal_uInt16>(nCount) ) );
for(sal_uInt32 i(0); i < nCount; i++)
{
const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(i).getDefaultAdaptiveSubdivision());
nPointCount += aCandidate.count();
- mpPolyPolygon->Insert( tools::Polygon(aCandidate), static_cast<sal_uInt16>(i) );
+ maPolyPolygon.Insert( tools::Polygon(aCandidate), static_cast<sal_uInt16>(i) );
}
if( pLinePolyPolygon )
@@ -93,7 +93,7 @@ namespace {
class SvxBoundArgs
{
std::vector<bool> aBoolArr;
- LongDqPtr pLongArr;
+ std::deque<long>* pLongArr;
TextRanger *pTextRanger;
long nMin;
long nMax;
@@ -126,7 +126,7 @@ class SvxBoundArgs
long A( const Point& rP ) const { return bRotate ? rP.Y() : rP.X(); }
long B( const Point& rP ) const { return bRotate ? rP.X() : rP.Y(); }
public:
- SvxBoundArgs( TextRanger* pRanger, LongDqPtr pLong, const Range& rRange );
+ SvxBoundArgs( TextRanger* pRanger, std::deque<long>* pLong, const Range& rRange );
void NotePoint( const long nA ) { NoteMargin( nA - nStart, nA + nEnd ); }
void NoteMargin( const long nL, const long nR )
{ if( nMin > nL ) nMin = nL; if( nMax < nR ) nMax = nR; }
@@ -142,7 +142,7 @@ public:
}
-SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, LongDqPtr pLong,
+SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, std::deque<long>* pLong,
const Range& rRange )
: pLongArr(pLong)
, pTextRanger(pRanger)
@@ -489,7 +489,7 @@ void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
{
SetConcat( true );
DBG_ASSERT( pPoly, "Nothing to do?" );
- LongDqPtr pOld = pLongArr;
+ std::deque<long>* pOld = pLongArr;
pLongArr = new std::deque<long>;
aBoolArr.clear();
bInner = false;
@@ -631,7 +631,7 @@ void SvxBoundArgs::NoteUpLow( long nA, const sal_uInt8 nArea )
}
}
-LongDqPtr TextRanger::GetTextRanges( const Range& rRange )
+std::deque<long>* TextRanger::GetTextRanges( const Range& rRange )
{
DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" );
//Can we find the result we need in the cache?
@@ -641,23 +641,23 @@ LongDqPtr TextRanger::GetTextRanges( const Range& rRange )
return &(elem.results);
}
//Calculate a new result
- RangeCache rngCache(rRange);
+ RangeCacheItem rngCache(rRange);
SvxBoundArgs aArg( this, &(rngCache.results), rRange );
- aArg.Calc( *mpPolyPolygon );
+ aArg.Calc( maPolyPolygon );
if( mpLinePolyPolygon )
aArg.Concat( mpLinePolyPolygon.get() );
//Add new result to the cache
- mRangeCache.push_back(rngCache);
+ mRangeCache.push_back(std::move(rngCache));
if (mRangeCache.size() > nCacheSize)
mRangeCache.pop_front();
return &(mRangeCache.back().results);
}
-const tools::Rectangle& TextRanger::GetBoundRect_()
+const tools::Rectangle& TextRanger::GetBoundRect_() const
{
- DBG_ASSERT( nullptr == pBound, "Don't call twice." );
- pBound.reset( new tools::Rectangle( mpPolyPolygon->GetBoundRect() ) );
- return *pBound;
+ DBG_ASSERT( !mxBound, "Don't call twice." );
+ mxBound = maPolyPolygon.GetBoundRect();
+ return *mxBound;
}