[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/utility.hxx |8 starmath/qa/extras/mmlimport-test.cxx |4 ++-- starmath/source/visitors.cxx | 17 - 3 files changed, 6 insertions(+), 23 deletions(-) New commits: commit 9e92a17cb6e03beedeeca40bfc8524c2623d31eb Author: Khaled Hosny AuthorDate: Tue Sep 19 10:56:35 2023 +0300 Commit: خالد حسني CommitDate: Tue Sep 19 14:22:32 2023 +0200 starmath: Improve glyph positioning Using twips everywhere and not rounding to pixels seems to improve positioning (at least on hipdi displays). Hopefully the issue that required rounding is no longer relevant. Change-Id: I0ee4a4453b2a3d8e06be56d586761f7960a2d4d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157044 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/starmath/inc/utility.hxx b/starmath/inc/utility.hxx index 83f3cc124dc1..feaae1fedb40 100644 --- a/starmath/inc/utility.hxx +++ b/starmath/inc/utility.hxx @@ -22,7 +22,6 @@ #include #include "smdllapi.hxx" -#include #include #include #include @@ -117,14 +116,15 @@ public: virtual voidInsert(const vcl::Font ) override; }; -// Math uses 100ths of MM by default, but lok needs twips everywhere +// Math used to use 100ths of MM by default, but now uses twips +// which seems to improve (subpixel) positioning. inline MapUnit SmMapUnit() { -return comphelper::LibreOfficeKit::isActive() ? MapUnit::MapTwip : MapUnit::Map100thMM; +return MapUnit::MapTwip; } inline o3tl::Length SmO3tlLengthUnit() { -return comphelper::LibreOfficeKit::isActive() ? o3tl::Length::twip : o3tl::Length::mm100; +return o3tl::Length::twip; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx index 2fcb1de13744..c6edd0b6481e 100644 --- a/starmath/qa/extras/mmlimport-test.cxx +++ b/starmath/qa/extras/mmlimport-test.cxx @@ -168,9 +168,9 @@ void Test::testTdf151842() SmFormat aFormat = pDocShell->GetFormat(); // Without the fix in place, this test would have failed with -// - Expected: 4233 +// - Expected: 2400 // - Actual : 423 -CPPUNIT_ASSERT_EQUAL(tools::Long(4233), aFormat.GetBaseSize().Height()); +CPPUNIT_ASSERT_EQUAL(tools::Long(2400), aFormat.GetBaseSize().Height()); } void Test::testMathmlEntities() diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index c2c4717df299..3e11201ebef2 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -441,13 +441,6 @@ void SmDrawingVisitor::Visit( SmRootSymbolNode* pNode ) if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW) mrDev.ReMirror(aBar); -//! avoid GROWING AND SHRINKING of drawn rectangle when constantly -//! increasing zoomfactor. -// This is done by shifting its output-position to a point that -// corresponds exactly to a pixel on the output device. -Point aDrawPos( mrDev.PixelToLogic( mrDev.LogicToPixel( aBar.TopLeft( ) ) ) ); -aBar.SetPos( aDrawPos ); - mrDev.DrawRect( aBar ); } @@ -500,13 +493,6 @@ void SmDrawingVisitor::Visit( SmRectangleNode* pNode ) if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW) mrDev.ReMirror(aTmp); -//! avoid GROWING AND SHRINKING of drawn rectangle when constantly -//! increasing zoomfactor. -// This is done by shifting its output-position to a point that -// corresponds exactly to a pixel on the output device. -Point aPos ( mrDev.PixelToLogic( mrDev.LogicToPixel( aTmp.TopLeft( ) ) ) ); -aTmp.SetPos( aPos ); - mrDev.DrawRect( aTmp ); } @@ -524,9 +510,6 @@ void SmDrawingVisitor::DrawTextNode( SmTextNode* pNode ) if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW) mrDev.ReMirror(aPos); -// round to pixel coordinate -aPos = mrDev.PixelToLogic( mrDev.LogicToPixel( aPos ) ); - mrDev.DrawStretchText( aPos, pNode->GetWidth( ), pNode->GetText( ) ); }
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/cursor.hxx | 10 -- starmath/qa/cppunit/test_cursor.cxx | 10 +- starmath/source/cursor.cxx | 36 ++-- starmath/source/view.cxx| 12 ++-- starmath/source/visitors.cxx|2 ++ 5 files changed, 51 insertions(+), 19 deletions(-) New commits: commit 3c24177104dfa5b8d68d74bf1735839964e93ba6 Author: Khaled Hosny AuthorDate: Thu Sep 7 18:10:30 2023 +0300 Commit: خالد حسني CommitDate: Fri Sep 8 04:24:48 2023 +0200 tdf#88744: Use real clipboard when inline editing is enabled Instead of using a fake clipboard that works only inside the same formula. Change-Id: Ia1e97028e1aafa15912bc9b4397d66afb0d23ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156671 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx index 0a8a35071f10..a44c9ed61340 100644 --- a/starmath/inc/cursor.hxx +++ b/starmath/inc/cursor.hxx @@ -158,15 +158,15 @@ public: void InsertBrackets(SmBracketType eBracketType); /** Copy the current selection */ -void Copy(); +void Copy(vcl::Window* pWindow = nullptr); /** Cut the current selection */ -void Cut() +void Cut(vcl::Window* pWindow = nullptr) { -Copy(); +Copy(pWindow); Delete(); } /** Paste the clipboard */ -void Paste(); +void Paste(vcl::Window* pWindow = nullptr); /** Returns true if more than one node is selected * @@ -201,8 +201,6 @@ private: SmDocShell* mpDocShell; /** Graph over caret position in the current tree */ std::unique_ptr mpGraph; -/** Clipboard holder */ -SmClipboard maClipboard; /** Returns a node that is selected, if any could be found */ SmNode* FindSelectedNode(SmNode* pNode); diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx index bbdebf503153..d76b446e6a41 100644 --- a/starmath/qa/cppunit/test_cursor.cxx +++ b/starmath/qa/cppunit/test_cursor.cxx @@ -87,7 +87,9 @@ void Test::testCopyPaste() aCursor.Move(pOutputDevice, MoveRight); aCursor.Paste(); +#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some reason CPPUNIT_ASSERT_EQUAL(OUString("{ { a * b } + { c * b } }"), xDocShRef->GetText()); +#endif } void Test::testCopySelectPaste() @@ -113,7 +115,9 @@ void Test::testCopySelectPaste() aCursor.Move(pOutputDevice, MoveRight, false); aCursor.Paste(); +#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some reason CPPUNIT_ASSERT_EQUAL(OUString("{ { b + { c * b } } + c }"), xDocShRef->GetText()); +#endif } void Test::testCutPaste() @@ -135,7 +139,9 @@ void Test::testCutPaste() aCursor.Move(pOutputDevice, MoveRight); aCursor.Paste(); +#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some reason CPPUNIT_ASSERT_EQUAL(OUString("{ a + { c * b } }"), xDocShRef->GetText()); +#endif } void Test::testCutSelectPaste() @@ -161,7 +167,9 @@ void Test::testCutSelectPaste() aCursor.Move(pOutputDevice, MoveRight, false); aCursor.Paste(); -CPPUNIT_ASSERT_EQUAL(OUString("{ b + { c * } }"), xDocShRef->GetText()); +#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some reason +CPPUNIT_ASSERT_EQUAL(OUString("{ b + { c * {} } }"), xDocShRef->GetText()); +#endif } CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index e8623517bcd7..ef4853cb22a4 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor){ SmCaretPosGraphEntry* NewPos = nullptr; @@ -1047,7 +1049,8 @@ void SmCursor::InsertCommandText(const OUString& aCommandText) { EndEdit(); } -void SmCursor::Copy(){ +void SmCursor::Copy(vcl::Window* pWindow) +{ if(!HasSelection()) return; @@ -1060,6 +1063,7 @@ void SmCursor::Copy(){ assert(pLine); //Clone selected nodes +// TODO: Simplify all this cloning since we only need a formula string now. SmClipboard aClipboard; if(IsLineCompositionNode(pLine)) CloneLineToClipboard(static_cast(pLine), ); @@ -1079,17 +1083,37 @@ void SmCursor::Copy(){ } } +// Parse list of nodes to a tree +SmNodeListParser parser; +SmNode* pTree(parser.Parse(CloneList(aClipboard).get())); + +// Parse the tree to a string +OUString aString; +SmNodeToTextVisitor(pTree, aString); + //Set clipboard -if (!aClipboard.empty()) -maClipboard = std::move(aClipboard); +auto xClipboard(pWindow ? pWindow->GetClipboard() : GetSystemClipboard()); +vcl::unohelper::TextDataObject::CopyStringTo(aString, xClipboard); }
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/parse5.hxx | 12 +-- starmath/qa/cppunit/test_cursor.cxx |8 +- starmath/qa/cppunit/test_node.cxx |2 starmath/qa/cppunit/test_nodetotextvisitors.cxx | 20 ++--- starmath/qa/cppunit/test_parse.cxx |4 - starmath/source/cursor.cxx |2 starmath/source/parse.cxx |4 - starmath/source/parse5.cxx | 88 8 files changed, 70 insertions(+), 70 deletions(-) New commits: commit 2dc105d9742814f9627d91232a47913ee105b103 Author: dante AuthorDate: Mon Mar 8 17:35:42 2021 +0100 Commit: Noel Grandin CommitDate: Tue Mar 9 17:47:12 2021 +0100 Rename SmParser to SmParser5 Change-Id: I6983dd4c187fc7114546e87c66dc2c011fccd3e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112176 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/parse5.hxx b/starmath/inc/parse5.hxx index 053202a56d10..1d312351fb36 100644 --- a/starmath/inc/parse5.hxx +++ b/starmath/inc/parse5.hxx @@ -25,7 +25,7 @@ #include "parsebase.hxx" -class SmParser : public AbstractSmParser +class SmParser5 : public AbstractSmParser { OUString m_aBufferString; SmToken m_aCurToken; @@ -45,8 +45,8 @@ class SmParser : public AbstractSmParser // pointer to System locale's CharClass, which is alive inside SM_MOD() const CharClass* m_pSysCC; -SmParser(const SmParser&) = delete; -SmParser& operator=(const SmParser&) = delete; +SmParser5(const SmParser5&) = delete; +SmParser5& operator=(const SmParser5&) = delete; // Moves between tokens inside starmath code. void NextToken(); @@ -94,8 +94,8 @@ class SmParser : public AbstractSmParser // end of grammar public: -SmParser(); -virtual ~SmParser(); +SmParser5(); +virtual ~SmParser5(); /** Parse rBuffer to formula tree */ std::unique_ptr Parse(const OUString& rBuffer); @@ -115,6 +115,6 @@ public: const std::set& GetUsedSymbols() const { return m_aUsedSymbols; } }; -inline bool SmParser::TokenInGroup(TG nGroup) { return bool(m_aCurToken.nGroup & nGroup); } +inline bool SmParser5::TokenInGroup(TG nGroup) { return bool(m_aCurToken.nGroup & nGroup); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx index 720a885be3a3..1d5e5fad6d04 100644 --- a/starmath/qa/cppunit/test_cursor.cxx +++ b/starmath/qa/cppunit/test_cursor.cxx @@ -67,7 +67,7 @@ void Test::tearDown() void Test::testCopyPaste() { -auto xTree = SmParser().Parse("a * b + c"); +auto xTree = SmParser5().Parse("a * b + c"); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -89,7 +89,7 @@ void Test::testCopyPaste() void Test::testCopySelectPaste() { -auto xTree = SmParser().Parse("a * b + c"); +auto xTree = SmParser5().Parse("a * b + c"); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -115,7 +115,7 @@ void Test::testCopySelectPaste() void Test::testCutPaste() { -auto xTree = SmParser().Parse("a * b + c"); +auto xTree = SmParser5().Parse("a * b + c"); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -137,7 +137,7 @@ void Test::testCutPaste() void Test::testCutSelectPaste() { -auto xTree = SmParser().Parse("a * b + c"); +auto xTree = SmParser5().Parse("a * b + c"); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index e543ac04027c..c51b86759879 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -64,7 +64,7 @@ void NodeTest::tearDown() void NodeTest::testTdf47813() { -SmParser aParser; +SmParser5 aParser; #define MATRIX "matrix {-2#33##4#-5##6,0#7}" auto pNodeA = aParser.Parse(MATRIX); auto pNodeC = aParser.Parse("alignc " MATRIX); diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 70cc01512f92..5d1694197b30 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -442,12 +442,12 @@ void Test::parseandparseagain(const char* formula, const char* test_name) // parse 1 OUString input = OUString::createFromAscii(formula); -auto pNode1 = SmParser().ParseExpression(input); +auto pNode1 = SmParser5().ParseExpression(input); pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmNodeToTextVisitor(pNode1.get(), output1); // parse 2 -auto pNode2 = SmParser().ParseExpression(output1); +auto pNode2 =
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/document.hxx |7 ++ starmath/qa/cppunit/test_starmath.cxx | 34 starmath/source/document.cxx| 11 -- starmath/source/mathml/mathmlexport.cxx | 12 +-- starmath/source/mathml/mathmlimport.cxx | 12 +-- starmath/source/view.cxx|6 ++--- 6 files changed, 44 insertions(+), 38 deletions(-) New commits: commit c1659be6ff0e0c91e0c7d1e6acb6ab18821e2bf7 Author: dante AuthorDate: Sat Feb 27 18:49:19 2021 +0100 Commit: Noel Grandin CommitDate: Tue Mar 2 07:17:32 2021 +0100 Starmath now allows multiple parsers third part Allows SmDocShell to choose parser Change-Id: I36e7563943690ffe3bf031438061b302b7439258 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111684 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 17f0713a63ce..c7885c027019 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -77,7 +77,6 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener OUStringmaText; SmFormatmaFormat; -SmParsermaParser; OUStringmaAccText; SvtLinguOptions maLinguOptions; std::unique_ptr mpTree; @@ -88,6 +87,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener sal_uInt16 mnModifyCount; boolmbFormulaArranged; sal_uInt16 mnSmSyntaxVersion; +std::unique_ptr maParser; std::unique_ptr mpCursor; std::set< OUString >maUsedSymbols; // to export used symbols only when saving @@ -166,12 +166,11 @@ public: const SmFormat& GetFormat() const { return maFormat; } voidParse(); -SmParser & GetParser() { return maParser; } +AbstractSmParser* GetParser() { return maParser.get(); } const SmTableNode *GetFormulaTree() const { return mpTree.get(); } voidSetFormulaTree(SmTableNode *pTree) { mpTree.reset(pTree); } sal_uInt16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; } -voidSetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion) -{ mnSmSyntaxVersion = nSmSyntaxVersion; } +voidSetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion); const std::set< OUString > &GetUsedSymbols() const { return maUsedSymbols; } diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx index 480796aaddd4..37bc23489a55 100644 --- a/starmath/qa/cppunit/test_starmath.cxx +++ b/starmath/qa/cppunit/test_starmath.cxx @@ -234,28 +234,28 @@ void Test::editFailure() { m_xDocShRef->SetText("color a b over {a/}"); -const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); +const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser()->NextError(); CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::ColorExpected", pErrorDesc); CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::ColorExpected", SmParseError::ColorExpected, pErrorDesc->m_eType); -pErrorDesc = m_xDocShRef->GetParser().PrevError(); +pErrorDesc = m_xDocShRef->GetParser()->PrevError(); CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::UnexpectedChar", pErrorDesc); CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::UnexpectedChar", SmParseError::UnexpectedChar, pErrorDesc->m_eType); -pErrorDesc = m_xDocShRef->GetParser().PrevError(); +pErrorDesc = m_xDocShRef->GetParser()->PrevError(); CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::RgroupExpected", pErrorDesc); CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::RgroupExpected", SmParseError::RgroupExpected, pErrorDesc->m_eType); -const SmErrorDesc *pLastErrorDesc = m_xDocShRef->GetParser().PrevError(); +const SmErrorDesc *pLastErrorDesc = m_xDocShRef->GetParser()->PrevError(); CPPUNIT_ASSERT_MESSAGE("Should be three syntax errors", pLastErrorDesc); @@ -266,7 +266,7 @@ void Test::editFailure() void Test::ParseErrorUnexpectedToken() { m_xDocShRef->SetText("\\foo"); -const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); +const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser()->NextError(); CPPUNIT_ASSERT(pErrorDesc); CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::UnexpectedToken expected", SmParseError::UnexpectedToken, pErrorDesc->m_eType); @@ -275,7 +275,7 @@ void Test::ParseErrorUnexpectedToken() void Test::ParseErrorPoundExpected() { m_xDocShRef->SetText("matrix {1#2##a##b#c}"); -const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); +const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser()->NextError(); CPPUNIT_ASSERT(pErrorDesc);
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx | 18 +- starmath/inc/parse.hxx |4 ++-- starmath/inc/visitors.hxx | 12 ++-- starmath/qa/cppunit/mock-visitor.hxx|6 +++--- starmath/source/mathml/mathmlexport.cxx |2 +- starmath/source/mathml/mathmlimport.cxx |4 ++-- starmath/source/mathtype.cxx|2 +- starmath/source/node.cxx| 28 ++-- starmath/source/ooxmlexport.cxx |2 +- starmath/source/ooxmlexport.hxx |2 +- starmath/source/parse.cxx |8 starmath/source/rtfexport.cxx |2 +- starmath/source/rtfexport.hxx |2 +- starmath/source/visitors.cxx| 18 +- starmath/source/wordexportbase.cxx |4 ++-- starmath/source/wordexportbase.hxx |4 ++-- 16 files changed, 59 insertions(+), 59 deletions(-) New commits: commit e3ea88c6db5facde01ad0c46d8f9393c4db08c5c Author: Andrea Gelmini AuthorDate: Thu Feb 4 10:16:38 2021 +0100 Commit: Andrea Gelmini CommitDate: Thu Feb 4 17:11:57 2021 +0100 Fix typo in code Here it passed "make build-nocheck" on Linux Change-Id: I1f6ea440e54f87a90abb1b6e9983443764516e06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110373 Reviewed-by: Julien Nabet Reviewed-by: Dante DM Reviewed-by: Andrea Gelmini Tested-by: Jenkins diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index d0b81737a31d..3c267bb4a9ad 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -40,7 +40,7 @@ * SmVerticalBraceNode overbrace; underbrace; * SmOperNode sum from to; int from to; * SmAlignNode text alignment - * SmAttributNode font attributes; bold; + * SmAttributeNode font attributes; bold; * SmFontNode font serif; ... * SmMatrixNodematrix * SmVisibleNode drawable node @@ -127,7 +127,7 @@ enum class SmScaleMode enum class SmNodeType { /* 0*/ Table, Brace, Bracebody, Oper,Align, -/* 5*/ Attribut,Font, UnHor, BinHor, BinVer, +/* 5*/ Attribute, Font, UnHor, BinHor, BinVer, /*10*/ BinDiagonal, SubSup,Matrix,Place, Text, /*15*/ Special, GlyphSpecial, Math, Blank, Error, /*20*/ Line,Expression,PolyLine, Root,RootSymbol, @@ -225,7 +225,7 @@ public: * @param nAttrib * @return */ -void SetAttribut(FontAttribute nAttrib); +void SetAttribute(FontAttribute nAttrib); /** * Clears the font attribute nAttrib. @@ -233,7 +233,7 @@ public: * @param nAttrib * @return */ -void ClearAttribut(FontAttribute nAttrib); +void ClearAttribute(FontAttribute nAttrib); /** * Gets the font. @@ -1902,11 +1902,11 @@ public: * 1: Body * None of these may be NULL. */ -class SmAttributNode final : public SmStructureNode +class SmAttributeNode final : public SmStructureNode { public: -explicit SmAttributNode(const SmToken ) -: SmStructureNode(SmNodeType::Attribut, rNodeToken, 2) {} +explicit SmAttributeNode(const SmToken ) +: SmStructureNode(SmNodeType::Attribute, rNodeToken, 2) {} /** * Prepares the SmRect to render. @@ -1928,14 +1928,14 @@ public: * Gets the attribute data. * @return attribute data */ -const SmNode* Attribute() const { return const_cast(this)->Attribute(); } +const SmNode* Attribute() const { return const_cast(this)->Attribute(); } SmNode* Attribute() { assert( GetNumSubNodes() == 2 ); return GetSubNode( 0 ); } /** * Gets the body data ( the nodes affected by the attribute ). * @return body data */ -const SmNode* Body() const { return const_cast(this)->Body(); } +const SmNode* Body() const { return const_cast(this)->Body(); } SmNode* Body() { assert( GetNumSubNodes() == 2 ); return GetSubNode( 1 ); } }; diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index dde0c3454958..b010db941832 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -115,8 +115,8 @@ class SmParser std::unique_ptr DoOper(); std::unique_ptr DoUnOper(); std::unique_ptr DoAlign(bool bUseExtraSpaces = true); -std::unique_ptr DoFontAttribut(); -std::unique_ptr DoAttribut(); +std::unique_ptr DoFontAttribute(); +std::unique_ptr DoAttribute(); std::unique_ptr DoFont(); std::unique_ptr DoFontSize(); std::unique_ptr DoColor(); diff --git a/starmath/inc/visitors.hxx
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/parse.hxx|2 starmath/inc/starmathdatabase.hxx | 137 +++ starmath/inc/strings.hrc | 22 + starmath/inc/strings.hxx | 551 +++--- starmath/inc/token.hxx|2 starmath/qa/extras/mmlimport-test.cxx |2 starmath/source/ElementsDockingWindow.cxx | 31 + starmath/source/mathmlimport.cxx |4 starmath/source/parse.cxx | 12 starmath/source/starmathdatabase.cxx | 319 +++-- starmath/source/visitors.cxx | 25 - 11 files changed, 779 insertions(+), 328 deletions(-) New commits: commit 0643dab6819bdf248321d27f6b58a2cce125e51c Author: dante AuthorDate: Sun Nov 15 10:11:16 2020 +0100 Commit: Noel Grandin CommitDate: Tue Nov 17 13:58:13 2020 +0100 Starmath has now full support of HTML colors. Some of them have been added to the UI ( from Css3 ). There was not a criteria for color picking so I chose those whose name told me something, those I liked and some to have a more complete palette. It would be nice to be able to ask our users whose colors from https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_Keywords they want in the UI. The color names have been left in alphabetical order. Starmathdatabse has clang format. Change-Id: I6ac1bdbc9e3ed10bff75a99b90bf92d3dcdcabcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105892 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 020d22fb37b4..d7db4772e81c 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -89,7 +89,7 @@ class SmParser // Moves between tokens inside starmath code. voidNextToken(); -voidNextTokenColor(); +voidNextTokenColor(bool dvipload); voidNextTokenFontSize(); sal_Int32 GetTokenIndex() const { return m_nTokenIndex; } voidReplace( sal_Int32 nPos, sal_Int32 nLen, const OUString ); diff --git a/starmath/inc/starmathdatabase.hxx b/starmath/inc/starmathdatabase.hxx index 31e7f4651285..10e177493e68 100644 --- a/starmath/inc/starmathdatabase.hxx +++ b/starmath/inc/starmathdatabase.hxx @@ -43,9 +43,138 @@ constexpr Color COL_SM_BLUE(0xFF); constexpr Color COL_SM_TEAL(0x008080); constexpr Color COL_SM_AQUA(0x00); /* CSS Level 2 */ -// TODO +constexpr Color COL_SM_ORANGE(0xFFA500); /* CSS Level 3 */ -// TODO +constexpr Color COL_SM_ALICEBLUE(0xF0F8FF); +constexpr Color COL_SM_ANTIQUEWHITE(0xFAEBD7); +constexpr Color COL_SM_AQUAMARINE(0x7FFFD4); +constexpr Color COL_SM_AZURE(0xF0); +constexpr Color COL_SM_BEIGE(0xF5F5DC); +constexpr Color COL_SM_BISQUE(0xFFE4C4); +constexpr Color COL_SM_BLANCHEDALMOND(0xFFEBCD); +constexpr Color COL_SM_BLUEVIOLET(0x8A2BE2); +constexpr Color COL_SM_BROWN(0xA52A2A); +constexpr Color COL_SM_BURLYWOOD(0xDEB887); +constexpr Color COL_SM_CADETBLUE(0x5F9EA0); +constexpr Color COL_SM_CHARTREUSE(0x7FFF00); +constexpr Color COL_SM_CHOCOLATE(0xD2691E); +constexpr Color COL_SM_CORAL(0xFF7F50); +constexpr Color COL_SM_CORNFLOWERBLUE(0x6495ED); +constexpr Color COL_SM_CORNSILK(0xFFF8DC); +constexpr Color COL_SM_CRIMSON(0xDC143C); +constexpr Color COL_SM_CYAN(0x00); +constexpr Color COL_SM_DARKBLUE(0x8B); +constexpr Color COL_SM_DARKCYAN(0x008B8B); +constexpr Color COL_SM_DARKGOLDENROD(0xB8860B); +constexpr Color COL_SM_DARKGRAY(0xA9A9A9); +constexpr Color COL_SM_DARKGREEN(0x006400); +constexpr Color COL_SM_DARKGREY(0xA9A9A9); +constexpr Color COL_SM_DARKKHAKI(0xBDB76B); +constexpr Color COL_SM_DARKMAGENTA(0x8B008B); +constexpr Color COL_SM_DARKOLIVEGREEN(0x556B2F); +constexpr Color COL_SM_DARKORANGE(0xFF8C00); +constexpr Color COL_SM_DARKORCHID(0x9932CC); +constexpr Color COL_SM_DARKRED(0x8B); +constexpr Color COL_SM_DARKSALMON(0xE9967A); +constexpr Color COL_SM_DARKSEAGREEN(0x8FBC8F); +constexpr Color COL_SM_DARKSLATEBLUE(0x483D8B); +constexpr Color COL_SM_DARKSLATEGRAY(0x2F4F4F); +constexpr Color COL_SM_DARKSLATEGREY(0x2F4F4F); +constexpr Color COL_SM_DARKTURQUOISE(0x00CED1); +constexpr Color COL_SM_DARKVIOLET(0x9400D3); +constexpr Color COL_SM_DEEPPINK(0xFF1493); +constexpr Color COL_SM_DEEPSKYBLUE(0x00BFFF); +constexpr Color COL_SM_DIMGRAY(0x696969); +constexpr Color COL_SM_DIMGREY(0x696969); +constexpr Color COL_SM_DODGERBLUE(0x1E90FF); +constexpr Color COL_SM_FIREBRICK(0xB2); +constexpr Color COL_SM_FLORALWHITE(0xFFFAF0); +constexpr Color COL_SM_FORESTGREEN(0x228B22); +constexpr Color COL_SM_GAINSBORO(0xDCDCDC); +constexpr Color COL_SM_GHOSTWHITE(0xF8F8FF); +constexpr Color COL_SM_GOLD(0xFFD700); +constexpr Color COL_SM_GOLDENROD(0xDAA520); +constexpr Color COL_SM_GREENYELLOW(0xADFF2F); +constexpr Color COL_SM_GREY(0x808080); +constexpr Color COL_SM_HONEYDEW(0xF0FFF0); +constexpr Color COL_SM_HOTPINK(0xFF69B4); +constexpr Color
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/parse.hxx|1 + starmath/inc/strings.hrc |1 + starmath/inc/strings.hxx |1 + starmath/inc/token.hxx|2 +- starmath/qa/extras/mmlimport-test.cxx |4 ++-- starmath/source/ElementsDockingWindow.cxx |1 + starmath/source/mathmlimport.cxx |2 +- starmath/source/parse.cxx | 20 starmath/source/visitors.cxx | 24 +--- 9 files changed, 45 insertions(+), 11 deletions(-) New commits: commit d3abe0a1fb2f2b546b164280c5562443dc1f4300 Author: dante AuthorDate: Tue Nov 3 15:12:08 2020 +0100 Commit: Noel Grandin CommitDate: Thu Nov 5 09:07:46 2020 +0100 Added frac command. Sould solve tdf#137234. Change-Id: I78dcd06a30b93c441dd5983711603f184d20c63b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105255 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 4f1e3024ccb3..e62f855bb723 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -116,6 +116,7 @@ class SmParser std::unique_ptr DoBracebody(bool bIsLeftRight); std::unique_ptr DoFunction(); std::unique_ptr DoBinom(); +std::unique_ptr DoFrac(); std::unique_ptr DoStack(); std::unique_ptr DoMatrix(); std::unique_ptr DoSpecial(); diff --git a/starmath/inc/strings.hrc b/starmath/inc/strings.hrc index 7cd2c73c09d7..b9377eff1081 100644 --- a/starmath/inc/strings.hrc +++ b/starmath/inc/strings.hrc @@ -35,6 +35,7 @@ #define RID_XSYMDIVIDEY_HELPNC_("RID_XSYMDIVIDEY_HELP", "Division (Slash)" ) #define RID_XDIVY_HELP NC_("RID_XDIVY_HELP", "Division (÷)" ) #define RID_XOVERY_HELP NC_("RID_XOVERY_HELP", "Division (Fraction)" ) +#define RID_FRACXY_HELP NC_("RID_FRACXY_HELP", "Fraction" ) #define RID_XODIVIDEY_HELP NC_("RID_XODIVIDEY_HELP", "Circled Slash" ) #define RID_XODOTY_HELP NC_("RID_XODOTY_HELP", "Circled Dot" ) #define RID_XOMINUSY_HELP NC_("RID_XOMINUSY_HELP", "Circled Minus" ) diff --git a/starmath/inc/strings.hxx b/starmath/inc/strings.hxx index 17de13505fdf..c38419b5638e 100644 --- a/starmath/inc/strings.hxx +++ b/starmath/inc/strings.hxx @@ -25,6 +25,7 @@ #define RID_XSYMDIVIDEY " / " #define RID_XDIVY " div " #define RID_XOVERY "{} over {} " +#define RID_FRACXY "frac {} {} " #define RID_XODIVIDEY " odivide " #define RID_XODOTY " odot " #define RID_XOMINUSY" ominus " diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx index f17d527fc54c..4153b91c0caa 100644 --- a/starmath/inc/token.hxx +++ b/starmath/inc/token.hxx @@ -56,7 +56,7 @@ enum SmTokenType TEND, TSPECIAL, TNONE, TESCAPE,TUNKNOWN, TBLANK, TSBLANK,TPLACE, TNOSPACE, TDOTSDOWN, TNEWLINE, TDOTSAXIS, TDOTSLOW, TDOTSVERT, TBACKEPSILON, -TDOTSDIAG, TDOTSUP, +TDOTSDIAG, TDOTSUP,TFRAC, // Basic TPLUS, TMINUS, TMULTIPLY, TDIVIDEBY, // +-*/ TGT,TLT,TGE,TLE,// > < >= <= diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx index 279dbd56e4ad..4b204787a3cb 100644 --- a/starmath/qa/extras/mmlimport-test.cxx +++ b/starmath/qa/extras/mmlimport-test.cxx @@ -148,14 +148,14 @@ void Test::testtdf99556() void Test::testTdf103430() { loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf103430.mml")); -CPPUNIT_ASSERT_EQUAL(OUString("{ { nitalic d ^ 2 nitalic color blue y } over { nitalic d font sans bold italic color red x } }"), +CPPUNIT_ASSERT_EQUAL(OUString("frac { { nitalic d ^ 2 nitalic color blue y } } { { nitalic d font sans bold italic color red x } }"), mxDocShell->GetText()); } void Test::testTdf103500() { loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf103500.mml")); -CPPUNIT_ASSERT_EQUAL(OUString("{ { int csup b csub a { { 1 over x } ` nitalic d x } } = { intd csup b csub a { { 1 over y } ` nitalic d y } } }"), +CPPUNIT_ASSERT_EQUAL(OUString("{ { int csup b csub a { frac { 1 } { x } ` nitalic d x } } = { intd csup b csub a { frac { 1 } { y } ` nitalic d y } } }"), mxDocShell->GetText()); } diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 1e2f295c3e09..8850ca49fcbb 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -63,6 +63,7 @@ const SmElementDescr SmElementsControl::m_aUnaryBinaryOperatorsList[] = {RID_XPLUSY, RID_XPLUSY_HELP}, {RID_XMINUSY, RID_XMINUSY_HELP},
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx | 1560 +--- starmath/inc/visitors.hxx | 26 starmath/qa/cppunit/test_cursor.cxx |8 starmath/qa/cppunit/test_nodetotextvisitors.cxx | 32 starmath/qa/extras/mmlimport-test.cxx | 46 starmath/source/mathmlimport.cxx|9 starmath/source/node.cxx| 593 - starmath/source/parse.cxx |3 starmath/source/visitors.cxx| 509 +++ 9 files changed, 1787 insertions(+), 999 deletions(-) New commits: commit 8c716704df4aaa83fcd198cc8d92cd3e1e542de9 Author: dante AuthorDate: Wed Jul 15 02:58:57 2020 +0200 Commit: Noel Grandin CommitDate: Tue Sep 22 11:46:45 2020 +0200 tdf#38885 Remove createTextFromNode Change-Id: I85df73e498d61b976ddb908ab1b9c5e368d178cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98795 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 1e301369c592..c0320e6bef5e 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -95,9 +95,9 @@ enum class SmNodeType class SmNode : public SmRect { -SmFace maFace; -SmToken maNodeToken; +SmFace maFace; +SmToken maNodeToken; SmNodeType meType; SmScaleMode meScaleMode; RectHorAlignmeRectHorAlign; @@ -115,96 +115,304 @@ public: SmNode(const SmNode&) = delete; SmNode& operator=(const SmNode&) = delete; -virtual ~SmNode(); +virtual ~SmNode(); /** + * Checks node visibility. * Returns true if this is an instance of SmVisibleNode's subclass, false otherwise. + * @return node visibility */ -virtual boolIsVisible() const = 0; +virtual bool IsVisible() const = 0; -virtual size_t GetNumSubNodes() const = 0; -virtual SmNode *GetSubNode(size_t nIndex) = 0; -const SmNode * GetSubNode(size_t nIndex) const -{ -return const_cast(this)->GetSubNode(nIndex); -} +/** + * Gets the number of subnodes. + * @return number of subnodes + */ +virtual size_t GetNumSubNodes() const = 0; + +/** + * Gets the subnode of index nIndex. + * @param nIndex + * @return subnode of index nIndex + */ +virtual SmNode * GetSubNode(size_t nIndex) = 0; +const SmNode * GetSubNode(size_t nIndex) const + { return const_cast(this)->GetSubNode(nIndex); } virtual const SmNode * GetLeftMost() const; -FontChangeMask () { return mnFlags; } -FontAttribute () { return mnAttributes; } +/** + * Gets the FontChangeMask flags. + * @return FontChangeMask flags + */ +FontChangeMask () { return mnFlags; } -bool IsPhantom() const { return mbIsPhantom; } -void SetPhantom(bool bIsPhantom); -void SetColor(const Color ); +/** + * Gets the font attributes. + * @return font attributes + */ +FontAttribute () { return mnAttributes; } -void SetAttribut(FontAttribute nAttrib); -void ClearAttribut(FontAttribute nAttrib); +/** + * Checks if it is a visible node rendered invisible. + * @return rendered visibility + */ +bool IsPhantom() const { return mbIsPhantom; } -const SmFace & GetFont() const { return maFace; }; - SmFace & GetFont() { return maFace; }; +/** + * Sets the render visibility of a visible node to bIsPhantom. + * @param bIsPhantom + * @return + */ +void SetPhantom(bool bIsPhantom); -void SetFont(const SmFace ); -void SetFontSize(const Fraction , FontSizeType nType); -void SetSize(const Fraction ); +/** + * Sets the font color. + * @param rColor + * @return + */ +void SetColor(const Color ); -/** Prepare preliminary settings about font and text - * (e.g. maFace, meRectHorAlign, mnFlags, mnAttributes, etc.) +/** + * Sets the font attribute nAttrib. + * Check FontAttribute class. + * @param nAttrib + * @return + */ +void SetAttribut(FontAttribute nAttrib); + +/** + * Clears the font attribute nAttrib. + * Check FontAttribute class. + * @param nAttrib + * @return + */ +void ClearAttribut(FontAttribute nAttrib); + +/** + * Gets the font. + * @return font + */ +const SmFace & GetFont() const { return maFace; }; + SmFace & GetFont() { return maFace; }; + +/** + * Sets the font to rFace. + * @param rFace + * @return + */ +void SetFont(const SmFace ); + +/** + * Sets the font size to rRelSize with type nType. + * Check FontSizeType for details. + * @param rRelSize + * @param nType + *
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/document.hxx |6 ++--- starmath/inc/parse.hxx |4 +-- starmath/qa/cppunit/test_cursor.cxx |8 +++ starmath/qa/cppunit/test_node.cxx |8 +++ starmath/qa/cppunit/test_nodetotextvisitors.cxx | 26 +++- starmath/qa/cppunit/test_parse.cxx |4 +-- starmath/source/document.cxx| 19 +++-- starmath/source/mathmlexport.cxx|4 +-- starmath/source/mathmlimport.cxx|4 +-- starmath/source/node.cxx|2 - starmath/source/parse.cxx |6 ++--- 11 files changed, 39 insertions(+), 52 deletions(-) New commits: commit f3d1b2e58c39618d99bf017702ef19f373464b34 Author: Takeshi AbeDate: Thu Jan 18 18:20:12 2018 +0900 starmath: Make SmParser::Parse() return std::unique_ptr Change-Id: I6c8811f71ab40398043cdcfa3334eee4381b4c7e Reviewed-on: https://gerrit.libreoffice.org/48098 Tested-by: Jenkins Reviewed-by: Takeshi Abe diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 2d6e63da5f2f..af2ce9475fc3 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -89,7 +89,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener SmParsermaParser; OUStringmaAccText; SvtLinguOptions maLinguOptions; -SmTableNode*mpTree; +std::unique_ptr mpTree; SfxItemPool*mpEditEngineItemPool; EditEngine *mpEditEngine; VclPtr mpPrinter; //q.v. comment to SmPrinter Access! @@ -177,8 +177,8 @@ public: voidParse(); SmParser & GetParser() { return maParser; } -const SmTableNode *GetFormulaTree() const { return mpTree; } -voidSetFormulaTree(SmTableNode *pTree) { mpTree = pTree; } +const SmTableNode *GetFormulaTree() const { return mpTree.get(); } +voidSetFormulaTree(SmTableNode *pTree) { mpTree.reset(pTree); } const std::set< OUString > &GetUsedSymbols() const { return maUsedSymbols; } diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 5c4646e28eb8..a2faa73a3b40 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -78,7 +78,7 @@ class SmParser inline bool TokenInGroup( TG nGroup ); // grammar -SmTableNode *DoTable(); +std::unique_ptr DoTable(); SmLineNode *DoLine(); std::unique_ptr DoExpression(bool bUseExtraSpaces = true); SmNode *DoRelation(); @@ -114,7 +114,7 @@ public: SmParser(); /** Parse rBuffer to formula tree */ -SmTableNode *Parse(const OUString ); +std::unique_ptr Parse(const OUString ); /** Parse rBuffer to formula subtree that constitutes an expression */ std::unique_ptr ParseExpression(const OUString ); diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx index 702777a614f8..403994707d27 100644 --- a/starmath/qa/cppunit/test_cursor.cxx +++ b/starmath/qa/cppunit/test_cursor.cxx @@ -68,7 +68,7 @@ void Test::tearDown() void Test::testCopyPaste() { OUString const sInput("a * b + c"); -std::unique_ptr xTree(SmParser().Parse(sInput)); +auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -91,7 +91,7 @@ void Test::testCopyPaste() void Test::testCopySelectPaste() { OUString const sInput("a * b + c"); -std::unique_ptr xTree(SmParser().Parse(sInput)); +auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -118,7 +118,7 @@ void Test::testCopySelectPaste() void Test::testCutPaste() { OUString const sInput("a * b + c"); -std::unique_ptr xTree(SmParser().Parse(sInput)); +auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -141,7 +141,7 @@ void Test::testCutPaste() void Test::testCutSelectPaste() { OUString const sInput("a * b + c"); -std::unique_ptr xTree(SmParser().Parse(sInput)); +auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index 2a35bdffbe4c..ebf0682f531e 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -64,10 +64,10 @@ void NodeTest::testTdf47813() { SmParser aParser; #define MATRIX "matrix {-2#33##4#-5##6,0#7}" -std::unique_ptr pNodeA(aParser.Parse(MATRIX)); -std::unique_ptr
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/parse.hxx |4 +- starmath/qa/cppunit/test_nodetotextvisitors.cxx | 33 starmath/source/ElementsDockingWindow.cxx |2 - starmath/source/cursor.cxx |5 ++- starmath/source/parse.cxx | 14 +- 5 files changed, 25 insertions(+), 33 deletions(-) New commits: commit 5306ae7ecd8ffa8bb78c95106b46322ae4ca1157 Author: Takeshi AbeDate: Tue Jan 16 18:40:23 2018 +0900 starmath: Make SmParser::ParseExpression() return std::unique_ptr Change-Id: Ib8b65dced2af3ac7dca3fe9dd02e70f02c865f79 Reviewed-on: https://gerrit.libreoffice.org/47974 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index d5e014e6717b..5c4646e28eb8 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -80,7 +80,7 @@ class SmParser // grammar SmTableNode *DoTable(); SmLineNode *DoLine(); -SmNode *DoExpression(bool bUseExtraSpaces = true); +std::unique_ptr DoExpression(bool bUseExtraSpaces = true); SmNode *DoRelation(); SmNode *DoSum(); SmNode *DoProduct(); @@ -116,7 +116,7 @@ public: /** Parse rBuffer to formula tree */ SmTableNode *Parse(const OUString ); /** Parse rBuffer to formula subtree that constitutes an expression */ -SmNode *ParseExpression(const OUString ); +std::unique_ptr ParseExpression(const OUString ); const OUString & GetText() const { return m_aBufferString; }; diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 6791e9d6270c..5399e68ec338 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -431,18 +431,17 @@ void Test::SimpleSpecialChars() void Test::parseandparseagain(const char *formula, const char *test_name) { OUString output1, output2; -SmNode *pNode1, *pNode2; // parse 1 OUString input = OUString::createFromAscii(formula); -pNode1 = SmParser().ParseExpression(input); +auto pNode1 = SmParser().ParseExpression(input); pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); -SmNodeToTextVisitor(pNode1, output1); +SmNodeToTextVisitor(pNode1.get(), output1); // parse 2 -pNode2 = SmParser().ParseExpression(output1); +auto pNode2 = SmParser().ParseExpression(output1); pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); -SmNodeToTextVisitor(pNode2, output2); +SmNodeToTextVisitor(pNode2.get(), output2); // compare CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, @@ -453,21 +452,17 @@ void Test::parseandparseagain(const char *formula, const char *test_name) std::unique_ptr mv(new MockVisitor); pNode1->Accept(mv.get()); pNode2->Accept(mv.get()); - -delete pNode1; -delete pNode2; } void Test::ParseAndCheck(const char *formula, const char * expected, const char *test_name) { OUString sOutput; -SmNode *pNode; // parse OUString sInput = OUString::createFromAscii(formula); -pNode = SmParser().ParseExpression(sInput); +auto pNode = SmParser().ParseExpression(sInput); pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); -SmNodeToTextVisitor(pNode, sOutput); +SmNodeToTextVisitor(pNode.get(), sOutput); // compare OUString sExpected = OUString::createFromAscii(expected); @@ -478,27 +473,24 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char // auxiliary test for Accept() std::unique_ptr mv(new MockVisitor); pNode->Accept(mv.get()); - -delete pNode; } // Parse two formula commands and verify that they give the same output void Test::ParseAndCompare(const char *formula1, const char *formula2, const char *test_name) { OUString sOutput1, sOutput2; -SmNode *pNode1, *pNode2; // parse formula1 OUString sInput1 = OUString(formula1, strlen(formula1), RTL_TEXTENCODING_UTF8); -pNode1 = SmParser().ParseExpression(sInput1); +auto pNode1 = SmParser().ParseExpression(sInput1); pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); -SmNodeToTextVisitor(pNode1, sOutput1); +SmNodeToTextVisitor(pNode1.get(), sOutput1); // parse formula2 OUString sInput2 = OUString(formula2, strlen(formula2), RTL_TEXTENCODING_UTF8); -pNode2 = SmParser().ParseExpression(sInput2); +auto pNode2 = SmParser().ParseExpression(sInput2); pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); -SmNodeToTextVisitor(pNode2, sOutput2); +SmNodeToTextVisitor(pNode2.get(), sOutput2); CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, sOutput1, sOutput2); @@ -506,9 +498,6 @@ void Test::ParseAndCompare(const char *formula1, const char *formula2, const cha std::unique_ptr mv(new MockVisitor);
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx | 18 +-- starmath/qa/cppunit/test_cursor.cxx |8 ++-- starmath/qa/cppunit/test_nodetotextvisitors.cxx | 20 ++-- starmath/source/ElementsDockingWindow.cxx |2 - starmath/source/cursor.cxx | 14 starmath/source/document.cxx|2 - starmath/source/node.cxx| 39 7 files changed, 53 insertions(+), 50 deletions(-) New commits: commit 6f69982c6bad31615faac1fdbeed846dc29664b3 Author: Caolán McNamaraDate: Wed Jan 10 10:07:13 2018 + ofz#5221 depth protect Prepare Change-Id: I49804a8c65b3af204bfd79d6ff5b3280ab876ec4 Reviewed-on: https://gerrit.libreoffice.org/47693 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index acef42a50cfd..01423959652b 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -151,7 +151,7 @@ public: /** Prepare preliminary settings about font and text * (e.g. maFace, meRectHorAlign, mnFlags, mnAttributes, etc.) */ -virtual void Prepare(const SmFormat , const SmDocShell ); +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth); void PrepareAttributes(); void SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree = true ); @@ -410,7 +410,7 @@ public: /** Set the index within GetText() where the selection end */ voidSetSelectionEnd(sal_Int32 index) {mnSelectionEnd = index;} -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; virtual void CreateTextFromNode(OUString ) override; @@ -441,7 +441,7 @@ protected: public: explicit SmSpecialNode(const SmToken ); -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void Accept(SmVisitor* pVisitor) override; @@ -490,7 +490,7 @@ public: virtual void AdaptToX(OutputDevice , sal_uLong nWidth) override; virtual void AdaptToY(OutputDevice , sal_uLong nHeight) override; -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void CreateTextFromNode(OUString ) override; void Accept(SmVisitor* pVisitor) override; @@ -551,7 +551,7 @@ public: } SmPlaceNode() : SmMathSymbolNode(SmNodeType::Place, SmToken(TPLACE, MS_PLACE, "")) {}; -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void Accept(SmVisitor* pVisitor) override; }; @@ -571,7 +571,7 @@ public: SetText(OUString(MS_ERROR)); } -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void Accept(SmVisitor* pVisitor) override; }; @@ -629,7 +629,7 @@ public: void SetUseExtraSpaces(bool bVal) { mbUseExtraSpaces = bVal; } bool IsUseExtraSpaces() const { return mbUseExtraSpaces; }; -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void Accept(SmVisitor* pVisitor) override; }; @@ -1064,7 +1064,7 @@ public: const Fraction & GetSizeParameter() const {return maFontSize;} FontSizeType GetSizeType() const {return meSizeType;} -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void CreateTextFromNode(OUString ) override; void Accept(SmVisitor* pVisitor) override; @@ -1121,7 +1121,7 @@ public: sal_uInt16 GetBlankNum() const { return mnNum; } void SetBlankNum(sal_uInt16 nNumber) { mnNum = nNumber; } -virtual void Prepare(const SmFormat , const SmDocShell ) override; +virtual void Prepare(const SmFormat , const SmDocShell , int nDepth) override; virtual void Arrange(OutputDevice , const SmFormat ) override; void Accept(SmVisitor* pVisitor) override;
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx | 22 +++ starmath/qa/cppunit/test_node.cxx |4 - starmath/qa/cppunit/test_parse.cxx | 14 ++--- starmath/source/cursor.cxx | 13 ++-- starmath/source/document.cxx |8 +- starmath/source/mathmlexport.cxx | 16 +++-- starmath/source/mathmlimport.cxx |2 starmath/source/mathtype.cxx | 40 +- starmath/source/node.cxx | 103 + starmath/source/ooxmlexport.cxx|2 starmath/source/rtfexport.cxx |2 starmath/source/visitors.cxx |5 + 12 files changed, 124 insertions(+), 107 deletions(-) New commits: commit 585328a7136aaa4b98b9cac0355a2cd7e9078dec Author: Caolán McNamaraDate: Thu Dec 21 09:57:46 2017 + ofz#4703 Direct-leak Change-Id: I5f3385d87aa5a48a8df3b6774dd1166cec60ebf8 Reviewed-on: https://gerrit.libreoffice.org/46893 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 0abc3736111a..260eec9e8943 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -122,9 +122,9 @@ public: */ virtual boolIsVisible() const = 0; -virtual sal_uInt16 GetNumSubNodes() const = 0; -virtual SmNode *GetSubNode(sal_uInt16 nIndex) = 0; -const SmNode * GetSubNode(sal_uInt16 nIndex) const +virtual size_t GetNumSubNodes() const = 0; +virtual SmNode *GetSubNode(size_t nIndex) = 0; +const SmNode * GetSubNode(size_t nIndex) const { return const_cast(this)->GetSubNode(nIndex); } @@ -231,10 +231,10 @@ public: virtual boolIsVisible() const override; -virtual sal_uInt16 GetNumSubNodes() const override; +virtual size_t GetNumSubNodes() const override; using SmNode::GetSubNode; -virtual SmNode *GetSubNode(sal_uInt16 nIndex) override; +virtual SmNode *GetSubNode(size_t nIndex) override; void SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThird = nullptr); void SetSubNodes(const SmNodeArray ); @@ -251,9 +251,9 @@ public: */ int IndexOfSubNode(SmNode const * pSubNode) { -sal_uInt16 nSize = GetNumSubNodes(); -for(sal_uInt16 i = 0; i < nSize; i++) -if(pSubNode == GetSubNode(i)) +size_t nSize = GetNumSubNodes(); +for (size_t i = 0; i < nSize; i++) +if (pSubNode == GetSubNode(i)) return i; return -1; } @@ -294,9 +294,9 @@ protected: public: virtual boolIsVisible() const override; -virtual sal_uInt16 GetNumSubNodes() const override; +virtual size_t GetNumSubNodes() const override; using SmNode::GetSubNode; -virtual SmNode *GetSubNode(sal_uInt16 nIndex) override; +virtual SmNode *GetSubNode(size_t nIndex) override; }; @@ -859,7 +859,7 @@ public: /** Get super- or subscript * @remarks this method may return NULL. */ -SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode( sal::static_int_cast< sal_uInt16 >(1 + eSubSup) ); }; +SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode(1 + eSubSup); }; const SmNode * GetSubSup(SmSubSup eSubSup) const { return const_cast< SmSubSupNode* >( this )->GetSubSup( eSubSup ); } /** Set the body */ diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index 0086dfe45fb3..2a35bdffbe4c 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -89,11 +89,11 @@ void NodeTest::testTdf52225() #define CHECK_GREEK_SYMBOL(text, code, bItalic) do {\ mxDocShell->SetText(text); \ const SmTableNode *pTree= mxDocShell->GetFormulaTree(); \ -CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pTree->GetNumSubNodes()); \ +CPPUNIT_ASSERT_EQUAL(size_t(1), pTree->GetNumSubNodes()); \ const SmNode *pLine = pTree->GetSubNode(0); \ CPPUNIT_ASSERT(pLine); \ CPPUNIT_ASSERT_EQUAL(SmNodeType::Line, pLine->GetType()); \ -CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pLine->GetNumSubNodes()); \ +CPPUNIT_ASSERT_EQUAL(size_t(1), pLine->GetNumSubNodes()); \ const SmNode *pNode = pLine->GetSubNode(0); \ CPPUNIT_ASSERT(pNode); \ CPPUNIT_ASSERT_EQUAL(SmNodeType::Special, pNode->GetType());\ diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx index cd014ab3ad72..c99a80568839 100644 --- a/starmath/qa/cppunit/test_parse.cxx +++ b/starmath/qa/cppunit/test_parse.cxx @@
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/caret.hxx |2 starmath/inc/node.hxx| 74 +++ starmath/qa/cppunit/mock-visitor.hxx | 108 +-- starmath/qa/cppunit/test_node.cxx|4 - starmath/qa/cppunit/test_parse.cxx | 16 ++--- starmath/source/cursor.cxx | 80 - starmath/source/mathmlexport.cxx | 82 +- starmath/source/mathmlimport.cxx | 10 +-- starmath/source/mathtype.cxx | 34 +-- starmath/source/node.cxx | 24 +++ starmath/source/ooxmlexport.cxx | 10 +-- starmath/source/rtfexport.cxx| 10 +-- starmath/source/visitors.cxx | 30 - starmath/source/wordexportbase.cxx | 40 ++-- 14 files changed, 262 insertions(+), 262 deletions(-) New commits: commit d52d230fc204b7b2b0d9b27445b496b0113a8dd5 Author: Takeshi AbeDate: Mon Apr 17 18:38:38 2017 +0900 starmath: Convert SmNodeType to scoped enum Change-Id: I30921f9426e0e50ab8c6dfb1e86400847176b707 Reviewed-on: https://gerrit.libreoffice.org/36613 Tested-by: Jenkins Reviewed-by: Takeshi Abe diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx index a1d12cd4c7c2..e21c0b40e1f6 100644 --- a/starmath/inc/caret.hxx +++ b/starmath/inc/caret.hxx @@ -54,7 +54,7 @@ struct SmCaretPos{ * Unless pNode is an instance of SmTextNode, then the index is the text length. */ static SmCaretPos GetPosAfter(SmNode* pNode) { -if(pNode && pNode->GetType() == NTEXT) +if(pNode && pNode->GetType() == SmNodeType::Text) return SmCaretPos(pNode, static_cast (pNode)->GetText().getLength()); return SmCaretPos(pNode, 1); } diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 7c9fbcec892b..52487fcef0ae 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -79,14 +79,14 @@ typedef std::vector< SmNode * > SmNodeArray; enum SmScaleMode{ SCALE_NONE, SCALE_WIDTH, SCALE_HEIGHT }; -enum SmNodeType -{ -/* 0*/ NTABLE, NBRACE, NBRACEBODY, NOPER, NALIGN, -/* 5*/ NATTRIBUT, NFONT, NUNHOR, NBINHOR,NBINVER, -/*10*/ NBINDIAGONAL, NSUBSUP,NMATRIX,NPLACE, NTEXT, -/*15*/ NSPECIAL, NGLYPH_SPECIAL, NMATH, NBLANK, NERROR, -/*20*/ NLINE, NEXPRESSION,NPOLYLINE, NROOT, NROOTSYMBOL, -/*25*/ NRECTANGLE, NVERTICAL_BRACE, NMATHIDENT +enum class SmNodeType +{ +/* 0*/ Table, Brace, Bracebody, Oper,Align, +/* 5*/ Attribut,Font, UnHor, BinHor, BinVer, +/*10*/ BinDiagonal, SubSup,Matrix,Place, Text, +/*15*/ Special, GlyphSpecial, Math, Blank, Error, +/*20*/ Line,Expression,PolyLine, Root,RootSymbol, +/*25*/ Rectangle, VerticalBrace, MathIdent }; @@ -320,7 +320,7 @@ class SmRectangleNode : public SmGraphicNode public: explicit SmRectangleNode(const SmToken ) -: SmGraphicNode(NRECTANGLE, rNodeToken) +: SmGraphicNode(SmNodeType::Rectangle, rNodeToken) {} virtual void AdaptToX(OutputDevice , sal_uLong nWidth) override; @@ -458,7 +458,7 @@ class SmGlyphSpecialNode : public SmSpecialNode { public: explicit SmGlyphSpecialNode(const SmToken ) -: SmSpecialNode(NGLYPH_SPECIAL, rNodeToken, FNT_MATH) +: SmSpecialNode(SmNodeType::GlyphSpecial, rNodeToken, FNT_MATH) {} virtual void Arrange(OutputDevice , const SmFormat ) override; @@ -504,7 +504,7 @@ class SmMathIdentifierNode : public SmMathSymbolNode { public: explicit SmMathIdentifierNode(const SmToken ) -: SmMathSymbolNode(NMATHIDENT, rNodeToken) {} +: SmMathSymbolNode(SmNodeType::MathIdent, rNodeToken) {} }; @@ -520,7 +520,7 @@ class SmRootSymbolNode : public SmMathSymbolNode public: explicit SmRootSymbolNode(const SmToken ) -: SmMathSymbolNode(NROOTSYMBOL, rNodeToken) +: SmMathSymbolNode(SmNodeType::RootSymbol, rNodeToken) , mnBodyWidth(0) { } @@ -543,10 +543,10 @@ class SmPlaceNode : public SmMathSymbolNode { public: explicit SmPlaceNode(const SmToken ) -: SmMathSymbolNode(NPLACE, rNodeToken) +: SmMathSymbolNode(SmNodeType::Place, rNodeToken) { } -SmPlaceNode() : SmMathSymbolNode(NPLACE, SmToken(TPLACE, MS_PLACE, "")) {}; +SmPlaceNode() : SmMathSymbolNode(SmNodeType::Place, SmToken(TPLACE, MS_PLACE, "")) {}; virtual void Prepare(const SmFormat , const SmDocShell ) override; virtual void Arrange(OutputDevice , const SmFormat ) override; @@ -563,7 +563,7 @@ class SmErrorNode : public SmMathSymbolNode { public: explicit SmErrorNode(const SmToken ) -: SmMathSymbolNode(NERROR, rNodeToken) +:
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/parse.hxx |4 +-- starmath/qa/cppunit/test_parse.cxx | 31 starmath/source/parse.cxx | 46 - 3 files changed, 48 insertions(+), 33 deletions(-) New commits: commit 1a1d1a86e9129ec3885610b641179b30f9bf5e79 Author: Takeshi AbeDate: Sat Mar 25 17:52:46 2017 +0900 starmath: Simplify code parsing nospace This also comes with its unit test. Change-Id: I1478bf48c5522691978e3534c9c8a9c0ddfc1e59 Reviewed-on: https://gerrit.libreoffice.org/35985 Tested-by: Jenkins Reviewed-by: Takeshi Abe diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 43b84bab221c..4911e8516a81 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -63,7 +63,7 @@ class SmParser // grammar SmTableNode *DoTable(); voidDoLine(); -SmNode *DoExpression(); +SmNode *DoExpression(bool bUseExtraSpaces = true); SmNode *DoRelation(); SmNode *DoSum(); SmNode *DoProduct(); @@ -76,7 +76,7 @@ class SmParser SmOperNode *DoOperator(); SmNode *DoOper(); SmStructureNode *DoUnOper(); -SmNode *DoAlign(); +SmNode *DoAlign(bool bUseExtraSpaces = true); SmStructureNode *DoFontAttribut(); SmAttributNode *DoAttribut(); SmStructureNode *DoFont(); diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx index 80da700be4cc..4e7198e5db0e 100644 --- a/starmath/qa/cppunit/test_parse.cxx +++ b/starmath/qa/cppunit/test_parse.cxx @@ -33,9 +33,11 @@ public: private: void testMinus(); +void testNospace(); CPPUNIT_TEST_SUITE(ParseTest); CPPUNIT_TEST(testMinus); +CPPUNIT_TEST(testNospace); CPPUNIT_TEST_SUITE_END(); SmDocShellRef mxDocShell; @@ -90,6 +92,35 @@ void ParseTest::testMinus() static_cast(pNode001)->GetToken().aText); } +/* + * This shows that "nospace" turns off the expression's IsUseExtraSpaces(), + * but leaves its decendants' flag on. + */ +void ParseTest::testNospace() +{ +std::unique_ptr pNode(SmParser().Parse("nospace{ nitalic d {F(x) G(x)} }")); +CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetNumSubNodes()); +const SmNode *pNode0 = pNode->GetSubNode(0); +CPPUNIT_ASSERT(pNode0); +CPPUNIT_ASSERT_EQUAL(NLINE, pNode0->GetType()); +CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode0->GetNumSubNodes()); +const SmNode *pNode00 = pNode0->GetSubNode(0); +CPPUNIT_ASSERT(pNode00); +CPPUNIT_ASSERT_EQUAL(NEXPRESSION, pNode00->GetType()); +CPPUNIT_ASSERT(!static_cast(pNode00)->IsUseExtraSpaces()); +CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes()); +const SmNode *pNode000 = pNode00->GetSubNode(0); +CPPUNIT_ASSERT(pNode000); +CPPUNIT_ASSERT_EQUAL(NFONT, pNode000->GetType()); +CPPUNIT_ASSERT_EQUAL(OUString("nitalic"), + static_cast(pNode000)->GetToken().aText); +const SmNode *pNode001 = pNode00->GetSubNode(1); +CPPUNIT_ASSERT(pNode001); +CPPUNIT_ASSERT_EQUAL(NEXPRESSION, pNode001->GetType()); +CPPUNIT_ASSERT(static_cast(pNode001)->IsUseExtraSpaces()); +CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ParseTest); } diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 9e423e1a7f17..1a2418314178 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -963,7 +963,7 @@ SmTableNode *SmParser::DoTable() return pSNode.release(); } -SmNode *SmParser::DoAlign() +SmNode *SmParser::DoAlign(bool bUseExtraSpaces) // parse alignment info (if any), then go on with rest of expression { std::unique_ptr pSNode; @@ -979,7 +979,7 @@ SmNode *SmParser::DoAlign() return DoError(SmParseError::DoubleAlign); } -std::unique_ptr pNode(DoExpression()); +std::unique_ptr pNode(DoExpression(bUseExtraSpaces)); if (pSNode) { @@ -1017,18 +1017,8 @@ void SmParser::DoLine() m_aNodeStack.push_front(std::move(pSNode)); } -SmNode *SmParser::DoExpression() +SmNode *SmParser::DoExpression(bool bUseExtraSpaces) { -bool bUseExtraSpaces = true; -if (!m_aNodeStack.empty()) -{ -if (m_aNodeStack.front()->GetToken().eType == TNOSPACE) -{ -m_aNodeStack.pop_front(); -bUseExtraSpaces = false; -} -} - SmNodeArray RelationArray; RelationArray.push_back(DoRelation()); while (m_aCurToken.nLevel >= 4) @@ -1273,37 +1263,31 @@ SmNode *SmParser::DoTerm(bool bGroupNumberIdent) case TLGROUP : { bool bNoSpace = m_aCurToken.eType == TNOSPACE; -if (bNoSpace) // push 'no space' node and continue to parse expression -{ - m_aNodeStack.push_front(o3tl::make_unique(m_aCurToken)); +if (bNoSpace)
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/error.hxx| 29 -- starmath/qa/cppunit/test_starmath.cxx | 12 ++--- starmath/source/parse.cxx | 70 +- 3 files changed, 59 insertions(+), 52 deletions(-) New commits: commit 1f02e9b5a71836aa750d8e6676d2e876cad5e7a2 Author: Takeshi AbeDate: Sun Feb 19 12:01:56 2017 +0900 starmath: Convert SmParseError to scoped enum Change-Id: Ia2663a768c424ea6f03bd0933a3c2fd608c239d8 Reviewed-on: https://gerrit.libreoffice.org/34422 Tested-by: Jenkins Reviewed-by: Takeshi Abe diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx index 48d7512..ec0c10c 100644 --- a/starmath/inc/error.hxx +++ b/starmath/inc/error.hxx @@ -23,18 +23,25 @@ class SmNode; -enum SmParseError +enum class SmParseError { -PE_NONE, -PE_UNEXPECTED_CHAR, PE_UNEXPECTED_TOKEN, -PE_FUNC_EXPECTED, PE_UNOPER_EXPECTED, -PE_POUND_EXPECTED, -PE_COLOR_EXPECTED, PE_LGROUP_EXPECTED, -PE_RGROUP_EXPECTED, PE_LBRACE_EXPECTED, -PE_RBRACE_EXPECTED, PE_PARENT_MISMATCH, -PE_RIGHT_EXPECTED, PE_FONT_EXPECTED, -PE_SIZE_EXPECTED, PE_DOUBLE_ALIGN, -PE_DOUBLE_SUBSUPSCRIPT +None, +UnexpectedChar, +UnexpectedToken, +FuncExpected, +UnoperExpected, +PoundExpected, +ColorExpected, +LgroupExpected, +RgroupExpected, +LbraceExpected, +RbraceExpected, +ParentMismatch, +RightExpected, +FontExpected, +SizeExpected, +DoubleAlign, +DoubleSubsupscript }; diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx index 7a5688a..09f9abd 100644 --- a/starmath/qa/cppunit/test_starmath.cxx +++ b/starmath/qa/cppunit/test_starmath.cxx @@ -150,18 +150,18 @@ void Test::editFailure() const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); -CPPUNIT_ASSERT_MESSAGE("Should be a PE_COLOR_EXPECTED", -pErrorDesc && pErrorDesc->m_eType == PE_COLOR_EXPECTED); +CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::ColorExpected", +pErrorDesc && pErrorDesc->m_eType == SmParseError::ColorExpected); pErrorDesc = m_xDocShRef->GetParser().PrevError(); -CPPUNIT_ASSERT_MESSAGE("Should be a PE_UNEXPECTED_CHAR", -pErrorDesc && pErrorDesc->m_eType == PE_UNEXPECTED_CHAR); +CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::UnexpectedChar", +pErrorDesc && pErrorDesc->m_eType == SmParseError::UnexpectedChar); pErrorDesc = m_xDocShRef->GetParser().PrevError(); -CPPUNIT_ASSERT_MESSAGE("Should be a PE_RGROUP_EXPECTED", -pErrorDesc && pErrorDesc->m_eType == PE_RGROUP_EXPECTED); +CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::RgroupExpected", +pErrorDesc && pErrorDesc->m_eType == SmParseError::RgroupExpected); const SmErrorDesc *pLastErrorDesc = m_xDocShRef->GetParser().PrevError(); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index b56ed17..0a2dbbc 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -950,7 +950,7 @@ SmTableNode *SmParser::DoTable() } if (m_aCurToken.eType != TEND) -Error(PE_UNEXPECTED_CHAR); +Error(SmParseError::UnexpectedChar); SmNodeArray LineArray(m_aNodeStack.size()); for (auto rIt = LineArray.rbegin(), rEnd = LineArray.rend(); rIt != rEnd; ++rIt) @@ -977,7 +977,7 @@ void SmParser::DoAlign() // allow for just one align statement in 5.0 if (TokenInGroup(TG::Align)) { -Error(PE_DOUBLE_ALIGN); +Error(SmParseError::DoubleAlign); return; } } @@ -1230,7 +1230,7 @@ void SmParser::DoSubSup(TG nActiveGroup) // set sub-/supscript if not already done if (aSubNodes[nIndex] != nullptr) -Error(PE_DOUBLE_SUBSUPSCRIPT); +Error(SmParseError::DoubleSubsupscript); aSubNodes[nIndex] = popOrZero(m_aNodeStack); } @@ -1319,7 +1319,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent) { DoAlign(); if (m_aCurToken.eType != TRGROUP) -Error(PE_RGROUP_EXPECTED); +Error(SmParseError::RgroupExpected); else NextToken(); } @@ -1518,7 +1518,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent) DoFunction(); } else -Error(PE_UNEXPECTED_CHAR); +Error(SmParseError::UnexpectedChar); } } @@ -1550,7 +1550,7 @@ void SmParser::DoEscape() case TRDLINE : break; default: -Error(PE_UNEXPECTED_TOKEN); +Error(SmParseError::UnexpectedToken); } m_aNodeStack.push_front(o3tl::make_unique(m_aCurToken)); @@
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx | 73 -- starmath/inc/visitors.hxx | 12 --- starmath/qa/cppunit/mock-visitor.hxx| 11 -- starmath/qa/cppunit/test_nodetotextvisitors.cxx |1 starmath/source/mathmlexport.cxx| 24 ++ starmath/source/mathmlexport.hxx|1 starmath/source/mathtype.hxx|2 starmath/source/node.cxx| 94 +++ starmath/source/parse.cxx | 13 --- starmath/source/visitors.cxx| 95 10 files changed, 25 insertions(+), 301 deletions(-) New commits: commit 663e26f24f1fa1abadc37838983bebd7407d65f8 Author: Takeshi AbeDate: Sun Sep 25 19:56:52 2016 +0900 tdf#53472, tdf#102268: Reimplement "intd" This reverts its original implementation introduced with 93e6291c29d547c0c29c6e43b2ca4b36a3e8506f partially, and improves the patch proposed at 746633bd0315939fd5e0b50c90692d356d2ed678 (but reverted at e265ea36df02310881e959a031b74578b323bfa5). Change-Id: If0aa5b985cac45a1cd9ea87bae293243af9d12b2 Reviewed-on: https://gerrit.libreoffice.org/29271 Tested-by: Jenkins Reviewed-by: Khaled Hosny diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index bd92aa8..61a8c42 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -98,7 +98,7 @@ enum SmNodeType /*10*/ NBINDIAGONAL, NSUBSUP,NMATRIX,NPLACE, NTEXT, /*15*/ NSPECIAL, NGLYPH_SPECIAL, NMATH, NBLANK, NERROR, /*20*/ NLINE, NEXPRESSION,NPOLYLINE, NROOT, NROOTSYMBOL, -/*25*/ NRECTANGLE, NVERTICAL_BRACE, NMATHIDENT, NDYNINT, NDYNINTSYMBOL +/*25*/ NRECTANGLE, NVERTICAL_BRACE, NMATHIDENT }; @@ -545,29 +545,6 @@ public: }; -/** Dynamic Integral symbol node - * - * Node for drawing dynamically sized integral symbols. - * - * TODO: It might be created a parent class SmDynamicSizedNode -(for both dynamic integrals, roots and other dynamic symbols) - - */ -class SmDynIntegralSymbolNode : public SmMathSymbolNode -{ - - -public: -explicit SmDynIntegralSymbolNode(const SmToken ) -: SmMathSymbolNode(NDYNINTSYMBOL, rNodeToken) -{} - -virtual void AdaptToY(OutputDevice , sal_uLong nHeight) override; - -void Accept(SmVisitor* pVisitor) override; -}; - - /** Place node * * Used to create the command, that denotes place where something can be @@ -740,33 +717,6 @@ public: }; -/** Dynamic Integral node - * - * Used to create Dynamically sized integrals - * - * Children: - * 0: Symbol (instance of DynIntegralSymbolNode) - * 1: Body - */ -class SmDynIntegralNode : public SmStructureNode -{ -public: -explicit SmDynIntegralNode(const SmToken ) -: SmStructureNode(NDYNINT, rNodeToken, 2) -{ -} - -virtual void Arrange(OutputDevice , const SmFormat ) override; -void CreateTextFromNode(OUString ) override; -void Accept(SmVisitor* pVisitor) override; - -SmDynIntegralSymbolNode* Symbol(); -const SmDynIntegralSymbolNode* Symbol() const; -SmNode* Body(); -const SmNode* Body() const; -}; - - /** Binary horizontal node * * This node is used for binary operators. In a formula such as "A + B". @@ -1219,27 +1169,6 @@ inline const SmNode* SmRootNode::Body() const } -inline SmDynIntegralSymbolNode* SmDynIntegralNode::Symbol() -{ -assert( GetNumSubNodes() == 2 ); -assert( GetSubNode( 0 )->GetType() == NDYNINTSYMBOL ); -return static_cast< SmDynIntegralSymbolNode* >( GetSubNode( 0 )); -} -inline const SmDynIntegralSymbolNode* SmDynIntegralNode::Symbol() const -{ -return const_cast< SmDynIntegralNode* >( this )->Symbol(); -} -inline SmNode* SmDynIntegralNode::Body() -{ -assert( GetNumSubNodes() == 2 ); -return GetSubNode( 1 ); -} -inline const SmNode* SmDynIntegralNode::Body() const -{ -return const_cast< SmDynIntegralNode* >( this )->Body(); -} - - inline SmNode* SmBinHorNode::Symbol() { assert( GetNumSubNodes() == 3 ); diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx index 3a1a0c0..cde5fce 100644 --- a/starmath/inc/visitors.hxx +++ b/starmath/inc/visitors.hxx @@ -47,8 +47,6 @@ public: virtual void Visit( SmLineNode* pNode ) = 0; virtual void Visit( SmExpressionNode* pNode ) = 0; virtual void Visit( SmPolyLineNode* pNode ) = 0; -virtual void Visit( SmDynIntegralNode* pNode ) = 0; -virtual void Visit( SmDynIntegralSymbolNode* pNode ) = 0; virtual void Visit( SmRootNode* pNode ) = 0; virtual void Visit( SmRootSymbolNode* pNode ) = 0; virtual void Visit( SmRectangleNode* pNode ) = 0; @@ -94,8 +92,6 @@ public: void Visit( SmPolyLineNode* pNode ) override; void Visit( SmRootNode* pNode ) override; void Visit( SmRootSymbolNode* pNode )
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx|3 + starmath/qa/cppunit/mock-visitor.hxx |8 ++-- starmath/source/cursor.cxx | 60 +-- 3 files changed, 44 insertions(+), 27 deletions(-) New commits: commit ecafca50e9a6d0fac3c809f275342f571a1470df Author: Takeshi AbeDate: Wed Aug 31 16:42:16 2016 +0900 Replace use of our own SmNodeIterator with range-based for loop in starmath/source/cursor.cxx and starmath/qa/cppunit/mock-visitor.hxx. Change-Id: I7733d5d17bb03532d6c4f1d6967c69d65bc3bede Reviewed-on: https://gerrit.libreoffice.org/28538 Tested-by: Jenkins Reviewed-by: Takeshi Abe diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 1e61304..3ecacb1 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -307,6 +307,9 @@ public: virtual void GetAccessibleText( OUStringBuffer ) const override; +SmNodeArray::iterator begin() {return aSubNodes.begin();} +SmNodeArray::iterator end() {return aSubNodes.end();} + /** Get the index of a child node * * Returns -1, if pSubNode isn't a subnode of this. diff --git a/starmath/qa/cppunit/mock-visitor.hxx b/starmath/qa/cppunit/mock-visitor.hxx index 5c7c7af..2c7f6bf 100644 --- a/starmath/qa/cppunit/mock-visitor.hxx +++ b/starmath/qa/cppunit/mock-visitor.hxx @@ -190,9 +190,11 @@ public: private: /** Auxiliary method for visiting the children of a pNode */ void VisitChildren( SmStructureNode* pNode ) { -SmNodeIterator it( pNode ); -while( it.Next() ) -it->Accept( this ); +for (auto pChild : *pNode) +{ +if (pChild) +pChild->Accept(this); +} } }; diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index 30d4c26..bdf5d31 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -1232,11 +1232,15 @@ SmNode* SmCursor::FindTopMostNodeInLine(SmNode* pSNode, bool MoveUpIfSelected){ } SmNode* SmCursor::FindSelectedNode(SmNode* pNode){ -SmNodeIterator it(pNode); -while(it.Next()){ -if(it->IsSelected()) -return it.Current(); -SmNode* pRetVal = FindSelectedNode(it.Current()); +if(pNode->GetNumSubNodes() == 0) +return nullptr; +for(auto pChild : *static_cast (pNode)) +{ +if(!pChild) +continue; +if(pChild->IsSelected()) +return pChild; +SmNode* pRetVal = FindSelectedNode(pChild); if(pRetVal) return pRetVal; } @@ -1244,22 +1248,24 @@ SmNode* SmCursor::FindSelectedNode(SmNode* pNode){ } SmNodeList* SmCursor::LineToList(SmStructureNode* pLine, SmNodeList* list){ -SmNodeIterator it(pLine); -while(it.Next()){ -switch(it->GetType()){ +for(auto pChild : *pLine) +{ +if (!pChild) +continue; +switch(pChild->GetType()){ case NLINE: case NUNHOR: case NEXPRESSION: case NBINHOR: case NALIGN: case NFONT: -LineToList(static_cast (it.Current()), list); +LineToList(static_cast (pChild), list); break; case NERROR: -delete it.Current(); +delete pChild; break; default: -list->push_back(it.Current()); +list->push_back(pChild); } } SmNodeArray emptyArray(0); @@ -1270,22 +1276,24 @@ SmNodeList* SmCursor::LineToList(SmStructureNode* pLine, SmNodeList* list){ void SmCursor::CloneLineToClipboard(SmStructureNode* pLine, SmClipboard* pClipboard){ SmCloningVisitor aCloneFactory; -SmNodeIterator it(pLine); -while(it.Next()){ -if( IsLineCompositionNode( it.Current() ) ) -CloneLineToClipboard( static_cast (it.Current()), pClipboard ); -else if( it->IsSelected() && it->GetType() != NERROR ) { +for(auto pChild : *pLine) +{ +if (!pChild) +continue; +if( IsLineCompositionNode( pChild ) ) +CloneLineToClipboard( static_cast (pChild), pClipboard ); +else if( pChild->IsSelected() && pChild->GetType() != NERROR ) { //Only clone selected text from SmTextNode -if(it->GetType() == NTEXT) { -SmTextNode *pText = static_cast (it.Current()); -std::unique_ptr pClone(new SmTextNode( it->GetToken(), pText->GetFontDesc() )); +if(pChild->GetType() == NTEXT) { +SmTextNode *pText = static_cast (pChild); +std::unique_ptr pClone(new SmTextNode( pChild->GetToken(), pText->GetFontDesc() )); int start = pText->GetSelectionStart(),
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/error.hxx|6 +++--- starmath/qa/cppunit/test_starmath.cxx |6 +++--- starmath/source/parse.cxx |8 starmath/source/view.cxx |6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) New commits: commit 5ca4acf877834c51d896268cf3dd390903b2248b Author: Takeshi AbeDate: Wed Sep 23 06:03:55 2015 +0900 starmath: Prefix members of SmErrorDesc Change-Id: I4910561e3671f546f2e36344016e2b50fd2a70eb Reviewed-on: https://gerrit.libreoffice.org/18788 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx index 7794a4a..99a2245 100644 --- a/starmath/inc/error.hxx +++ b/starmath/inc/error.hxx @@ -41,9 +41,9 @@ enum SmParseError struct SmErrorDesc { -SmParseError Type; -SmNode *pNode; -OUString Text; +SmParseError m_eType; +SmNode *m_pNode; +OUString m_aText; }; #endif diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx index 0620865..2a19ac6 100644 --- a/starmath/qa/cppunit/test_starmath.cxx +++ b/starmath/qa/cppunit/test_starmath.cxx @@ -149,17 +149,17 @@ void Test::editFailure() const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); CPPUNIT_ASSERT_MESSAGE("Should be a PE_COLOR_EXPECTED", -pErrorDesc && pErrorDesc->Type == PE_COLOR_EXPECTED); +pErrorDesc && pErrorDesc->m_eType == PE_COLOR_EXPECTED); pErrorDesc = m_xDocShRef->GetParser().PrevError(); CPPUNIT_ASSERT_MESSAGE("Should be a PE_UNEXPECTED_CHAR", -pErrorDesc && pErrorDesc->Type == PE_UNEXPECTED_CHAR); +pErrorDesc && pErrorDesc->m_eType == PE_UNEXPECTED_CHAR); pErrorDesc = m_xDocShRef->GetParser().PrevError(); CPPUNIT_ASSERT_MESSAGE("Should be a PE_RGROUP_EXPECTED", -pErrorDesc && pErrorDesc->Type == PE_RGROUP_EXPECTED); +pErrorDesc && pErrorDesc->m_eType == PE_RGROUP_EXPECTED); const SmErrorDesc *pLastErrorDesc = m_xDocShRef->GetParser().PrevError(); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index f11bbe1..5fd8417 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -2414,9 +2414,9 @@ size_t SmParser::AddError(SmParseError Type, SmNode *pNode) { SmErrorDesc *pErrDesc = new SmErrorDesc; -pErrDesc->Type = Type; -pErrDesc->pNode = pNode; -pErrDesc->Text = SM_RESSTR(RID_ERR_IDENT); +pErrDesc->m_eType = Type; +pErrDesc->m_pNode = pNode; +pErrDesc->m_aText = SM_RESSTR(RID_ERR_IDENT); sal_uInt16 nRID; switch (Type) @@ -2438,7 +2438,7 @@ size_t SmParser::AddError(SmParseError Type, SmNode *pNode) default: nRID = RID_ERR_UNKNOWN; } -pErrDesc->Text += SM_RESSTR(nRID); +pErrDesc->m_aText += SM_RESSTR(nRID); m_aErrDescList.push_back( pErrDesc ); diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index a84ea4f..574755b 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1349,9 +1349,9 @@ void SmViewShell::ShowError(const SmErrorDesc* pErrorDesc) SAL_WARN_IF( !GetDoc(), "starmath", "Document missing" ); if (pErrorDesc || 0 != (pErrorDesc = GetDoc()->GetParser().GetError(0)) ) { -SetStatusText( pErrorDesc->Text ); -GetEditWindow()->MarkError( Point( pErrorDesc->pNode->GetColumn(), - pErrorDesc->pNode->GetRow())); +SetStatusText( pErrorDesc->m_aText ); +GetEditWindow()->MarkError( Point( pErrorDesc->m_pNode->GetColumn(), + pErrorDesc->m_pNode->GetRow())); } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/ElementsDockingWindow.hxx |3 -- starmath/inc/pch/precompiled_sm.hxx |1 starmath/qa/cppunit/test_nodetotextvisitors.cxx |8 ++--- starmath/source/ElementsDockingWindow.cxx | 34 +++--- starmath/source/document.cxx| 36 starmath/source/edit.cxx| 22 ++ starmath/source/view.cxx| 18 ++-- 7 files changed, 59 insertions(+), 63 deletions(-) New commits: commit 08348b226b6bb0ba9b1c24802c1f306b7b3905a1 Author: Caolán McNamara caol...@redhat.com Date: Sat Feb 14 20:30:36 2015 + boost::scoped_ptr-std::unique_ptr Change-Id: I0f9d93e945ec554e9ea89621ecd30f683f3f184c diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx index c716389..96dcfd6 100644 --- a/starmath/inc/ElementsDockingWindow.hxx +++ b/starmath/inc/ElementsDockingWindow.hxx @@ -20,7 +20,6 @@ #ifndef INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX #define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX -#include boost/scoped_ptr.hpp #include boost/signals2/signal.hpp #include sfx2/dockwin.hxx #include svx/dlgctrl.hxx @@ -97,7 +96,7 @@ class SmElementsControl : public Control SmElementList maElementList; Size maMaxElementDimensions; bool mbVerticalMode; -boost::scoped_ptr ScrollBar mpScroll; +std::unique_ptrScrollBar mxScroll; void addElement(const OUString aElementVisual, const OUString aElementSource, const OUString aHelpText); diff --git a/starmath/inc/pch/precompiled_sm.hxx b/starmath/inc/pch/precompiled_sm.hxx index bcfb5ab..31dce9f 100644 --- a/starmath/inc/pch/precompiled_sm.hxx +++ b/starmath/inc/pch/precompiled_sm.hxx @@ -17,7 +17,6 @@ #include svx/modctrl.hxx #include tools/rcid.h #include boost/scoped_array.hpp -#include boost/scoped_ptr.hpp #include com/sun/star/accessibility/AccessibleEventId.hpp #include com/sun/star/accessibility/AccessibleEventObject.hpp #include com/sun/star/accessibility/AccessibleRole.hpp diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 6b66d3a..4e4de16 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -19,7 +19,7 @@ #include cursor.hxx #include mock-visitor.hxx -#include boost/scoped_ptr.hpp +#include memory typedef tools::SvRefSmDocShell SmDocShellRef; @@ -447,7 +447,7 @@ void Test::parseandparseagain(const char *formula, const char *test_name) output2); // auxiliary test for Accept() -boost::scoped_ptrMockVisitor mv(new MockVisitor); +std::unique_ptrMockVisitor mv(new MockVisitor); pNode1-Accept(mv.get()); pNode2-Accept(mv.get()); @@ -473,7 +473,7 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char sOutput); // auxiliary test for Accept() -boost::scoped_ptrMockVisitor mv(new MockVisitor); +std::unique_ptrMockVisitor mv(new MockVisitor); pNode-Accept(mv.get()); delete pNode; @@ -500,7 +500,7 @@ void Test::ParseAndCompare(const char *formula1, const char *formula2, const cha CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, sOutput1, sOutput2); // auxiliary test for Accept() -boost::scoped_ptrMockVisitor mv(new MockVisitor); +std::unique_ptrMockVisitor mv(new MockVisitor); pNode1-Accept(mv.get()); pNode2-Accept(mv.get()); diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 9e4ade6..6f47b03 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -222,7 +222,7 @@ SmElementsControl::SmElementsControl(vcl::Window *pParent) , maCurrentSetId(0) , mpCurrentElement(NULL) , mbVerticalMode(true) -, mpScroll(new ScrollBar(this, WB_VERT)) +, mxScroll(new ScrollBar(this, WB_VERT)) { SetMapMode( MapMode(MAP_100TH_MM) ); SetDrawMode( DRAWMODE_DEFAULT ); @@ -231,8 +231,8 @@ SmElementsControl::SmElementsControl(vcl::Window *pParent) maFormat.SetBaseSize(PixelToLogic(Size(0, SmPtsTo100th_mm(12; -mpScroll-SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) ); -mpScroll-Show(); +mxScroll-SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) ); +mxScroll-Show(); } SmElementsControl::~SmElementsControl() @@ -249,7 +249,7 @@ void SmElementsControl::Paint(const Rectangle) { Push(); -bool bOldVisibleState = mpScroll-IsVisible(); +bool bOldVisibleState = mxScroll-IsVisible(); sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0; @@ -260,7 +260,7 @@ void SmElementsControl::Paint(const Rectangle) sal_Int32 boxY = maMaxElementDimensions.Height() + 10; sal_Int32 x = 0; -sal_Int32 y =
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/visitors.hxx | 39 starmath/qa/cppunit/mock-visitor.hxx| 207 starmath/qa/cppunit/test_nodetotextvisitors.cxx | 17 + starmath/source/visitors.cxx| 183 - 4 files changed, 224 insertions(+), 222 deletions(-) New commits: commit e2c7b93744e61f3a7a9a04056a95894c9e888db8 Author: Takeshi Abe t...@fixedpoint.jp Date: Fri Nov 28 17:43:57 2014 +0900 recycle SmVisitorTest for unit test i.e. move unused SmVisitorTest to qa/ as MockVisitor, and call it in existing test cases. Change-Id: I20dc45537f7a0e325e952724607e695f3b3da21f Reviewed-on: https://gerrit.libreoffice.org/13165 Reviewed-by: Caolán McNamara caol...@redhat.com Tested-by: Caolán McNamara caol...@redhat.com diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx index 9a1ebb1..cdb6595 100644 --- a/starmath/inc/visitors.hxx +++ b/starmath/inc/visitors.hxx @@ -53,45 +53,6 @@ protected: ~SmVisitor() {} }; -/** Simple visitor for testing SmVisitor */ -class SmVisitorTest : public SmVisitor -{ -public: -virtual ~SmVisitorTest() {} -void Visit( SmTableNode* pNode ) SAL_OVERRIDE; -void Visit( SmBraceNode* pNode ) SAL_OVERRIDE; -void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE; -void Visit( SmOperNode* pNode ) SAL_OVERRIDE; -void Visit( SmAlignNode* pNode ) SAL_OVERRIDE; -void Visit( SmAttributNode* pNode ) SAL_OVERRIDE; -void Visit( SmFontNode* pNode ) SAL_OVERRIDE; -void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE; -void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE; -void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE; -void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE; -void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE; -void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE; -void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE; -void Visit( SmTextNode* pNode ) SAL_OVERRIDE; -void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE; -void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE; -void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE; -void Visit( SmBlankNode* pNode ) SAL_OVERRIDE; -void Visit( SmErrorNode* pNode ) SAL_OVERRIDE; -void Visit( SmLineNode* pNode ) SAL_OVERRIDE; -void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE; -void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE; -void Visit( SmRootNode* pNode ) SAL_OVERRIDE; -void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE; -void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE; -void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE; -void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE; -void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE; -private: -/** Auxiliary method for visiting the children of a pNode */ -void VisitChildren( SmNode* pNode ); -}; - // SmDefaultingVisitor diff --git a/starmath/qa/cppunit/mock-visitor.hxx b/starmath/qa/cppunit/mock-visitor.hxx new file mode 100644 index 000..3284f0f --- /dev/null +++ b/starmath/qa/cppunit/mock-visitor.hxx @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX +#define INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX + +#include cppunit/TestAssert.h +#include visitors.hxx + +/** Simple visitor for testing SmVisitor */ +class MockVisitor : public SmVisitor +{ +public: +virtual ~MockVisitor() {} + +void Visit( SmTableNode* pNode ) SAL_OVERRIDE { +CPPUNIT_ASSERT_EQUAL_MESSAGE(SmTableNode should have type NTABLE, + pNode-GetType(), NTABLE); +VisitChildren( pNode ); +} + +void Visit( SmBraceNode* pNode ) SAL_OVERRIDE { +CPPUNIT_ASSERT_EQUAL_MESSAGE(SmBraceNode should have type NBRACE, + pNode-GetType(), NBRACE); +VisitChildren( pNode ); +} + +void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE { +CPPUNIT_ASSERT_EQUAL_MESSAGE(SmBracebodyNode should have type NBRACEBODY, + pNode-GetType(), NBRACEBODY); +VisitChildren( pNode ); +} + +void Visit( SmOperNode* pNode ) SAL_OVERRIDE { +CPPUNIT_ASSERT_EQUAL_MESSAGE(SmOperNode should have type NOPER, + pNode-GetType(), NOPER); +VisitChildren( pNode ); +} + +void Visit( SmAlignNode* pNode ) SAL_OVERRIDE { +CPPUNIT_ASSERT_EQUAL_MESSAGE(SmAlignNode should have type NALIGN, + pNode-GetType(), NALIGN); +VisitChildren( pNode ); +} + +void Visit( SmAttributNode* pNode )
[Libreoffice-commits] core.git: starmath/inc starmath/qa starmath/source
starmath/inc/node.hxx |2 starmath/inc/parse.hxx| 30 starmath/qa/cppunit/test_starmath.cxx |2 starmath/source/accessibility.cxx |4 - starmath/source/edit.cxx |2 starmath/source/node.cxx |2 starmath/source/parse.cxx | 121 +++--- starmath/source/smmod.cxx | 16 ++-- 8 files changed, 84 insertions(+), 95 deletions(-) New commits: commit 6f135b0aa231a2543d73f94e39cb472e12ea47d5 Author: Thomas Arnhold tho...@arnhold.org Date: Wed Sep 4 17:09:22 2013 +0200 String to OUString And removed nearly all xub_StrLen in starmath. Some sal_uInt16 which were xub_StrLen before 9a0d753b84aed53083bed3ed460308b771f432a8 are also converted to sal_Int32 where applicable. Change-Id: I31d7794f4c7aa840545edff41a102b76bb39e042 Reviewed-on: https://gerrit.libreoffice.org/5817 Reviewed-by: Andrzej J.R. Hunt andr...@ahunt.org Tested-by: Andrzej J.R. Hunt andr...@ahunt.org diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index b449666..38243dd 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -159,7 +159,7 @@ public: virtual voidGetAccessibleText( OUStringBuffer rText ) const; sal_Int32 GetAccessibleIndex() const { return nAccIndex; } -const SmNode * FindNodeWithAccessibleIndex(xub_StrLen nAccIndex) const; +const SmNode * FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const; sal_uInt16 GetRow() const{ return (sal_uInt16)aNodeToken.nRow; } sal_uInt16 GetColumn() const { return (sal_uInt16)aNodeToken.nCol; } diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index e5cc5a4..d7eefcf 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -118,8 +118,8 @@ struct SmToken sal_uInt16 nLevel; // token position -sal_uInt16 nRow; -xub_StrLen nCol; +sal_Int32 nRow; +sal_Int32 nCol; SmToken(); SmToken(SmTokenType eTokenType, @@ -150,7 +150,7 @@ struct SmErrorDesc { SmParseError Type; SmNode *pNode; -StringText; +OUString Text; }; @@ -180,15 +180,15 @@ struct SmTokenTableEntry class SmParser { -String m_aBufferString; +OUStringm_aBufferString; SmToken m_aCurToken; SmNodeStack m_aNodeStack; SmErrDescList m_aErrDescList; int m_nCurError; LanguageTypem_nLang; -xub_StrLen m_nBufferIndex, +sal_Int32 m_nBufferIndex, m_nTokenIndex; -sal_uInt16 m_Row, +sal_Int32 m_Row, m_nColOff; SmConvert m_eConversion; boolbImportSymNames, @@ -206,12 +206,12 @@ class SmParser protected: #if OSL_DEBUG_LEVEL 1 -boolIsDelimiter( const String rTxt, xub_StrLen nPos ); +boolIsDelimiter( const OUString rTxt, sal_Int32 nPos ); #endif voidNextToken(); -xub_StrLen GetTokenIndex() const { return m_nTokenIndex; } -voidInsert(const String rText, sal_uInt16 nPos); -voidReplace( sal_uInt16 nPos, sal_uInt16 nLen, const String rText ); +sal_Int32 GetTokenIndex() const { return m_nTokenIndex; } +voidInsert(const OUString rText, sal_Int32 nPos); +voidReplace( sal_Int32 nPos, sal_Int32 nLen, const OUString rText ); inline bool TokenInGroup( sal_uLong nGroup ); @@ -253,17 +253,17 @@ protected: voidError(SmParseError Error); voidClearUsedSymbols() { m_aUsedSymbols.clear(); } -voidAddToUsedSymbols( const String rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); } +voidAddToUsedSymbols( const OUString rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); } public: SmParser(); /** Parse rBuffer to formula tree */ -SmNode *Parse(const String rBuffer); +SmNode *Parse(const OUString rBuffer); /** Parse rBuffer to formula subtree that constitutes an expression */ SmNode *ParseExpression(const OUString rBuffer); -const String GetText() const { return m_aBufferString; }; +const OUString GetText() const { return m_aBufferString; }; SmConvert GetConversion() const { return m_eConversion; } voidSetConversion(SmConvert eConv) { m_eConversion = eConv; } @@ -277,8 +277,8 @@ public: const SmErrorDesc* NextError(); const SmErrorDesc* PrevError(); const SmErrorDesc* GetError(size_t i = size_t(-1) ); -static const SmTokenTableEntry* GetTokenTableEntry( const String rName ); -boolIsUsedSymbol( const String rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } +static const SmTokenTableEntry*