editeng: prefix EditLine members, clean-up
Change-Id: Ie8c8ee86f139854137ba95875f51ddaf64cc5848 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165336 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
7b9905df45
commit
7f4d31f2d6
@@ -31,105 +31,107 @@ public:
|
|||||||
typedef std::vector<sal_Int32> CharPosArrayType;
|
typedef std::vector<sal_Int32> CharPosArrayType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CharPosArrayType aPositions;
|
CharPosArrayType maPositions;
|
||||||
std::vector<sal_Bool> aKashidaPositions;
|
std::vector<sal_Bool> maKashidaPositions;
|
||||||
sal_Int32 nTxtWidth = 0;
|
sal_Int32 mnTextWidth = 0;
|
||||||
sal_Int32 nStartPosX = 0;
|
sal_Int32 mnStartPosX = 0;
|
||||||
sal_Int32 nNextLinePosXDiff = 0;
|
sal_Int32 mnNextLinePosXDiff = 0;
|
||||||
sal_Int32 nStart = 0; // could be replaced by nStartPortion
|
sal_Int32 mnStart = 0; // could be replaced by nStartPortion
|
||||||
sal_Int32 nEnd = 0; // could be replaced by nEndPortion
|
sal_Int32 mnEnd = 0; // could be replaced by nEndPortion
|
||||||
sal_Int32 nStartPortion = 0;
|
sal_Int32 mnStartPortion = 0;
|
||||||
sal_Int32 nEndPortion = 0;
|
sal_Int32 mnEndPortion = 0;
|
||||||
sal_uInt16 nHeight = 0; // Total height of the line
|
sal_uInt16 mnHeight = 0; // Total height of the line
|
||||||
sal_uInt16 nTxtHeight = 0; // Pure Text height
|
sal_uInt16 mnTextHeight = 0; // Pure Text height
|
||||||
sal_uInt16 nMaxAscent = 0;
|
sal_uInt16 mnMaxAscent = 0;
|
||||||
bool bHangingPunctuation : 1 = false;
|
bool mbHangingPunctuation : 1 = false;
|
||||||
bool bInvalid : 1 = true; // for skillful formatting
|
bool mbInvalid : 1 = true; // for skillful formatting
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditLine() = default;
|
EditLine() = default;
|
||||||
EditLine(const EditLine& rEditLine)
|
EditLine(const EditLine& rEditLine)
|
||||||
: nStart(rEditLine.nStart)
|
: mnStart(rEditLine.mnStart)
|
||||||
, nEnd(rEditLine.nEnd)
|
, mnEnd(rEditLine.mnEnd)
|
||||||
, nStartPortion(rEditLine.nStartPortion)
|
, mnStartPortion(rEditLine.mnStartPortion)
|
||||||
, nEndPortion(rEditLine.nEndPortion)
|
, mnEndPortion(rEditLine.mnEndPortion)
|
||||||
, bHangingPunctuation(rEditLine.bHangingPunctuation)
|
, mbHangingPunctuation(rEditLine.mbHangingPunctuation)
|
||||||
, bInvalid(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex < nEnd)); }
|
bool IsIn(sal_Int32 nIndex) const { return nIndex >= mnStart && nIndex < mnEnd; }
|
||||||
|
|
||||||
bool IsIn(sal_Int32 nIndex, bool bInclEnd) const
|
bool IsIn(sal_Int32 nIndex, bool bIncludeEnd) const
|
||||||
{
|
{
|
||||||
return ((nIndex >= nStart) && (bInclEnd ? (nIndex <= nEnd) : (nIndex < nEnd)));
|
return nIndex >= mnStart && (bIncludeEnd ? nIndex <= mnEnd : nIndex < mnEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStart(sal_Int32 n) { nStart = n; }
|
void SetStart(sal_Int32 nStart) { mnStart = nStart; }
|
||||||
sal_Int32 GetStart() const { return nStart; }
|
sal_Int32 GetStart() const { return mnStart; }
|
||||||
sal_Int32& GetStart() { return nStart; }
|
sal_Int32& GetStart() { return mnStart; }
|
||||||
|
|
||||||
void SetEnd(sal_Int32 n) { nEnd = n; }
|
void SetEnd(sal_Int32 nEnd) { mnEnd = nEnd; }
|
||||||
sal_Int32 GetEnd() const { return nEnd; }
|
sal_Int32 GetEnd() const { return mnEnd; }
|
||||||
sal_Int32& GetEnd() { return nEnd; }
|
sal_Int32& GetEnd() { return mnEnd; }
|
||||||
|
|
||||||
void SetStartPortion(sal_Int32 n) { nStartPortion = n; }
|
void SetStartPortion(sal_Int32 nStartPortion) { mnStartPortion = nStartPortion; }
|
||||||
sal_Int32 GetStartPortion() const { return nStartPortion; }
|
sal_Int32 GetStartPortion() const { return mnStartPortion; }
|
||||||
sal_Int32& GetStartPortion() { return nStartPortion; }
|
sal_Int32& GetStartPortion() { return mnStartPortion; }
|
||||||
|
|
||||||
void SetEndPortion(sal_Int32 n) { nEndPortion = n; }
|
void SetEndPortion(sal_Int32 nEndPortion) { mnEndPortion = nEndPortion; }
|
||||||
sal_Int32 GetEndPortion() const { return nEndPortion; }
|
sal_Int32 GetEndPortion() const { return mnEndPortion; }
|
||||||
sal_Int32& GetEndPortion() { return nEndPortion; }
|
sal_Int32& GetEndPortion() { return mnEndPortion; }
|
||||||
|
|
||||||
void SetHeight(sal_uInt16 nH, sal_uInt16 nTxtH = 0);
|
void SetHeight(sal_uInt16 nHeight, sal_uInt16 nTextHeight = 0);
|
||||||
sal_uInt16 GetHeight() const { return nHeight; }
|
sal_uInt16 GetHeight() const { return mnHeight; }
|
||||||
sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
|
sal_uInt16 GetTxtHeight() const { return mnTextHeight; }
|
||||||
|
|
||||||
void SetTextWidth(sal_Int32 n) { nTxtWidth = n; }
|
void SetTextWidth(sal_Int32 nTextWidth) { mnTextWidth = nTextWidth; }
|
||||||
sal_Int32 GetTextWidth() const { return nTxtWidth; }
|
sal_Int32 GetTextWidth() const { return mnTextWidth; }
|
||||||
|
|
||||||
void SetMaxAscent(sal_uInt16 n) { nMaxAscent = n; }
|
void SetMaxAscent(sal_uInt16 nMaxAscent) { mnMaxAscent = nMaxAscent; }
|
||||||
sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
|
sal_uInt16 GetMaxAscent() const { return mnMaxAscent; }
|
||||||
|
|
||||||
void SetHangingPunctuation(bool b) { bHangingPunctuation = b; }
|
void SetHangingPunctuation(bool bHangingPunctuation)
|
||||||
bool IsHangingPunctuation() const { return bHangingPunctuation; }
|
{
|
||||||
|
mbHangingPunctuation = bHangingPunctuation;
|
||||||
|
}
|
||||||
|
bool IsHangingPunctuation() const { return mbHangingPunctuation; }
|
||||||
|
|
||||||
sal_Int32 GetLen() const { return nEnd - nStart; }
|
sal_Int32 GetLen() const { return mnEnd - mnStart; }
|
||||||
|
|
||||||
sal_Int32 GetStartPosX() const { return nStartPosX; }
|
sal_Int32 GetStartPosX() const { return mnStartPosX; }
|
||||||
void SetStartPosX(sal_Int32 start);
|
void SetStartPosX(sal_Int32 nStart);
|
||||||
sal_Int32 GetNextLinePosXDiff() const { return nNextLinePosXDiff; }
|
sal_Int32 GetNextLinePosXDiff() const { return mnNextLinePosXDiff; }
|
||||||
void SetNextLinePosXDiff(sal_Int32 diff) { nNextLinePosXDiff = diff; }
|
void SetNextLinePosXDiff(sal_Int32 nDiff) { mnNextLinePosXDiff = nDiff; }
|
||||||
Size CalcTextSize(ParaPortion& rParaPortion);
|
Size CalcTextSize(ParaPortion& rParaPortion);
|
||||||
|
|
||||||
bool IsInvalid() const { return bInvalid; }
|
bool IsInvalid() const { return mbInvalid; }
|
||||||
bool IsValid() const { return !bInvalid; }
|
bool IsValid() const { return !mbInvalid; }
|
||||||
void SetInvalid() { bInvalid = true; }
|
void SetInvalid() { mbInvalid = true; }
|
||||||
void SetValid() { bInvalid = false; }
|
void SetValid() { mbInvalid = false; }
|
||||||
|
|
||||||
bool IsEmpty() const { return nEnd <= nStart; }
|
bool IsEmpty() const { return mnEnd <= mnStart; }
|
||||||
|
|
||||||
CharPosArrayType& GetCharPosArray() { return aPositions; }
|
CharPosArrayType& GetCharPosArray() { return maPositions; }
|
||||||
const CharPosArrayType& GetCharPosArray() const { return aPositions; }
|
const CharPosArrayType& GetCharPosArray() const { return maPositions; }
|
||||||
|
|
||||||
std::vector<sal_Bool>& GetKashidaArray() { return aKashidaPositions; }
|
std::vector<sal_Bool>& GetKashidaArray() { return maKashidaPositions; }
|
||||||
const std::vector<sal_Bool>& GetKashidaArray() const { return aKashidaPositions; }
|
const std::vector<sal_Bool>& GetKashidaArray() const { return maKashidaPositions; }
|
||||||
|
|
||||||
EditLine* Clone() const;
|
EditLine* Clone() const;
|
||||||
|
|
||||||
EditLine& operator=(const EditLine& rLine)
|
EditLine& operator=(const EditLine& rLine)
|
||||||
{
|
{
|
||||||
nEnd = rLine.nEnd;
|
mnEnd = rLine.mnEnd;
|
||||||
nStart = rLine.nStart;
|
mnStart = rLine.mnStart;
|
||||||
nEndPortion = rLine.nEndPortion;
|
mnEndPortion = rLine.mnEndPortion;
|
||||||
nStartPortion = rLine.nStartPortion;
|
mnStartPortion = rLine.mnStartPortion;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const EditLine& rLine) const
|
bool operator==(const EditLine& rLine) const
|
||||||
{
|
{
|
||||||
return nStart == rLine.nStart && nEnd == rLine.nEnd && nStartPortion == rLine.nStartPortion
|
return mnStart == rLine.mnStart && mnEnd == rLine.mnEnd
|
||||||
&& nEndPortion == rLine.nEndPortion;
|
&& mnStartPortion == rLine.mnStartPortion && mnEndPortion == rLine.mnEndPortion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -20,72 +20,77 @@
|
|||||||
|
|
||||||
#include <EditLine.hxx>
|
#include <EditLine.hxx>
|
||||||
#include <editdoc.hxx>
|
#include <editdoc.hxx>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
EditLine* EditLine::Clone() const
|
EditLine* EditLine::Clone() const
|
||||||
{
|
{
|
||||||
EditLine* pL = new EditLine;
|
EditLine* pLine = new EditLine;
|
||||||
pL->aPositions = aPositions;
|
pLine->maPositions = maPositions;
|
||||||
pL->nStartPosX = nStartPosX;
|
pLine->mnStartPosX = mnStartPosX;
|
||||||
pL->nNextLinePosXDiff = nNextLinePosXDiff;
|
pLine->mnNextLinePosXDiff = mnNextLinePosXDiff;
|
||||||
pL->nStart = nStart;
|
pLine->mnStart = mnStart;
|
||||||
pL->nEnd = nEnd;
|
pLine->mnEnd = mnEnd;
|
||||||
pL->nStartPortion = nStartPortion;
|
pLine->mnStartPortion = mnStartPortion;
|
||||||
pL->nEndPortion = nEndPortion;
|
pLine->mnEndPortion = mnEndPortion;
|
||||||
pL->nHeight = nHeight;
|
pLine->mnHeight = mnHeight;
|
||||||
pL->nTxtWidth = nTxtWidth;
|
pLine->mnTextWidth = mnTextWidth;
|
||||||
pL->nTxtHeight = nTxtHeight;
|
pLine->mnTextHeight = mnTextHeight;
|
||||||
pL->nMaxAscent = nMaxAscent;
|
pLine->mnMaxAscent = mnMaxAscent;
|
||||||
|
|
||||||
return pL;
|
return pLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size EditLine::CalcTextSize(ParaPortion& rParaPortion)
|
Size EditLine::CalcTextSize(ParaPortion& rParaPortion)
|
||||||
{
|
{
|
||||||
Size aSz;
|
Size aSize;
|
||||||
Size aTmpSz;
|
|
||||||
|
|
||||||
DBG_ASSERT(rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !");
|
DBG_ASSERT(rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !");
|
||||||
|
|
||||||
for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ )
|
for (sal_Int32 nPosition = mnStartPortion; nPosition <= mnEndPortion; nPosition++)
|
||||||
{
|
{
|
||||||
TextPortion& rPortion = rParaPortion.GetTextPortions()[n];
|
TextPortion& rPortion = rParaPortion.GetTextPortions()[nPosition];
|
||||||
switch (rPortion.GetKind())
|
switch (rPortion.GetKind())
|
||||||
{
|
{
|
||||||
case PortionKind::TEXT:
|
case PortionKind::TEXT:
|
||||||
case PortionKind::FIELD:
|
case PortionKind::FIELD:
|
||||||
case PortionKind::HYPHENATOR:
|
case PortionKind::HYPHENATOR:
|
||||||
{
|
{
|
||||||
aTmpSz = rPortion.GetSize();
|
Size aTmpSize = rPortion.GetSize();
|
||||||
aSz.AdjustWidth(aTmpSz.Width() );
|
aSize.AdjustWidth(aTmpSize.Width());
|
||||||
if ( aSz.Height() < aTmpSz.Height() )
|
if (aSize.Height() < aTmpSize.Height() )
|
||||||
aSz.setHeight( aTmpSz.Height() );
|
aSize.setHeight( aTmpSize.Height() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PortionKind::TAB:
|
case PortionKind::TAB:
|
||||||
{
|
{
|
||||||
aSz.AdjustWidth(rPortion.GetSize().Width() );
|
aSize.AdjustWidth(rPortion.GetSize().Width());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PortionKind::LINEBREAK: break;
|
case PortionKind::LINEBREAK:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHeight( static_cast<sal_uInt16>(aSz.Height()) );
|
SetHeight(sal_uInt16(aSize.Height()));
|
||||||
return aSz;
|
return aSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditLine::SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH )
|
void EditLine::SetHeight(sal_uInt16 nHeight, sal_uInt16 nTextHeight)
|
||||||
{
|
{
|
||||||
nHeight = nH;
|
mnHeight = nHeight;
|
||||||
nTxtHeight = ( nTxtH ? nTxtH : nH );
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditLine::SetStartPosX( sal_Int32 start )
|
if (nTextHeight != 0)
|
||||||
{
|
mnTextHeight = nTextHeight;
|
||||||
if (start > 0)
|
|
||||||
nStartPosX = start;
|
|
||||||
else
|
else
|
||||||
nStartPosX = 0;
|
mnTextHeight = nHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditLine::SetStartPosX(sal_Int32 nStart)
|
||||||
|
{
|
||||||
|
if (nStart > 0)
|
||||||
|
mnStartPosX = nStart;
|
||||||
|
else
|
||||||
|
mnStartPosX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user