summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-02-05 18:21:49 +0900
committerMichael Stahl <mstahl@redhat.com>2016-02-08 20:47:26 +0000
commitdea2e507c14df21f0cd45095c5ab8095cac14de2 (patch)
treee04ffcd4689154348af50ab3493e8f0124b9d8db /starmath
parent35fe6dfd2e9ff62a2a8634fc2cfe9e574661b545 (diff)
starmath: Convert RectVerAlign to scoped enum
Change-Id: I6c9a7e1527cf2083f567397eb41db7ae3437c25e Reviewed-on: https://gerrit.libreoffice.org/22141 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/rect.hxx14
-rw-r--r--starmath/source/node.cxx48
-rw-r--r--starmath/source/rect.cxx18
3 files changed, 44 insertions, 36 deletions
diff --git a/starmath/inc/rect.hxx b/starmath/inc/rect.hxx
index 979f22186cdf..172af4a01279 100644
--- a/starmath/inc/rect.hxx
+++ b/starmath/inc/rect.hxx
@@ -67,9 +67,17 @@ enum class RectHorAlign
Center,
Right
};
-enum RectVerAlign
-{ RVA_TOP, RVA_MID, RVA_BOTTOM, RVA_BASELINE, RVA_CENTERY,
- RVA_ATTRIBUT_HI, RVA_ATTRIBUT_MID, RVA_ATTRIBUT_LO
+
+enum class RectVerAlign
+{
+ Top,
+ Mid,
+ Bottom,
+ Baseline,
+ CenterY,
+ AttributeHi,
+ AttributeMid,
+ AttributeLo
};
// different methods of copying baselines and mid's in 'ExtendBy' function
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index ce3bbbdb4bf4..7eb60dcc5aa0 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -711,7 +711,7 @@ void SmTableNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
RectHorAlign eHorAlign = pCoNode->GetRectHorAlign();
aPos = rNodeRect.AlignTo(*this, RectPos::Bottom,
- eHorAlign, RVA_BASELINE);
+ eHorAlign, RectVerAlign::Baseline);
if (i)
aPos.Y() += nDist;
pNode->MoveTo(aPos);
@@ -806,7 +806,7 @@ void SmLineNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
for (i = 1; i < nSize; i++)
if (nullptr != (pNode = GetSubNode(i)))
{
- aPos = pNode->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RVA_BASELINE);
+ aPos = pNode->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
// add horizontal space to the left for each but the first sub node
aPos.X() += nDist;
@@ -849,7 +849,7 @@ void SmUnHorNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
pBody->Arrange(rDev, rFormat);
Point aPos = pOper->AlignTo(*pBody, bIsPostfix ? RectPos::Right : RectPos::Left,
- RectHorAlign::Center, RVA_BASELINE);
+ RectHorAlign::Center, RectVerAlign::Baseline);
// add a bit space between operator and argument
// (worst case -{1 over 2} where - and over have almost no space inbetween)
long nDelta = pOper->GetFont().GetFontSize().Height() / 20;
@@ -934,7 +934,7 @@ void SmRootNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
pRootSym->Arrange(rDev, rFormat);
- Point aPos = pRootSym->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, RVA_BASELINE);
+ Point aPos = pRootSym->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, RectVerAlign::Baseline);
//! override calculated vertical position
aPos.Y() = pRootSym->GetTop() + pBody->GetBottom() - pRootSym->GetBottom();
aPos.Y() -= nVerOffset;
@@ -992,7 +992,7 @@ void SmDynIntegralNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
pDynIntegralSym->Arrange(rDev, rFormat);
- Point aPos = pDynIntegralSym->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, RVA_BASELINE);
+ Point aPos = pDynIntegralSym->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, RectVerAlign::Baseline);
//! override calculated vertical position
aPos.Y() = pDynIntegralSym->GetTop() + pBody->GetBottom() - pDynIntegralSym->GetBottom();
pDynIntegralSym->MoveTo(aPos);
@@ -1049,12 +1049,12 @@ void SmBinHorNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
SmRect::operator = (*pLeft);
Point aPos;
- aPos = pOper->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RVA_BASELINE);
+ aPos = pOper->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.X() += nDist;
pOper->MoveTo(aPos);
ExtendBy(*pOper, RCP_XOR);
- aPos = pRight->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RVA_BASELINE);
+ aPos = pRight->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.X() += nDist;
pRight->MoveTo(aPos);
@@ -1105,7 +1105,7 @@ void SmBinVerNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
RectHorAlign eHorAlign = pLM->GetRectHorAlign();
// move numerator to its position
- Point aPos = pNum->AlignTo(*pLine, RectPos::Top, eHorAlign, RVA_BASELINE);
+ Point aPos = pNum->AlignTo(*pLine, RectPos::Top, eHorAlign, RectVerAlign::Baseline);
aPos.Y() -= nNumDist;
pNum->MoveTo(aPos);
@@ -1114,7 +1114,7 @@ void SmBinVerNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
eHorAlign = pLM->GetRectHorAlign();
// move denominator to its position
- aPos = pDenom->AlignTo(*pLine, RectPos::Bottom, eHorAlign, RVA_BASELINE);
+ aPos = pDenom->AlignTo(*pLine, RectPos::Bottom, eHorAlign, RectVerAlign::Baseline);
aPos.Y() += nDenomDist;
pDenom->MoveTo(aPos);
@@ -1458,7 +1458,7 @@ void SmSubSupNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
* rFormat.GetDistance(DIS_SUBSCRIPT) / 100L;
aPos = pSubSup->GetRect().AlignTo(aTmpRect,
eSubSup == LSUB ? RectPos::Left : RectPos::Right,
- RectHorAlign::Center, RVA_BOTTOM);
+ RectHorAlign::Center, RectVerAlign::Bottom);
aPos.Y() += nDist;
nDelta = nDelimLine - aPos.Y();
if (nDelta > 0)
@@ -1471,7 +1471,7 @@ void SmSubSupNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
* rFormat.GetDistance(DIS_SUPERSCRIPT) / 100L;
aPos = pSubSup->GetRect().AlignTo(aTmpRect,
eSubSup == LSUP ? RectPos::Left : RectPos::Right,
- RectHorAlign::Center, RVA_TOP);
+ RectHorAlign::Center, RectVerAlign::Top);
aPos.Y() -= nDist;
nDelta = aPos.Y() + pSubSup->GetHeight() - nDelimLine;
if (nDelta > 0)
@@ -1482,7 +1482,7 @@ void SmSubSupNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
nDist = nOrigHeight
* rFormat.GetDistance(DIS_LOWERLIMIT) / 100L;
aPos = pSubSup->GetRect().AlignTo(rBodyRect, RectPos::Bottom,
- RectHorAlign::Center, RVA_BASELINE);
+ RectHorAlign::Center, RectVerAlign::Baseline);
aPos.Y() += nDist;
break;
case CSUP :
@@ -1490,7 +1490,7 @@ void SmSubSupNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
nDist = nOrigHeight
* rFormat.GetDistance(DIS_UPPERLIMIT) / 100L;
aPos = pSubSup->GetRect().AlignTo(rBodyRect, RectPos::Top,
- RectHorAlign::Center, RVA_BASELINE);
+ RectHorAlign::Center, RectVerAlign::Baseline);
aPos.Y() -= nDist;
break;
}
@@ -1672,7 +1672,7 @@ void SmBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
pRight->Arrange(rDev, rFormat);
// required in order to make "\(a\) - (a) - left ( a right )" look alright
- RectVerAlign eVerAlign = bScale ? RVA_CENTERY : RVA_BASELINE;
+ RectVerAlign eVerAlign = bScale ? RectVerAlign::CenterY : RectVerAlign::Baseline;
Point aPos;
aPos = pLeft->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, eVerAlign);
@@ -1707,7 +1707,7 @@ void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
for (i = 0; i < nNumSubNodes; i += 2)
{
SmRect aTmpRect (*GetSubNode(i));
- Point aPos = aTmpRect.AlignTo(aRefRect, RectPos::Right, RectHorAlign::Center, RVA_BASELINE);
+ Point aPos = aTmpRect.AlignTo(aRefRect, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
aTmpRect.MoveTo(aPos);
aRefRect.ExtendBy(aTmpRect, RCP_XOR);
}
@@ -1738,7 +1738,7 @@ void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
for (i = 1; i < nNumSubNodes; i++)
{
bool bIsSeparator = i % 2 != 0;
- RectVerAlign eVerAlign = bIsSeparator ? RVA_CENTERY : RVA_BASELINE;
+ RectVerAlign eVerAlign = bIsSeparator ? RectVerAlign::CenterY : RectVerAlign::Baseline;
SmNode *pRight = GetSubNode(i);
Point aPosX = pRight->AlignTo(*pLeft, RectPos::Right, RectHorAlign::Center, eVerAlign),
@@ -1801,11 +1801,11 @@ void SmVerticalBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
nDistBody /= 100L;
nDistScript /= 100L;
- Point aPos = pBrace->AlignTo(*pBody, eRectPos, RectHorAlign::Center, RVA_BASELINE);
+ Point aPos = pBrace->AlignTo(*pBody, eRectPos, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.Y() += nDistBody;
pBrace->MoveTo(aPos);
- aPos = pScript->AlignTo(*pBrace, eRectPos, RectHorAlign::Center, RVA_BASELINE);
+ aPos = pScript->AlignTo(*pBrace, eRectPos, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.Y() += nDistScript;
pScript->MoveTo(aPos);
@@ -1877,7 +1877,7 @@ void SmOperNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
nDist = nOrigHeight
* rFormat.GetDistance(DIS_OPERATORSPACE) / 100L;
- Point aPos = pOper->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, /*RVA_CENTERY*/RVA_MID);
+ Point aPos = pOper->AlignTo(*pBody, RectPos::Left, RectHorAlign::Center, /*RectVerAlign::CenterY*/RectVerAlign::Mid);
aPos.X() -= nDist;
pOper->MoveTo(aPos);
@@ -1934,13 +1934,13 @@ void SmAttributNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
long nDist = 0;
switch (GetToken().eType)
{ case TUNDERLINE :
- eVerAlign = RVA_ATTRIBUT_LO;
+ eVerAlign = RectVerAlign::AttributeLo;
break;
case TOVERSTRIKE :
- eVerAlign = RVA_ATTRIBUT_MID;
+ eVerAlign = RectVerAlign::AttributeMid;
break;
default :
- eVerAlign = RVA_ATTRIBUT_HI;
+ eVerAlign = RectVerAlign::AttributeHi;
if (pBody->GetType() == NATTRIBUT)
nDist = GetFont().GetFontSize().Height()
* rFormat.GetDistance(DIS_ORNAMENTSPACE) / 100L;
@@ -2535,7 +2535,7 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
const SmRect &rNodeRect = pTmpNode->GetRect();
// align all baselines in that row if possible
- aPos = rNodeRect.AlignTo(aLineRect, RectPos::Right, RectHorAlign::Center, RVA_BASELINE);
+ aPos = rNodeRect.AlignTo(aLineRect, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.X() += nHorDist;
// get horizontal alignment
@@ -2565,7 +2565,7 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
aLineRect.ExtendBy(rNodeRect, RCP_XOR);
}
- aPos = aLineRect.AlignTo(*this, RectPos::Bottom, RectHorAlign::Center, RVA_BASELINE);
+ aPos = aLineRect.AlignTo(*this, RectPos::Bottom, RectHorAlign::Center, RectVerAlign::Baseline);
aPos.Y() += nVerDist;
// move 'aLineRect' and rectangles in that line to final position
diff --git a/starmath/source/rect.cxx b/starmath/source/rect.cxx
index ce9232bbf477..2dd06841639f 100644
--- a/starmath/source/rect.cxx
+++ b/starmath/source/rect.cxx
@@ -334,37 +334,37 @@ const Point SmRect::AlignTo(const SmRect &rRect, RectPos ePos,
if (ePos == RectPos::Left || ePos == RectPos::Right || ePos == RectPos::Attribute)
// correct error in current vertical position
switch (eVer)
- { case RVA_TOP :
+ { case RectVerAlign::Top :
aPos.Y() += rRect.GetAlignT() - GetAlignT();
break;
- case RVA_MID :
+ case RectVerAlign::Mid :
aPos.Y() += rRect.GetAlignM() - GetAlignM();
break;
- case RVA_BASELINE :
+ case RectVerAlign::Baseline :
// align baselines if possible else align mid's
if (HasBaseline() && rRect.HasBaseline())
aPos.Y() += rRect.GetBaseline() - GetBaseline();
else
aPos.Y() += rRect.GetAlignM() - GetAlignM();
break;
- case RVA_BOTTOM :
+ case RectVerAlign::Bottom :
aPos.Y() += rRect.GetAlignB() - GetAlignB();
break;
- case RVA_CENTERY :
+ case RectVerAlign::CenterY :
aPos.Y() += rRect.GetCenterY() - GetCenterY();
break;
- case RVA_ATTRIBUT_HI:
+ case RectVerAlign::AttributeHi:
aPos.Y() += rRect.GetHiAttrFence() - GetBottom();
break;
- case RVA_ATTRIBUT_MID :
+ case RectVerAlign::AttributeMid :
aPos.Y() += SmFromTo(rRect.GetAlignB(), rRect.GetAlignT(), 0.4)
- GetCenterY();
break;
- case RVA_ATTRIBUT_LO :
+ case RectVerAlign::AttributeLo :
aPos.Y() += rRect.GetLoAttrFence() - GetTop();
break;
default :
- SAL_WARN("starmath", "unknown case");
+ assert(false);
}
// check if vertical position is already set