[Libreoffice-commits] core.git: starmath/inc starmath/source

Takeshi Abe tabe at fixedpoint.jp
Mon Dec 26 12:17:35 UTC 2016


 starmath/inc/caret.hxx       |   11 ++++++-----
 starmath/source/caret.cxx    |    2 +-
 starmath/source/cursor.cxx   |   18 +++++++++---------
 starmath/source/visitors.cxx |   32 ++++++++++++++++----------------
 4 files changed, 32 insertions(+), 31 deletions(-)

New commits:
commit d6a7f7fe98af19b43d8e82555a10bf1e835d0533
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Dec 26 18:41:53 2016 +0900

    starmath: Prefix n to SmCaretPos's Index
    
    Change-Id: Ie1647d8143c4c38ebcf5111bffc291c26704c4c0
    Reviewed-on: https://gerrit.libreoffice.org/32428
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
index 08afcce..113ab8f 100644
--- a/starmath/inc/caret.hxx
+++ b/starmath/inc/caret.hxx
@@ -20,9 +20,10 @@
 
 /** Representation of caret position with an equation */
 struct SmCaretPos{
-    SmCaretPos(SmNode* selectedNode = nullptr, int iIndex = 0) {
-        pSelectedNode = selectedNode;
-        Index = iIndex;
+    SmCaretPos(SmNode* selectedNode = nullptr, int iIndex = 0)
+        : pSelectedNode(selectedNode)
+        , nIndex(iIndex)
+    {
     }
     /** Selected node */
     SmNode* pSelectedNode;
@@ -36,11 +37,11 @@ struct SmCaretPos{
      */
     //TODO: Special cases for SmBlankNode is needed
     //TODO: Consider forgetting about the todo above... As it's really unpleasant.
-    int Index;
+    int nIndex;
     /** True, if this is a valid caret position */
     bool IsValid() const { return pSelectedNode != nullptr; }
     bool operator==(const SmCaretPos &pos) const {
-        return pos.pSelectedNode == pSelectedNode && Index == pos.Index;
+        return pos.pSelectedNode == pSelectedNode && nIndex == pos.nIndex;
     }
     /** Get the caret position after pNode, regardless of pNode
      *
diff --git a/starmath/source/caret.cxx b/starmath/source/caret.cxx
index 5119914..3504ec8 100644
--- a/starmath/source/caret.cxx
+++ b/starmath/source/caret.cxx
@@ -17,7 +17,7 @@ SmCaretPosGraph::~SmCaretPosGraph() = default;
 SmCaretPosGraphEntry* SmCaretPosGraph::Add(SmCaretPos pos,
                                            SmCaretPosGraphEntry* left)
 {
-    SAL_WARN_IF( pos.Index < 0, "starmath", "Index shouldn't be -1!" );
+    SAL_WARN_IF( pos.nIndex < 0, "starmath", "nIndex shouldn't be -1!" );
     auto entry = o3tl::make_unique<SmCaretPosGraphEntry>(pos, left, nullptr);
     SmCaretPosGraphEntry* e = entry.get();
     //Set Left and Right to point to the entry itself if they are NULL
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index fadb103..db788d4 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -184,7 +184,7 @@ void SmCursor::DeletePrev(OutputDevice* pDev){
     assert(nLineOffset >= 0);
 
     //If we're in front of a node who's parent is a TABLE
-    if(pLineParent->GetType() == NTABLE && mpPosition->CaretPos.Index == 0 && nLineOffset > 0){
+    if(pLineParent->GetType() == NTABLE && mpPosition->CaretPos.nIndex == 0 && nLineOffset > 0){
         //Now we can merge with nLineOffset - 1
         BeginEdit();
         //Line to merge things into, so we can delete pLine
@@ -342,13 +342,13 @@ SmNodeList::iterator SmCursor::FindPositionInLineList(SmNodeList* pLineList,
             if((*it)->GetType() == NTEXT)
             {
                 //Split textnode if needed
-                if(rCaretPos.Index > 0)
+                if(rCaretPos.nIndex > 0)
                 {
                     SmTextNode* pText = static_cast<SmTextNode*>(rCaretPos.pSelectedNode);
-                    if (rCaretPos.Index == pText->GetText().getLength())
+                    if (rCaretPos.nIndex == pText->GetText().getLength())
                         return ++it;
-                    OUString str1 = pText->GetText().copy(0, rCaretPos.Index);
-                    OUString str2 = pText->GetText().copy(rCaretPos.Index);
+                    OUString str1 = pText->GetText().copy(0, rCaretPos.nIndex);
+                    OUString str2 = pText->GetText().copy(rCaretPos.nIndex);
                     pText->ChangeText(str1);
                     ++it;
                     //Insert str2 as new text node
@@ -1462,12 +1462,12 @@ bool SmCursor::IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** ppBra
 
     if (pNode->GetType() == NTEXT) {
         SmTextNode* pTextNode = static_cast<SmTextNode*>(pNode);
-        if (pos.Index < pTextNode->GetText().getLength()) {
+        if (pos.nIndex < pTextNode->GetText().getLength()) {
             // The cursor is on a text node and at the middle of it.
             return false;
         }
     } else {
-        if (pos.Index < 1) {
+        if (pos.nIndex < 1) {
             return false;
         }
     }
@@ -1533,9 +1533,9 @@ bool SmCursor::IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** ppBra
 void SmCursor::MoveAfterBracket(SmBraceNode* pBraceNode)
 {
     mpPosition->CaretPos.pSelectedNode = pBraceNode;
-    mpPosition->CaretPos.Index = 1;
+    mpPosition->CaretPos.nIndex = 1;
     mpAnchor->CaretPos.pSelectedNode = pBraceNode;
-    mpAnchor->CaretPos.Index = 1;
+    mpAnchor->CaretPos.nIndex = 1;
     RequestRepaint();
 }
 
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index d1dc6ba..93230d3 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -176,7 +176,7 @@ SmCaretDrawingVisitor::SmCaretDrawingVisitor( OutputDevice& rDevice,
 
 void SmCaretDrawingVisitor::Visit( SmTextNode* pNode )
 {
-    long i = maPos.Index;
+    long i = maPos.nIndex;
 
     mrDev.SetFont( pNode->GetFont( ) );
 
@@ -212,7 +212,7 @@ void SmCaretDrawingVisitor::DefaultVisit( SmNode* pNode )
     SmNode* pLine = SmCursor::FindTopMostNodeInLine( pNode );
 
     //Find coordinates
-    long left = pNode->GetLeft( ) + maOffset.X( ) + ( maPos.Index == 1 ? pNode->GetWidth( ) : 0 );
+    long left = pNode->GetLeft( ) + maOffset.X( ) + ( maPos.nIndex == 1 ? pNode->GetWidth( ) : 0 );
     long top = pLine->GetTop( ) + maOffset.Y( );
     long height = pLine->GetHeight( );
     long left_line = pLine->GetLeft( ) + maOffset.X( );
@@ -241,7 +241,7 @@ void SmCaretPos2LineVisitor::Visit( SmTextNode* pNode )
     //Save device state
     mpDev->Push( PushFlags::FONT | PushFlags::TEXTCOLOR );
 
-    long i = maPos.Index;
+    long i = maPos.nIndex;
 
     mpDev->SetFont( pNode->GetFont( ) );
 
@@ -260,7 +260,7 @@ void SmCaretPos2LineVisitor::DefaultVisit( SmNode* pNode )
 {
     //Vertical line ( code from SmCaretDrawingVisitor )
     Point p1 = pNode->GetTopLeft( );
-    if( maPos.Index == 1 )
+    if( maPos.nIndex == 1 )
         p1.Move( pNode->GetWidth( ), 0 );
 
     maLine = SmCaretLine( p1.X( ), p1.Y( ), pNode->GetHeight( ) );
@@ -528,10 +528,10 @@ SmSetSelectionVisitor::SmSetSelectionVisitor( SmCaretPos startPos, SmCaretPos en
     //Visit root node, this is special as this node cannot be selected, but its children can!
     if(pTree->GetType() == NTABLE){
         //Change state if maStartPos is in front of this node
-        if( maStartPos.pSelectedNode == pTree && maStartPos.Index == 0 )
+        if( maStartPos.pSelectedNode == pTree && maStartPos.nIndex == 0 )
             mbSelecting = !mbSelecting;
         //Change state if maEndPos is in front of this node
-        if( maEndPos.pSelectedNode == pTree && maEndPos.Index == 0 )
+        if( maEndPos.pSelectedNode == pTree && maEndPos.nIndex == 0 )
             mbSelecting = !mbSelecting;
         SAL_WARN_IF(mbSelecting, "starmath", "Caret positions needed to set mbSelecting about, shouldn't be possible!");
 
@@ -575,10 +575,10 @@ void SmSetSelectionVisitor::SetSelectedOnAll( SmNode* pSubTree, bool IsSelected
 
 void SmSetSelectionVisitor::DefaultVisit( SmNode* pNode ) {
     //Change state if maStartPos is in front of this node
-    if( maStartPos.pSelectedNode == pNode && maStartPos.Index == 0 )
+    if( maStartPos.pSelectedNode == pNode && maStartPos.nIndex == 0 )
         mbSelecting = !mbSelecting;
     //Change state if maEndPos is in front of this node
-    if( maEndPos.pSelectedNode == pNode && maEndPos.Index == 0 )
+    if( maEndPos.pSelectedNode == pNode && maEndPos.nIndex == 0 )
         mbSelecting = !mbSelecting;
 
     //Cache current state
@@ -621,12 +621,12 @@ void SmSetSelectionVisitor::DefaultVisit( SmNode* pNode ) {
     }
 
     //Change state if maStartPos is after this node
-    if( maStartPos.pSelectedNode == pNode && maStartPos.Index == 1 )
+    if( maStartPos.pSelectedNode == pNode && maStartPos.nIndex == 1 )
     {
         mbSelecting = !mbSelecting;
     }
     //Change state if maEndPos is after of this node
-    if( maEndPos.pSelectedNode == pNode && maEndPos.Index == 1 )
+    if( maEndPos.pSelectedNode == pNode && maEndPos.nIndex == 1 )
     {
         mbSelecting = !mbSelecting;
     }
@@ -635,10 +635,10 @@ void SmSetSelectionVisitor::DefaultVisit( SmNode* pNode ) {
 void SmSetSelectionVisitor::VisitCompositionNode( SmStructureNode* pNode )
 {
     //Change state if maStartPos is in front of this node
-    if( maStartPos.pSelectedNode == pNode && maStartPos.Index == 0 )
+    if( maStartPos.pSelectedNode == pNode && maStartPos.nIndex == 0 )
         mbSelecting = !mbSelecting;
     //Change state if maEndPos is in front of this node
-    if( maEndPos.pSelectedNode == pNode && maEndPos.Index == 0 )
+    if( maEndPos.pSelectedNode == pNode && maEndPos.nIndex == 0 )
         mbSelecting = !mbSelecting;
 
     //Cache current state
@@ -656,10 +656,10 @@ void SmSetSelectionVisitor::VisitCompositionNode( SmStructureNode* pNode )
     pNode->SetSelected( WasSelecting && mbSelecting );
 
     //Change state if maStartPos is after this node
-    if( maStartPos.pSelectedNode == pNode && maStartPos.Index == 1 )
+    if( maStartPos.pSelectedNode == pNode && maStartPos.nIndex == 1 )
         mbSelecting = !mbSelecting;
     //Change state if maEndPos is after of this node
-    if( maEndPos.pSelectedNode == pNode && maEndPos.Index == 1 )
+    if( maEndPos.pSelectedNode == pNode && maEndPos.nIndex == 1 )
         mbSelecting = !mbSelecting;
 }
 
@@ -667,9 +667,9 @@ void SmSetSelectionVisitor::Visit( SmTextNode* pNode ) {
     long    i1 = -1,
             i2 = -1;
     if( maStartPos.pSelectedNode == pNode )
-        i1 = maStartPos.Index;
+        i1 = maStartPos.nIndex;
     if( maEndPos.pSelectedNode == pNode )
-        i2 = maEndPos.Index;
+        i2 = maEndPos.nIndex;
 
     long start, end;
     pNode->SetSelected(true);


More information about the Libreoffice-commits mailing list