Hello Jonas and list, I started looking at the SmNodeToTextVisitor.
There were a few problems I noticed. 1. The Greek and special characters beginning with a % get changed to comments (%%) and then lost. 2. Stacks get ## inserted instead of # for rows. 3. Some of the subs & sups seemed to need extra brackets when used with an operator node (for example int or sum). I also added something I spotted in SmNode::CreateTextFromNode to the NodeToTextVisitor for SmExpressionNodes which makes it so that not so many brackets are added. I also have a very small patch which removes a couple of things from the todo list (maybe it ought to be an unnumbered list, so all the numbers don't need changing each time). Regards, Luke
>From 7cb737c90fa6b4f5bcef96add805c2f47b441a86 Mon Sep 17 00:00:00 2001 From: Luke Dixon <6b8b4...@gmail.com> Date: Tue, 23 Nov 2010 10:36:18 +0000 Subject: [PATCH] Fix Greek characters, stacks and subs/sups for operators. --- starmath/source/visitors.cxx | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index 6ca86fd..ab2ac87 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -2174,7 +2174,7 @@ void SmNodeToTextVisitor::Visit( SmTableNode* pNode ) LineToText( it.Current( ) ); if( it.Next( ) ) { Separate( ); - Append( "## " ); + Append( "# " ); }else break; } @@ -2242,33 +2242,39 @@ void SmNodeToTextVisitor::Visit( SmOperNode* pNode ) SmNode* pChild; if( ( pChild = pSubSup->GetSubSup( LSUP ) ) ) { Separate( ); - Append( "lsup " ); + Append( "lsup { " ); LineToText( pChild ); + Append( "} "); } if( ( pChild = pSubSup->GetSubSup( LSUB ) ) ) { Separate( ); - Append( "lsub " ); + Append( "lsub { " ); LineToText( pChild ); + Append( "} "); } if( ( pChild = pSubSup->GetSubSup( RSUP ) ) ) { Separate( ); - Append( "rsup " ); + Append( "rsup { " ); LineToText( pChild ); + Append( "} "); } if( ( pChild = pSubSup->GetSubSup( RSUB ) ) ) { Separate( ); - Append( "rsub " ); + Append( "rsub { " ); LineToText( pChild ); + Append( "} "); } if( ( pChild = pSubSup->GetSubSup( CSUP ) ) ) { Separate( ); - Append( "csup " ); + Append( "csup { " ); LineToText( pChild ); + Append( "} "); } if( ( pChild = pSubSup->GetSubSup( CSUB ) ) ) { Separate( ); - Append( "csub " ); + Append( "csub { " ); LineToText( pChild ); + Append( "} "); } } LineToText( pNode->GetSubNode( 1 ) ); @@ -2490,7 +2496,6 @@ void SmNodeToTextVisitor::Visit( SmTextNode* pNode ) void SmNodeToTextVisitor::Visit( SmSpecialNode* pNode ) { - Append( "%" ); Append( pNode->GetToken( ).aText ); } @@ -2528,13 +2533,18 @@ void SmNodeToTextVisitor::Visit( SmLineNode* pNode ) void SmNodeToTextVisitor::Visit( SmExpressionNode* pNode ) { - Append( "{ " ); + USHORT nSize = pNode->GetNumSubNodes(); + if (nSize > 1) { + Append( "{ " ); + } SmNodeIterator it( pNode ); while( it.Next( ) ) { it->Accept( this ); Separate( ); } - Append( "}" ); + if (nSize > 1) { + Append( "} " ); + } } void SmNodeToTextVisitor::Visit( SmPolyLineNode* ) -- 1.7.3.2
>From 413ec5e6f3f63253a2f2eaff814f1ee82ac6b408 Mon Sep 17 00:00:00 2001 From: Luke Dixon <6b8b4...@gmail.com> Date: Tue, 23 Nov 2010 10:41:04 +0000 Subject: [PATCH] Clear 2 things from the visual formula editor todo list. --- starmath/visual-editor-todo | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/starmath/visual-editor-todo b/starmath/visual-editor-todo index 9f19e88..b19c1e7 100644 --- a/starmath/visual-editor-todo +++ b/starmath/visual-editor-todo @@ -12,13 +12,12 @@ on IRC (jopsen) or e-mail me at jop...@gmail.com. Easy ---- -1. Draw a non-blinking line under the visual line that the caret is in, in SmCaretDrawingVisitor. -2. SmGraphicWindow::KeyInput relies on comparison of sal_Char, a better way must be available for CTRL+c -3. Code style (missing spaces, linebreaks and a few renames) -4. More documentation -5. Replace j_assert with DBG_ASSERT (don't do this yet). -6. Remove the CreateTextFromNode methods and replace calls to it with NodeToTextVisitor -7. Extend NodeToTextVisitor to update token offsets so SmNode::GetRow and SmNode::GetColumn will work. +1. SmGraphicWindow::KeyInput relies on comparison of sal_Char, a better way must be available for CTRL+c +2. Code style (missing spaces, linebreaks and a few renames) +3. More documentation +4. Replace j_assert with DBG_ASSERT (don't do this yet). +5. Remove the CreateTextFromNode methods and replace calls to it with NodeToTextVisitor +6. Extend NodeToTextVisitor to update token offsets so SmNode::GetRow and SmNode::GetColumn will work. (These methods can be used to enable synchronization of caret positions between visual and non-visual editor). Medium @@ -26,8 +25,7 @@ Medium 1. SmCursor::InsertCol() method for added columns to matrices should be implemented. 2. SmCursor` should support deletion of lines, rows, cols and sub-/superscripts. 3. SmCursor::InsertSubSup() should wrap the body in a SmBraceNode if the body is an SmOperNode, SmBinVerNode, etc. -4. Make caret in visual editor blink. -5. When OpenOffice Math runs in standalone mode it centers the current formula, this is not nice for visual editing. +4. When OpenOffice Math runs in standalone mode it centers the current formula, this is not nice for visual editing. Complex ------- -- 1.7.3.2
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice