Kaydet (Commit) b2b4184e authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

starmath: Prefix members of SmCaretDrawingVisitor

Change-Id: I9d033a67f6073f3da368f8241ac48c7d391b89c9
Reviewed-on: https://gerrit.libreoffice.org/20080Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 97978f7f
...@@ -117,11 +117,11 @@ public: ...@@ -117,11 +117,11 @@ public:
void Visit( SmTextNode* pNode ) override; void Visit( SmTextNode* pNode ) override;
using SmDefaultingVisitor::Visit; using SmDefaultingVisitor::Visit;
private: private:
OutputDevice &rDev; OutputDevice &mrDev;
SmCaretPos pos; SmCaretPos maPos;
/** Offset to draw from */ /** Offset to draw from */
Point Offset; Point maOffset;
bool isCaretVisible; bool mbCaretVisible;
protected: protected:
/** Default method for drawing pNodes */ /** Default method for drawing pNodes */
void DefaultVisit( SmNode* pNode ) override; void DefaultVisit( SmNode* pNode ) override;
......
...@@ -166,83 +166,83 @@ SmCaretDrawingVisitor::SmCaretDrawingVisitor( OutputDevice& rDevice, ...@@ -166,83 +166,83 @@ SmCaretDrawingVisitor::SmCaretDrawingVisitor( OutputDevice& rDevice,
SmCaretPos position, SmCaretPos position,
Point offset, Point offset,
bool caretVisible ) bool caretVisible )
: rDev( rDevice ) : mrDev( rDevice )
, maPos( position )
, maOffset( offset )
, mbCaretVisible( caretVisible )
{ {
pos = position;
Offset = offset;
isCaretVisible = caretVisible;
SAL_WARN_IF( !position.IsValid(), "starmath", "Cannot draw invalid position!" ); SAL_WARN_IF( !position.IsValid(), "starmath", "Cannot draw invalid position!" );
if( !position.IsValid( ) ) if( !position.IsValid( ) )
return; return;
//Save device state //Save device state
rDev.Push( PushFlags::FONT | PushFlags::MAPMODE | PushFlags::LINECOLOR | PushFlags::FILLCOLOR | PushFlags::TEXTCOLOR ); mrDev.Push( PushFlags::FONT | PushFlags::MAPMODE | PushFlags::LINECOLOR | PushFlags::FILLCOLOR | PushFlags::TEXTCOLOR );
pos.pSelectedNode->Accept( this ); maPos.pSelectedNode->Accept( this );
//Restore device state //Restore device state
rDev.Pop( ); mrDev.Pop( );
} }
void SmCaretDrawingVisitor::Visit( SmTextNode* pNode ) void SmCaretDrawingVisitor::Visit( SmTextNode* pNode )
{ {
long i = pos.Index; long i = maPos.Index;
rDev.SetFont( pNode->GetFont( ) ); mrDev.SetFont( pNode->GetFont( ) );
//Find the line //Find the line
SmNode* pLine = SmCursor::FindTopMostNodeInLine( pNode ); SmNode* pLine = SmCursor::FindTopMostNodeInLine( pNode );
//Find coordinates //Find coordinates
long left = pNode->GetLeft( ) + rDev.GetTextWidth( pNode->GetText( ), 0, i ) + Offset.X( ); long left = pNode->GetLeft( ) + mrDev.GetTextWidth( pNode->GetText( ), 0, i ) + maOffset.X( );
long top = pLine->GetTop( ) + Offset.Y( ); long top = pLine->GetTop( ) + maOffset.Y( );
long height = pLine->GetHeight( ); long height = pLine->GetHeight( );
long left_line = pLine->GetLeft( ) + Offset.X( ); long left_line = pLine->GetLeft( ) + maOffset.X( );
long right_line = pLine->GetRight( ) + Offset.X( ); long right_line = pLine->GetRight( ) + maOffset.X( );
//Set color //Set color
rDev.SetLineColor( Color( COL_BLACK ) ); mrDev.SetLineColor( Color( COL_BLACK ) );
if ( isCaretVisible ) { if ( mbCaretVisible ) {
//Draw vertical line //Draw vertical line
Point p1( left, top ); Point p1( left, top );
Point p2( left, top + height ); Point p2( left, top + height );
rDev.DrawLine( p1, p2 ); mrDev.DrawLine( p1, p2 );
} }
//Underline the line //Underline the line
Point pLeft( left_line, top + height ); Point pLeft( left_line, top + height );
Point pRight( right_line, top + height ); Point pRight( right_line, top + height );
rDev.DrawLine( pLeft, pRight ); mrDev.DrawLine( pLeft, pRight );
} }
void SmCaretDrawingVisitor::DefaultVisit( SmNode* pNode ) void SmCaretDrawingVisitor::DefaultVisit( SmNode* pNode )
{ {
rDev.SetLineColor( Color( COL_BLACK ) ); mrDev.SetLineColor( Color( COL_BLACK ) );
//Find the line //Find the line
SmNode* pLine = SmCursor::FindTopMostNodeInLine( pNode ); SmNode* pLine = SmCursor::FindTopMostNodeInLine( pNode );
//Find coordinates //Find coordinates
long left = pNode->GetLeft( ) + Offset.X( ) + ( pos.Index == 1 ? pNode->GetWidth( ) : 0 ); long left = pNode->GetLeft( ) + maOffset.X( ) + ( maPos.Index == 1 ? pNode->GetWidth( ) : 0 );
long top = pLine->GetTop( ) + Offset.Y( ); long top = pLine->GetTop( ) + maOffset.Y( );
long height = pLine->GetHeight( ); long height = pLine->GetHeight( );
long left_line = pLine->GetLeft( ) + Offset.X( ); long left_line = pLine->GetLeft( ) + maOffset.X( );
long right_line = pLine->GetRight( ) + Offset.X( ); long right_line = pLine->GetRight( ) + maOffset.X( );
//Set color //Set color
rDev.SetLineColor( Color( COL_BLACK ) ); mrDev.SetLineColor( Color( COL_BLACK ) );
if ( isCaretVisible ) { if ( mbCaretVisible ) {
//Draw vertical line //Draw vertical line
Point p1( left, top ); Point p1( left, top );
Point p2( left, top + height ); Point p2( left, top + height );
rDev.DrawLine( p1, p2 ); mrDev.DrawLine( p1, p2 );
} }
//Underline the line //Underline the line
Point pLeft( left_line, top + height ); Point pLeft( left_line, top + height );
Point pRight( right_line, top + height ); Point pRight( right_line, top + height );
rDev.DrawLine( pLeft, pRight ); mrDev.DrawLine( pLeft, pRight );
} }
// SmCaretPos2LineVisitor // SmCaretPos2LineVisitor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment