Line data Source code
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 NODE_HXX
21 : #define NODE_HXX
22 :
23 : #include <vector>
24 : #include <ostream>
25 : #include <stdio.h>
26 :
27 : #include "parse.hxx"
28 : #include "types.hxx"
29 : #include "rect.hxx"
30 : #include "format.hxx"
31 :
32 :
33 : #define ATTR_BOLD 0x0001
34 : #define ATTR_ITALIC 0x0002
35 :
36 :
37 : #define FNTSIZ_ABSOLUT 1
38 : #define FNTSIZ_PLUS 2
39 : #define FNTSIZ_MINUS 3
40 : #define FNTSIZ_MULTIPLY 4
41 : #define FNTSIZ_DIVIDE 5
42 :
43 : // flags to interdict respective status changes
44 : #define FLG_FONT 0x0001
45 : #define FLG_SIZE 0x0002
46 : #define FLG_BOLD 0x0004
47 : #define FLG_ITALIC 0x0008
48 : #define FLG_COLOR 0x0010
49 : #define FLG_VISIBLE 0x0020
50 : #define FLG_HORALIGN 0x0040
51 :
52 :
53 : extern SmFormat *pActiveFormat;
54 :
55 : class SmVisitor;
56 : class SmDocShell;
57 : class SmNode;
58 : class SmStructureNode;
59 :
60 : typedef boost::shared_ptr<SmNode> SmNodePointer;
61 : typedef std::vector< SmNode * > SmNodeArray;
62 : typedef std::vector< SmStructureNode * > SmStructureNodeArray;
63 :
64 :
65 : ////////////////////////////////////////////////////////////////////////////////
66 :
67 : enum SmScaleMode { SCALE_NONE, SCALE_WIDTH, SCALE_HEIGHT };
68 :
69 : enum SmNodeType
70 : {
71 : /* 0*/ NTABLE, NBRACE, NBRACEBODY, NOPER, NALIGN,
72 : /* 5*/ NATTRIBUT, NFONT, NUNHOR, NBINHOR, NBINVER,
73 : /*10*/ NBINDIAGONAL, NSUBSUP, NMATRIX, NPLACE, NTEXT,
74 : /*15*/ NSPECIAL, NGLYPH_SPECIAL, NMATH, NBLANK, NERROR,
75 : /*20*/ NLINE, NEXPRESSION, NPOLYLINE, NROOT, NROOTSYMBOL,
76 : /*25*/ NRECTANGLE, NVERTICAL_BRACE, NMATHIDENT
77 : };
78 :
79 :
80 : ////////////////////////////////////////////////////////////////////////////////
81 :
82 :
83 0 : class SmNode : public SmRect
84 : {
85 : SmFace aFace;
86 :
87 : SmToken aNodeToken;
88 : SmNodeType eType;
89 : SmScaleMode eScaleMode;
90 : RectHorAlign eRectHorAlign;
91 : sal_uInt16 nFlags,
92 : nAttributes;
93 : bool bIsPhantom,
94 : bIsDebug;
95 :
96 : bool bIsSelected;
97 :
98 : protected:
99 : SmNode(SmNodeType eNodeType, const SmToken &rNodeToken);
100 :
101 : // index in accessible text -1 if not (yet) applicable
102 : sal_Int32 nAccIndex;
103 :
104 : public:
105 : virtual ~SmNode();
106 :
107 : virtual bool IsVisible() const;
108 :
109 : virtual sal_uInt16 GetNumSubNodes() const;
110 : virtual SmNode * GetSubNode(sal_uInt16 nIndex);
111 7530 : const SmNode * GetSubNode(sal_uInt16 nIndex) const
112 : {
113 7530 : return const_cast<SmNode *>(this)->GetSubNode(nIndex);
114 : }
115 :
116 : virtual SmNode * GetLeftMost();
117 : const SmNode * GetLeftMost() const
118 : {
119 : return const_cast<SmNode *>(this)->GetLeftMost();
120 : }
121 :
122 4419 : sal_uInt16 & Flags() { return nFlags; }
123 12181 : sal_uInt16 & Attributes() { return nAttributes; }
124 :
125 : bool IsDebug() const { return bIsDebug; }
126 46217 : bool IsPhantom() const { return bIsPhantom; }
127 : void SetPhantom(bool bIsPhantom);
128 : void SetColor(const Color &rColor);
129 :
130 : void SetAttribut(sal_uInt16 nAttrib);
131 : void ClearAttribut(sal_uInt16 nAttrib);
132 :
133 1343 : const SmFace & GetFont() const { return aFace; };
134 123892 : SmFace & GetFont() { return aFace; };
135 :
136 : void SetFont(const SmFace &rFace);
137 : void SetFontSize(const Fraction &rRelSize, sal_uInt16 nType);
138 : void SetSize(const Fraction &rScale);
139 :
140 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
141 : virtual void PrepareAttributes();
142 :
143 : sal_uInt16 FindIndex() const;
144 :
145 : #if OSL_DEBUG_LEVEL
146 : void ToggleDebug() const;
147 : #endif
148 :
149 : void SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree = true );
150 1541 : RectHorAlign GetRectHorAlign() const { return eRectHorAlign; }
151 :
152 : const SmRect & GetRect() const { return *this; }
153 3228 : SmRect & GetRect() { return *this; }
154 :
155 : virtual void Move(const Point &rPosition);
156 4994 : void MoveTo(const Point &rPosition) { Move(rPosition - GetTopLeft()); }
157 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
158 : virtual void CreateTextFromNode(String &rText);
159 :
160 : virtual void GetAccessibleText( OUStringBuffer &rText ) const;
161 0 : sal_Int32 GetAccessibleIndex() const { return nAccIndex; }
162 : const SmNode * FindNodeWithAccessibleIndex(xub_StrLen nAccIndex) const;
163 :
164 0 : sal_uInt16 GetRow() const { return (sal_uInt16)aNodeToken.nRow; }
165 0 : sal_uInt16 GetColumn() const { return (sal_uInt16)aNodeToken.nCol; }
166 :
167 1670 : SmScaleMode GetScaleMode() const { return eScaleMode; }
168 910 : void SetScaleMode(SmScaleMode eMode) { eScaleMode = eMode; }
169 :
170 : virtual void AdaptToX(const OutputDevice &rDev, sal_uLong nWidth);
171 : virtual void AdaptToY(const OutputDevice &rDev, sal_uLong nHeight);
172 :
173 9997 : SmNodeType GetType() const { return eType; }
174 23635 : const SmToken & GetToken() const { return aNodeToken; }
175 :
176 : const SmNode * FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const;
177 : const SmNode * FindRectClosestTo(const Point &rPoint) const;
178 :
179 : virtual long GetFormulaBaseline() const;
180 :
181 : /** Accept a visitor
182 : * Calls the method for this class on the visitor
183 : */
184 : virtual void Accept(SmVisitor* pVisitor);
185 :
186 : /** True if this node is selected */
187 36 : bool IsSelected() const {return bIsSelected;}
188 10879 : void SetSelected(bool Selected = true) {bIsSelected = Selected;}
189 :
190 : #ifdef DEBUG_ENABLE_DUMPASDOT
191 : /** The tree as dot graph for graphviz, usable for debugging
192 : * Convert the output to a image using $ dot graph.gv -Tpng > graph.png
193 : */
194 : inline void DumpAsDot(std::ostream &out, OUString* label = NULL) const{
195 : int id = 0;
196 : DumpAsDot(out, label, -1, id, -1);
197 : }
198 : #endif /* DEBUG_ENABLE_DUMPASDOT */
199 :
200 : /** Get the parent node of this node */
201 175 : SmStructureNode* GetParent(){ return aParentNode; }
202 0 : const SmStructureNode* GetParent() const { return aParentNode; }
203 : /** Set the parent node */
204 9563 : void SetParent(SmStructureNode* parent){
205 9563 : aParentNode = parent;
206 9563 : }
207 :
208 : /** Get the index of a child node
209 : *
210 : * Returns -1, if pSubNode isn't a subnode of this.
211 : */
212 32 : int IndexOfSubNode(SmNode* pSubNode){
213 32 : sal_uInt16 nSize = GetNumSubNodes();
214 64 : for(sal_uInt16 i = 0; i < nSize; i++)
215 64 : if(pSubNode == GetSubNode(i))
216 32 : return i;
217 0 : return -1;
218 : }
219 : /** Set the token for this node */
220 17 : void SetToken(SmToken& token){
221 17 : aNodeToken = token;
222 17 : }
223 : protected:
224 : /** Sets parent on children of this node */
225 4517 : void ClaimPaternity(){
226 : SmNode* pNode;
227 4517 : sal_uInt16 nSize = GetNumSubNodes();
228 16246 : for (sal_uInt16 i = 0; i < nSize; i++)
229 11729 : if (NULL != (pNode = GetSubNode(i)))
230 9563 : pNode->SetParent((SmStructureNode*)this); //Cast is valid if we have children
231 4517 : }
232 : private:
233 : SmStructureNode* aParentNode;
234 : void DumpAsDot(std::ostream &out, OUString* label, int number, int& id, int parent) const;
235 : };
236 :
237 : ////////////////////////////////////////////////////////////////////////////////
238 :
239 : /** A simple auxiliary iterator class for SmNode
240 : *
241 : * Example of iteration over children of pMyNode:
242 : * \code
243 : * //Node to iterate over:
244 : * SmNode* pMyNode = 0;// A pointer from somewhere
245 : * //The iterator:
246 : * SmNodeIterator it(pMyNode);
247 : * //The iteration:
248 : * while(it.Next()) {
249 : * it->SetSelected(true);
250 : * }
251 : * \endcode
252 : */
253 : class SmNodeIterator{
254 : public:
255 20293 : SmNodeIterator(SmNode* node, bool bReverse = false){
256 20293 : pNode = node;
257 20293 : nSize = pNode->GetNumSubNodes();
258 20293 : nIndex = 0;
259 20293 : pChildNode = NULL;
260 20293 : bIsReverse = bReverse;
261 20293 : }
262 : /** Get the subnode or NULL if none */
263 64081 : SmNode* Next(){
264 140036 : while(!bIsReverse && nIndex < nSize){
265 55664 : if(NULL != (pChildNode = pNode->GetSubNode(nIndex++)))
266 43790 : return pChildNode;
267 : }
268 40582 : while(bIsReverse && nSize > 0){
269 4 : if(NULL != (pChildNode = pNode->GetSubNode((nSize--)-1)))
270 4 : return pChildNode;
271 : }
272 20287 : pChildNode = NULL;
273 20287 : return NULL;
274 : }
275 : /** Get the current child node, NULL if none */
276 100 : SmNode* Current(){
277 100 : return pChildNode;
278 : }
279 : /** Get the current child node, NULL if none */
280 86844 : SmNode* operator->(){
281 86844 : return pChildNode;
282 : }
283 : private:
284 : /** Current child */
285 : SmNode* pChildNode;
286 : /** Node whos children we're iterating over */
287 : SmNode* pNode;
288 : /** Size of the node */
289 : sal_uInt16 nSize;
290 : /** Current index in the node */
291 : sal_uInt16 nIndex;
292 : /** Move reverse */
293 : bool bIsReverse;
294 : };
295 :
296 : ////////////////////////////////////////////////////////////////////////////////
297 :
298 : /** Abstract baseclass for all composite node
299 : *
300 : * Subclasses of this class can have subnodes. Nodes that doesn't derivate from
301 : * this class does not have subnodes.
302 : */
303 : class SmStructureNode : public SmNode
304 : {
305 : SmNodeArray aSubNodes;
306 :
307 : protected:
308 4285 : SmStructureNode(SmNodeType eNodeType, const SmToken &rNodeToken)
309 4285 : : SmNode(eNodeType, rNodeToken)
310 4285 : {}
311 :
312 : public:
313 : SmStructureNode( const SmStructureNode &rNode );
314 : virtual ~SmStructureNode();
315 :
316 : virtual bool IsVisible() const;
317 :
318 : virtual sal_uInt16 GetNumSubNodes() const;
319 2084 : void SetNumSubNodes(sal_uInt16 nSize) { aSubNodes.resize(nSize); }
320 :
321 : using SmNode::GetSubNode;
322 : virtual SmNode * GetSubNode(sal_uInt16 nIndex);
323 : void SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThird = NULL);
324 : void SetSubNodes(const SmNodeArray &rNodeArray);
325 :
326 : SmStructureNode & operator = ( const SmStructureNode &rNode );
327 :
328 : virtual void GetAccessibleText( OUStringBuffer &rText ) const;
329 :
330 34 : void SetSubNode(size_t nIndex, SmNode* pNode)
331 : {
332 34 : size_t size = aSubNodes.size();
333 34 : if (size <= nIndex)
334 : {
335 : //Resize subnodes array
336 0 : aSubNodes.resize(nIndex + 1);
337 : //Set new slots to NULL
338 0 : for (size_t i = size; i < nIndex+1; i++)
339 0 : aSubNodes[i] = NULL;
340 : }
341 34 : aSubNodes[nIndex] = pNode;
342 34 : ClaimPaternity();
343 34 : }
344 : };
345 :
346 :
347 : ////////////////////////////////////////////////////////////////////////////////
348 :
349 : /** Abstract base class for all visible node
350 : *
351 : * Nodes that doesn't derivate from this class doesn't draw anything, but their
352 : * children.
353 : */
354 6349 : class SmVisibleNode : public SmNode
355 : {
356 : protected:
357 6364 : SmVisibleNode(SmNodeType eNodeType, const SmToken &rNodeToken)
358 6364 : : SmNode(eNodeType, rNodeToken)
359 6364 : {}
360 :
361 : public:
362 :
363 : virtual bool IsVisible() const;
364 : virtual sal_uInt16 GetNumSubNodes() const;
365 : using SmNode::GetSubNode;
366 : virtual SmNode * GetSubNode(sal_uInt16 nIndex);
367 : };
368 :
369 :
370 : ////////////////////////////////////////////////////////////////////////////////
371 :
372 :
373 275 : class SmGraphicNode : public SmVisibleNode
374 : {
375 : protected:
376 276 : SmGraphicNode(SmNodeType eNodeType, const SmToken &rNodeToken)
377 276 : : SmVisibleNode(eNodeType, rNodeToken)
378 276 : {}
379 :
380 : public:
381 :
382 : virtual void GetAccessibleText( OUStringBuffer &rText ) const;
383 : };
384 :
385 :
386 : ////////////////////////////////////////////////////////////////////////////////
387 :
388 : /** Draws a rectangle
389 : *
390 : * Used for drawing the line in the OVER and OVERSTRIKE commands.
391 : */
392 474 : class SmRectangleNode : public SmGraphicNode
393 : {
394 : Size aToSize;
395 :
396 : public:
397 238 : SmRectangleNode(const SmToken &rNodeToken)
398 238 : : SmGraphicNode(NRECTANGLE, rNodeToken)
399 238 : {}
400 :
401 : virtual void AdaptToX(const OutputDevice &rDev, sal_uLong nWidth);
402 : virtual void AdaptToY(const OutputDevice &rDev, sal_uLong nHeight);
403 :
404 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
405 :
406 : void CreateTextFromNode(String &rText);
407 : void Accept(SmVisitor* pVisitor);
408 : };
409 :
410 :
411 : ////////////////////////////////////////////////////////////////////////////////
412 :
413 : /** Polygon line node
414 : *
415 : * Used to draw the slash of the WIDESLASH command by SmBinDiagonalNode.
416 : */
417 68 : class SmPolyLineNode : public SmGraphicNode
418 : {
419 : Polygon aPoly;
420 : Size aToSize;
421 : long nWidth;
422 :
423 : public:
424 : SmPolyLineNode(const SmToken &rNodeToken);
425 :
426 60 : long GetWidth() const { return nWidth; }
427 : Size GetToSize() const { return aToSize; }
428 78 : Polygon &GetPolygon() { return aPoly; }
429 :
430 : virtual void AdaptToX(const OutputDevice &rDev, sal_uLong nWidth);
431 : virtual void AdaptToY(const OutputDevice &rDev, sal_uLong nHeight);
432 :
433 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
434 :
435 : void Accept(SmVisitor* pVisitor);
436 : };
437 :
438 :
439 : ////////////////////////////////////////////////////////////////////////////////
440 :
441 : /** Text node
442 : *
443 : * @remarks This class also serves as baseclass for all nodes that contains text.
444 : */
445 9360 : class SmTextNode : public SmVisibleNode
446 : {
447 : OUString aText;
448 : sal_uInt16 nFontDesc;
449 : /** Index within text where the selection starts
450 : * @remarks Only valid if SmNode::IsSelected() is true
451 : */
452 : sal_Int32 nSelectionStart;
453 : /** Index within text where the selection ends
454 : * @remarks Only valid if SmNode::IsSelected() is true
455 : */
456 : sal_Int32 nSelectionEnd;
457 :
458 : protected:
459 : SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 nFontDescP );
460 :
461 : public:
462 : SmTextNode(const SmToken &rNodeToken, sal_uInt16 nFontDescP );
463 :
464 8054 : sal_uInt16 GetFontDesc() const { return nFontDesc; }
465 2785 : void SetText(const OUString &rText) { aText = rText; }
466 87259 : const OUString & GetText() const { return aText; }
467 : /** Change the text of this node, including the underlying token */
468 4 : void ChangeText(const OUString &rText) {
469 4 : aText = rText;
470 4 : SmToken token = GetToken();
471 4 : token.aText = rText;
472 4 : SetToken(token); //TODO: Merge this with AdjustFontDesc for better performance
473 4 : AdjustFontDesc();
474 4 : }
475 : /** Try to guess the correct FontDesc, used during visual editing */
476 : void AdjustFontDesc();
477 : /** Index within GetText() where the selection starts
478 : * @remarks Only valid of SmNode::IsSelected() is true
479 : */
480 2 : sal_Int32 GetSelectionStart() const {return nSelectionStart;}
481 : /** Index within GetText() where the selection end
482 : * @remarks Only valid of SmNode::IsSelected() is true
483 : */
484 2 : sal_Int32 GetSelectionEnd() const {return nSelectionEnd;}
485 : /** Set the index within GetText() where the selection starts */
486 42 : void SetSelectionStart(sal_Int32 index) {nSelectionStart = index;}
487 : /** Set the index within GetText() where the selection end */
488 42 : void SetSelectionEnd(sal_Int32 index) {nSelectionEnd = index;}
489 :
490 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
491 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
492 : virtual void CreateTextFromNode(String &rText);
493 :
494 : virtual void GetAccessibleText( OUStringBuffer &rText ) const;
495 : void Accept(SmVisitor* pVisitor);
496 : /**
497 : Converts the character from StarMath's private area symbols to a matching Unicode
498 : character, if necessary. To be used when converting GetText() to a normal text.
499 : */
500 : static sal_Unicode ConvertSymbolToUnicode(sal_Unicode nIn);
501 : };
502 :
503 :
504 : ////////////////////////////////////////////////////////////////////////////////
505 :
506 : /** Special node for user defined characters
507 : *
508 : * Node used for pre- and user-defined characters from:
509 : * officecfg/registry/data/org/openoffice/Office/Math.xcu
510 : *
511 : * This is just single characters, I think.
512 : */
513 2918 : class SmSpecialNode : public SmTextNode
514 : {
515 : bool bIsFromGreekSymbolSet;
516 :
517 : protected:
518 : SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc);
519 :
520 : public:
521 : SmSpecialNode(const SmToken &rNodeToken);
522 :
523 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
524 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
525 :
526 : void Accept(SmVisitor* pVisitor);
527 : };
528 :
529 :
530 : ////////////////////////////////////////////////////////////////////////////////
531 :
532 : /** Glyph node for custom operators
533 : *
534 : * This node is used with commands: oper, uoper and boper.
535 : * E.g. in "A boper op B", "op" will be an instance of SmGlyphSpecialNode.
536 : * "boper" simply inteprets "op", the following token, as an binary operator.
537 : * The command "uoper" interprets the following token as unary operator.
538 : * For these commands an instance of SmGlyphSpecialNode is used for the
539 : * operator token, following the command.
540 : */
541 0 : class SmGlyphSpecialNode : public SmSpecialNode
542 : {
543 : public:
544 0 : SmGlyphSpecialNode(const SmToken &rNodeToken)
545 0 : : SmSpecialNode(NGLYPH_SPECIAL, rNodeToken, FNT_MATH)
546 0 : {}
547 :
548 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
549 : void Accept(SmVisitor* pVisitor);
550 : };
551 :
552 :
553 : ////////////////////////////////////////////////////////////////////////////////
554 :
555 : /** Math symbol node
556 : *
557 : * Use for math symbols such as plus, minus and integrale in the INT command.
558 : */
559 4654 : class SmMathSymbolNode : public SmSpecialNode
560 : {
561 : protected:
562 665 : SmMathSymbolNode(SmNodeType eNodeType, const SmToken &rNodeToken)
563 665 : : SmSpecialNode(eNodeType, rNodeToken, FNT_MATH)
564 : {
565 665 : sal_Unicode cChar = GetToken().cMathChar;
566 665 : if ((sal_Unicode) '\0' != cChar)
567 659 : SetText(OUString(cChar));
568 665 : }
569 :
570 : public:
571 : SmMathSymbolNode(const SmToken &rNodeToken);
572 :
573 : virtual void AdaptToX(const OutputDevice &rDev, sal_uLong nWidth);
574 : virtual void AdaptToY(const OutputDevice &rDev, sal_uLong nHeight);
575 :
576 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
577 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
578 : void CreateTextFromNode(String &rText);
579 : void Accept(SmVisitor* pVisitor);
580 : };
581 :
582 : ////////////////////////////////////////////////////////////////////////////////
583 :
584 : /** Math Identifier
585 : *
586 : * This behaves essentially the same as SmMathSymbolNode and is only used to
587 : * represent math symbols that should be exported as <mi> elements rather than
588 : * <mo> elements.
589 : */
590 52 : class SmMathIdentifierNode : public SmMathSymbolNode
591 : {
592 : public:
593 26 : SmMathIdentifierNode(const SmToken &rNodeToken)
594 26 : : SmMathSymbolNode(NMATHIDENT, rNodeToken) {}
595 : };
596 :
597 : ////////////////////////////////////////////////////////////////////////////////
598 :
599 : /** Root symbol node
600 : *
601 : * Root symbol node used by SmRootNode to create the root symbol, in front of
602 : * the line with the line above. I don't think this node should be used for
603 : * anything else.
604 : */
605 80 : class SmRootSymbolNode : public SmMathSymbolNode
606 : {
607 : sal_uLong nBodyWidth; // width of body (argument) of root sign
608 :
609 : public:
610 40 : SmRootSymbolNode(const SmToken &rNodeToken)
611 40 : : SmMathSymbolNode(NROOTSYMBOL, rNodeToken)
612 40 : {}
613 :
614 216 : sal_uLong GetBodyWidth() const {return nBodyWidth;};
615 : virtual void AdaptToX(const OutputDevice &rDev, sal_uLong nHeight);
616 : virtual void AdaptToY(const OutputDevice &rDev, sal_uLong nHeight);
617 :
618 : void Accept(SmVisitor* pVisitor);
619 : };
620 :
621 :
622 : ////////////////////////////////////////////////////////////////////////////////
623 :
624 : /** Place node
625 : *
626 : * Used to create the <?> command, that denotes place where something can be
627 : * written.
628 : * It is drawn as a square with a shadow.
629 : */
630 1184 : class SmPlaceNode : public SmMathSymbolNode
631 : {
632 : public:
633 590 : SmPlaceNode(const SmToken &rNodeToken)
634 590 : : SmMathSymbolNode(NPLACE, rNodeToken)
635 : {
636 590 : }
637 2 : SmPlaceNode() : SmMathSymbolNode(NPLACE, SmToken(TPLACE, MS_PLACE, "<?>")) {};
638 :
639 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
640 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
641 : void Accept(SmVisitor* pVisitor);
642 : };
643 :
644 :
645 : ////////////////////////////////////////////////////////////////////////////////
646 :
647 : /** Error node, for parsing errors
648 : *
649 : * This node is used for parsing errors and draws an questionmark turned upside
650 : * down (inverted question mark).
651 : */
652 8 : class SmErrorNode : public SmMathSymbolNode
653 : {
654 : public:
655 7 : SmErrorNode(SmParseError /*eError*/, const SmToken &rNodeToken)
656 7 : : SmMathSymbolNode(NERROR, rNodeToken)
657 : {
658 7 : SetText(OUString(MS_ERROR));
659 7 : }
660 :
661 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
662 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
663 : void Accept(SmVisitor* pVisitor);
664 : };
665 :
666 :
667 : ////////////////////////////////////////////////////////////////////////////////
668 :
669 : /** Table node
670 : *
671 : * This is the root node for the formula tree. This node is also used for the
672 : * STACK and BINOM commands. When used for root node, its
673 : * children are instances of SmLineNode, and in some obscure cases the a child
674 : * can be an instance of SmExpressionNode, mainly when errors occur.
675 : */
676 1114 : class SmTableNode : public SmStructureNode
677 : {
678 : long nFormulaBaseline;
679 : public:
680 565 : SmTableNode(const SmToken &rNodeToken)
681 565 : : SmStructureNode(NTABLE, rNodeToken)
682 565 : {}
683 :
684 : using SmNode::GetLeftMost;
685 : virtual SmNode * GetLeftMost();
686 :
687 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
688 : virtual long GetFormulaBaseline() const;
689 :
690 : void Accept(SmVisitor* pVisitor);
691 : };
692 :
693 :
694 : ////////////////////////////////////////////////////////////////////////////////
695 :
696 : /** A line
697 : *
698 : * Used as child of SmTableNode when the SmTableNode is the root node of the
699 : * formula tree.
700 : */
701 1481 : class SmLineNode : public SmStructureNode
702 : {
703 : bool bUseExtraSpaces;
704 :
705 : protected:
706 523 : SmLineNode(SmNodeType eNodeType, const SmToken &rNodeToken)
707 523 : : SmStructureNode(eNodeType, rNodeToken)
708 : {
709 523 : bUseExtraSpaces = true;
710 523 : }
711 :
712 : public:
713 492 : SmLineNode(const SmToken &rNodeToken)
714 492 : : SmStructureNode(NLINE, rNodeToken)
715 : {
716 492 : bUseExtraSpaces = true;
717 492 : }
718 :
719 471 : void SetUseExtraSpaces(bool bVal) { bUseExtraSpaces = bVal; }
720 944 : bool IsUseExtraSpaces() const { return bUseExtraSpaces; };
721 :
722 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
723 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
724 : void Accept(SmVisitor* pVisitor);
725 : };
726 :
727 :
728 : ////////////////////////////////////////////////////////////////////////////////
729 :
730 : /** Expression node
731 : *
732 : * Used whenever you have an expression such as "A OVER {B + C}", here there is
733 : * an expression node that allows "B + C" to be the denominator of the
734 : * SmBinVerNode, that the OVER command creates.
735 : */
736 1026 : class SmExpressionNode : public SmLineNode
737 : {
738 : public:
739 523 : SmExpressionNode(const SmToken &rNodeToken)
740 523 : : SmLineNode(NEXPRESSION, rNodeToken)
741 523 : {}
742 :
743 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
744 : void CreateTextFromNode(String &rText);
745 : void Accept(SmVisitor* pVisitor);
746 : };
747 :
748 :
749 : ////////////////////////////////////////////////////////////////////////////////
750 :
751 : /** Unary horizontical node
752 : *
753 : * The same as SmBinHorNode except this is for unary operators.
754 : */
755 252 : class SmUnHorNode : public SmStructureNode
756 : {
757 : public:
758 126 : SmUnHorNode(const SmToken &rNodeToken)
759 126 : : SmStructureNode(NUNHOR, rNodeToken)
760 : {
761 126 : SetNumSubNodes(2);
762 126 : }
763 :
764 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
765 : void Accept(SmVisitor* pVisitor);
766 : };
767 :
768 :
769 : ////////////////////////////////////////////////////////////////////////////////
770 :
771 : /** Root node
772 : *
773 : * Used for create square roots and other roots, example:
774 : * \f$ \sqrt[\mbox{[Argument]}]{\mbox{[Body]}} \f$.
775 : *
776 : * Children:<BR>
777 : * 0: Argument (optional)<BR>
778 : * 1: Symbol (instance of SmRootSymbolNode)<BR>
779 : * 2: Body<BR>
780 : * Where argument is optional and may be NULL.
781 : */
782 80 : class SmRootNode : public SmStructureNode
783 : {
784 : protected:
785 : void GetHeightVerOffset(const SmRect &rRect,
786 : long &rHeight, long &rVerOffset) const;
787 : Point GetExtraPos(const SmRect &rRootSymbol, const SmRect &rExtra) const;
788 :
789 : public:
790 40 : SmRootNode(const SmToken &rNodeToken)
791 40 : : SmStructureNode(NROOT, rNodeToken)
792 : {
793 40 : SetNumSubNodes(3);
794 40 : }
795 :
796 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
797 : void CreateTextFromNode(String &rText);
798 : void Accept(SmVisitor* pVisitor);
799 :
800 : SmNode* Argument();
801 : const SmNode* Argument() const;
802 : SmRootSymbolNode* Symbol();
803 : const SmRootSymbolNode* Symbol() const;
804 : SmNode* Body();
805 : const SmNode* Body() const;
806 : };
807 :
808 :
809 : ////////////////////////////////////////////////////////////////////////////////
810 :
811 : /** Binary horizontial node
812 : *
813 : * This node is used for binary operators. In a formula such as "A + B".
814 : *
815 : * Children:<BR>
816 : * 0: Left operand<BR>
817 : * 1: Binary operator<BR>
818 : * 2: Right operand<BR>
819 : *
820 : * None of the children may be NULL.
821 : */
822 1434 : class SmBinHorNode : public SmStructureNode
823 : {
824 : public:
825 718 : SmBinHorNode(const SmToken &rNodeToken)
826 718 : : SmStructureNode(NBINHOR, rNodeToken)
827 : {
828 718 : SetNumSubNodes(3);
829 718 : }
830 :
831 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
832 : void Accept(SmVisitor* pVisitor);
833 :
834 : SmMathSymbolNode* Symbol();
835 : const SmMathSymbolNode* Symbol() const;
836 : SmNode* LeftOperand();
837 : const SmNode* LeftOperand() const;
838 : SmNode* RightOperand();
839 : const SmNode* RightOperand() const;
840 : };
841 :
842 :
843 : ////////////////////////////////////////////////////////////////////////////////
844 :
845 : /** Binary horizontical node
846 : *
847 : * This node is used for creating the OVER command, consider the formula:
848 : * "numerator OVER denominator", which looks like
849 : * \f$ \frac{\mbox{numerator}}{\mbox{denominator}} \f$
850 : *
851 : * Children:<BR>
852 : * 0: Numerator<BR>
853 : * 1: Line (instance of SmRectangleNode)<BR>
854 : * 2: Denominator<BR>
855 : * None of the children may be NULL.
856 : */
857 414 : class SmBinVerNode : public SmStructureNode
858 : {
859 : public:
860 208 : SmBinVerNode(const SmToken &rNodeToken)
861 208 : : SmStructureNode(NBINVER, rNodeToken)
862 : {
863 208 : SetNumSubNodes(3);
864 208 : }
865 :
866 : using SmNode::GetLeftMost;
867 : virtual SmNode * GetLeftMost();
868 :
869 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
870 : void CreateTextFromNode(String &rText);
871 : void Accept(SmVisitor* pVisitor);
872 : };
873 :
874 :
875 : ////////////////////////////////////////////////////////////////////////////////
876 :
877 : /** Binary diagonal node
878 : *
879 : * Used for implementing the WIDESLASH command, example: "A WIDESLASH B".
880 : *
881 : * Children:<BR>
882 : * 0: Left operand<BR>
883 : * 1: right operand<BR>
884 : * 2: Line (instance of SmPolyLineNode).<BR>
885 : * None of the children may be NULL.
886 : */
887 68 : class SmBinDiagonalNode : public SmStructureNode
888 : {
889 : bool bAscending;
890 :
891 : void GetOperPosSize(Point &rPos, Size &rSize,
892 : const Point &rDiagPoint, double fAngleDeg) const;
893 :
894 : public:
895 : SmBinDiagonalNode(const SmToken &rNodeToken);
896 :
897 136 : bool IsAscending() const { return bAscending; }
898 34 : void SetAscending(bool bVal) { bAscending = bVal; }
899 :
900 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
901 : void Accept(SmVisitor* pVisitor);
902 : };
903 :
904 :
905 : ////////////////////////////////////////////////////////////////////////////////
906 :
907 :
908 : /** Enum used to index sub-/supscripts in the 'aSubNodes' array
909 : * in 'SmSubSupNode'
910 : *
911 : * See graphic for positions at char:
912 : *
913 : * \code
914 : * CSUP
915 : *
916 : * LSUP H H RSUP
917 : * H H
918 : * HHHH
919 : * H H
920 : * LSUB H H RSUB
921 : *
922 : * CSUB
923 : * \endcode
924 : */
925 : enum SmSubSup
926 : { CSUB, CSUP, RSUB, RSUP, LSUB, LSUP
927 : };
928 :
929 : /** numbers of entries in the above enum (that is: the number of possible
930 : * sub-/supscripts)
931 : */
932 : #define SUBSUP_NUM_ENTRIES 6
933 :
934 : /** Super- and subscript node
935 : *
936 : * Used for creating super- and subscripts for commands such as:
937 : * "^", "_", "lsup", "lsub", "csup" and "csub".
938 : * Example: "A^2" which looks like: \f$ A^2 \f$
939 : *
940 : * This node is also used for creating limits on SmOperNode, when
941 : * "FROM" and "TO" commands are used with "INT", "SUM" or similar.
942 : *
943 : * Children of this node can be enumerated using the SmSubSup enum.
944 : * Please note that children may be NULL, except for the body.
945 : * It is recommended that you access children using GetBody() and
946 : * GetSubSup().
947 : */
948 876 : class SmSubSupNode : public SmStructureNode
949 : {
950 : bool bUseLimits;
951 :
952 : public:
953 438 : SmSubSupNode(const SmToken &rNodeToken)
954 438 : : SmStructureNode(NSUBSUP, rNodeToken)
955 : {
956 438 : SetNumSubNodes(1 + SUBSUP_NUM_ENTRIES);
957 438 : bUseLimits = false;
958 438 : }
959 :
960 : /** Get body (Not NULL) */
961 631 : SmNode * GetBody() { return GetSubNode(0); }
962 : /** Get body (Not NULL) */
963 67 : const SmNode * GetBody() const
964 : {
965 67 : return ((SmSubSupNode *) this)->GetBody();
966 : }
967 :
968 437 : void SetUseLimits(bool bVal) { bUseLimits = bVal; }
969 10 : bool IsUseLimits() const { return bUseLimits; };
970 :
971 : /** Get super- or subscript
972 : * @remarks this method may return NULL.
973 : */
974 3158 : SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode( sal::static_int_cast< sal_uInt16 >(1 + eSubSup) ); };
975 463 : const SmNode * GetSubSup(SmSubSup eSubSup) const { return const_cast< SmSubSupNode* >( this )->GetSubSup( eSubSup ); }
976 :
977 : /** Set the body */
978 1 : void SetBody(SmNode* pBody) { SetSubNode(0, pBody); }
979 1 : void SetSubSup(SmSubSup eSubSup, SmNode* pScript) { SetSubNode( 1 + eSubSup, pScript); }
980 :
981 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
982 : void CreateTextFromNode(String &rText);
983 : void Accept(SmVisitor* pVisitor);
984 :
985 : };
986 :
987 :
988 : ////////////////////////////////////////////////////////////////////////////////
989 :
990 : /** Node for brace construction
991 : *
992 : * Used for "lbrace [body] rbrace" and similar constructions.
993 : * Should look like \f$ \{\mbox{[body]}\} \f$
994 : *
995 : * Children:<BR>
996 : * 0: Opening brace<BR>
997 : * 1: Body (usually SmBracebodyNode)<BR>
998 : * 2: Closing brace<BR>
999 : * None of the children can be NULL.
1000 : *
1001 : * Note that child 1 (Body) is usually SmBracebodyNode, but it can also be e.g. SmExpressionNode.
1002 : */
1003 708 : class SmBraceNode : public SmStructureNode
1004 : {
1005 : public:
1006 354 : SmBraceNode(const SmToken &rNodeToken)
1007 354 : : SmStructureNode(NBRACE, rNodeToken)
1008 : {
1009 354 : SetNumSubNodes(3);
1010 354 : }
1011 :
1012 : SmMathSymbolNode* OpeningBrace();
1013 : const SmMathSymbolNode* OpeningBrace() const;
1014 : SmNode* Body();
1015 : const SmNode* Body() const;
1016 : SmMathSymbolNode* ClosingBrace();
1017 : const SmMathSymbolNode* ClosingBrace() const;
1018 :
1019 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1020 : void CreateTextFromNode(String &rText);
1021 : void Accept(SmVisitor* pVisitor);
1022 : };
1023 :
1024 :
1025 : ////////////////////////////////////////////////////////////////////////////////
1026 :
1027 : /** Body of an SmBraceNode
1028 : *
1029 : * This usually only has one child an SmExpressionNode, however, it can also
1030 : * have other children.
1031 : * Consider the formula "lbrace [body1] mline [body2] rbrace", looks like:
1032 : * \f$ \{\mbox{[body1] | [body2]}\} \f$.
1033 : * In this case SmBracebodyNode will have three children, "[body1]", "|" and
1034 : * [body2].
1035 : */
1036 700 : class SmBracebodyNode : public SmStructureNode
1037 : {
1038 : long nBodyHeight;
1039 :
1040 : public:
1041 : inline SmBracebodyNode(const SmToken &rNodeToken);
1042 :
1043 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1044 246 : long GetBodyHeight() const { return nBodyHeight; }
1045 : void Accept(SmVisitor* pVisitor);
1046 : };
1047 :
1048 :
1049 350 : inline SmBracebodyNode::SmBracebodyNode(const SmToken &rNodeToken) :
1050 350 : SmStructureNode(NBRACEBODY, rNodeToken)
1051 : {
1052 350 : nBodyHeight = 0;
1053 350 : }
1054 :
1055 :
1056 : ////////////////////////////////////////////////////////////////////////////////
1057 :
1058 : /** Node for vertical brace construction
1059 : *
1060 : * Used to implement commands "[body] underbrace [script]" and
1061 : * "[body] overbrace [script]".
1062 : * Underbrace should look like this \f$ \underbrace{\mbox{body}}_{\mbox{script}}\f$.
1063 : *
1064 : * Children:<BR>
1065 : * 0: body<BR>
1066 : * 1: brace<BR>
1067 : * 2: script<BR>
1068 : * (None of these children are optional, e.g. they must all be not NULL).
1069 : */
1070 56 : class SmVerticalBraceNode : public SmStructureNode
1071 : {
1072 : public:
1073 : inline SmVerticalBraceNode(const SmToken &rNodeToken);
1074 :
1075 : SmNode* Body();
1076 : const SmNode* Body() const;
1077 : SmMathSymbolNode* Brace();
1078 : const SmMathSymbolNode* Brace() const;
1079 : SmNode* Script();
1080 : const SmNode* Script() const;
1081 :
1082 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1083 : void Accept(SmVisitor* pVisitor);
1084 : };
1085 :
1086 :
1087 28 : inline SmVerticalBraceNode::SmVerticalBraceNode(const SmToken &rNodeToken) :
1088 28 : SmStructureNode(NVERTICAL_BRACE, rNodeToken)
1089 : {
1090 28 : SetNumSubNodes(3);
1091 28 : }
1092 :
1093 :
1094 : ////////////////////////////////////////////////////////////////////////////////
1095 :
1096 :
1097 : /** Operation Node
1098 : *
1099 : * Used for commands like SUM, INT and similar.
1100 : *
1101 : * Children:<BR>
1102 : * 0: Operation (instance of SmMathSymbolNode or SmSubSupNode)<BR>
1103 : * 1: Body<BR>
1104 : * None of the children may be NULL.
1105 : *
1106 : */
1107 276 : class SmOperNode : public SmStructureNode
1108 : {
1109 : public:
1110 138 : SmOperNode(const SmToken &rNodeToken)
1111 138 : : SmStructureNode(NOPER, rNodeToken)
1112 : {
1113 138 : SetNumSubNodes(2);
1114 138 : }
1115 :
1116 : SmNode * GetSymbol();
1117 2 : const SmNode * GetSymbol() const
1118 : {
1119 2 : return ((SmOperNode *) this)->GetSymbol();
1120 : }
1121 :
1122 : long CalcSymbolHeight(const SmNode &rSymbol, const SmFormat &rFormat) const;
1123 :
1124 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1125 : void Accept(SmVisitor* pVisitor);
1126 : };
1127 :
1128 :
1129 : ////////////////////////////////////////////////////////////////////////////////
1130 :
1131 : /** Node used for alignment
1132 : */
1133 28 : class SmAlignNode : public SmStructureNode
1134 : {
1135 : public:
1136 14 : SmAlignNode(const SmToken &rNodeToken)
1137 14 : : SmStructureNode(NALIGN, rNodeToken)
1138 14 : {}
1139 :
1140 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1141 : void Accept(SmVisitor* pVisitor);
1142 : };
1143 :
1144 :
1145 : ////////////////////////////////////////////////////////////////////////////////
1146 :
1147 : /** Attribute node
1148 : *
1149 : * Used to give an attribute to another node. Used for commands such as:
1150 : * UNDERLINE, OVERLINE, OVERSTRIKE, WIDEVEC, WIDEHAT and WIDETILDE.
1151 : *
1152 : * Children:<BR>
1153 : * 0: Attribute<BR>
1154 : * 1: Body<BR>
1155 : * None of these may be NULL.
1156 : */
1157 412 : class SmAttributNode : public SmStructureNode
1158 : {
1159 : public:
1160 206 : SmAttributNode(const SmToken &rNodeToken)
1161 206 : : SmStructureNode(NATTRIBUT, rNodeToken)
1162 206 : {}
1163 :
1164 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1165 : void CreateTextFromNode(String &rText);
1166 : void Accept(SmVisitor* pVisitor);
1167 :
1168 : SmNode* Attribute();
1169 : const SmNode* Attribute() const;
1170 : SmNode* Body();
1171 : const SmNode* Body() const;
1172 : };
1173 :
1174 :
1175 : ////////////////////////////////////////////////////////////////////////////////
1176 :
1177 : /** Font node
1178 : *
1179 : * Used to change the font of it's children.
1180 : */
1181 68 : class SmFontNode : public SmStructureNode
1182 : {
1183 : sal_uInt16 nSizeType;
1184 : Fraction aFontSize;
1185 :
1186 : public:
1187 35 : SmFontNode(const SmToken &rNodeToken)
1188 35 : : SmStructureNode(NFONT, rNodeToken)
1189 : {
1190 35 : nSizeType = FNTSIZ_MULTIPLY;
1191 35 : aFontSize = Fraction(1L);
1192 35 : }
1193 :
1194 : void SetSizeParameter(const Fraction &rValue, sal_uInt16 nType);
1195 2 : const Fraction & GetSizeParameter() const {return aFontSize;}
1196 2 : const sal_uInt16& GetSizeType() const {return nSizeType;}
1197 :
1198 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
1199 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1200 : void CreateTextFromNode(String &rText);
1201 : void Accept(SmVisitor* pVisitor);
1202 : };
1203 :
1204 :
1205 : ////////////////////////////////////////////////////////////////////////////////
1206 :
1207 : /** Matrix node
1208 : *
1209 : * Used to implement the MATRIX command, example:
1210 : * "matrix{ 1 # 2 ## 3 # 4}".
1211 : */
1212 32 : class SmMatrixNode : public SmStructureNode
1213 : {
1214 : sal_uInt16 nNumRows,
1215 : nNumCols;
1216 :
1217 : public:
1218 16 : SmMatrixNode(const SmToken &rNodeToken)
1219 16 : : SmStructureNode(NMATRIX, rNodeToken)
1220 : {
1221 16 : nNumRows = nNumCols = 0;
1222 16 : }
1223 :
1224 50 : sal_uInt16 GetNumRows() const {return nNumRows;}
1225 136 : sal_uInt16 GetNumCols() const {return nNumCols;}
1226 : void SetRowCol(sal_uInt16 nMatrixRows, sal_uInt16 nMatrixCols);
1227 :
1228 : using SmNode::GetLeftMost;
1229 : virtual SmNode * GetLeftMost();
1230 :
1231 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1232 : void CreateTextFromNode(String &rText);
1233 : void Accept(SmVisitor* pVisitor);
1234 : };
1235 :
1236 :
1237 : ////////////////////////////////////////////////////////////////////////////////
1238 :
1239 : /** Node for whitespace
1240 : *
1241 : * Used to implement the "~" command. This node is just a blank space.
1242 : */
1243 8 : class SmBlankNode : public SmGraphicNode
1244 : {
1245 : sal_uInt16 nNum;
1246 :
1247 : public:
1248 4 : SmBlankNode(const SmToken &rNodeToken)
1249 4 : : SmGraphicNode(NBLANK, rNodeToken)
1250 : {
1251 4 : nNum = 0;
1252 4 : }
1253 :
1254 : void IncreaseBy(const SmToken &rToken);
1255 0 : void Clear() { nNum = 0; }
1256 0 : sal_uInt16 GetBlankNum() const { return nNum; }
1257 0 : void SetBlankNum(sal_uInt16 nNumber) { nNum = nNumber; }
1258 :
1259 : virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
1260 : virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
1261 : void Accept(SmVisitor* pVisitor);
1262 : };
1263 :
1264 :
1265 : ////////////////////////////////////////////////////////////////////////////////
1266 :
1267 :
1268 6 : inline SmNode* SmRootNode::Argument()
1269 : {
1270 : OSL_ASSERT( GetNumSubNodes() > 0 );
1271 6 : return GetSubNode( 0 );
1272 : }
1273 6 : inline const SmNode* SmRootNode::Argument() const
1274 : {
1275 6 : return const_cast< SmRootNode* >( this )->Argument();
1276 : }
1277 : inline SmRootSymbolNode* SmRootNode::Symbol()
1278 : {
1279 : OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NROOTSYMBOL );
1280 : return static_cast< SmRootSymbolNode* >( GetSubNode( 1 ));
1281 : }
1282 : inline const SmRootSymbolNode* SmRootNode::Symbol() const
1283 : {
1284 : return const_cast< SmRootNode* >( this )->Symbol();
1285 : }
1286 6 : inline SmNode* SmRootNode::Body()
1287 : {
1288 : OSL_ASSERT( GetNumSubNodes() > 2 );
1289 6 : return GetSubNode( 2 );
1290 : }
1291 6 : inline const SmNode* SmRootNode::Body() const
1292 : {
1293 6 : return const_cast< SmRootNode* >( this )->Body();
1294 : }
1295 :
1296 380 : inline SmMathSymbolNode* SmBinHorNode::Symbol()
1297 : {
1298 : OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NMATH );
1299 380 : return static_cast< SmMathSymbolNode* >( GetSubNode( 1 ));
1300 : }
1301 380 : inline const SmMathSymbolNode* SmBinHorNode::Symbol() const
1302 : {
1303 380 : return const_cast< SmBinHorNode* >( this )->Symbol();
1304 : }
1305 300 : inline SmNode* SmBinHorNode::LeftOperand()
1306 : {
1307 : OSL_ASSERT( GetNumSubNodes() > 0 );
1308 300 : return GetSubNode( 0 );
1309 : }
1310 300 : inline const SmNode* SmBinHorNode::LeftOperand() const
1311 : {
1312 300 : return const_cast< SmBinHorNode* >( this )->LeftOperand();
1313 : }
1314 300 : inline SmNode* SmBinHorNode::RightOperand()
1315 : {
1316 : OSL_ASSERT( GetNumSubNodes() > 2 );
1317 300 : return GetSubNode( 2 );
1318 : }
1319 300 : inline const SmNode* SmBinHorNode::RightOperand() const
1320 : {
1321 300 : return const_cast< SmBinHorNode* >( this )->RightOperand();
1322 : }
1323 :
1324 54 : inline SmNode* SmAttributNode::Attribute()
1325 : {
1326 : OSL_ASSERT( GetNumSubNodes() > 0 );
1327 54 : return GetSubNode( 0 );
1328 : }
1329 54 : inline const SmNode* SmAttributNode::Attribute() const
1330 : {
1331 54 : return const_cast< SmAttributNode* >( this )->Attribute();
1332 : }
1333 28 : inline SmNode* SmAttributNode::Body()
1334 : {
1335 : OSL_ASSERT( GetNumSubNodes() > 1 );
1336 28 : return GetSubNode( 1 );
1337 : }
1338 28 : inline const SmNode* SmAttributNode::Body() const
1339 : {
1340 28 : return const_cast< SmAttributNode* >( this )->Body();
1341 : }
1342 :
1343 45 : inline SmMathSymbolNode* SmBraceNode::OpeningBrace()
1344 : {
1345 : OSL_ASSERT( GetNumSubNodes() > 0 && GetSubNode( 0 )->GetType() == NMATH );
1346 45 : return static_cast< SmMathSymbolNode* >( GetSubNode( 0 ));
1347 : }
1348 45 : inline const SmMathSymbolNode* SmBraceNode::OpeningBrace() const
1349 : {
1350 45 : return const_cast< SmBraceNode* >( this )->OpeningBrace();
1351 : }
1352 90 : inline SmNode* SmBraceNode::Body()
1353 : {
1354 : OSL_ASSERT( GetNumSubNodes() > 1 );
1355 90 : return GetSubNode( 1 );
1356 : }
1357 90 : inline const SmNode* SmBraceNode::Body() const
1358 : {
1359 90 : return const_cast< SmBraceNode* >( this )->Body();
1360 : }
1361 45 : inline SmMathSymbolNode* SmBraceNode::ClosingBrace()
1362 : {
1363 : OSL_ASSERT( GetNumSubNodes() > 2 && GetSubNode( 2 )->GetType() == NMATH );
1364 45 : return static_cast< SmMathSymbolNode* >( GetSubNode( 2 ));
1365 : }
1366 45 : inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const
1367 : {
1368 45 : return const_cast< SmBraceNode* >( this )->ClosingBrace();
1369 : }
1370 :
1371 4 : inline SmNode* SmVerticalBraceNode::Body()
1372 : {
1373 : OSL_ASSERT( GetNumSubNodes() > 0 );
1374 4 : return GetSubNode( 0 );
1375 : }
1376 4 : inline const SmNode* SmVerticalBraceNode::Body() const
1377 : {
1378 4 : return const_cast< SmVerticalBraceNode* >( this )->Body();
1379 : }
1380 4 : inline SmMathSymbolNode* SmVerticalBraceNode::Brace()
1381 : {
1382 : OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NMATH );
1383 4 : return static_cast< SmMathSymbolNode* >( GetSubNode( 1 ));
1384 : }
1385 4 : inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const
1386 : {
1387 4 : return const_cast< SmVerticalBraceNode* >( this )->Brace();
1388 : }
1389 4 : inline SmNode* SmVerticalBraceNode::Script()
1390 : {
1391 : OSL_ASSERT( GetNumSubNodes() > 2 );
1392 4 : return GetSubNode( 2 );
1393 : }
1394 4 : inline const SmNode* SmVerticalBraceNode::Script() const
1395 : {
1396 4 : return const_cast< SmVerticalBraceNode* >( this )->Script();
1397 : }
1398 :
1399 : #endif
1400 :
1401 :
1402 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|