diff options
author | Luke Dixon <6b8b4567@gmail.com> | 2010-12-19 15:24:46 +0000 |
---|---|---|
committer | Jonas Finnemann Jensen <jopsen@gmail.com> | 2010-12-19 17:15:55 +0100 |
commit | d80b166d6aa125fd639d282ab5d00d1594448d98 (patch) | |
tree | c4faae9ee0635b978df6f61bfe088447b76858dd /starmath | |
parent | 72228b8893f43443c6ef0c98514e3ef4bdb0f9b0 (diff) |
Put brackets around binoms in SmNodeToTextVisitor, with test
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/qa/cppunit/test_nodetotextvisitors.cxx | 37 | ||||
-rw-r--r-- | 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 45386d13aa7a..e5b9e9338e6b 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 2e7e4e3d3244..fbdb379f2c62 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 ); |