Hi Jonas, I'm very sorry for not responding very quickly. And I'm very sorry for sending pretty much the same message twice, I forgot to CC the list.
> That's not all true... I added all the brackets initially because I > had some problems with a few isolated things... > Try writing binom a b + c in the command text field... Then enter > visual editor an move as much to the right as possible, e.g. the > rightmost position in the toplevel line, and write + d > Now "+d" will be in the toplevel line... But if you enter the command > text editor and changes c to e, then +d will be in the second line of > the binom... > I don't think this is parsing error... But an unpleasant obscurity in > the format... I'm not even sure I fixed this one with my excessive use > of brackets... But the issue is there now... We should probably fix it > and add a unit test for it to avoid regressions... > The problem is that when binom has these obscurities maybe some of the > other command have similar obscurities... :( Yep, I'm very sorry for breaking things. I've attached a patch for this particular problem (with a test). In trying to work out the correct form for binoms, I found that even "binom {a} {b + c} + d" doesn't seem to work when it goes through the parser, so I guess it needs to be "{ binom {a} {b + c} } + d". I've noticed other stuff I've messed up though, so I'm going to continue on this some more :) > Btw, you latest patch didn't introduce this issue... So it's probably > been there for a while... > > > Oh, another thing I noticed was that there seems to be a crash when > > moving to the right of an SmPlaceNode and deleting it > Interesting... I've had that bug once, but I've never been able to > reproduce it... Can't this time either... Do you have any more > specific steps ? I described this pretty badly, sorry, the steps I use are: 1. type something in the visual editor eg. "A + B = C" 2. press enter to go to a new line 3. press the right arrow key to move to the right of the place node When I do this the underline that goes with the caret moves up a little bit and the caret gets shorter. 4. press enter or backspace and it crashes (every time for me) I really haven't looked at it any further at this point. The libreoffice-3-3 version seems to work fine though. Regards, Luke
>From a4a4205c85373ba1a26f8cf5930aaba483172ae4 Mon Sep 17 00:00:00 2001 From: Luke Dixon <6b8b4...@gmail.com> Date: Sun, 19 Dec 2010 15:24:46 +0000 Subject: [PATCH] Put brackets around binoms in SmNodeToTextVisitor, with test --- starmath/qa/cppunit/test_nodetotextvisitors.cxx | 37 +++++++++++++++++++++++ starmath/source/visitors.cxx | 3 +- 2 files changed, 39 insertions(+), 1 deletions(-) diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 45386d1..e5b9e93 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -41,6 +41,7 @@ #include <document.hxx> #include <node.hxx> #include <visitors.hxx> +#include <cursor.hxx> #include "preextstl.h" #include <cppunit/TestSuite.h> @@ -72,6 +73,14 @@ struct assertion_traits<String> SO2_DECL_REF(SmDocShell) SO2_IMPL_REF(SmDocShell) +class TestOutputDevice : public OutputDevice +{ +public: + TestOutputDevice() + { + } +}; + using namespace ::com::sun::star; namespace { @@ -95,6 +104,7 @@ public: void SimpleFormats(); void SimpleGreekChars(); void SimpleSpecialChars(); + void testBinomInBinHor(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(SimpleUnaryOp); @@ -109,6 +119,7 @@ public: CPPUNIT_TEST(SimpleFormats); CPPUNIT_TEST(SimpleGreekChars); CPPUNIT_TEST(SimpleSpecialChars); + CPPUNIT_TEST(testBinomInBinHor); CPPUNIT_TEST_SUITE_END(); private: @@ -480,6 +491,32 @@ void Test::parseandparseagain(const char *formula, const char *test_name) delete pNode2; } +void Test::testBinomInBinHor() +{ + String sInput, sExpected, sOutput; + SmNode* pTree; + + // set up a binom (table) node + sInput.AppendAscii("binom a b + c"); + pTree = SmParser().Parse(sInput); + pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef); + + SmCursor aCursor(pTree, xDocShRef); + TestOutputDevice aOutputDevice; + + // move forward (more than) enough places to be at the end + int i; + for (i = 0; i < 8; ++i) + aCursor.Move(&aOutputDevice, MoveRight); + + // tack +d on the end, which will put the binom into an SmBinHorNode + aCursor.InsertElement(PlusElement); + aCursor.InsertText('d'); + + sExpected.AppendAscii(" { { binom a b + c } + d } "); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Binom Node in BinHor Node", sExpected, xDocShRef->GetText()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index 2e7e4e3..fbdb379 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -2163,9 +2163,10 @@ void SmSelectionDrawingVisitor::Visit( SmTextNode* pNode ) void SmNodeToTextVisitor::Visit( SmTableNode* pNode ) { if( pNode->GetToken( ).eType == TBINOM ) { - Append( "binom" ); + Append( "{ binom" ); LineToText( pNode->GetSubNode( 0 ) ); LineToText( pNode->GetSubNode( 1 ) ); + Append("} "); } else if( pNode->GetToken( ).eType == TSTACK ) { Append( "stack{ " ); SmNodeIterator it( pNode ); -- 1.7.3.3
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice