summaryrefslogtreecommitdiff
path: root/vcl/source/edit
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2015-08-13 19:03:15 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2015-08-16 09:10:18 +0200
commit800b0241c213b42dada56ca41a6f9e02eb541a23 (patch)
tree4b3b8b704e3da483fac7d6c32cac2366ae29fa91 /vcl/source/edit
parent259784c15181acedce0ed0abb52c7afb675a6ea9 (diff)
sal_uInt16/short to sal_uInt16, minor optimizations
Change-Id: If52de6e7fbfef92ab53086c6dcc405dad6cffe2d
Diffstat (limited to 'vcl/source/edit')
-rw-r--r--vcl/source/edit/textdat2.hxx8
-rw-r--r--vcl/source/edit/textdata.cxx6
-rw-r--r--vcl/source/edit/texteng.cxx28
-rw-r--r--vcl/source/edit/textview.cxx2
4 files changed, 21 insertions, 23 deletions
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx
index 47b973105246..6e57f9005d7e 100644
--- a/vcl/source/edit/textdat2.hxx
+++ b/vcl/source/edit/textdat2.hxx
@@ -47,7 +47,7 @@ class TextView;
class TETextPortion
{
private:
- sal_uInt16 nLen;
+ sal_Int32 nLen;
long nWidth;
sal_uInt8 nKind;
bool bRightToLeft;
@@ -60,14 +60,14 @@ private:
{}
public:
- TETextPortion( sal_uInt16 nL )
+ TETextPortion( sal_Int32 nL )
: nLen {nL}
, nWidth {-1}
, nKind {PORTIONKIND_TEXT}
, bRightToLeft {false}
{}
- sal_uInt16& GetLen() { return nLen; }
+ sal_Int32& GetLen() { return nLen; }
long& GetWidth() { return nWidth; }
sal_uInt8& GetKind() { return nKind; }
void SetRightToLeft(bool b) { bRightToLeft = b; }
@@ -82,7 +82,7 @@ public:
~TETextPortionList();
void Reset();
- sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false );
+ sal_uInt16 FindPortion( sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false );
void DeleteFromPortion( sal_uInt16 nDelFrom );
};
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index 6e24de93ee23..fe95af59c754 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -70,14 +70,14 @@ void TETextPortionList::DeleteFromPortion( sal_uInt16 nDelFrom )
erase( begin() + nDelFrom, end() );
}
-sal_uInt16 TETextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPortionStart, bool bPreferStartingPortion )
+sal_uInt16 TETextPortionList::FindPortion( sal_Int32 nCharPos, sal_Int32& nPortionStart, bool bPreferStartingPortion )
{
// find left portion at nCharPos at portion border
- sal_uInt16 nTmpPos = 0;
+ sal_Int32 nTmpPos = 0;
for ( size_t nPortion = 0; nPortion < size(); nPortion++ )
{
TETextPortion* pPortion = operator[]( nPortion );
- nTmpPos = nTmpPos + pPortion->GetLen();
+ nTmpPos += pPortion->GetLen();
if ( nTmpPos >= nCharPos )
{
// take this one if we don't prefer the starting portion, or if it's the last one
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 27ca96d1b7d1..bedcb58d4356 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -942,7 +942,7 @@ long TextEngine::ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_Int32 nIndex,
TEParaPortion* pParaPortion = mpTEParaPortions->GetObject( nPara );
- sal_uInt16 nTextPortionStart = 0;
+ sal_Int32 nTextPortionStart = 0;
size_t nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
DBG_ASSERT( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line!" );
@@ -1136,7 +1136,7 @@ sal_Int32 TextEngine::GetCharPos( sal_uLong nPortion, sal_uInt16 nLine, long nXP
}
return nCurIndex;
}
- nCurIndex = nCurIndex + pTextPortion->GetLen();
+ nCurIndex += pTextPortion->GetLen();
}
return nCurIndex;
}
@@ -1730,7 +1730,7 @@ sal_uInt16 TextEngine::SplitTextPortion( sal_uLong nPara, sal_Int32 nPos )
DBG_ASSERT( pTextPortion, "SplitTextPortion: position outside of region!" );
const sal_Int32 nOverlapp = nTmpPos - nPos;
- pTextPortion->GetLen() = pTextPortion->GetLen() - nOverlapp;
+ pTextPortion->GetLen() -= nOverlapp;
TETextPortion* pNewPortion = new TETextPortion( nOverlapp );
pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nSplitPortion + 1, pNewPortion );
pTextPortion->GetWidth() = (long)CalcTextWidth( nPara, nPos-pTextPortion->GetLen(), pTextPortion->GetLen() );
@@ -1809,7 +1809,7 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_Int32 nStartPos )
// But only if it was within the Portion; otherwise it might be
// the only one in the previous line!
nInvPortion--;
- nPortionStart = nPortionStart - pTEParaPortion->GetTextPortions()[nInvPortion]->GetLen();
+ nPortionStart -= pTEParaPortion->GetTextPortions()[nInvPortion]->GetLen();
}
pTEParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
@@ -1831,7 +1831,7 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_Int32 nStartPos )
OSL_ENSURE(pTEParaPortion->GetTextPortions().size(), "CreateTextPortions: No Portions?!");
}
-void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, short nNewChars )
+void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, sal_Int32 nNewChars )
{
TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara );
OSL_ENSURE(pTEParaPortion->GetTextPortions().size(), "RecalcTextPortion: no Portions!");
@@ -1858,9 +1858,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, short
!pTEParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
{
// use the empty Portion
- sal_uInt16 & r =
- pTEParaPortion->GetTextPortions()[nNewPortionPos]->GetLen();
- r = r + nNewChars;
+ pTEParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() = nNewChars;
}
else
{
@@ -1870,11 +1868,11 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, short
}
else
{
- sal_uInt16 nPortionStart;
+ sal_Int32 nPortionStart {0};
const sal_uInt16 nTP = pTEParaPortion->GetTextPortions().FindPortion( nStartPos, nPortionStart );
TETextPortion* const pTP = pTEParaPortion->GetTextPortions()[ nTP ];
DBG_ASSERT( pTP, "RecalcTextPortion: Portion not found!" );
- pTP->GetLen() = pTP->GetLen() + nNewChars;
+ pTP->GetLen() += nNewChars;
pTP->GetWidth() = (-1);
}
}
@@ -1899,7 +1897,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, short
DBG_ASSERT( nPos+pTP->GetLen() >= nEnd, "RecalcTextPortion: Bad End!" );
break;
}
- nPos = nPos + pTP->GetLen();
+ nPos += pTP->GetLen();
}
DBG_ASSERT( pTP, "RecalcTextPortion: Portion not found!" );
if ( ( nPos == nStartPos ) && ( (nPos+pTP->GetLen()) == nEnd ) )
@@ -1911,7 +1909,7 @@ void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_Int32 nStartPos, short
else
{
DBG_ASSERT( pTP->GetLen() > (-nNewChars), "RecalcTextPortion: Portion too small to shrink!" );
- pTP->GetLen() = pTP->GetLen() + nNewChars;
+ pTP->GetLen() += nNewChars;
}
OSL_ENSURE( pTEParaPortion->GetTextPortions().size(),
"RecalcTextPortion: none are left!" );
@@ -2102,7 +2100,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan
}
}
- nIndex = nIndex + pTextPortion->GetLen();
+ nIndex += pTextPortion->GetLen();
}
}
@@ -2171,7 +2169,7 @@ bool TextEngine::CreateLines( sal_uLong nPara )
for ( const auto pTP : pTEParaPortion->GetTextPortions() )
{
// there must be no Start/End in the deleted region
- nPos = nPos + pTP->GetLen();
+ nPos += pTP->GetLen();
if ( nPos > nInvalidStart && nPos < nInvalidEnd )
{
bQuickFormat = false;
@@ -3059,7 +3057,7 @@ long TextEngine::ImpGetOutputOffset( sal_uLong nPara, TextLine* pLine, sal_Int32
{
TEParaPortion* pPortion = mpTEParaPortions->GetObject( nPara );
- sal_uInt16 nPortionStart;
+ sal_Int32 nPortionStart {0};
sal_uInt16 nPortion = pPortion->GetTextPortions().FindPortion( nIndex, nPortionStart, true );
TETextPortion* pTextPortion = pPortion->GetTextPortions()[ nPortion ];
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index a218141966e8..fb28c7d2a8e8 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -1702,7 +1702,7 @@ void TextView::ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bSpec
TEParaPortion* pParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
- sal_uInt16 nTextPortionStart = 0;
+ sal_Int32 nTextPortionStart = 0;
sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
TETextPortion* pTextPortion = pParaPortion->GetTextPortions()[ nTextPortion ];
if ( pTextPortion->GetKind() == PORTIONKIND_TAB )