29#include <osl/diagnose.h>
35void ForEachNonNull(
SmNode *pNode, F && f)
38 for (
size_t i = 0;
i < nSize; ++
i)
41 if (pSubNode !=
nullptr)
49 : maNodeToken(
std::move( aNodeToken ))
55 , mbIsPhantom( false )
58 , mpParentNode( nullptr )
93 ForEachNonNull(
this, [&rColor](
SmNode *pNode){pNode->
SetColor(rColor);});
129 ForEachNonNull(
this, [&rFace](
SmNode *pNode){pNode->
SetFont(rFace);});
173 if (aFntSize.
Height() > nMaxVal)
187 ForEachNonNull(
this, [&rSize](
SmNode *pNode){pNode->
SetSize(rSize);});
210 throw std::range_error(
"parser depth limit");
223 OSL_ENSURE(
GetFont().GetCharSet() == RTL_TEXTENCODING_UNICODE,
224 "unexpected CharSet" );
228 ForEachNonNull(
this, [&rFormat, &rDocShell, nDepth](
SmNode *pNode){pNode->
Prepare(rFormat, rDocShell, nDepth + 1);});
233 if (rVector.
X() == 0 && rVector.
Y() == 0)
238 ForEachNonNull(
this, [&rVector](
SmNode *pNode){pNode->
Move(rVector);});
262 size_t nNumSubNodes = GetNumSubNodes();
263 for (
size_t i = 0;
i < nNumSubNodes; ++
i)
265 const SmNode *pNode = GetSubNode(
i);
283 const SmNode *pResult =
nullptr;
290 for (
size_t i = 0;
i < nNumSubNodes; ++
i)
324 const SmNode *pResult =
nullptr;
332 && nIdx <= nAccIdx && nAccIdx < nIdx + aTxt.getLength())
337 for (
size_t i = 0;
i < nNumSubNodes; ++
i)
355 ForEachNonNull(
this, std::default_delete<SmNode>());
366 size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0));
380 size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0));
396 size_t nSize = pSecond ? 3 : (pThird ? 2 : (pFirst ? 1 : 0));
407 size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0));
471 for (
size_t i = 0;
i < nSize;
i++)
529 for (
size_t i = 0;
i < nSize; ++
i)
532 { pNode->
Arrange(rDev, rFormat);
539 SmRect::operator = (
SmRect(nMaxWidth, 1));
540 for (
size_t i = 0;
i < nSize; ++
i)
605 for (
size_t i = 0;
i < nSize; ++
i)
622 SmRect::operator = (
SmRect(aTmpDev, &rFormat,
"a",
638 SmRect::operator = (pNode->
GetRect());
640 for (
size_t i = 1;
i < nSize; ++
i)
680 SmNode *pOper = bIsPostfix ? pNode1 : pNode0,
681 *pBody = bIsPostfix ? pNode0 : pNode1;
687 pBody->Arrange(rDev, rFormat);
691 SmRect::operator = (*pNode0);
695 pNode1->MoveTo(aPos);
704void lcl_GetHeightVerOffset(
const SmRect &rRect,
709 rHeight = rRect.
GetHeight() - rVerOffset;
711 OSL_ENSURE(rHeight >= 0,
"Sm : Ooops...");
712 OSL_ENSURE(rVerOffset >= 0,
"Sm : Ooops...");
723 (rSymSize.
Height() * 52) / 100);
752 pBody->Arrange(rDev, rFormat);
756 lcl_GetHeightVerOffset(*pBody, nHeight, nVerOffset);
762 SAL_WARN(
"starmath",
"negative height");
767 pRootSym->AdaptToY(rDev, nHeight);
768 pRootSym->AdaptToX(rDev, pBody->GetItalicWidth());
770 pRootSym->Arrange(rDev, rFormat);
774 aPos.
setY( pRootSym->GetTop() + pBody->GetBottom() - pRootSym->GetBottom() );
776 pRootSym->MoveTo(aPos);
780 pExtra->
Arrange(rDev, rFormat);
782 aPos = lcl_GetExtraPos(*pRootSym, *pExtra);
786 SmRect::operator = (*pBody);
806 pLeft ->
Arrange(rDev, rFormat);
807 pOper ->Arrange(rDev, rFormat);
808 pRight->Arrange(rDev, rFormat);
810 const SmRect &rOpRect = pOper->GetRect();
815 SAL_WARN(
"starmath",
"integer overflow");
821 SmRect::operator = (*pLeft);
832 pRight->MoveTo(aPos);
854 pLine ->SetSize(aFraction);
855 pDenom->SetSize(aFraction);
859 pDenom->Arrange(rDev, rFormat);
864 nWidth = std::max(pNum->
GetItalicWidth(), pDenom->GetItalicWidth()),
865 nNumDist = bIsTextmode ? 0 :
867 nDenomDist = bIsTextmode ? 0 :
871 pLine->AdaptToY(rDev, nThick);
872 pLine->AdaptToX(rDev, nWidth + 2 * nExtLen);
873 pLine->Arrange(rDev, rFormat);
891 pDenom->MoveTo(aPos);
893 SmRect::operator = (*pNum);
906double Det(
const Point &rHeading1,
const Point &rHeading2)
908 return rHeading1.
X() * rHeading2.
Y() - rHeading1.
Y() * rHeading2.
X();
914bool IsPointInLine(
const Point &rPoint1,
917 assert(rHeading2 !=
Point());
923 if (std::abs(rHeading2.
X()) > std::abs(rHeading2.
Y()))
925 fLambda = (rPoint1.
X() - rPoint2.
X()) /
static_cast<double>(rHeading2.
X());
926 bRes = fabs(rPoint1.
Y() - (rPoint2.
Y() + fLambda * rHeading2.
Y())) < eps;
930 fLambda = (rPoint1.
Y() - rPoint2.
Y()) /
static_cast<double>(rHeading2.
Y());
931 bRes = fabs(rPoint1.
X() - (rPoint2.
X() + fLambda * rHeading2.
X())) < eps;
938sal_uInt16 GetLineIntersectionPoint(
Point &rResult,
942 assert(rHeading1 !=
Point());
943 assert(rHeading2 !=
Point());
949 double fDet = Det(rHeading1, rHeading2);
950 if (fabs(fDet) < eps)
952 nRes = IsPointInLine(rPoint1, rPoint2, rHeading2) ? USHRT_MAX : 0;
953 rResult = nRes ? rPoint1 :
Point();
959 double fLambda = ( (rPoint1.
Y() - rPoint2.
Y()) * rHeading2.
X()
960 - (rPoint1.
X() - rPoint2.
X()) * rHeading2.
Y())
963 rPoint1.
Y() +
static_cast<tools::Long>(fLambda * rHeading1.
Y()));
975 const Point &rDiagPoint,
double fAngleDeg)
const
983 Point aRightHdg (100, 0),
985 aDiagHdg (
static_cast<tools::Long>(100.0 * cos(fAngleRad)),
986 static_cast<tools::Long>(-100.0 * sin(fAngleRad)) );
993 GetLineIntersectionPoint(aPoint,
994 Point(nRectLeft, nRectTop), aRightHdg,
995 rDiagPoint, aDiagHdg);
997 if (aPoint.
X() <= nRectRight)
1005 GetLineIntersectionPoint(aPoint,
1006 Point(nRectRight, nRectTop), aDownHdg,
1007 rDiagPoint, aDiagHdg);
1009 nRight = nRectRight;
1014 GetLineIntersectionPoint(aPoint,
1015 Point(nRectLeft, nRectBottom), aRightHdg,
1016 rDiagPoint, aDiagHdg);
1018 if (aPoint.
X() >= nRectLeft)
1021 nBottom = nRectBottom;
1026 GetLineIntersectionPoint(aPoint,
1027 Point(nRectLeft, nRectTop), aDownHdg,
1028 rDiagPoint, aDiagHdg);
1031 nBottom = aPoint.
Y();
1037 GetLineIntersectionPoint(aPoint,
1038 Point(nRectLeft, nRectTop), aRightHdg,
1039 rDiagPoint, aDiagHdg);
1041 if (aPoint.
X() >= nRectLeft)
1049 GetLineIntersectionPoint(aPoint,
1050 Point(nRectLeft, nRectTop), aDownHdg,
1051 rDiagPoint, aDiagHdg);
1058 GetLineIntersectionPoint(aPoint,
1059 Point(nRectLeft, nRectBottom), aRightHdg,
1060 rDiagPoint, aDiagHdg);
1062 if (aPoint.
X() <= nRectRight)
1064 nRight = aPoint.
X();
1065 nBottom = nRectBottom;
1070 GetLineIntersectionPoint(aPoint,
1071 Point(nRectRight, nRectTop), aDownHdg,
1072 rDiagPoint, aDiagHdg);
1074 nRight = nRectRight;
1075 nBottom = aPoint.
Y();
1079 rSize =
Size(nRight - nLeft + 1, nBottom - nTop + 1);
1105 pLeft->
Arrange(aTmpDev, rFormat);
1106 pRight->Arrange(aTmpDev, rFormat);
1109 pOper->
Arrange(aTmpDev, rFormat);
1119 aPos.
setY( pLeft->
GetTop() - nDelta - pRight->GetHeight() );
1121 pRight->MoveTo(aPos);
1125 : (pLeft->
GetTop() + pRight->GetBottom()) / 2;
1129 SmRect::operator = (*pLeft);
1141 pOper->
Arrange(aTmpDev, rFormat);
1155 "Sm: wrong number of subnodes");
1162 pBody->
Arrange(rDev, rFormat);
1165 SmRect::operator = (rBodyRect);
1174 SmRect aTmpRect (rBodyRect);
1186 {
case CSUB: eSubSup =
RSUB;
break;
1202 pSubSup->
Arrange(rDev, rFormat);
1218 nDelta = nDelimLine - aPos.
Y();
1231 nDelta = aPos.
Y() + pSubSup->
GetHeight() - nDelimLine;
1258 if (eSubSup ==
CSUB || eSubSup ==
CSUP)
1274 pBody->Arrange(rDev, rFormat);
1277 bScale = pBody->GetHeight() > 0 &&
1284 sal_uInt16 nPerc = 0;
1285 if (!bIsABS && bScale)
1298 : pBody->GetHeight();
1299 nBraceHeight += 2 * (nBraceHeight * nPerc / 100);
1302 nBraceHeight = nFaceHeight;
1312 OSL_ENSURE(pRight->GetFont().GetFontSize() == aTmpSize,
1313 "Sm : different font sizes");
1314 aTmpSize.
setWidth( std::min(nBraceHeight * 60 / 100,
1326 cChar = pRight->GetToken().cMathChar[0];
1329 pRight->GetFont().SetSize(aTmpSize);
1331 pLeft ->
AdaptToY(rDev, nBraceHeight);
1332 pRight->AdaptToY(rDev, nBraceHeight);
1335 pLeft ->
Arrange(rDev, rFormat);
1336 pRight->Arrange(rDev, rFormat);
1348 pRight->MoveTo(aPos);
1350 SmRect::operator = (*pBody);
1361 if (nNumSubNodes == 0)
1365 for (
size_t i = 0;
i < nNumSubNodes;
i += 2)
1370 for (
size_t i = 0;
i < nNumSubNodes;
i += 2)
1387 nHeight += 2 * (nHeight * nPerc / 100);
1388 for (
size_t i = 1;
i < nNumSubNodes;
i += 2)
1392 pNode->
Arrange(rDev, rFormat);
1400 SmRect::operator = (*pLeft);
1401 for (
size_t i = 1;
i < nNumSubNodes; ++
i)
1403 bool bIsSeparator =
i % 2 != 0;
1434 pBody->
Arrange(aTmpDev, rFormat);
1439 pBrace ->SetSize(
Fraction(3, 2) );
1442 if (nItalicWidth > 0)
1443 pBrace->AdaptToX(aTmpDev, nItalicWidth);
1445 pBrace ->Arrange(aTmpDev, rFormat);
1446 pScript->Arrange(aTmpDev, rFormat);
1452 nDistScript = nFontHeight;
1456 nDistBody = - nDistBody;
1469 pBrace->MoveTo(aPos);
1473 pScript->MoveTo(aPos);
1475 SmRect::operator = (*pBody);
1491 OSL_ENSURE(pNode,
"Sm: NULL pointer!");
1506 if (!rFormat.IsTextmode())
1509 nHeight += (nHeight * 20) / 100;
1513 nHeight = nHeight * 686 / 845;
1517 if (rSymbol.GetToken().eType ==
TSPECIAL)
1518 nHeight = nHeight * 845 / 686;
1536 pBody->
Arrange(rDev, rFormat);
1537 bool bDynamicallySized =
false;
1542 if (nFontHeight < nBodyHeight)
1545 bDynamicallySized =
true;
1548 pOper->
Arrange(rDev, rFormat);
1558 SmRect::operator = (*pBody);
1585 pNode->
Arrange(rDev, rFormat);
1587 SmRect::operator = (pNode->
GetRect());
1601 pBody->Arrange(rDev, rFormat);
1604 pAttr->
AdaptToX(rDev, pBody->GetItalicWidth());
1605 pAttr->
Arrange(rDev, rFormat);
1627 SmRect::operator = (*pBody);
1646 {
GetFont() = rFormat.
GetFont( sal::static_int_cast< sal_uInt16 >(nFnt) );
1691 SAL_WARN(
"starmath",
"unknown case");
1694 pNode->
Arrange(rDev, rFormat);
1696 SmRect::operator = (pNode->
GetRect());
1735 Point aPointA, aPointB;
1738 aPointA.
setX( nBorderwidth );
1741 aPointB.
setY( nBorderwidth );
1746 aPointA.
setX( nBorderwidth );
1747 aPointA.
setY( nBorderwidth );
1756 mnWidth = nThick + 2 * nBorderwidth;
1800 nHeight = nFontHeight / 30;
1802 nWidth = nFontHeight / 3;
1809 nHeight += 2 * nTmpBorderWidth;
1813 SmRect::operator = (
SmRect(nWidth, nHeight));
1822 , mnFontDesc(nFontDescP)
1823 , mnSelectionStart(0)
1830 , mnFontDesc(nFontDescP)
1831 , mnSelectionStart(0)
1893 if( (
'0' <= firstChar && firstChar <=
'9') || firstChar ==
'.' || firstChar ==
',')
1902 static const sal_Unicode aStarMathPrivateToUnicode[] =
1904 0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208,
1905 0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8,
1906 0x00B4, 0x0060, 0x02DC, 0x00AF, 0x0362, 0xE099, 0xE09A, 0x20DB, 0xE09C, 0xE09D,
1907 0x0028, 0x0029, 0x2220, 0x22AF, 0xE0A2, 0xE0A3, 0xE0A4, 0xE0A5, 0xE0A6, 0xE0A7,
1908 0x002F, 0x005C, 0x274F, 0xE0AB, 0x0393, 0x0394, 0x0398, 0x039b, 0x039e, 0x03A0,
1909 0x03a3, 0x03a5, 0x03a6, 0x03a8, 0x03A9, 0x03B1, 0x03B2, 0x03b3, 0x03b4, 0x03b5,
1910 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
1911 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03b5,
1912 0x03d1, 0x03d6, 0xE0D2, 0x03db, 0x2118, 0x2202, 0x2129, 0xE0D7, 0xE0D8, 0x22A4,
1913 0xE0DA, 0x2190, 0x2191, 0x2193
1915 if ((nIn >= 0xE080) && (nIn <= 0xE0DD))
1916 nIn = aStarMathPrivateToUnicode[nIn-0xE080];
1940 std::vector<tools::Long> aColWidth(
mnNumCols);
1944 for (
size_t i = 0;
i < nNodes; ++
i)
1946 size_t nIdx = nNodes - 1 -
i;
1949 pNode->
Arrange(rDev, rFormat);
1951 aColWidth[nCol] = std::max(aColWidth[nCol], pNode->
GetItalicWidth());
1964 std::vector<tools::Long> aColLeft(
mnNumCols);
1969 nX += aColWidth[j] + nHorDist;
1972 SmRect::operator = (
SmRect());
1995 aPos.
setX( aColLeft[j] );
2003 aPos.
setX( aColLeft[j]
2020 aPos.
Y() - aLineRect.
GetTop());
2021 aLineRect.
Move(aDelta);
2025 pNode->
Move(aDelta);
2065 aFntSize.
setWidth( aFntSize.
Width() / ( nDenom ? nDenom : 1) );
2077 if (aFntSize.
Width() == 0)
2084 OSL_ENSURE(aFntSize.
Width() != 0,
"Sm: ");
2098 nDenom =
SmRect(aTmpDev,
nullptr,
GetText(), nTmpBorderWidth).GetHeight();
2116 OSL_ENSURE(
GetFont().GetCharSet() == RTL_TEXTENCODING_SYMBOL ||
2117 GetFont().GetCharSet() == RTL_TEXTENCODING_UNICODE,
2118 "wrong charset for character from StarMath/OpenSymbol font");
2126 const OUString &rText =
GetText();
2128 if (rText.isEmpty() || rText[0] ==
'\0')
2129 { SmRect::operator = (
SmRect());
2150 if (aTokenText.size() > 2 && aTokenText[0] ==
u'%')
2152 OUString
aName( aTokenText.substr(1) );
2163 :
SmTextNode(eNodeType, rNodeToken, _nFontDesc)
2187 OUString aTmp( &cChar, 1 );
2214 OSL_ENSURE(
GetText().
getLength() == 1,
"a symbol should only consist of 1 char!" );
2215 bool bItalic =
false;
2217 OSL_ENSURE( nStyle >= 0 && nStyle <= 2,
"unexpected value for GreekCharStyle" );
2220 else if (nStyle == 2)
2222 const OUString& rTmp(
GetText());
2223 if (!rTmp.isEmpty())
2225 static const sal_Unicode cUppercaseAlpha = 0x0391;
2226 static const sal_Unicode cUppercaseOmega = 0x03A9;
2229 bItalic = cUppercaseAlpha > cChar || cChar > cUppercaseOmega;
2308 const OUString &rText =
GetText();
2316 switch(rToken.
eType)
2345 nSpace =
mnNum * nDist;
2348 SmRect::operator = (
SmRect(aTmpDev, &rFormat, OUString(
' '),
2360 pVisitor->
Visit(
this);
2364 pVisitor->
Visit(
this);
2368 pVisitor->
Visit(
this);
2372 pVisitor->
Visit(
this);
2376 pVisitor->
Visit(
this);
2380 pVisitor->
Visit(
this);
2384 pVisitor->
Visit(
this);
2388 pVisitor->
Visit(
this);
2392 pVisitor->
Visit(
this);
2396 pVisitor->
Visit(
this);
2400 pVisitor->
Visit(
this);
2404 pVisitor->
Visit(
this);
2408 pVisitor->
Visit(
this);
2412 pVisitor->
Visit(
this);
2416 pVisitor->
Visit(
this);
2420 pVisitor->
Visit(
this);
2424 pVisitor->
Visit(
this);
2428 pVisitor->
Visit(
this);
2432 pVisitor->
Visit(
this);
2436 pVisitor->
Visit(
this);
2440 pVisitor->
Visit(
this);
2444 pVisitor->
Visit(
this);
2448 pVisitor->
Visit(
this);
2452 pVisitor->
Visit(
this);
2456 pVisitor->
Visit(
this);
2460 pVisitor->
Visit(
this);
2464 pVisitor->
Visit(
this);
Fraction conversionFract(o3tl::Length from, o3tl::Length to)
constexpr auto DBL_EPSILON
void SetFont(const vcl::Font &rNewFont)
FontMetric GetFontMetric() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
const SmNode * Body() const
Gets the body data ( the nodes affected by the attribute ).
const SmNode * Attribute() const
Gets the attribute data.
void GetOperPosSize(Point &rPos, Size &rSize, const Point &rDiagPoint, double fAngleDeg) const
Returns the position and size of the diagonal line by reference.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
bool IsAscending() const
Checks if it is of ascending type.
const SmNode * Symbol() const
Returns the node containing the data of the binary operator.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
const SmNode * LeftOperand() const
Returns the node containing the data of the left operand.
const SmNode * RightOperand() const
Returns the node containing the data of the right operand.
virtual const SmNode * GetLeftMost() const override
(this assumes the one with index 0 is always the leftmost subnode for the current node).
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void IncreaseBy(const SmToken &rToken, sal_uInt32 nMultiplyBy=1)
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
const SmMathSymbolNode * OpeningBrace() const
Returns the node containing the data of the opening brace.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
const SmNode * Body() const
Returns the node containing the data of what is between braces.
const SmMathSymbolNode * ClosingBrace() const
Returns the node containing the data of the closing brace.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void SetSize(const Size &rSize)
tools::Long GetBorderWidth() const
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void GetAccessibleText(OUStringBuffer &rText) const override
Appends to rText the node text.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
bool IsUseExtraSpaces() const
Checks if it is using extra spaces.
virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
SmMathSymbolNode(SmNodeType eNodeType, const SmToken &rNodeToken)
virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual const SmNode * GetLeftMost() const override
(this assumes the one with index 0 is always the leftmost subnode for the current node).
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
SmSymbolManager & GetSymbolManager()
virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight)
FontAttribute mnAttributes
FontAttribute & Attributes()
Gets the font attributes.
sal_Int32 GetAccessibleIndex() const
Gets the node accessible index.
void SetAttribute(FontAttribute nAttrib)
Sets the font attribute nAttrib.
void SetSize(const Fraction &rScale)
Sets the font size to rRelSize with type FontSizeType::ABSOLUT.
void Move(const Point &rVector)
Moves the rectangle by rVector.
SmNode(SmNodeType eNodeType, SmToken aNodeToken)
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat)=0
Prepares the SmRect to render.
SmScaleMode GetScaleMode() const
Gets the scale mode.
virtual bool IsVisible() const =0
Checks node visibility.
void SetFont(const SmFace &rFace)
Sets the font to rFace.
RectHorAlign GetRectHorAlign() const
Gets the alignment of the text.
void SetFontSize(const Fraction &rRelSize, FontSizeType nType)
Sets the font size to rRelSize with type nType.
const SmNode * FindRectClosestTo(const Point &rPoint) const
Finds the closest rectangle in the screen.
const SmRect & GetRect() const
Parses itself to SmRect.
void SetAccessibleIndex(sal_Int32 nAccIndex)
Sets the node accessible index to nAccIndex.
void PrepareAttributes()
Prepare preliminary font attributes Called on Prepare(...).
virtual size_t GetNumSubNodes() const =0
Gets the number of subnodes.
RectHorAlign meRectHorAlign
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth)
Prepare preliminary settings about font and text (e.g.
void SetPhantom(bool bIsPhantom)
Sets the render visibility of a visible node to bIsPhantom.
const SmToken & GetToken() const
Gets the token.
virtual const SmNode * GetLeftMost() const
(this assumes the one with index 0 is always the leftmost subnode for the current node).
void ClearAttribute(FontAttribute nAttrib)
Clears the font attribute nAttrib.
void SetParent(SmStructureNode *parent)
Sets the parent node.
void MoveTo(const Point &rPoint)
Moves the rectangle to rPoint, being the top left corner the origin.
const SmNode * FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const
Finds the node from the position in the text.
virtual void GetAccessibleText(OUStringBuffer &rText) const =0
Appends to rText the node text.
virtual SmNode * GetSubNode(size_t nIndex)=0
Gets the subnode of index nIndex.
const SmNode * FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const
Finds the node with accessible index nAccIndex.
void SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree=true)
Sets the alignment of the text.
virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth)
void SetColor(const Color &rColor)
Sets the font color.
SmNodeType GetType() const
Gets the node type.
FontChangeMask & Flags()
Gets the FontChangeMask flags.
const SmFace & GetFont() const
Gets the font.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
tools::Long CalcSymbolHeight(const SmNode &rSymbol, const SmFormat &rFormat) const
Returns the height of the node in base to the symbol ( rSymbol contains the operator data ) and the f...
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
const SmNode * GetSymbol() const
Returns the node with the operator data.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
tools::Long GetWidth() const
Gets the width of the rect.
SmPolyLineNode(const SmToken &rNodeToken)
virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override
virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
tools::Long GetItalicLeft() const
const Point & GetTopLeft() const
tools::Long GetItalicWidth() const
bool IsInsideRect(const Point &rPoint) const
tools::Long GetItalicRight() const
SmRect AsGlyphRect() const
tools::Long GetAlignT() const
tools::Long GetHeight() const
tools::Long OrientedDist(const Point &rPoint) const
tools::Long GetItalicCenterX() const
void Move(const Point &rPosition)
tools::Long GetTop() const
tools::Long GetBottom() const
sal_uInt16 GetBorderWidth() const
SmRect & ExtendBy(const SmRect &rRect, RectCopyMBL eCopyMode)
tools::Long GetBaseline() const
Point AlignTo(const SmRect &rRect, RectPos ePos, RectHorAlign eHor, RectVerAlign eVer) const
tools::Long GetAlignB() const
tools::Long GetWidth() const
tools::Long GetAlignM() const
void SetItalicSpaces(tools::Long nLeftSpace, tools::Long nRightSpace)
void MoveTo(const Point &rPosition)
tools::Long GetLeft() const
void SetWidth(sal_uLong nWidth)
const Size & GetSize() const
tools::Long GetItalicRightSpace() const
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void AdaptToX(OutputDevice &rDev, sal_uLong nHeight) override
virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override
Special node for user defined characters.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc)
bool mbIsFromGreekSymbolSet
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
Abstract baseclass for all composite node.
virtual ~SmStructureNode() override
void SetSubNodesBinMo(std::unique_ptr< SmNode > pFirst, std::unique_ptr< SmNode > pSecond, std::unique_ptr< SmNode > pThird=nullptr)
Sets subnodes, used for operators.
int IndexOfSubNode(SmNode const *pSubNode)
Get the index of the child node pSubNode.
void ClaimPaternity()
Sets parent on children of this node.
SmNode * GetSubNodeBinMo(size_t nIndex) const
Gets the subnode of index nIndex, used for operators.
virtual size_t GetNumSubNodes() const override
Gets the number of subnodes.
virtual void GetAccessibleText(OUStringBuffer &rText) const override
Appends to rText the node text.
void SetSubNodes(std::unique_ptr< SmNode > pFirst, std::unique_ptr< SmNode > pSecond, std::unique_ptr< SmNode > pThird=nullptr)
Sets subnodes, used for operators.
virtual SmNode * GetSubNode(size_t nIndex) override
Gets the subnode of index nIndex.
void SetSubNode(size_t nIndex, SmNode *pNode)
Sets the subnode pNode at nIndex.
void ClearSubNodes()
Does the cleaning of the subnodes.
virtual bool IsVisible() const override
Checks node visibility.
Super- and subscript node.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
const SmNode * GetBody() const
Returns the node with the data of what has to be superindex or subindex.
const SmNode * GetSubSup(SmSubSup eSubSup) const
Gets the node with the data of what has to be superindex or subindex.
const OUString & GetSymbolSetName() const
sal_UCS4 GetCharacter() const
const vcl::Font & GetFace() const
SmSym * GetSymbolByName(const OUString &rSymbolName)
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual const SmNode * GetLeftMost() const override
(this assumes the one with index 0 is always the leftmost subnode for the current node).
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
tools::Long mnFormulaBaseline
tools::Long GetFormulaBaseline() const
Gets the formula baseline.
void ChangeText(const OUString &rText)
Change the text of this node, including the underlying token to rText.
void AdjustFontDesc()
Try to guess the correct FontDesc, used during visual editing.
void SetText(const OUString &rText)
Sets the node text to rText.
static sal_Unicode ConvertSymbolToUnicode(sal_Unicode nIn)
Converts the character from StarMath's private area symbols to a matching Unicode character,...
const OUString & GetText() const
Gets the node text.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void GetAccessibleText(OUStringBuffer &rText) const override
Appends to rText the node text.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 nFontDescP)
sal_uInt16 GetFontDesc() const
Returns the font type being used (text, variable, symbol, ...).
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override
Prepare preliminary settings about font and text (e.g.
void SetFont(const vcl::Font &rNewFont)
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override
Prepares the SmRect to render.
void Accept(SmVisitor *pVisitor) override
Accept a visitor.
const SmMathSymbolNode * Brace() const
Returns the node containing the data of the brace.
const SmNode * Script() const
Returns the node containing the data of what is in the brace.
const SmNode * Body() const
Returns the node containing the data of what the brace is pointing for.
Abstract base class for all visible node.
virtual SmNode * GetSubNode(size_t nIndex) override
Gets the subnode of index nIndex.
virtual size_t GetNumSubNodes() const override
Gets the number of subnodes.
virtual bool IsVisible() const override
Checks node visibility.
Visitors are an easy way to automating operations with nodes.
virtual void Visit(SmTableNode *pNode)=0
void SetColor(const Color &)
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const Size & GetFontSize() const
constexpr ::Color COL_GRAY(0x80, 0x80, 0x80)
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
#define SAL_WARN(area, stream)
OUString GetExportSymbolSetName(std::u16string_view rUiName)
sal_uInt16 GetFontSize(sal_uInt16 nPos)
double getLength(const B2DPolygon &rCandidate)
constexpr double deg2rad(double v)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
static bool lcl_IsFromGreekSymbolSet(std::u16string_view aTokenText)
std::vector< SmNode * > SmNodeArray
SmSubSup
Enum used to index sub-/supscripts in the 'maSubNodes' array in 'SmSubSupNode'.
#define SUBSUP_NUM_ENTRIES
numbers of entries in the above enum (that is: the number of possible sub-/supscripts)
FontAttribute
The SmNode is the basic structure of formula data.
SmNodeType
This file provides definition for the nodetypes.
tools::Long SmFromTo(tools::Long nFrom, tools::Long nTo, double fRelDist)
sal_Unicode const MS_DVERTLINE
sal_Unicode const MS_DLINE
sal_Unicode const MS_LINE
sal_Unicode const MS_VERTLINE
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
bool IsItalic(const vcl::Font &rFont)
bool IsBold(const vcl::Font &rFont)
o3tl::Length SmO3tlLengthUnit()