/** Visitors are an easy way to automating operations with nodes. * *Theavailablevisitorsare: *SmVisitorbaseclass *SmDefaultingVisitordefaultvisitor *SmDrawingVisitordrawsformula *SmCaretPosGraphBuildingVisitorpositionofthenodeinsidestarmathcode *SmCloningVisitorduplicatenodes *SmNodeToTextVisitorcreatecodefromnodes *
*/
private:
OutputDevice& mrDev;
SmCaretPos maPos; /** Offset to draw from */
Point maOffset;
};
// SmCaretRectanglesVisitor: obtains the set of rectangles to sent to lok
class SmCaretRectanglesVisitor final : public SmCaretLinesVisitor
{ public:
SmCaretRectanglesVisitor(OutputDevice& rDevice, SmCaretPos position); const tools::Rectangle& getCaret() const { return maCaret; }
protected: virtualvoid ProcessCaretLine(Point from, Point to) override; virtualvoid ProcessUnderline(Point from, Point to) override;
private:
tools::Rectangle maCaret;
};
// SmCaretDrawingVisitor
/** Visitor for drawing a caret position */ class SmCaretDrawingVisitor final : public SmCaretLinesVisitor
{ public: /** Given position and device this constructor will draw the caret */
SmCaretDrawingVisitor( OutputDevice& rDevice, SmCaretPos position, Point offset, bool caretVisible );
protected: virtualvoid ProcessCaretLine(Point from, Point to) override; virtualvoid ProcessUnderline(Point from, Point to) override;
private: bool mbCaretVisible;
};
// SmCaretPos2LineVisitor
/** Visitor getting a line from a caret position */ class SmCaretPos2LineVisitor final : public SmDefaultingVisitor
{ public: /** Given position and device this constructor will compute a line for the caret */
SmCaretPos2LineVisitor( OutputDevice *pDevice, SmCaretPos position )
: mpDev( pDevice )
, maPos( position )
{
SAL_WARN_IF( !position.IsValid(), "starmath", "Cannot draw invalid position!" );
/** Draw an SmTextNode or a subclass of this */ void DrawTextNode( SmTextNode* pNode ); /** Draw an SmSpecialNode or a subclass of this */ void DrawSpecialNode( SmSpecialNode* pNode ); /** OutputDevice to draw on */
OutputDevice& mrDev; /** Position to draw on the mrDev *@remarksThisvariableisusedtopassparametersinDrawChildren(),thismeans thatafteracalltoDrawChildren()thecontentsofthismethodisundefined soifneededcacheitlocallyonthestack.
*/
Point maPosition; const SmFormat& mrFormat;
};
// SmSetSelectionVisitor
/** Set Selection Visitor *SetstheIsSelected()propertyonallSmNodesofthetree
*/ class SmSetSelectionVisitor final : public SmDefaultingVisitor
{ public:
SmSetSelectionVisitor( SmCaretPos startPos, SmCaretPos endPos, SmNode* pNode); void Visit( SmBinHorNode* pNode ) override; void Visit( SmUnHorNode* pNode ) override; void Visit( SmFontNode* pNode ) override; void Visit( SmTextNode* pNode ) override; void Visit( SmExpressionNode* pNode ) override; void Visit( SmLineNode* pNode ) override; void Visit( SmAlignNode* pNode ) override; using SmDefaultingVisitor::Visit; /** Set IsSelected on all pNodes of pSubTree */ staticvoid SetSelectedOnAll( SmNode* pSubTree, bool IsSelected = true ); private: /** Visit a selectable pNode *CanbeusedtohandlepNodesthatcanbeselected,thatdoesn'thavemoreSmCaretPos' *than0and1insidethem.SmTextNodeshouldbehandleseparately! *AlsonotethatpNodessuchasSmBinVerNodecannotbeselected,don'tthismethodfor *it.
*/ void DefaultVisit( SmNode* pNode ) override; void VisitCompositionNode( SmStructureNode* pNode ); /** Caret position where the selection starts */
SmCaretPos maStartPos; /** Caret position where the selection ends */
SmCaretPos maEndPos; /** The current state of this visitor *ThispropertychangeswhenthevisitormeetseithermaStartPos *ormaEndPos.Thismeansthatanythingvisitedinbetweenwillbe *selected.
*/ bool mbSelecting;
};
private: /** Reference to drawing device */
OutputDevice& mrDev; /** The current area that is selected */
tools::Rectangle maSelectionArea; /** Extend the area that must be selected */ void ExtendSelectionArea(const tools::Rectangle& rArea) { maSelectionArea.Union(rArea); } /** Default visiting method */ void DefaultVisit( SmNode* pNode ) override; /** Visit the children of a given pNode */ void VisitChildren( SmNode* pNode );
};
// SmSelectionDrawingVisitor
class SmSelectionDrawingVisitor final : public SmSelectionRectanglesVisitor
{ public: /** Draws a selection on rDevice for the selection on pTree */
SmSelectionDrawingVisitor( OutputDevice& rDevice, SmNode* pTree, const Point& rOffset );
};
// SmNodeToTextVisitor
/** Extract command text from pNodes */ class SmNodeToTextVisitor final : public SmVisitor
{ public:
SmNodeToTextVisitor( SmNode* pNode, OUString &rText );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.