LCOV - code coverage report
Current view: top level - starmath/inc - node.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 206 285 72.3 %
Date: 2012-08-25 Functions: 120 172 69.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50 144 34.7 %

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

Generated by: LCOV version 1.10