summaryrefslogtreecommitdiff
path: root/starmath/source/node.cxx
diff options
context:
space:
mode:
authormatteocam <matteo.campanelli@gmail.com>2014-02-25 14:37:55 -0500
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-03-15 22:45:51 +0000
commit93e6291c29d547c0c29c6e43b2ca4b36a3e8506f (patch)
tree50d3560576046dd111e5a9aad5d37afa1add69a9 /starmath/source/node.cxx
parentedc8ee009943e7fc9a68730b0efb303b019a62d4 (diff)
fdo#53472 Created Dynamic Integral Node classes. Integrals size made dependent on body.
Change-Id: I0348155f2429cf7dd3cbe7d71f333879ec6de980 Reviewed-on: https://gerrit.libreoffice.org/8569 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'starmath/source/node.cxx')
-rw-r--r--starmath/source/node.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index bbac173f9b69..75d752901d4c 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -622,6 +622,8 @@ void SmNode::DumpAsDot(std::ostream &out, OUString* label, int number, int& id,
case NRECTANGLE: out<<"SmRectangleNode"; break;
case NVERTICAL_BRACE: out<<"SmVerticalBraceNode"; break;
case NMATHIDENT: out<<"SmMathIdentifierNode"; break;
+ case NINTDYNSYMBOL: out<<"SmDynIntegralSymbolNode"; break;
+ case NINTDYN: out<<"SmDynIntegralNode"; break;
default:
out<<"Unknown Node";
}
@@ -1115,6 +1117,53 @@ void SmRootNode::CreateTextFromNode(OUString &rText)
rText += "} ";
}
+/**************************************************************************/
+
+
+void SmDynIntegralNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
+{
+ SmNode *pDynIntegralSym = Symbol(),
+ *pBody = Body();
+ OSL_ENSURE(pDynIntegralSym, "Sm: NULL pointer");
+ OSL_ENSURE(pBody, "Sm: NULL pointer");
+
+ pBody->Arrange(rDev, rFormat);
+
+ long nHeight = pBody->GetHeight();
+ pDynIntegralSym->AdaptToY(rDev, nHeight);
+
+ pDynIntegralSym->Arrange(rDev, rFormat);
+
+ Point aPos = pDynIntegralSym->AlignTo(*pBody, RP_LEFT, RHA_CENTER, RVA_BASELINE);
+ //! override calculated vertical position
+ aPos.Y() = pDynIntegralSym->GetTop() + pBody->GetBottom() - pDynIntegralSym->GetBottom();
+ pDynIntegralSym->MoveTo(aPos);
+
+
+ // override its own rectangle with pBody's
+ SmRect::operator = (*pBody);
+ // extends this rectangle with the symbol's one
+ ExtendBy(*pDynIntegralSym, RCP_THIS);
+
+}
+
+
+void SmDynIntegralNode::CreateTextFromNode(OUString &rText)
+{
+
+ rText += "intd ";
+ SmNode *pBody = GetSubNode(1);
+
+ if (pBody->GetNumSubNodes() > 1)
+ rText += "{ ";
+
+ pBody->CreateTextFromNode(rText);
+
+ if (pBody->GetNumSubNodes() > 1)
+ rText += "} ";
+}
+
+
/**************************************************************************/
@@ -2297,6 +2346,23 @@ void SmRootSymbolNode::AdaptToY(const OutputDevice &rDev, sal_uLong nHeight)
/**************************************************************************/
+void SmDynIntegralSymbolNode::AdaptToY(const OutputDevice &rDev, sal_uLong nHeight)
+{
+ long nFactor = 12L;
+
+ // The new height equals (1 + nFactor) * oldHeight
+ // nFactor was chosen for keeping the integral sign from becoming too "fat".
+ SmMathSymbolNode::AdaptToY(rDev, nHeight + nHeight / nFactor);
+
+ // keep the ratio
+ long nCurWidth = GetSize().Width();
+ SmMathSymbolNode::AdaptToX(rDev, nCurWidth + nCurWidth / nFactor);
+}
+
+
+/**************************************************************************/
+
+
void SmRectangleNode::AdaptToX(const OutputDevice &/*rDev*/, sal_uLong nWidth)
{
aToSize.Width() = nWidth;
@@ -3196,6 +3262,15 @@ void SmRootSymbolNode::Accept(SmVisitor* pVisitor) {
pVisitor->Visit(this);
}
+void SmDynIntegralNode::Accept(SmVisitor* pVisitor) {
+ pVisitor->Visit(this);
+}
+
+
+void SmDynIntegralSymbolNode::Accept(SmVisitor* pVisitor) {
+ pVisitor->Visit(this);
+}
+
void SmRectangleNode::Accept(SmVisitor* pVisitor) {
pVisitor->Visit(this);
}