LCOV - code coverage report
Current view: top level - starmath/inc - visitors.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 37 42 88.1 %
Date: 2014-11-03 Functions: 15 28 53.6 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_STARMATH_INC_VISITORS_HXX
      10             : #define INCLUDED_STARMATH_INC_VISITORS_HXX
      11             : 
      12             : #include "node.hxx"
      13             : #include "caret.hxx"
      14             : 
      15             : /** Base class for visitors that visits a tree of SmNodes
      16             :  * @remarks all methods have been left abstract to ensure that implementers
      17             :  * don't forget to implement one.
      18             :  */
      19       10598 : class SmVisitor
      20             : {
      21             : public:
      22             :     virtual void Visit( SmTableNode* pNode ) = 0;
      23             :     virtual void Visit( SmBraceNode* pNode ) = 0;
      24             :     virtual void Visit( SmBracebodyNode* pNode ) = 0;
      25             :     virtual void Visit( SmOperNode* pNode ) = 0;
      26             :     virtual void Visit( SmAlignNode* pNode ) = 0;
      27             :     virtual void Visit( SmAttributNode* pNode ) = 0;
      28             :     virtual void Visit( SmFontNode* pNode ) = 0;
      29             :     virtual void Visit( SmUnHorNode* pNode ) = 0;
      30             :     virtual void Visit( SmBinHorNode* pNode ) = 0;
      31             :     virtual void Visit( SmBinVerNode* pNode ) = 0;
      32             :     virtual void Visit( SmBinDiagonalNode* pNode ) = 0;
      33             :     virtual void Visit( SmSubSupNode* pNode ) = 0;
      34             :     virtual void Visit( SmMatrixNode* pNode ) = 0;
      35             :     virtual void Visit( SmPlaceNode* pNode ) = 0;
      36             :     virtual void Visit( SmTextNode* pNode ) = 0;
      37             :     virtual void Visit( SmSpecialNode* pNode ) = 0;
      38             :     virtual void Visit( SmGlyphSpecialNode* pNode ) = 0;
      39             :     virtual void Visit( SmMathSymbolNode* pNode ) = 0;
      40             :     virtual void Visit( SmBlankNode* pNode ) = 0;
      41             :     virtual void Visit( SmErrorNode* pNode ) = 0;
      42             :     virtual void Visit( SmLineNode* pNode ) = 0;
      43             :     virtual void Visit( SmExpressionNode* pNode ) = 0;
      44             :     virtual void Visit( SmPolyLineNode* pNode ) = 0;
      45             :     virtual void Visit( SmDynIntegralNode* pNode ) = 0;
      46             :     virtual void Visit( SmDynIntegralSymbolNode* pNode ) = 0;
      47             :     virtual void Visit( SmRootNode* pNode ) = 0;
      48             :     virtual void Visit( SmRootSymbolNode* pNode ) = 0;
      49             :     virtual void Visit( SmRectangleNode* pNode ) = 0;
      50             :     virtual void Visit( SmVerticalBraceNode* pNode ) = 0;
      51             : 
      52             : protected:
      53       10598 :     ~SmVisitor() {}
      54             : };
      55             : 
      56             : /** Simple visitor for testing SmVisitor */
      57             : class SmVisitorTest : public SmVisitor
      58             : {
      59             : public:
      60           0 :     virtual ~SmVisitorTest() {}
      61             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
      62             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
      63             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
      64             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
      65             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
      66             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
      67             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
      68             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
      69             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
      70             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
      71             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
      72             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
      73             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
      74             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
      75             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
      76             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
      77             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
      78             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
      79             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
      80             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
      81             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
      82             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
      83             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
      84             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
      85             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
      86             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
      87             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
      88             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
      89             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
      90             : private:
      91             :     /** Auxiliary method for visiting the children of a pNode */
      92             :     void VisitChildren( SmNode* pNode );
      93             : };
      94             : 
      95             : // SmDefaultingVisitor
      96             : 
      97             : 
      98             : /** Visitor that uses DefaultVisit for handling visits by default
      99             :  *
     100             :  * This abstract baseclass is useful for visitors where many methods share the same
     101             :  * implementation.
     102             :  */
     103          66 : class SmDefaultingVisitor : public SmVisitor
     104             : {
     105             : public:
     106             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
     107             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
     108             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
     109             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
     110             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     111             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
     112             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     113             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     114             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     115             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
     116             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
     117             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
     118             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
     119             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
     120             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     121             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
     122             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
     123             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
     124             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
     125             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
     126             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     127             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     128             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
     129             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
     130             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
     131             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
     132             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
     133             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
     134             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
     135             : protected:
     136          66 :     ~SmDefaultingVisitor() {}
     137             : 
     138             :     /** Method invoked by Visit methods by default */
     139             :     virtual void DefaultVisit( SmNode* pNode ) = 0;
     140             : };
     141             : 
     142             : // SmCaretDrawingVisitor
     143             : 
     144             : /** Visitor for drawing a caret position */
     145             : class SmCaretDrawingVisitor : public SmDefaultingVisitor
     146             : {
     147             : public:
     148             :     /** Given position and device this constructor will draw the caret */
     149             :     SmCaretDrawingVisitor( OutputDevice& rDevice, SmCaretPos position, Point offset, bool caretVisible );
     150           0 :     virtual ~SmCaretDrawingVisitor() {}
     151             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     152             :     using SmDefaultingVisitor::Visit;
     153             : private:
     154             :     OutputDevice &rDev;
     155             :     SmCaretPos pos;
     156             :     /** Offset to draw from */
     157             :     Point Offset;
     158             :     bool isCaretVisible;
     159             : protected:
     160             :     /** Default method for drawing pNodes */
     161             :     void DefaultVisit( SmNode* pNode ) SAL_OVERRIDE;
     162             : };
     163             : 
     164             : // SmCaretPos2LineVisitor
     165             : 
     166             : /** Visitor getting a line from a caret position */
     167             : class SmCaretPos2LineVisitor : public SmDefaultingVisitor
     168             : {
     169             : public:
     170             :     /** Given position and device this constructor will compute a line for the caret */
     171          28 :     SmCaretPos2LineVisitor( OutputDevice *pDevice, SmCaretPos position ) {
     172          28 :         pDev = pDevice;
     173          28 :         pos = position;
     174             :         SAL_WARN_IF( !position.IsValid(), "starmath", "Cannot draw invalid position!" );
     175             : 
     176          28 :         pos.pSelectedNode->Accept( this );
     177          28 :     }
     178          28 :     virtual ~SmCaretPos2LineVisitor() {}
     179             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     180             :     using SmDefaultingVisitor::Visit;
     181          28 :     SmCaretLine GetResult( ){
     182          28 :         return line;
     183             :     }
     184             : private:
     185             :     SmCaretLine line;
     186             :     OutputDevice *pDev;
     187             :     SmCaretPos pos;
     188             : protected:
     189             :     /** Default method for computing lines for pNodes */
     190             :     void DefaultVisit( SmNode* pNode ) SAL_OVERRIDE;
     191             : };
     192             : 
     193             : // SmDrawingVisitor
     194             : 
     195             : /** Visitor for drawing SmNodes to OutputDevice */
     196             : class SmDrawingVisitor : public SmVisitor
     197             : {
     198             : public:
     199             :     /** Create an instance of SmDrawingVisitor, and use it to draw a formula
     200             :      * @param rDevice   Device to draw on
     201             :      * @param position  Offset on device to draw the formula
     202             :      * @param pTree     Formula tree to draw
     203             :      * @remarks This constructor will do the drawing, no need to anything more.
     204             :      */
     205        9380 :     SmDrawingVisitor( OutputDevice &rDevice, Point position, SmNode* pTree )
     206        9380 :         : rDev( rDevice ) {
     207        9380 :         this->Position = position;
     208        9380 :         pTree->Accept( this );
     209        9380 :     }
     210        9380 :     virtual ~SmDrawingVisitor() {}
     211             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
     212             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
     213             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
     214             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
     215             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     216             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
     217             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     218             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     219             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     220             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
     221             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
     222             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
     223             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
     224             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
     225             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     226             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
     227             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
     228             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
     229             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
     230             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
     231             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     232             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     233             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
     234             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
     235             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
     236             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
     237             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
     238             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
     239             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
     240             : private:
     241             :     /** Draw the children of a pNode
     242             :      * This the default method, use by most pNodes
     243             :      */
     244             :     void DrawChildren( SmNode* pNode );
     245             : 
     246             :     /** Draw an SmTextNode or a subclass of this */
     247             :     void DrawTextNode( SmTextNode* pNode );
     248             :     /** Draw an SmSpecialNode or a subclass of this  */
     249             :     void DrawSpecialNode( SmSpecialNode* pNode );
     250             :     /** OutputDevice to draw on */
     251             :     OutputDevice& rDev;
     252             :     /** Position to draw on the rDev
     253             :      * @remarks This variable is used to pass parameters in DrawChildren( ), this means
     254             :                 that after a call to DrawChildren( ) the contents of this method is undefined
     255             :                 so if needed cache it locally on the stack.
     256             :      */
     257             :     Point Position;
     258             : };
     259             : 
     260             : // SmSetSelectionVisitor
     261             : 
     262             : /** Set Selection Visitor
     263             :  * Sets the IsSelected( ) property on all SmNodes of the tree
     264             :  */
     265             : class SmSetSelectionVisitor : public SmDefaultingVisitor
     266             : {
     267             : public:
     268             :     SmSetSelectionVisitor( SmCaretPos startPos, SmCaretPos endPos, SmNode* pNode);
     269          38 :     virtual ~SmSetSelectionVisitor() {}
     270             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     271             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     272             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     273             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     274             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     275             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     276             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     277             :     using SmDefaultingVisitor::Visit;
     278             :     /** Set IsSelected on all pNodes of pSubTree */
     279             :     static void SetSelectedOnAll( SmNode* pSubTree, bool IsSelected = true );
     280             : private:
     281             :     /** Visit a selectable pNode
     282             :      * Can be used to handle pNodes that can be selected, that doesn't have more SmCaretPos'
     283             :      * than 0 and 1 inside them. SmTextNode should be handle separately!
     284             :      * Also note that pNodes such as SmBinVerNode cannot be selected, don't this method for
     285             :      * it.
     286             :      */
     287             :     void DefaultVisit( SmNode* pNode ) SAL_OVERRIDE;
     288             :     void VisitCompositionNode( SmNode* pNode );
     289             :     /** Caret position where the selection starts */
     290             :     SmCaretPos  StartPos;
     291             :     /** Caret position where the selection ends */
     292             :     SmCaretPos  EndPos;
     293             :     /** The current state of this visitor
     294             :      * This property changes when the visitor meets either StartPos
     295             :      * or EndPos. This means that anything visited in between will be
     296             :      * selected.
     297             :      */
     298             :     bool IsSelecting;
     299             : };
     300             : 
     301             : 
     302             : // SmCaretPosGraphBuildingVisitor
     303             : 
     304             : 
     305             : /** A visitor for building a SmCaretPosGraph
     306             :  *
     307             :  * Visit invariant:
     308             :  * Each pNode, except SmExpressionNode, SmBinHorNode and a few others, constitutes an entry
     309             :  * in a line. Consider the line entry "H", this entry creates one carat position, here
     310             :  * denoted by | in "H|".
     311             :  *
     312             :  * Parameter variables:
     313             :  *  The following variables are used to transfer parameters in to calls and results out
     314             :  *  of calls.
     315             :  *      pRightMost : SmCaretPosGraphEntry*
     316             :  *
     317             :  * Prior to a Visit call:
     318             :  *  pRightMost: A pointer to right most position in front of the current line entry.
     319             :  *
     320             :  * After a Visit call:
     321             :  *  pRightMost: A pointer to the right most position in the called line entry, if no there's
     322             :  *              no caret positions in called line entry don't change this variable.
     323             :  */
     324             : class SmCaretPosGraphBuildingVisitor : public SmVisitor
     325             : {
     326             : public:
     327             :     /** Builds a caret position graph for pRootNode */
     328             :     SmCaretPosGraphBuildingVisitor( SmNode* pRootNode );
     329             :     virtual ~SmCaretPosGraphBuildingVisitor();
     330             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
     331             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
     332             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
     333             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
     334             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     335             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
     336             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     337             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     338             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     339             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
     340             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
     341             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
     342             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
     343             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
     344             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     345             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
     346             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
     347             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
     348             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
     349             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
     350             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     351             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     352             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
     353             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
     354             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
     355             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
     356             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
     357             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
     358             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
     359          40 :     SmCaretPosGraph* takeGraph()
     360             :     {
     361          40 :         SmCaretPosGraph *pRet = pGraph;
     362          40 :         pGraph = 0;
     363          40 :         return pRet;
     364             :     }
     365             : private:
     366             :     SmCaretPosGraphEntry* pRightMost;
     367             :     SmCaretPosGraph*      pGraph;
     368             : };
     369             : 
     370             : // SmCloningVisitor
     371             : 
     372             : /** Visitor for cloning a pNode
     373             :  *
     374             :  * This visitor creates deep clones.
     375             :  */
     376             : class SmCloningVisitor : public SmVisitor
     377             : {
     378             : public:
     379           0 :     SmCloningVisitor( ){ pResult = NULL; }
     380           0 :     virtual ~SmCloningVisitor() {}
     381             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
     382             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
     383             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
     384             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
     385             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     386             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
     387             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     388             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     389             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     390             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
     391             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
     392             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
     393             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
     394             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
     395             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     396             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
     397             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
     398             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
     399             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
     400             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
     401             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     402             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     403             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
     404             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
     405             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
     406             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
     407             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
     408             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
     409             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
     410             :     /** Clone a pNode */
     411             :     SmNode* Clone( SmNode* pNode );
     412             : private:
     413             :     SmNode* pResult;
     414             :     /** Clone children of pSource and give them to pTarget */
     415             :     void CloneKids( SmStructureNode* pSource, SmStructureNode* pTarget );
     416             :     /** Clone attributes on a pNode */
     417             :     void CloneNodeAttr( SmNode* pSource, SmNode* pTarget );
     418             : };
     419             : 
     420             : 
     421             : // SmSelectionDrawingVisitor
     422             : 
     423             : class SmSelectionDrawingVisitor : public SmDefaultingVisitor
     424             : {
     425             : public:
     426             :     /** Draws a selection on rDevice for the selection on pTree */
     427             :     SmSelectionDrawingVisitor( OutputDevice& rDevice, SmNode* pTree, Point Offset );
     428           0 :     virtual ~SmSelectionDrawingVisitor() {}
     429             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     430             :     using SmDefaultingVisitor::Visit;
     431             : private:
     432             :     /** Reference to drawing device */
     433             :     OutputDevice& rDev;
     434             :     /** True if  aSelectionArea have been initialized */
     435             :     bool bHasSelectionArea;
     436             :     /** The current area that is selected */
     437             :     Rectangle aSelectionArea;
     438             :     /** Extend the area that must be selected  */
     439             :     void ExtendSelectionArea( Rectangle aArea );
     440             :     /** Default visiting method */
     441             :     void DefaultVisit( SmNode* pNode ) SAL_OVERRIDE;
     442             :     /** Visit the children of a given pNode */
     443             :     void VisitChildren( SmNode* pNode );
     444             : };
     445             : 
     446             : // SmNodeToTextVisitor
     447             : 
     448             : /** Extract command text from pNodes */
     449             : class SmNodeToTextVisitor : public SmVisitor
     450             : {
     451             : public:
     452             :     SmNodeToTextVisitor( SmNode* pNode, OUString &rText );
     453        1112 :     virtual ~SmNodeToTextVisitor() {}
     454             : 
     455             :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE;
     456             :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE;
     457             :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE;
     458             :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE;
     459             :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE;
     460             :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE;
     461             :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE;
     462             :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE;
     463             :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE;
     464             :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE;
     465             :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE;
     466             :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE;
     467             :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE;
     468             :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE;
     469             :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE;
     470             :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE;
     471             :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE;
     472             :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE;
     473             :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE;
     474             :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE;
     475             :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE;
     476             :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE;
     477             :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE;
     478             :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE;
     479             :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE;
     480             :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE;
     481             :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE;
     482             :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE;
     483             :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE;
     484             : private:
     485             :     /** Extract text from a pNode that constitutes a line */
     486         568 :     void LineToText( SmNode* pNode ) {
     487         568 :         Separate( );
     488         568 :         if( pNode )
     489         568 :             pNode->Accept( this );
     490         568 :         Separate( );
     491         568 :     }
     492        3472 :     void Append( const OUString &rText ) {
     493        3472 :         aCmdText.append( rText );
     494        3472 :     }
     495             :     /** Append a blank for separation, if needed */
     496        3424 :     inline void Separate( ){
     497        3424 :         if( aCmdText.isEmpty() || aCmdText[ aCmdText.getLength() - 1 ] != ' ' )
     498        2460 :             aCmdText.append(' ');
     499        3424 :     }
     500             :     /** Output text generated from the pNodes */
     501             :     OUStringBuffer aCmdText;
     502             : };
     503             : 
     504             : #endif // INCLUDED_STARMATH_INC_VISITORS_HXX
     505             : 
     506             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10