1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_STARMATH_INC_NODE_HXX
21 #define INCLUDED_STARMATH_INC_NODE_HXX
22 
23 #include "types.hxx"
24 #include "token.hxx"
25 #include "rect.hxx"
26 #include "format.hxx"
27 
28 #include <o3tl/typed_flags_set.hxx>
29 
30 #include <cassert>
31 #include <vector>
32 
33 enum class FontAttribute {
34     None   = 0x0000,
35     Bold   = 0x0001,
36     Italic = 0x0002
37 };
38 
39 namespace o3tl
40 {
41     template<> struct typed_flags<FontAttribute> : is_typed_flags<FontAttribute, 0x0003> {};
42 }
43 
44 
45 enum class FontSizeType {
46   ABSOLUT  = 1,
47   PLUS     = 2,
48   MINUS    = 3,
49   MULTIPLY = 4,
50   DIVIDE   = 5
51 };
52 
53 // flags to interdict respective status changes
54 enum class FontChangeMask {
55     None     = 0x0000,
56     Face     = 0x0001,
57     Size     = 0x0002,
58     Bold     = 0x0004,
59     Italic   = 0x0008,
60     Color    = 0x0010,
61     Phantom  = 0x0020
62 };
63 
64 namespace o3tl
65 {
66     template<> struct typed_flags<FontChangeMask> : is_typed_flags<FontChangeMask, 0x003f> {};
67 }
68 
69 
70 class SmVisitor;
71 class SmDocShell;
72 class SmNode;
73 class SmStructureNode;
74 
75 typedef std::vector< SmNode * > SmNodeArray;
76 
77 enum class SmScaleMode
78 {
79     None,
80     Width,
81     Height
82 };
83 
84 enum class SmNodeType
85 {
86 /* 0*/ Table,       Brace,         Bracebody,     Oper,        Align,
87 /* 5*/ Attribut,    Font,          UnHor,         BinHor,      BinVer,
88 /*10*/ BinDiagonal, SubSup,        Matrix,        Place,       Text,
89 /*15*/ Special,     GlyphSpecial,  Math,          Blank,       Error,
90 /*20*/ Line,        Expression,    PolyLine,      Root,        RootSymbol,
91 /*25*/ Rectangle,   VerticalBrace, MathIdent
92 };
93 
94 
95 class SmNode : public SmRect
96 {
97     SmFace      maFace;
98 
99     SmToken     maNodeToken;
100     SmNodeType const meType;
101     SmScaleMode     meScaleMode;
102     RectHorAlign    meRectHorAlign;
103     FontChangeMask  mnFlags;
104     FontAttribute   mnAttributes;
105     bool            mbIsPhantom;
106     bool            mbIsSelected;
107     // index in accessible text; -1 if not (yet) applicable
108     sal_Int32       mnAccIndex;
109 
110 protected:
111     SmNode(SmNodeType eNodeType, const SmToken &rNodeToken);
112 
113 public:
114     SmNode(const SmNode&) = delete;
115     SmNode& operator=(const SmNode&) = delete;
116 
117     virtual             ~SmNode();
118 
119     /**
120      * Returns true if this is an instance of SmVisibleNode's subclass, false otherwise.
121      */
122     virtual bool        IsVisible() const = 0;
123 
124     virtual size_t      GetNumSubNodes() const = 0;
125     virtual SmNode *    GetSubNode(size_t nIndex) = 0;
GetSubNode(size_t nIndex) const126             const SmNode * GetSubNode(size_t nIndex) const
127             {
128                 return const_cast<SmNode *>(this)->GetSubNode(nIndex);
129             }
130 
131     virtual const SmNode * GetLeftMost() const;
132 
Flags()133             FontChangeMask &Flags() { return mnFlags; }
Attributes()134             FontAttribute  &Attributes() { return mnAttributes; }
135 
IsPhantom() const136             bool IsPhantom() const { return mbIsPhantom; }
137             void SetPhantom(bool bIsPhantom);
138             void SetColor(const Color &rColor);
139 
140             void SetAttribut(FontAttribute nAttrib);
141             void ClearAttribut(FontAttribute nAttrib);
142 
GetFont() const143             const SmFace & GetFont() const { return maFace; };
GetFont()144                   SmFace & GetFont()       { return maFace; };
145 
146             void SetFont(const SmFace &rFace);
147             void SetFontSize(const Fraction &rRelSize, FontSizeType nType);
148             void SetSize(const Fraction &rScale);
149 
150     /** Prepare preliminary settings about font and text
151      *  (e.g. maFace, meRectHorAlign, mnFlags, mnAttributes, etc.)
152      */
153     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth);
154     void PrepareAttributes();
155 
156     void         SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree = true );
GetRectHorAlign() const157     RectHorAlign GetRectHorAlign() const { return meRectHorAlign; }
158 
GetRect() const159     const SmRect & GetRect() const { return *this; }
160 
161     void Move(const Point &rPosition);
MoveTo(const Point & rPosition)162     void MoveTo(const Point &rPosition) { Move(rPosition - GetTopLeft()); }
163     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) = 0;
164     virtual void CreateTextFromNode(OUStringBuffer &rText);
165 
166     virtual void    GetAccessibleText( OUStringBuffer &rText ) const = 0;
GetAccessibleIndex() const167     sal_Int32       GetAccessibleIndex() const { return mnAccIndex; }
SetAccessibleIndex(sal_Int32 nAccIndex)168     void            SetAccessibleIndex(sal_Int32 nAccIndex) { mnAccIndex = nAccIndex; }
169     const SmNode *  FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const;
170 
GetRow() const171     sal_uInt16  GetRow() const    { return sal::static_int_cast<sal_uInt16>(maNodeToken.nRow); }
GetColumn() const172     sal_uInt16  GetColumn() const { return sal::static_int_cast<sal_uInt16>(maNodeToken.nCol); }
173 
GetScaleMode() const174     SmScaleMode     GetScaleMode() const { return meScaleMode; }
SetScaleMode(SmScaleMode eMode)175     void            SetScaleMode(SmScaleMode eMode) { meScaleMode = eMode; }
176 
177     virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth);
178     virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight);
179 
GetType() const180     SmNodeType      GetType() const  { return meType; }
GetToken() const181     const SmToken & GetToken() const { return maNodeToken; }
182 
183     const SmNode *  FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const;
184     const SmNode *  FindRectClosestTo(const Point &rPoint) const;
185 
186     /** Accept a visitor
187      * Calls the method for this class on the visitor
188      */
189     virtual void Accept(SmVisitor* pVisitor) = 0;
190 
191     /** True if this node is selected */
IsSelected() const192     bool IsSelected() const {return mbIsSelected;}
SetSelected(bool Selected)193     void SetSelected(bool Selected) {mbIsSelected = Selected;}
194 
195     /** Get the parent node of this node */
GetParent()196     SmStructureNode* GetParent(){ return mpParentNode; }
GetParent() const197     const SmStructureNode* GetParent() const { return mpParentNode; }
198     /** Set the parent node */
SetParent(SmStructureNode * parent)199     void SetParent(SmStructureNode* parent){
200         mpParentNode = parent;
201     }
202 
203     /** Set the token for this node */
SetToken(SmToken const & token)204     void SetToken(SmToken const & token){
205         maNodeToken = token;
206     }
207 
208 private:
209     SmStructureNode* mpParentNode;
210 };
211 
212 
213 /** Abstract baseclass for all composite node
214  *
215  * Subclasses of this class can have subnodes. Nodes that doesn't derivate from
216  * this class does not have subnodes.
217  */
218 class SmStructureNode : public SmNode
219 {
220     SmNodeArray maSubNodes;
221 
222 protected:
SmStructureNode(SmNodeType eNodeType,const SmToken & rNodeToken,size_t nSize=0)223     SmStructureNode(SmNodeType eNodeType, const SmToken &rNodeToken, size_t nSize = 0)
224         : SmNode(eNodeType, rNodeToken)
225         , maSubNodes(nSize)
226     {}
227 
228 public:
229     virtual ~SmStructureNode() override;
230 
231     virtual bool        IsVisible() const override;
232 
233     virtual size_t      GetNumSubNodes() const override;
234 
235     using   SmNode::GetSubNode;
236     virtual SmNode *    GetSubNode(size_t nIndex) override;
237     void ClearSubNodes();
238             void SetSubNodes(std::unique_ptr<SmNode> pFirst, std::unique_ptr<SmNode> pSecond, std::unique_ptr<SmNode> pThird = nullptr);
239             void SetSubNodes(SmNodeArray&& rNodeArray);
240 
241     virtual void  GetAccessibleText( OUStringBuffer &rText ) const override;
242 
begin()243     SmNodeArray::iterator begin() {return maSubNodes.begin();}
end()244     SmNodeArray::iterator end() {return maSubNodes.end();}
rbegin()245     SmNodeArray::reverse_iterator rbegin() {return maSubNodes.rbegin();}
rend()246     SmNodeArray::reverse_iterator rend() {return maSubNodes.rend();}
247 
248     /** Get the index of a child node
249      *
250      * Returns -1, if pSubNode isn't a subnode of this.
251      */
IndexOfSubNode(SmNode const * pSubNode)252     int IndexOfSubNode(SmNode const * pSubNode)
253     {
254         size_t nSize = GetNumSubNodes();
255         for (size_t i = 0; i < nSize; i++)
256             if (pSubNode == GetSubNode(i))
257                 return i;
258         return -1;
259     }
260 
SetSubNode(size_t nIndex,SmNode * pNode)261     void SetSubNode(size_t nIndex, SmNode* pNode)
262     {
263         size_t size = maSubNodes.size();
264         if (size <= nIndex)
265         {
266             //Resize subnodes array
267             maSubNodes.resize(nIndex + 1);
268             //Set new slots to NULL except at nIndex
269             for (size_t i = size; i < nIndex; i++)
270                 maSubNodes[i] = nullptr;
271         }
272         maSubNodes[nIndex] = pNode;
273         if (pNode)
274             pNode->SetParent(this);
275     }
276 
277 private:
278     /** Sets parent on children of this node */
279     void ClaimPaternity();
280 };
281 
282 
283 /** Abstract base class for all visible node
284  *
285  * Nodes that doesn't derivate from this class doesn't draw anything, but their
286  * children.
287  */
288 class SmVisibleNode : public SmNode
289 {
290 protected:
SmVisibleNode(SmNodeType eNodeType,const SmToken & rNodeToken)291     SmVisibleNode(SmNodeType eNodeType, const SmToken &rNodeToken)
292     :   SmNode(eNodeType, rNodeToken)
293     {}
294 
295 public:
296 
297     virtual bool        IsVisible() const override;
298     virtual size_t      GetNumSubNodes() const override;
299     using   SmNode::GetSubNode;
300     virtual SmNode *    GetSubNode(size_t nIndex) override;
301 };
302 
303 
304 class SmGraphicNode : public SmVisibleNode
305 {
306 protected:
SmGraphicNode(SmNodeType eNodeType,const SmToken & rNodeToken)307     SmGraphicNode(SmNodeType eNodeType, const SmToken &rNodeToken)
308     :   SmVisibleNode(eNodeType, rNodeToken)
309     {}
310 
311 public:
312 
313     virtual void  GetAccessibleText( OUStringBuffer &rText ) const override;
314 };
315 
316 
317 /** Draws a rectangle
318  *
319  * Used for drawing the line in the OVER and OVERSTRIKE commands.
320  */
321 class SmRectangleNode : public SmGraphicNode
322 {
323     Size maToSize;
324 
325 public:
SmRectangleNode(const SmToken & rNodeToken)326     explicit SmRectangleNode(const SmToken &rNodeToken)
327         : SmGraphicNode(SmNodeType::Rectangle, rNodeToken)
328     {}
329 
330     virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
331     virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
332 
333     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
334 
335     void CreateTextFromNode(OUStringBuffer &rText) override;
336     void Accept(SmVisitor* pVisitor) override;
337 };
338 
339 
340 /** Polygon line node
341  *
342  * Used to draw the slash of the WIDESLASH command by SmBinDiagonalNode.
343  */
344 class SmPolyLineNode : public SmGraphicNode
345 {
346     tools::Polygon maPoly;
347     Size maToSize;
348     long mnWidth;
349 
350 public:
351     explicit SmPolyLineNode(const SmToken &rNodeToken);
352 
GetWidth() const353     long         GetWidth() const { return mnWidth; }
GetPolygon()354     tools::Polygon &GetPolygon() { return maPoly; }
355 
356     virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
357     virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
358 
359     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
360 
361     void Accept(SmVisitor* pVisitor) override;
362 };
363 
364 
365 /** Text node
366  *
367  * @remarks This class also serves as baseclass for all nodes that contains text.
368  */
369 class SmTextNode : public SmVisibleNode
370 {
371     OUString   maText;
372     sal_uInt16 mnFontDesc;
373     /** Index within text where the selection starts
374      * @remarks Only valid if SmNode::IsSelected() is true
375      */
376     sal_Int32  mnSelectionStart;
377     /** Index within text where the selection ends
378      * @remarks Only valid if SmNode::IsSelected() is true
379      */
380     sal_Int32  mnSelectionEnd;
381 
382 protected:
383     SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 nFontDescP );
384 
385 public:
386     SmTextNode(const SmToken &rNodeToken, sal_uInt16 nFontDescP );
387 
GetFontDesc() const388     sal_uInt16              GetFontDesc() const { return mnFontDesc; }
SetText(const OUString & rText)389     void                SetText(const OUString &rText) { maText = rText; }
GetText() const390     const OUString &    GetText() const { return maText; }
391     /** Change the text of this node, including the underlying token */
ChangeText(const OUString & rText)392     void                ChangeText(const OUString &rText) {
393         maText = rText;
394         SmToken token = GetToken();
395         token.aText = rText;
396         SetToken(token); //TODO: Merge this with AdjustFontDesc for better performance
397         AdjustFontDesc();
398     }
399     /** Try to guess the correct FontDesc, used during visual editing */
400     void                AdjustFontDesc();
401     /** Index within GetText() where the selection starts
402      * @remarks Only valid of SmNode::IsSelected() is true
403      */
GetSelectionStart() const404     sal_Int32           GetSelectionStart() const {return mnSelectionStart;}
405     /** Index within GetText() where the selection end
406      * @remarks Only valid of SmNode::IsSelected() is true
407      */
GetSelectionEnd() const408     sal_Int32           GetSelectionEnd() const {return mnSelectionEnd;}
409     /** Set the index within GetText() where the selection starts */
SetSelectionStart(sal_Int32 index)410     void                SetSelectionStart(sal_Int32 index) {mnSelectionStart = index;}
411     /** Set the index within GetText() where the selection end */
SetSelectionEnd(sal_Int32 index)412     void                SetSelectionEnd(sal_Int32 index) {mnSelectionEnd = index;}
413 
414     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
415     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
416     virtual void CreateTextFromNode(OUStringBuffer &rText) override;
417 
418     virtual void  GetAccessibleText( OUStringBuffer &rText ) const override;
419     void Accept(SmVisitor* pVisitor) override;
420     /**
421       Converts the character from StarMath's private area symbols to a matching Unicode
422       character, if necessary. To be used when converting GetText() to a normal text.
423     */
424     static sal_Unicode ConvertSymbolToUnicode(sal_Unicode nIn);
425 };
426 
427 
428 /** Special node for user defined characters
429  *
430  * Node used for pre- and user-defined characters from:
431  * officecfg/registry/data/org/openoffice/Office/Math.xcu
432  *
433  * This is just single characters, I think.
434  */
435 class SmSpecialNode : public SmTextNode
436 {
437     bool const mbIsFromGreekSymbolSet;
438 
439 protected:
440     SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc);
441 
442 public:
443     explicit SmSpecialNode(const SmToken &rNodeToken);
444 
445     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
446     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
447 
448     void Accept(SmVisitor* pVisitor) override;
449 };
450 
451 
452 /** Glyph node for custom operators
453  *
454  * This node is used with commands: oper, uoper and boper.
455  * E.g. in "A boper op B", "op" will be an instance of SmGlyphSpecialNode.
456  * "boper" simply interprets "op", the following token, as a binary operator.
457  * The command "uoper" interprets the following token as unary operator.
458  * For these commands an instance of SmGlyphSpecialNode is used for the
459  * operator token, following the command.
460  */
461 class SmGlyphSpecialNode : public SmSpecialNode
462 {
463 public:
SmGlyphSpecialNode(const SmToken & rNodeToken)464     explicit SmGlyphSpecialNode(const SmToken &rNodeToken)
465         : SmSpecialNode(SmNodeType::GlyphSpecial, rNodeToken, FNT_MATH)
466     {}
467 
468     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
469     void Accept(SmVisitor* pVisitor) override;
470 };
471 
472 
473 /** Math symbol node
474  *
475  * Use for math symbols such as plus, minus and integral in the INT command.
476  */
477 class SmMathSymbolNode : public SmSpecialNode
478 {
479 protected:
SmMathSymbolNode(SmNodeType eNodeType,const SmToken & rNodeToken)480     SmMathSymbolNode(SmNodeType eNodeType, const SmToken &rNodeToken)
481     :   SmSpecialNode(eNodeType, rNodeToken, FNT_MATH)
482     {
483         sal_Unicode cChar = GetToken().cMathChar;
484         if (u'\0' != cChar)
485             SetText(OUString(cChar));
486     }
487 
488 public:
489     explicit SmMathSymbolNode(const SmToken &rNodeToken);
490 
491     virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
492     virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
493 
494     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
495     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
496     void CreateTextFromNode(OUStringBuffer &rText) override;
497     void Accept(SmVisitor* pVisitor) override;
498 };
499 
500 
501 /** Math Identifier
502  *
503  * This behaves essentially the same as SmMathSymbolNode and is only used to
504  * represent math symbols that should be exported as <mi> elements rather than
505  * <mo> elements.
506  */
507 class SmMathIdentifierNode : public SmMathSymbolNode
508 {
509 public:
SmMathIdentifierNode(const SmToken & rNodeToken)510     explicit SmMathIdentifierNode(const SmToken &rNodeToken)
511         : SmMathSymbolNode(SmNodeType::MathIdent, rNodeToken) {}
512 };
513 
514 
515 /** Root symbol node
516  *
517  * Root symbol node used by SmRootNode to create the root symbol, in front of
518  * the line with the line above. I don't think this node should be used for
519  * anything else.
520  */
521 class SmRootSymbolNode : public SmMathSymbolNode
522 {
523     sal_uLong mnBodyWidth;  // width of body (argument) of root sign
524 
525 public:
SmRootSymbolNode(const SmToken & rNodeToken)526     explicit SmRootSymbolNode(const SmToken &rNodeToken)
527         : SmMathSymbolNode(SmNodeType::RootSymbol, rNodeToken)
528         , mnBodyWidth(0)
529     {
530     }
531 
GetBodyWidth() const532     sal_uLong GetBodyWidth() const {return mnBodyWidth;};
533     virtual void AdaptToX(OutputDevice &rDev, sal_uLong nHeight) override;
534     virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
535 
536     void Accept(SmVisitor* pVisitor) override;
537 };
538 
539 
540 /** Place node
541  *
542  * Used to create the <?> command, that denotes place where something can be
543  * written.
544  * It is drawn as a square with a shadow.
545  */
546 class SmPlaceNode : public SmMathSymbolNode
547 {
548 public:
SmPlaceNode(const SmToken & rNodeToken)549     explicit SmPlaceNode(const SmToken &rNodeToken)
550         : SmMathSymbolNode(SmNodeType::Place, rNodeToken)
551     {
552     }
SmPlaceNode()553     SmPlaceNode() : SmMathSymbolNode(SmNodeType::Place, SmToken(TPLACE, MS_PLACE, "<?>")) {};
554 
555     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
556     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
557     void Accept(SmVisitor* pVisitor) override;
558 };
559 
560 
561 /** Error node, for parsing errors
562  *
563  * This node is used for parsing errors and draws a questionmark turned upside
564  * down (inverted question mark).
565  */
566 class SmErrorNode : public SmMathSymbolNode
567 {
568 public:
SmErrorNode(const SmToken & rNodeToken)569     explicit SmErrorNode(const SmToken &rNodeToken)
570         : SmMathSymbolNode(SmNodeType::Error, rNodeToken)
571     {
572         SetText(OUString(MS_ERROR));
573     }
574 
575     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
576     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
577     void Accept(SmVisitor* pVisitor) override;
578 };
579 
580 
581 /** Table node
582  *
583  * This is the root node for the formula tree. This node is also used for the
584  * STACK and BINOM commands. When used for root node, its
585  * children are instances of SmLineNode, and in some obscure cases the child
586  * can be an instance of SmExpressionNode, mainly when errors occur.
587  */
588 class SmTableNode : public SmStructureNode
589 {
590     long mnFormulaBaseline;
591 public:
SmTableNode(const SmToken & rNodeToken)592     explicit SmTableNode(const SmToken &rNodeToken)
593         : SmStructureNode(SmNodeType::Table, rNodeToken)
594         , mnFormulaBaseline(0)
595     {
596     }
597 
598     virtual const SmNode * GetLeftMost() const override;
599 
600     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
601     long GetFormulaBaseline() const;
602 
603     void Accept(SmVisitor* pVisitor) override;
604 };
605 
606 
607 /** A line
608  *
609  * Used as child of SmTableNode when the SmTableNode is the root node of the
610  * formula tree.
611  */
612 class SmLineNode : public SmStructureNode
613 {
614     bool mbUseExtraSpaces;
615 
616 protected:
SmLineNode(SmNodeType eNodeType,const SmToken & rNodeToken)617     SmLineNode(SmNodeType eNodeType, const SmToken &rNodeToken)
618         : SmStructureNode(eNodeType, rNodeToken)
619         , mbUseExtraSpaces(true)
620     {
621     }
622 
623 public:
SmLineNode(const SmToken & rNodeToken)624     explicit SmLineNode(const SmToken &rNodeToken)
625         : SmStructureNode(SmNodeType::Line, rNodeToken)
626         , mbUseExtraSpaces(true)
627     {
628     }
629 
SetUseExtraSpaces(bool bVal)630     void  SetUseExtraSpaces(bool bVal) { mbUseExtraSpaces = bVal; }
IsUseExtraSpaces() const631     bool  IsUseExtraSpaces() const { return mbUseExtraSpaces; };
632 
633     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
634     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
635     void Accept(SmVisitor* pVisitor) override;
636 };
637 
638 
639 /** Expression node
640  *
641  * Used whenever you have an expression such as "A OVER {B + C}", here there is
642  * an expression node that allows "B + C" to be the denominator of the
643  * SmBinVerNode, that the OVER command creates.
644  */
645 class SmExpressionNode : public SmLineNode
646 {
647 public:
SmExpressionNode(const SmToken & rNodeToken)648     explicit SmExpressionNode(const SmToken &rNodeToken)
649         : SmLineNode(SmNodeType::Expression, rNodeToken)
650     {}
651 
652     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
653     void CreateTextFromNode(OUStringBuffer &rText) override;
654     void Accept(SmVisitor* pVisitor) override;
655 };
656 
657 
658 /** Unary horizontal node
659  *
660  * The same as SmBinHorNode except this is for unary operators.
661  */
662 class SmUnHorNode : public SmStructureNode
663 {
664 public:
SmUnHorNode(const SmToken & rNodeToken)665     explicit SmUnHorNode(const SmToken &rNodeToken)
666         : SmStructureNode(SmNodeType::UnHor, rNodeToken, 2)
667     {
668     }
669 
670     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
671     void Accept(SmVisitor* pVisitor) override;
672 };
673 
674 
675 /** Root node
676  *
677  * Used for create square roots and other roots, example:
678  * \f$ \sqrt[\mbox{[Argument]}]{\mbox{[Body]}} \f$.
679  *
680  * Children:<BR>
681  * 0: Argument (optional)<BR>
682  * 1: Symbol (instance of SmRootSymbolNode)<BR>
683  * 2: Body<BR>
684  * Where argument is optional and may be NULL.
685  */
686 class SmRootNode : public SmStructureNode
687 {
688 public:
SmRootNode(const SmToken & rNodeToken)689     explicit SmRootNode(const SmToken &rNodeToken)
690         : SmStructureNode(SmNodeType::Root, rNodeToken, 3)
691     {
692     }
693 
694     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
695     void CreateTextFromNode(OUStringBuffer &rText) override;
696     void Accept(SmVisitor* pVisitor) override;
697 
698     SmNode* Argument();
699     const SmNode* Argument() const;
700     SmRootSymbolNode* Symbol();
701     const SmRootSymbolNode* Symbol() const;
702     SmNode* Body();
703     const SmNode* Body() const;
704 };
705 
706 
707 /** Binary horizontal node
708  *
709  * This node is used for binary operators. In a formula such as "A + B".
710  *
711  * Children:<BR>
712  * 0: Left operand<BR>
713  * 1: Binary operator<BR>
714  * 2: Right operand<BR>
715  *
716  * None of the children may be NULL.
717  */
718 class SmBinHorNode : public SmStructureNode
719 {
720 public:
SmBinHorNode(const SmToken & rNodeToken)721     explicit SmBinHorNode(const SmToken &rNodeToken)
722         : SmStructureNode(SmNodeType::BinHor, rNodeToken, 3)
723     {
724     }
725 
726     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
727     void Accept(SmVisitor* pVisitor) override;
728 
729     SmNode* Symbol();
730     const SmNode* Symbol() const;
731     SmNode* LeftOperand();
732     const SmNode* LeftOperand() const;
733     SmNode* RightOperand();
734     const SmNode* RightOperand() const;
735 };
736 
737 
738 /** Binary horizontal node
739  *
740  * This node is used for creating the OVER command, consider the formula:
741  * "numerator OVER denominator", which looks like
742  * \f$ \frac{\mbox{numerator}}{\mbox{denominator}} \f$
743  *
744  * Children:<BR>
745  * 0: Numerator<BR>
746  * 1: Line (instance of SmRectangleNode)<BR>
747  * 2: Denominator<BR>
748  * None of the children may be NULL.
749  */
750 class SmBinVerNode : public SmStructureNode
751 {
752 public:
SmBinVerNode(const SmToken & rNodeToken)753     explicit SmBinVerNode(const SmToken &rNodeToken)
754         : SmStructureNode(SmNodeType::BinVer, rNodeToken, 3)
755     {
756     }
757 
758     virtual const SmNode * GetLeftMost() const override;
759 
760     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
761     void CreateTextFromNode(OUStringBuffer &rText) override;
762     void Accept(SmVisitor* pVisitor) override;
763 };
764 
765 
766 /** Binary diagonal node
767  *
768  * Used for implementing the WIDESLASH command, example: "A WIDESLASH B".
769  *
770  * Children:<BR>
771  * 0: Left operand<BR>
772  * 1: right operand<BR>
773  * 2: Line (instance of SmPolyLineNode).<BR>
774  * None of the children may be NULL.
775  */
776 class SmBinDiagonalNode : public SmStructureNode
777 {
778     bool mbAscending;
779 
780     void    GetOperPosSize(Point &rPos, Size &rSize,
781                            const Point &rDiagPoint, double fAngleDeg) const;
782 
783 public:
SmBinDiagonalNode(const SmToken & rNodeToken)784     explicit SmBinDiagonalNode(const SmToken &rNodeToken)
785         : SmStructureNode(SmNodeType::BinDiagonal, rNodeToken, 3)
786         , mbAscending(false)
787     {
788     }
789 
IsAscending() const790     bool    IsAscending() const { return mbAscending; }
SetAscending(bool bVal)791     void    SetAscending(bool bVal)  { mbAscending = bVal; }
792 
793     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
794     void Accept(SmVisitor* pVisitor) override;
795 };
796 
797 
798 /** Enum used to index sub-/supscripts in the 'maSubNodes' array
799  * in 'SmSubSupNode'
800  *
801  * See graphic for positions at char:
802  *
803  * \code
804  *      CSUP
805  *
806  * LSUP H  H RSUP
807  *      H  H
808  *      HHHH
809  *      H  H
810  * LSUB H  H RSUB
811  *
812  *      CSUB
813  * \endcode
814  */
815 enum SmSubSup
816 {   CSUB, CSUP, RSUB, RSUP, LSUB, LSUP
817 };
818 
819 /** numbers of entries in the above enum (that is: the number of possible
820  * sub-/supscripts)
821  */
822 #define SUBSUP_NUM_ENTRIES 6
823 
824 /** Super- and subscript node
825  *
826  * Used for creating super- and subscripts for commands such as:
827  * "^", "_", "lsup", "lsub", "csup" and "csub".
828  * Example: "A^2" which looks like: \f$ A^2 \f$
829  *
830  * This node is also used for creating limits on SmOperNode, when
831  * "FROM" and "TO" commands are used with "INT", "SUM" or similar.
832  *
833  * Children of this node can be enumerated using the SmSubSup enum.
834  * Please note that children may be NULL, except for the body.
835  * It is recommended that you access children using GetBody() and
836  * GetSubSup().
837  */
838 class SmSubSupNode : public SmStructureNode
839 {
840     bool mbUseLimits;
841 
842 public:
SmSubSupNode(const SmToken & rNodeToken)843     explicit SmSubSupNode(const SmToken &rNodeToken)
844         : SmStructureNode(SmNodeType::SubSup, rNodeToken, 1 + SUBSUP_NUM_ENTRIES)
845         , mbUseLimits(false)
846     {
847     }
848 
849     /** Get body (Not NULL) */
GetBody()850     SmNode *       GetBody()    { return GetSubNode(0); }
851     /** Get body (Not NULL) */
GetBody() const852     const SmNode * GetBody() const
853     {
854         return const_cast<SmSubSupNode *>(this)->GetBody();
855     }
856 
SetUseLimits(bool bVal)857     void  SetUseLimits(bool bVal) { mbUseLimits = bVal; }
IsUseLimits() const858     bool  IsUseLimits() const { return mbUseLimits; };
859 
860     /** Get super- or subscript
861      * @remarks this method may return NULL.
862      */
GetSubSup(SmSubSup eSubSup)863     SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode(1 + eSubSup); };
GetSubSup(SmSubSup eSubSup) const864     const SmNode * GetSubSup(SmSubSup eSubSup) const { return const_cast< SmSubSupNode* >( this )->GetSubSup( eSubSup ); }
865 
866     /** Set the body */
SetBody(SmNode * pBody)867     void SetBody(SmNode* pBody) { SetSubNode(0, pBody); }
SetSubSup(SmSubSup eSubSup,SmNode * pScript)868     void SetSubSup(SmSubSup eSubSup, SmNode* pScript) { SetSubNode( 1 + eSubSup, pScript); }
869 
870     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
871     void CreateTextFromNode(OUStringBuffer &rText) override;
872     void Accept(SmVisitor* pVisitor) override;
873 
874 };
875 
876 
877 /** Node for brace construction
878  *
879  * Used for "lbrace [body] rbrace" and similar constructions.
880  * Should look like \f$ \{\mbox{[body]}\} \f$
881  *
882  * Children:<BR>
883  * 0: Opening brace<BR>
884  * 1: Body (usually SmBracebodyNode)<BR>
885  * 2: Closing brace<BR>
886  * None of the children can be NULL.
887  *
888  * Note that child 1 (Body) is usually SmBracebodyNode, but it can also be e.g. SmExpressionNode.
889  */
890 class SmBraceNode : public SmStructureNode
891 {
892 public:
SmBraceNode(const SmToken & rNodeToken)893     explicit SmBraceNode(const SmToken &rNodeToken)
894         : SmStructureNode(SmNodeType::Brace, rNodeToken, 3)
895     {
896     }
897 
898     SmMathSymbolNode* OpeningBrace();
899     const SmMathSymbolNode* OpeningBrace() const;
900     SmNode* Body();
901     const SmNode* Body() const;
902     SmMathSymbolNode* ClosingBrace();
903     const SmMathSymbolNode* ClosingBrace() const;
904 
905     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
906     void CreateTextFromNode(OUStringBuffer &rText) override;
907     void Accept(SmVisitor* pVisitor) override;
908 };
909 
910 
911 /** Body of an SmBraceNode
912  *
913  * This usually only has one child an SmExpressionNode, however, it can also
914  * have other children.
915  * Consider the formula "lbrace [body1] mline [body2] rbrace", looks like:
916  * \f$ \{\mbox{[body1] | [body2]}\} \f$.
917  * In this case SmBracebodyNode will have three children, "[body1]", "|" and
918  * [body2].
919  */
920 class SmBracebodyNode : public SmStructureNode
921 {
922     long mnBodyHeight;
923 
924 public:
SmBracebodyNode(const SmToken & rNodeToken)925     explicit SmBracebodyNode(const SmToken &rNodeToken)
926         : SmStructureNode(SmNodeType::Bracebody, rNodeToken)
927         , mnBodyHeight(0)
928     {
929     }
930 
931     virtual void    Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
GetBodyHeight() const932     long GetBodyHeight() const { return mnBodyHeight; }
933     void Accept(SmVisitor* pVisitor) override;
934 };
935 
936 
937 /** Node for vertical brace construction
938  *
939  * Used to implement commands "[body] underbrace [script]" and
940  * "[body] overbrace [script]".
941  * Underbrace should look like this \f$ \underbrace{\mbox{body}}_{\mbox{script}}\f$.
942  *
943  * Children:<BR>
944  * 0: body<BR>
945  * 1: brace<BR>
946  * 2: script<BR>
947  * (None of these children are optional, e.g. they must all be not NULL).
948  */
949 class SmVerticalBraceNode : public SmStructureNode
950 {
951 public:
952     explicit inline SmVerticalBraceNode(const SmToken &rNodeToken);
953 
954     SmNode* Body();
955     const SmNode* Body() const;
956     SmMathSymbolNode* Brace();
957     const SmMathSymbolNode* Brace() const;
958     SmNode* Script();
959     const SmNode* Script() const;
960 
961     virtual void    Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
962     void Accept(SmVisitor* pVisitor) override;
963 };
964 
965 
SmVerticalBraceNode(const SmToken & rNodeToken)966 inline SmVerticalBraceNode::SmVerticalBraceNode(const SmToken &rNodeToken)
967     : SmStructureNode(SmNodeType::VerticalBrace, rNodeToken, 3)
968 {
969 }
970 
971 
972 /** Operation Node
973  *
974  * Used for commands like SUM, INT and similar.
975  *
976  * Children:<BR>
977  * 0: Operation (instance of SmMathSymbolNode or SmSubSupNode)<BR>
978  * 1: Body<BR>
979  * None of the children may be NULL.
980  *
981  */
982 class SmOperNode : public SmStructureNode
983 {
984 public:
SmOperNode(const SmToken & rNodeToken)985     explicit SmOperNode(const SmToken &rNodeToken)
986         : SmStructureNode(SmNodeType::Oper, rNodeToken, 2)
987     {
988     }
989 
990     SmNode *       GetSymbol();
GetSymbol() const991     const SmNode * GetSymbol() const
992     {
993         return const_cast<SmOperNode *>(this)->GetSymbol();
994     }
995 
996     long CalcSymbolHeight(const SmNode &rSymbol, const SmFormat &rFormat) const;
997 
998     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
999     void Accept(SmVisitor* pVisitor) override;
1000 };
1001 
1002 
1003 /** Node used for alignment
1004  *
1005  * This node has exactly one child at index 0.
1006  */
1007 class SmAlignNode : public SmStructureNode
1008 {
1009 public:
SmAlignNode(const SmToken & rNodeToken)1010     explicit SmAlignNode(const SmToken &rNodeToken)
1011         : SmStructureNode(SmNodeType::Align, rNodeToken)
1012     {}
1013 
1014     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
1015     void Accept(SmVisitor* pVisitor) override;
1016 };
1017 
1018 
1019 /** Attribute node
1020  *
1021  * Used to give an attribute to another node. Used for commands such as:
1022  * UNDERLINE, OVERLINE, OVERSTRIKE, WIDEVEC, WIDEHARPOON, WIDEHAT and WIDETILDE.
1023  *
1024  * Children:<BR>
1025  * 0: Attribute<BR>
1026  * 1: Body<BR>
1027  * None of these may be NULL.
1028  */
1029 class SmAttributNode : public SmStructureNode
1030 {
1031 public:
SmAttributNode(const SmToken & rNodeToken)1032     explicit SmAttributNode(const SmToken &rNodeToken)
1033         : SmStructureNode(SmNodeType::Attribut, rNodeToken, 2)
1034     {}
1035 
1036     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
1037     void CreateTextFromNode(OUStringBuffer &rText) override;
1038     void Accept(SmVisitor* pVisitor) override;
1039 
1040     SmNode* Attribute();
1041     const SmNode* Attribute() const;
1042     SmNode* Body();
1043     const SmNode* Body() const;
1044 };
1045 
1046 
1047 /** Font node
1048  *
1049  * Used to change the font of its children.
1050  */
1051 class SmFontNode : public SmStructureNode
1052 {
1053     FontSizeType meSizeType;
1054     Fraction     maFontSize;
1055 
1056 public:
SmFontNode(const SmToken & rNodeToken)1057     explicit SmFontNode(const SmToken &rNodeToken)
1058         : SmStructureNode(SmNodeType::Font, rNodeToken)
1059         , meSizeType(FontSizeType::MULTIPLY)
1060         , maFontSize(1)
1061     {
1062     }
1063 
1064     void SetSizeParameter(const Fraction &rValue, FontSizeType nType);
GetSizeParameter() const1065     const Fraction & GetSizeParameter() const {return maFontSize;}
GetSizeType() const1066     FontSizeType GetSizeType() const {return meSizeType;}
1067 
1068     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
1069     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
1070     void CreateTextFromNode(OUStringBuffer &rText) override;
1071     void Accept(SmVisitor* pVisitor) override;
1072 };
1073 
1074 
1075 /** Matrix node
1076  *
1077  * Used to implement the MATRIX command, example:
1078  * "matrix{ 1 # 2 ## 3 # 4}".
1079  */
1080 class SmMatrixNode : public SmStructureNode
1081 {
1082     sal_uInt16 mnNumRows,
1083                mnNumCols;
1084 
1085 public:
SmMatrixNode(const SmToken & rNodeToken)1086     explicit SmMatrixNode(const SmToken &rNodeToken)
1087         : SmStructureNode(SmNodeType::Matrix, rNodeToken)
1088         , mnNumRows(0)
1089         , mnNumCols(0)
1090     {
1091     }
1092 
GetNumRows() const1093     sal_uInt16 GetNumRows() const {return mnNumRows;}
GetNumCols() const1094     sal_uInt16 GetNumCols() const {return mnNumCols;}
1095     void SetRowCol(sal_uInt16 nMatrixRows, sal_uInt16 nMatrixCols);
1096 
1097     virtual const SmNode * GetLeftMost() const override;
1098 
1099     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
1100     void CreateTextFromNode(OUStringBuffer &rText) override;
1101     void Accept(SmVisitor* pVisitor) override;
1102 };
1103 
1104 
1105 /** Node for whitespace
1106  *
1107  * Used to implement the commands "~" and "`". This node is just a blank space.
1108  */
1109 class SmBlankNode : public SmGraphicNode
1110 {
1111     sal_uInt16 mnNum;
1112 
1113 public:
SmBlankNode(const SmToken & rNodeToken)1114     explicit SmBlankNode(const SmToken &rNodeToken)
1115         : SmGraphicNode(SmNodeType::Blank, rNodeToken)
1116         , mnNum(0)
1117     {
1118     }
1119 
1120     void         IncreaseBy(const SmToken &rToken, sal_uInt32 nMultiplyBy = 1);
Clear()1121     void         Clear() { mnNum = 0; }
GetBlankNum() const1122     sal_uInt16   GetBlankNum() const { return mnNum; }
SetBlankNum(sal_uInt16 nNumber)1123     void         SetBlankNum(sal_uInt16 nNumber) { mnNum = nNumber; }
1124 
1125     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
1126     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
1127     void Accept(SmVisitor* pVisitor) override;
1128     virtual void CreateTextFromNode(OUStringBuffer &rText) override;
1129 };
1130 
1131 
Argument()1132 inline SmNode* SmRootNode::Argument()
1133 {
1134     assert( GetNumSubNodes() == 3 );
1135     return GetSubNode( 0 );
1136 }
Argument() const1137 inline const SmNode* SmRootNode::Argument() const
1138 {
1139     return const_cast< SmRootNode* >( this )->Argument();
1140 }
Symbol()1141 inline SmRootSymbolNode* SmRootNode::Symbol()
1142 {
1143     assert( GetNumSubNodes() == 3 );
1144     assert( GetSubNode( 1 )->GetType() == SmNodeType::RootSymbol );
1145     return static_cast< SmRootSymbolNode* >( GetSubNode( 1 ));
1146 }
Symbol() const1147 inline const SmRootSymbolNode* SmRootNode::Symbol() const
1148 {
1149     return const_cast< SmRootNode* >( this )->Symbol();
1150 }
Body()1151 inline SmNode* SmRootNode::Body()
1152 {
1153     assert( GetNumSubNodes() == 3 );
1154     return GetSubNode( 2 );
1155 }
Body() const1156 inline const SmNode* SmRootNode::Body() const
1157 {
1158     return const_cast< SmRootNode* >( this )->Body();
1159 }
1160 
1161 
Symbol()1162 inline SmNode* SmBinHorNode::Symbol()
1163 {
1164     assert( GetNumSubNodes() == 3 );
1165     return GetSubNode( 1 );
1166 }
Symbol() const1167 inline const SmNode* SmBinHorNode::Symbol() const
1168 {
1169     return const_cast< SmBinHorNode* >( this )->Symbol();
1170 }
LeftOperand()1171 inline SmNode* SmBinHorNode::LeftOperand()
1172 {
1173     assert( GetNumSubNodes() == 3 );
1174     return GetSubNode( 0 );
1175 }
LeftOperand() const1176 inline const SmNode* SmBinHorNode::LeftOperand() const
1177 {
1178     return const_cast< SmBinHorNode* >( this )->LeftOperand();
1179 }
RightOperand()1180 inline SmNode* SmBinHorNode::RightOperand()
1181 {
1182     assert( GetNumSubNodes() == 3 );
1183     return GetSubNode( 2 );
1184 }
RightOperand() const1185 inline const SmNode* SmBinHorNode::RightOperand() const
1186 {
1187     return const_cast< SmBinHorNode* >( this )->RightOperand();
1188 }
1189 
Attribute()1190 inline SmNode* SmAttributNode::Attribute()
1191 {
1192     assert( GetNumSubNodes() == 2 );
1193     return GetSubNode( 0 );
1194 }
Attribute() const1195 inline const SmNode* SmAttributNode::Attribute() const
1196 {
1197     return const_cast< SmAttributNode* >( this )->Attribute();
1198 }
Body()1199 inline SmNode* SmAttributNode::Body()
1200 {
1201     assert( GetNumSubNodes() == 2 );
1202     return GetSubNode( 1 );
1203 }
Body() const1204 inline const SmNode* SmAttributNode::Body() const
1205 {
1206     return const_cast< SmAttributNode* >( this )->Body();
1207 }
1208 
OpeningBrace()1209 inline SmMathSymbolNode* SmBraceNode::OpeningBrace()
1210 {
1211     assert( GetNumSubNodes() == 3 );
1212     assert( GetSubNode( 0 )->GetType() == SmNodeType::Math );
1213     return static_cast< SmMathSymbolNode* >( GetSubNode( 0 ));
1214 }
OpeningBrace() const1215 inline const SmMathSymbolNode* SmBraceNode::OpeningBrace() const
1216 {
1217     return const_cast< SmBraceNode* >( this )->OpeningBrace();
1218 }
Body()1219 inline SmNode* SmBraceNode::Body()
1220 {
1221     assert( GetNumSubNodes() == 3 );
1222     return GetSubNode( 1 );
1223 }
Body() const1224 inline const SmNode* SmBraceNode::Body() const
1225 {
1226     return const_cast< SmBraceNode* >( this )->Body();
1227 }
ClosingBrace()1228 inline SmMathSymbolNode* SmBraceNode::ClosingBrace()
1229 {
1230     assert( GetNumSubNodes() == 3 );
1231     assert( GetSubNode( 2 )->GetType() == SmNodeType::Math );
1232     return static_cast< SmMathSymbolNode* >( GetSubNode( 2 ));
1233 }
ClosingBrace() const1234 inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const
1235 {
1236     return const_cast< SmBraceNode* >( this )->ClosingBrace();
1237 }
1238 
Body()1239 inline SmNode* SmVerticalBraceNode::Body()
1240 {
1241     assert( GetNumSubNodes() == 3 );
1242     return GetSubNode( 0 );
1243 }
Body() const1244 inline const SmNode* SmVerticalBraceNode::Body() const
1245 {
1246     return const_cast< SmVerticalBraceNode* >( this )->Body();
1247 }
Brace()1248 inline SmMathSymbolNode* SmVerticalBraceNode::Brace()
1249 {
1250     assert( GetNumSubNodes() == 3 );
1251     assert( GetSubNode( 1 )->GetType() == SmNodeType::Math );
1252     return static_cast< SmMathSymbolNode* >( GetSubNode( 1 ));
1253 }
Brace() const1254 inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const
1255 {
1256     return const_cast< SmVerticalBraceNode* >( this )->Brace();
1257 }
Script()1258 inline SmNode* SmVerticalBraceNode::Script()
1259 {
1260     assert( GetNumSubNodes() == 3 );
1261     return GetSubNode( 2 );
1262 }
Script() const1263 inline const SmNode* SmVerticalBraceNode::Script() const
1264 {
1265     return const_cast< SmVerticalBraceNode* >( this )->Script();
1266 }
1267 
1268 #endif
1269 
1270 
1271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1272