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

2023-11-19 Thread Stephan Bergmann (via logerrit)
 starmath/qa/extras/mmlexport-test.cxx |   41 +++---
 starmath/source/smmod.cxx |2 -
 2 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit 75d256929387eb8258439808e830b73abcdf2d8b
Author: Stephan Bergmann 
AuthorDate: Sun Nov 19 15:24:11 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Sun Nov 19 20:37:13 2023 +0100

Extended loplugin:ostr: starmath

Change-Id: I24ab27d0f92d2d5d10ca2694138d7964ae947b62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159676
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/starmath/qa/extras/mmlexport-test.cxx 
b/starmath/qa/extras/mmlexport-test.cxx
index 98607dbec3f2..402df43130d5 100644
--- a/starmath/qa/extras/mmlexport-test.cxx
+++ b/starmath/qa/extras/mmlexport-test.cxx
@@ -62,8 +62,8 @@ void MathMLExportTest::testBlank()
 save("MathML XML (Math)");
 xmlDocUniquePtr pDoc = parseXml(maTempFile);
 CPPUNIT_ASSERT(pDoc);
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[1]", "width", 
"0.5em");
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[2]", "width", 
"4em");
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[1]"_ostr, 
"width"_ostr, "0.5em");
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[2]"_ostr, 
"width"_ostr, "4em");
 }
 
 void MathMLExportTest::testTdf97049()
@@ -75,8 +75,8 @@ void MathMLExportTest::testTdf97049()
 save("MathML XML (Math)");
 xmlDocUniquePtr pDoc = parseXml(maTempFile);
 CPPUNIT_ASSERT(pDoc);
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]", "stretchy", 
"true");
-auto aContent = getXPathContent(pDoc, 
"/m:math/m:semantics/m:mrow/m:mo[1]");
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]"_ostr, 
"stretchy"_ostr, "true");
+auto aContent = getXPathContent(pDoc, 
"/m:math/m:semantics/m:mrow/m:mo[1]"_ostr);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength());
 CPPUNIT_ASSERT_EQUAL(u'\x222B', aContent[0]);
 }
@@ -89,19 +89,23 @@ void MathMLExportTest::checkMathVariant(SmDocShell& 
rDocShell, bool bCapital, bo
 xmlDocUniquePtr pDoc = parseXml(maTempFile);
 CPPUNIT_ASSERT(pDoc);
 if (bCapital)
-assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", 
"mathvariant");
+assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mi[1]"_ostr, "mathvariant"_ostr);
 else
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant", 
"normal");
-assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mstyle[1]/m:mi[1]", "mathvariant");
-assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[2]", 
"mathvariant");
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[2]/m:mi[1]", 
"mathvariant", "normal");
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]"_ostr, 
"mathvariant"_ostr, "normal");
+assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mstyle[1]/m:mi[1]"_ostr,
+   "mathvariant"_ostr);
+assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[2]"_ostr, 
"mathvariant"_ostr);
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[2]/m:mi[1]"_ostr, 
"mathvariant"_ostr,
+"normal");
 if (bSmall)
-assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", 
"mathvariant");
+assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mi[3]"_ostr, "mathvariant"_ostr);
 else
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", "mathvariant", 
"normal");
-assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mstyle[3]/m:mi[1]", "mathvariant");
-assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[4]", 
"mathvariant");
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[4]/m:mi[1]", 
"mathvariant", "normal");
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]"_ostr, 
"mathvariant"_ostr, "normal");
+assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mstyle[3]/m:mi[1]"_ostr,
+   "mathvariant"_ostr);
+assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[4]"_ostr, 
"mathvariant"_ostr);
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[4]/m:mi[1]"_ostr, 
"mathvariant"_ostr,
+"normal");
 rDocShell.SetText("");
 }
 
@@ -130,8 +134,10 @@ void MathMLExportTest::testMaj()
 save("MathML XML (Math)");
 xmlDocUniquePtr pDoc = parseXml(maTempFile);
 CPPUNIT_ASSERT(pDoc);
-assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mo", 
"stretchy", "false");
-assertXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mo", 
u"\U0001EEF0"_ustr);
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mo"_ostr, 
"stretchy"_ostr,
+"false");
+assertXPathContent(pDoc, 
"/m:math/m:semantics/m:mrow/m:munderover/m:mo"_ostr,
+   u"\U0001EEF0"_ustr);
 }
 
 void 

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

2023-09-11 Thread Khaled Hosny (via logerrit)
 starmath/qa/cppunit/test_cursor.cxx |   20 
 starmath/source/visitors.cxx|7 +--
 2 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit d52feb11c7eab0adf82c1fb410adfd3127bf9497
Author: Khaled Hosny 
AuthorDate: Mon Sep 11 20:32:22 2023 +0300
Commit: خالد حسني 
CommitDate: Mon Sep 11 21:24:57 2023 +0200

starmath: Fix selection of surrogate pairs in inline editing

Don’t split nodes in the middle of surrogate pairs.

Change-Id: I3ce8cf19d4c331e2ead73ed375745e8866b3d7a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156827
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/starmath/qa/cppunit/test_cursor.cxx 
b/starmath/qa/cppunit/test_cursor.cxx
index d76b446e6a41..f5be3f5beeaa 100644
--- a/starmath/qa/cppunit/test_cursor.cxx
+++ b/starmath/qa/cppunit/test_cursor.cxx
@@ -39,12 +39,14 @@ public:
 void testCopySelectPaste();
 void testCutPaste();
 void testCutSelectPaste();
+void testSelectSurrogatePairs();
 
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testCopyPaste);
 CPPUNIT_TEST(testCopySelectPaste);
 CPPUNIT_TEST(testCutPaste);
 CPPUNIT_TEST(testCutSelectPaste);
+CPPUNIT_TEST(testSelectSurrogatePairs);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -172,6 +174,24 @@ void Test::testCutSelectPaste()
 #endif
 }
 
+void Test::testSelectSurrogatePairs()
+{
+auto xTree = SmParser5().Parse(u"\U0001EE4E");
+xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
+
+SmCursor aCursor(xTree.get(), xDocShRef.get());
+ScopedVclPtrInstance pOutputDevice;
+
+// selct the first character, cut, then paste
+aCursor.Move(pOutputDevice, MoveRight, false);
+aCursor.Cut();
+aCursor.Paste();
+
+#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some 
reason
+CPPUNIT_ASSERT_EQUAL(OUString(u"\U0001EE4E"), xDocShRef->GetText());
+#endif
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 }
 
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 936097ccef3f..c2c4717df299 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1040,8 +1040,11 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmTextNode* 
pNode )
 {
 SAL_WARN_IF( pNode->GetText().isEmpty(), "starmath", "Empty SmTextNode is 
bad" );
 
-int size = pNode->GetText().getLength();
-for( int i = 1; i <= size; i++ ){
+OUString& aText = pNode->GetText();
+sal_Int32 i = 0;
+while (i < aText.getLength())
+{
+aText.iterateCodePoints(&i);
 SmCaretPosGraphEntry* pRight = mpRightMost;
 mpRightMost = mpGraph->Add( SmCaretPos( pNode, i ), pRight );
 pRight->SetRight( mpRightMost );


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

2023-09-07 Thread Khaled Hosny (via logerrit)
 starmath/qa/cppunit/test_cursor.cxx |   10 +-
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |4 ++--
 starmath/source/visitors.cxx|4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 8c982bf86ff9ca5a4ed86505ec1133cc183f1b58
Author: Khaled Hosny 
AuthorDate: Thu Sep 7 10:21:24 2023 +0300
Commit: خالد حسني 
CommitDate: Thu Sep 7 16:18:28 2023 +0200

tdf#130741: Insert brackets around horizontal binary nodes more generously

When converting node tree creating with visual editor back to text for
the command editor, try to always insert brackets around binary
expressions. It might look redundant at times but it is safer, and the
code is not supposed to be edited by hand anymore so doesn’t have to
look pretty.

Change-Id: Ifff574494c9e8f8b948e432f6832d88c334aba00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156640
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/starmath/qa/cppunit/test_cursor.cxx 
b/starmath/qa/cppunit/test_cursor.cxx
index 5f4c551675a1..bbdebf503153 100644
--- a/starmath/qa/cppunit/test_cursor.cxx
+++ b/starmath/qa/cppunit/test_cursor.cxx
@@ -87,7 +87,7 @@ void Test::testCopyPaste()
 aCursor.Move(pOutputDevice, MoveRight);
 aCursor.Paste();
 
-CPPUNIT_ASSERT_EQUAL(OUString("{ a * b + c * b }"), xDocShRef->GetText());
+CPPUNIT_ASSERT_EQUAL(OUString("{ { a * b } + { c * b } }"), 
xDocShRef->GetText());
 }
 
 void Test::testCopySelectPaste()
@@ -113,7 +113,7 @@ void Test::testCopySelectPaste()
 aCursor.Move(pOutputDevice, MoveRight, false);
 aCursor.Paste();
 
-CPPUNIT_ASSERT_EQUAL(OUString("{ b + c * b + c }"), xDocShRef->GetText());
+CPPUNIT_ASSERT_EQUAL(OUString("{ { b + { c * b } } + c }"), 
xDocShRef->GetText());
 }
 
 void Test::testCutPaste()
@@ -130,12 +130,12 @@ void Test::testCutPaste()
 aCursor.Move(pOutputDevice, MoveRight, false);
 aCursor.Move(pOutputDevice, MoveRight, false);
 aCursor.Cut();
-// go to the left end and then paste
+// go to the right end and then paste
 aCursor.Move(pOutputDevice, MoveRight);
 aCursor.Move(pOutputDevice, MoveRight);
 aCursor.Paste();
 
-CPPUNIT_ASSERT_EQUAL(OUString("{ a + c * b }"), xDocShRef->GetText());
+CPPUNIT_ASSERT_EQUAL(OUString("{ a + { c * b } }"), xDocShRef->GetText());
 }
 
 void Test::testCutSelectPaste()
@@ -161,7 +161,7 @@ void Test::testCutSelectPaste()
 aCursor.Move(pOutputDevice, MoveRight, false);
 aCursor.Paste();
 
-CPPUNIT_ASSERT_EQUAL(OUString("{ b + c * }"), xDocShRef->GetText());
+CPPUNIT_ASSERT_EQUAL(OUString("{ b + { c * } }"), xDocShRef->GetText());
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 11ef5affcc4c..aba582e281d3 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -528,7 +528,7 @@ void Test::testBinomInBinHor()
 aCursor.InsertElement(PlusElement);
 aCursor.InsertText("d");
 
-sExpected += "{ { binom a b + c } + d }";
+sExpected += "{ { binom a { b + c } } + d }";
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Binom Node in BinHor Node", sExpected, 
xDocShRef->GetText());
 }
 
@@ -623,7 +623,7 @@ void Test::testUnaryInMixedNumberAsNumerator()
 aCursor.InsertText("4");
 
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unary in mixed number as Numerator",
- OUString("{ 2 { - 1 over 2 } + 4 }"), 
xDocShRef->GetText());
+ OUString("{ 2 { { - 1 over 2 } + 4 } }"), 
xDocShRef->GetText());
 }
 
 void Test::testMiscEquivalent()
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 732c27f9840f..b205e710b72f 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2189,7 +2189,7 @@ void SmNodeToTextVisitor::Visit( SmUnHorNode* pNode )
 void SmNodeToTextVisitor::Visit( SmBinHorNode* pNode )
 {
 const SmNode *pParent = pNode->GetParent();
-bool bBraceNeeded = pParent && pParent->GetType() == SmNodeType::Font;
+bool bBraceNeeded = pParent;
 SmNode *pLeft  = pNode->LeftOperand(),
*pOper  = pNode->Symbol(),
*pRight = pNode->RightOperand();
@@ -2598,7 +2598,7 @@ void SmNodeToTextVisitor::Visit( SmLineNode* pNode )
 
 void SmNodeToTextVisitor::Visit( SmExpressionNode* pNode )
 {
-bool bracketsNeeded = pNode->GetNumSubNodes() != 1 || 
pNode->GetSubNode(0)->GetType() == SmNodeType::BinHor;
+bool bracketsNeeded = pNode->GetNumSubNodes() != 1;
 if (!bracketsNeeded)
 {
 const SmNode *pParent = pNode->GetParent();


[Libreoffice-commits] core.git: starmath/qa starmath/source uitest/math_tests

2023-02-21 Thread DowwdyJ (via logerrit)
 starmath/qa/extras/mmlimport-test.cxx |   18 ++
 starmath/source/visitors.cxx  |4 ++--
 uitest/math_tests/tdf128610.py|2 +-
 3 files changed, 13 insertions(+), 11 deletions(-)

New commits:
commit ac0e3e11d14d31b66e0f9a08f96d0233ec55951d
Author: DowwdyJ 
AuthorDate: Thu Feb 16 04:27:40 2023 +
Commit: Noel Grandin 
CommitDate: Tue Feb 21 12:11:06 2023 +

tdf#152850: Fix bad scoping of MathML frac command

Change-Id: I4f5d0290e522fa6f3faccd26f74540abf848629b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147153
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 0f80f375acea..d6411f8ff406 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -160,17 +160,19 @@ void Test::testtdf99556()
 void Test::testTdf103430()
 {
 
loadURL(m_directories.getURLFromSrc(u"starmath/qa/extras/data/tdf103430.mml"));
-CPPUNIT_ASSERT_EQUAL(OUString("frac { { nitalic d ^ 2 nitalic color blue y 
} } { { color dvip "
-  "apricot nitalic d font sans bold italic 
color red x } }"),
- mxDocShell->GetText());
+CPPUNIT_ASSERT_EQUAL(
+OUString("{ frac { { nitalic d ^ 2 nitalic color blue y } } { { color 
dvip "
+ "apricot nitalic d font sans bold italic color red x } } }"),
+mxDocShell->GetText());
 }
 
 void Test::testTdf103500()
 {
 
loadURL(m_directories.getURLFromSrc(u"starmath/qa/extras/data/tdf103500.mml"));
-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());
+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());
 }
 
 void Test::testTdf137008()
@@ -200,8 +202,8 @@ void Test::testMathmlEntities()
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-}
+} // namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 6efe9936b948..42257925d38e 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2305,11 +2305,11 @@ void SmNodeToTextVisitor::Visit( SmBinVerNode* pNode )
 } else{
 SmNode *pNum= pNode->GetSubNode( 0 ),
*pDenom  = pNode->GetSubNode( 2 );
-Append(u"frac {");
+Append(u"{ frac {");
 LineToText( pNum );
 Append(u"} {");
 LineToText( pDenom );
-Append(u"}");
+Append(u"} }");
 }
 }
 
diff --git a/uitest/math_tests/tdf128610.py b/uitest/math_tests/tdf128610.py
index 4fdd9c2dbc52..29b7d5ac4564 100644
--- a/uitest/math_tests/tdf128610.py
+++ b/uitest/math_tests/tdf128610.py
@@ -27,6 +27,6 @@ class Tdf128610(UITestCase):
 
 # Without the fix in place, this test would have failed with
 # AssertionError: '{ f _ c = frac { 1 } { K _ m } }' != ''
-self.assertEqual("{ f _ c = frac { 1 } { K _ m } }", 
get_state_as_dict(xEditView)["Text"])
+self.assertEqual("{ f _ c = { frac { 1 } { K _ m } } }", 
get_state_as_dict(xEditView)["Text"])
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:


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

2020-10-05 Thread Noel (via logerrit)
 starmath/qa/cppunit/test_starmath.cxx |   10 +-
 starmath/source/mathtype.cxx  |2 +-
 starmath/source/utility.cxx   |4 +---
 starmath/source/view.cxx  |3 +--
 starmath/source/visitors.cxx  |   16 +++-
 5 files changed, 15 insertions(+), 20 deletions(-)

New commits:
commit 980cb24e1e94ed928b6db9e6b8b5ba377de2a574
Author: Noel 
AuthorDate: Mon Oct 5 09:26:33 2020 +0200
Commit: Noel Grandin 
CommitDate: Mon Oct 5 11:24:21 2020 +0200

loplugin:reducevarscope in starmath

Change-Id: I5d90de0d2fdab876899a6e072b7911921d691d14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103946
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/starmath/qa/cppunit/test_starmath.cxx 
b/starmath/qa/cppunit/test_starmath.cxx
index 20dfd1148110..c9e6f2c35663 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -150,7 +150,6 @@ void Test::tearDown()
 void Test::testSmTmpDeviceRestoreFont()
 {
 ScopedVclPtrInstance pPrinter;
-bool bUseMap100th_mm = true;
 
 OUString aFontName("Linux Libertine G");
 CPPUNIT_ASSERT(pPrinter->IsFontAvailable(aFontName));
@@ -162,6 +161,7 @@ void Test::testSmTmpDeviceRestoreFont()
 vcl::Font aNewFont;
 
 {
+bool bUseMap100th_mm = true;
 SmTmpDevice aTmpDev(*pPrinter, bUseMap100th_mm);
 
 aNewFont = pPrinter->GetFont();
@@ -384,8 +384,8 @@ void Test::editUndoRedo()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings must match", sFinalText, 
sStringOne);
 }
 
-OUString sStringTwo("a over b");
 {
+OUString sStringTwo("a over b");
 rEditEngine.SetText(0, sStringTwo);
 m_xDocShRef->UpdateText();
 OUString sFinalText = m_xDocShRef->GetText();
@@ -439,12 +439,12 @@ void Test::replacePlaceholder()
 
 void Test::viewZoom()
 {
-sal_uInt16 nOrigZoom, nNextZoom, nFinalZoom;
+sal_uInt16 nOrigZoom, nFinalZoom;
 
 EditEngine &rEditEngine = m_xDocShRef->GetEditEngine();
 
-OUString sStringOne("a under b");
 {
+OUString sStringOne("a under b");
 rEditEngine.SetText(0, sStringOne);
 m_xDocShRef->UpdateText();
 OUString sFinalText = m_xDocShRef->GetText();
@@ -458,7 +458,7 @@ void Test::viewZoom()
 {
 SfxRequest aZoomIn(SID_ZOOMIN, SfxCallMode::SYNCHRON, 
m_pViewShell->GetPool());
 m_pViewShell->Execute(aZoomIn);
-nNextZoom = rGraphicWindow.GetZoom();
+sal_uInt16 nNextZoom = rGraphicWindow.GetZoom();
 CPPUNIT_ASSERT_MESSAGE("Should be bigger", nNextZoom > nOrigZoom);
 }
 
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 13297eb7fc34..43602a491d03 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -1799,10 +1799,10 @@ void MathType::HandleAlign(sal_uInt8 nHorAlign, int 
&rSetAlign)
  * indicator by mathtype file format*/
 bool MathType::HandleSize(sal_Int16 nLstSize,sal_Int16 nDefSize, int &rSetSize)
 {
-const sal_Int16 nDefaultSize = 12;
 bool bRet=false;
 if (nLstSize < 0)
 {
+const sal_Int16 nDefaultSize = 12;
 if ((-nLstSize/32 != nDefaultSize) && (-nLstSize/32 != nCurSize))
 {
 if (rSetSize)
diff --git a/starmath/source/utility.cxx b/starmath/source/utility.cxx
index a842c7ed66a2..62e0b0294afd 100644
--- a/starmath/source/utility.cxx
+++ b/starmath/source/utility.cxx
@@ -126,13 +126,11 @@ 
SmFontPickListBox::SmFontPickListBox(std::unique_ptr pWidget)
 
 IMPL_LINK_NOARG(SmFontPickListBox, SelectHdl, weld::ComboBox&, void)
 {
-OUString aString;
-
 const int nPos = m_xWidget->get_active();
 if (nPos != 0)
 {
 SmFontPickList::Insert(Get(nPos));
-aString = m_xWidget->get_text(nPos);
+OUString aString = m_xWidget->get_text(nPos);
 m_xWidget->remove(nPos);
 m_xWidget->insert_text(0, aString);
 }
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index dd967232723b..43132079dd16 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1579,10 +1579,9 @@ void SmViewShell::Execute(SfxRequest& rReq)
 {
 TransferableDataHelper aDataHelper( 
TransferableDataHelper::CreateFromSystemClipboard(GetEditWindow()) );
 uno::Reference < io::XInputStream > xStrm;
-SotClipboardFormatId nId = SOT_FORMAT_SYSTEM_START; //dummy 
initialize to avoid warning
 if  ( aDataHelper.GetTransferable().is() )
 {
-nId = SotClipboardFormatId::MATHML;
+SotClipboardFormatId nId = SotClipboardFormatId::MATHML;
 if (aDataHelper.HasFormat(nId))
 {
 xStrm = aDataHelper.GetInputStream(nId, "");
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index f4db5c10257f..b1a1798247c1 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@

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

2018-01-11 Thread Takeshi Abe
 starmath/qa/cppunit/test_starmath.cxx |4 ++--
 starmath/source/dialog.cxx|2 +-
 starmath/source/symbol.cxx|   10 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 0f2104cd745329852e6a6d9c93f6af7c5a8c646a
Author: Takeshi Abe 
Date:   Tue Jan 9 18:45:59 2018 +0900

starmath: getLength() > 0 -> !isEmpty()

Change-Id: I72e56e8e8cad77084bf771df8d85cb7d85712437
Reviewed-on: https://gerrit.libreoffice.org/47640
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/test_starmath.cxx 
b/starmath/qa/cppunit/test_starmath.cxx
index e2ee4afeadd9..41fcf3d75f88 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -363,7 +363,7 @@ void Test::editUndoRedo()
 m_xDocShRef->Execute(aUndo);
 m_xDocShRef->UpdateText();
 OUString sFinalText = m_xDocShRef->GetText();
-CPPUNIT_ASSERT_MESSAGE("Must now be empty", !sFinalText.getLength());
+CPPUNIT_ASSERT_MESSAGE("Must now be empty", sFinalText.isEmpty());
 }
 
 SfxRequest aRedo(SID_REDO, SfxCallMode::SYNCHRON, SmDocShell::GetPool());
@@ -379,7 +379,7 @@ void Test::editUndoRedo()
 m_xDocShRef->UpdateText();
 rEditEngine.ClearModifyFlag();
 OUString sFinalText = m_xDocShRef->GetText();
-CPPUNIT_ASSERT_MESSAGE("Must be empty", !sFinalText.getLength());
+CPPUNIT_ASSERT_MESSAGE("Must be empty", sFinalText.isEmpty());
 }
 
 }
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 3a92349c82f1..ca70ff1626c8 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -1929,7 +1929,7 @@ void SmSymDefineDialog::UpdateButtons()
 OUString aTmpSymbolName(pSymbols->GetText()),
   aTmpSymbolSetName (pSymbolSets->GetText());
 
-if (aTmpSymbolName.getLength() > 0  &&  aTmpSymbolSetName.getLength() > 0)
+if (!aTmpSymbolName.isEmpty() && !aTmpSymbolSetName.isEmpty())
 {
 // are all settings equal?
 //! (Font-, Style- and SymbolSet name comparison is not case sensitive)
diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx
index 92c799d90411..d989595cc14e 100644
--- a/starmath/source/symbol.cxx
+++ b/starmath/source/symbol.cxx
@@ -137,7 +137,7 @@ bool SmSymbolManager::AddOrReplaceSymbol( const SmSym 
&rSymbol, bool bForceChang
 bool bAdded = false;
 
 const OUString& aSymbolName( rSymbol.GetName() );
-if (aSymbolName.getLength() > 0 && rSymbol.GetSymbolSetName().getLength() 
> 0)
+if (!aSymbolName.isEmpty() && !rSymbol.GetSymbolSetName().isEmpty())
 {
 const SmSym *pFound = GetSymbolByName( aSymbolName );
 const bool bSymbolConflict = pFound && !pFound->IsEqualInUI( rSymbol );
@@ -170,7 +170,7 @@ bool SmSymbolManager::AddOrReplaceSymbol( const SmSym 
&rSymbol, bool bForceChang
 
 void SmSymbolManager::RemoveSymbol( const OUString & rSymbolName )
 {
-if (rSymbolName.getLength() > 0)
+if (!rSymbolName.isEmpty())
 {
 size_t nOldSize = m_aSymbols.size();
 m_aSymbols.erase( rSymbolName );
@@ -192,7 +192,7 @@ std::set< OUString > SmSymbolManager::GetSymbolSetNames() 
const
 const SymbolPtrVec_t SmSymbolManager::GetSymbolSet( const OUString& 
rSymbolSetName )
 {
 SymbolPtrVec_t aRes;
-if (rSymbolSetName.getLength() > 0)
+if (!rSymbolSetName.isEmpty())
 {
 SymbolMap_t::const_iterator aIt( m_aSymbols.begin() );
 for ( ; aIt != m_aSymbols.end(); ++aIt )
@@ -216,8 +216,8 @@ void SmSymbolManager::Load()
 for (size_t i = 0;  i < nSymbolCount;  ++i)
 {
 const SmSym &rSym = aSymbols[i];
-OSL_ENSURE( rSym.GetName().getLength() > 0, "symbol without name!" );
-if (rSym.GetName().getLength() > 0)
+OSL_ENSURE( !rSym.GetName().isEmpty(), "symbol without name!" );
+if (!rSym.GetName().isEmpty())
 AddOrReplaceSymbol( rSym );
 }
 m_bModified = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-02-20 Thread Takeshi Abe
 starmath/qa/cppunit/test_starmath.cxx |8 +++
 starmath/source/edit.cxx  |   36 +-
 2 files changed, 18 insertions(+), 26 deletions(-)

New commits:
commit 3efdd925e0ae1c080fbef3f1f79865eb6e172c68
Author: Takeshi Abe 
Date:   Tue Feb 21 12:48:33 2017 +0900

tdf#106116 "Previous Marker" changes selection only when needed

This fixes a hang caused by repeated Shift+F4. Although it seems
a regression from 2af1f5691e8d64afd5246d245d7876b5a2cd5cd8,
the original code of SmEditWindow::SelPrevMark() had been doomed
due to conditional loop depending on obscure signed/unsigned
conversion.

Change-Id: I61f630eec44b285dc1f1c27097acde4b48ed2991
Reviewed-on: https://gerrit.libreoffice.org/34503
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/test_starmath.cxx 
b/starmath/qa/cppunit/test_starmath.cxx
index 09f9abd..a6916bf 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -133,6 +133,14 @@ void Test::editMarker()
 m_pEditWindow->Delete();
 m_pEditWindow->InsertText("b");
 
+// tdf#106116: should be safe i.e. do nothing
+m_pEditWindow->SelPrevMark();
+auto aSelection = m_pEditWindow->GetSelection();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection.nStartPara);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection.nStartPos);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection.nEndPara);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection.nEndPos);
+
 m_pEditWindow->Flush();
 OUString sFinalText = m_pEditWindow->GetText();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a under b under c", 
sTargetText, sFinalText);
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index a60a766..47ecd52 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -878,36 +878,20 @@ void SmEditWindow::SelPrevMark()
 if (pEditEngine  &&  pEditView)
 {
 ESelection eSelection = pEditView->GetSelection();
-sal_Int32 nPos = -1;
+sal_Int32 nPara = eSelection.nStartPara;
 sal_Int32 nMax = eSelection.nStartPos;
-OUString aText(pEditEngine->GetText(eSelection.nStartPara));
-OUString aMark("");
-sal_Int32 nCounts = pEditEngine->GetParagraphCount();
-
-do
-{
-sal_Int32 nMarkIndex = aText.indexOf(aMark);
-while ((nMarkIndex < nMax) && (nMarkIndex != -1))
-{
-nPos = nMarkIndex;
-nMarkIndex = aText.indexOf(aMark, nMarkIndex + 1);
-}
-
-if (nPos == -1)
-{
-eSelection.nStartPara--;
-aText = pEditEngine->GetText(eSelection.nStartPara);
-nMax = aText.getLength();
-}
-}
-while ((eSelection.nStartPara < nCounts) &&
-(nPos == -1));
+OUString aText(pEditEngine->GetText(nPara));
+const OUString aMark("");
+sal_Int32 nPos;
 
-if (nPos != -1)
+while ( (nPos = aText.lastIndexOf(aMark, nMax)) < 0 )
 {
-pEditView->SetSelection(ESelection(
-eSelection.nStartPara, nPos, eSelection.nStartPara, nPos + 3));
+if (--nPara < 0)
+return;
+aText = pEditEngine->GetText(nPara);
+nMax = aText.getLength();
 }
+pEditView->SetSelection(ESelection(nPara, nPos, nPara, nPos + 3));
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-01-03 Thread Takeshi Abe
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |2 +-
 starmath/source/visitors.cxx|6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit d3c1a84d4c0bc24defcc497587fa6f258aa8ebdd
Author: Takeshi Abe 
Date:   Tue Jan 3 05:10:31 2017 +0900

starmath: Reenable a test case for SmNodeToTextVisitor

by fixing a regression which seems introduced at
4f294a90877d2f91bb88c7d6cd5b74e8e546a025.

Change-Id: If47f7528f5b5fd04432da134f345d69c25a1ca77
Reviewed-on: https://gerrit.libreoffice.org/32665
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index c3c17f9..e2575c0 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -228,7 +228,7 @@ void Test::SimpleOperators()
 parseandparseagain("coprod{a}", "Coproduct");
 parseandparseagain("int from {r_0} to {r_t} a", "Upper and lower bounds 
shown with integral (from & to)");
 ParseAndCheck("int csup {r_0} csub {r_t} a", "int csup { r _ 0 } csub { r 
_ t } a ", "Upper and lower bounds shown with integral (csub & csup)");
-//FIXMEParseAndCheck("sum csup { size 8 { x - 1 } } csub { size 8 a } b ", 
"sum csup { size 8 { x - 1 } } csub { size 8 a } b ", "Sum with sized upper and 
lower bounds");
+ParseAndCheck("sum csup { size 8 { x - 1 } } csub { size 8 a } b ", "sum 
csup { size 8 { x - 1 } } csub { size 8 a } b ", "Sum with sized upper and 
lower bounds");
 parseandparseagain("int{a}", "Integral");
 parseandparseagain("intd_{1}^{2}{x dx}", "Dynamically-sized integral");
 parseandparseagain("iint{a}", "Double integral");
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 90ce467..e6d3935 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2189,16 +2189,22 @@ void SmNodeToTextVisitor::Visit( SmUnHorNode* pNode )
 
 void SmNodeToTextVisitor::Visit( SmBinHorNode* pNode )
 {
+const SmNode *pParent = pNode->GetParent();
+bool bBraceNeeded = pParent && pParent->GetType() == NFONT;
 SmNode *pLeft  = pNode->LeftOperand(),
*pOper  = pNode->Symbol(),
*pRight = pNode->RightOperand();
 Separate( );
+if (bBraceNeeded)
+Append( "{ " );
 pLeft->Accept( this );
 Separate( );
 pOper->Accept( this );
 Separate( );
 pRight->Accept( this );
 Separate( );
+if (bBraceNeeded)
+Append( "} " );
 }
 
 void SmNodeToTextVisitor::Visit( SmBinVerNode* pNode )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-11-28 Thread Takeshi Abe
 starmath/qa/extras/data/tdf103430.mml |   15 ++
 starmath/qa/extras/mmlimport-test.cxx |   11 +
 starmath/source/mathmlattr.cxx|   35 +
 starmath/source/mathmlattr.hxx|   27 
 starmath/source/mathmlimport.cxx  |  201 +-
 starmath/source/mathmlimport.hxx  |3 
 starmath/source/node.cxx  |5 
 7 files changed, 267 insertions(+), 30 deletions(-)

New commits:
commit 2bad9f1cd8da0cd3d8ff33e875eaf10c1fd9d0bf
Author: Takeshi Abe 
Date:   Sun Nov 27 02:55:15 2016 +0900

tdf#103430 Apply mathvariant attribute to  and 

by emulating it with SmFontNode.
In case of , current implementation supports only the one named
with an alphabet.

Change-Id: I827a7e80f5aa94e243098a6e50eb758cf915c282
Reviewed-on: https://gerrit.libreoffice.org/31240
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/extras/data/tdf103430.mml 
b/starmath/qa/extras/data/tdf103430.mml
new file mode 100644
index 000..92fba05
--- /dev/null
+++ b/starmath/qa/extras/data/tdf103430.mml
@@ -0,0 +1,15 @@
+http://www.w3.org/1998/Math/MathML";>
+  
+   
+ 
+  d
+  2
+ 
+y
+   
+   
+ d
+ x
+   
+  
+
diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 3db697f..01ae2ff 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -34,6 +34,7 @@ public:
 void testMaction();
 void testMspace();
 void testtdf99556();
+void testTdf103430();
 void testTdf103500();
 
 CPPUNIT_TEST_SUITE(Test);
@@ -42,6 +43,7 @@ public:
 CPPUNIT_TEST(testMaction);
 CPPUNIT_TEST(testMspace);
 CPPUNIT_TEST(testtdf99556);
+CPPUNIT_TEST(testTdf103430);
 CPPUNIT_TEST(testTdf103500);
 CPPUNIT_TEST_SUITE_END();
 
@@ -122,10 +124,17 @@ void Test::testtdf99556()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
+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}"),
+ mxDocShell->GetText());
+}
+
 void Test::testTdf103500()
 {
 
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf103500.mml"));
-CPPUNIT_ASSERT_EQUAL(OUString("{{ int csub a csup b {1 over x ` d x}} = 
{intd csub a csup b {1 over y ` d y}}}"),
+CPPUNIT_ASSERT_EQUAL(OUString("{{ int csub a csup b {1 over x ` {nitalic 
d} x}} = {intd csub a csup b {1 over y ` {nitalic d} y}}}"),
  mxDocShell->GetText());
 }
 
diff --git a/starmath/source/mathmlattr.cxx b/starmath/source/mathmlattr.cxx
index 262609f..0c39c3e 100644
--- a/starmath/source/mathmlattr.cxx
+++ b/starmath/source/mathmlattr.cxx
@@ -10,6 +10,7 @@
 #include "mathmlattr.hxx"
 
 #include 
+#include 
 
 namespace {
 
@@ -144,4 +145,38 @@ sal_Int32 ParseMathMLAttributeLengthValue(const OUString 
&rStr, MathMLAttributeL
 return nIdx;
 }
 
+
+bool GetMathMLMathvariantValue(const OUString &rStr, MathMLMathvariantValue 
*pV)
+{
+static const std::unordered_map aMap{
+{"normal", MathMLMathvariantValue::Normal},
+{"bold", MathMLMathvariantValue::Bold},
+{"italic", MathMLMathvariantValue::Italic},
+{"bold-italic", MathMLMathvariantValue::BoldItalic},
+{"double-struck", MathMLMathvariantValue::DoubleStruck},
+{"bold-fraktur", MathMLMathvariantValue::BoldFraktur},
+{"script", MathMLMathvariantValue::Script},
+{"bold-script", MathMLMathvariantValue::BoldScript},
+{"fraktur", MathMLMathvariantValue::Fraktur},
+{"sans-serif", MathMLMathvariantValue::SansSerif},
+{"bold-sans-serif", MathMLMathvariantValue::BoldSansSerif},
+{"sans-serif-italic", MathMLMathvariantValue::SansSerifItalic},
+{"sans-serif-bold-italic", 
MathMLMathvariantValue::SansSerifBoldItalic},
+{"monospace", MathMLMathvariantValue::Monospace},
+{"initial", MathMLMathvariantValue::Initial},
+{"tailed", MathMLMathvariantValue::Tailed},
+{"looped", MathMLMathvariantValue::Looped},
+{"stretched", MathMLMathvariantValue::Stretched}
+};
+
+assert(pV);
+auto it = aMap.find(rStr);
+if (it != aMap.end())
+{
+*pV = it->second;
+return true;
+}
+return false;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/starmath/source/mathmlattr.hxx b/starmath/source/mathmlattr.hxx
index 75dddb0..f540254 100644
--- a/starmath/source/mathmlattr.hxx
+++ b/starmath/source/mathmlattr.hxx
@@ -47,6 +47,33 @@ struct MathMLAttributeLengthValue
 
 sal_Int32 ParseMathMLAttributeLengthValue(const OUString &rStr, 
MathMLAttributeLengthValue *pV);
 
+
+// MathML 3: 3.2.2 Mathematics style attribute

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

2016-11-18 Thread Takeshi Abe
 starmath/qa/extras/data/tdf103500.mml |   41 ++
 starmath/qa/extras/mmlimport-test.cxx |9 +++
 starmath/source/node.cxx  |6 
 3 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit f533b3f39956fe8028c1f7f7cc3c37b0feed8b57
Author: Takeshi Abe 
Date:   Fri Nov 18 17:10:44 2016 +0900

tdf#103500 Import stretchy integral symbol from MathML

as "intd".

Change-Id: Ic8a4feef7a3a19c8ed5bca2f09f80901e2b6d343
Reviewed-on: https://gerrit.libreoffice.org/30953
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/extras/data/tdf103500.mml 
b/starmath/qa/extras/data/tdf103500.mml
new file mode 100644
index 000..7c49669
--- /dev/null
+++ b/starmath/qa/extras/data/tdf103500.mml
@@ -0,0 +1,41 @@
+http://www.w3.org/1998/Math/MathML";>
+  
+
+  
+∫
+a
+b
+  
+  
+
+  1
+  x
+
+
+
+  d
+
+x
+  
+
+=
+
+  
+∫
+a
+b
+  
+  
+
+  1
+  y
+
+
+
+  d
+
+y
+  
+
+  
+
diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 9bbc08a..3db697f 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -34,6 +34,7 @@ public:
 void testMaction();
 void testMspace();
 void testtdf99556();
+void testTdf103500();
 
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testSimple);
@@ -41,6 +42,7 @@ public:
 CPPUNIT_TEST(testMaction);
 CPPUNIT_TEST(testMspace);
 CPPUNIT_TEST(testtdf99556);
+CPPUNIT_TEST(testTdf103500);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -120,6 +122,13 @@ void Test::testtdf99556()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
+void Test::testTdf103500()
+{
+
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf103500.mml"));
+CPPUNIT_ASSERT_EQUAL(OUString("{{ int csub a csup b {1 over x ` d x}} = 
{intd csub a csup b {1 over y ` d y}}}"),
+ mxDocShell->GetText());
+}
+
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 3db53a9..fe84e55 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -2447,7 +2447,11 @@ void SmMathSymbolNode::Arrange(OutputDevice &rDev, const 
SmFormat &rFormat)
 void SmMathSymbolNode::CreateTextFromNode(OUString &rText)
 {
 OUString sStr;
-MathType::LookupChar(GetToken().cMathChar, sStr, 3);
+sal_Unicode cChar = GetToken().cMathChar;
+if (cChar == MS_INT && GetScaleMode() == SCALE_HEIGHT)
+sStr = "intd ";
+else
+MathType::LookupChar(cChar, sStr, 3);
 rText += sStr;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-09-29 Thread Gulsah Kose
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |3 +++
 starmath/source/parse.cxx   |2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 8e466c431e6d61911b2b15895a4b63df12422057
Author: Gulsah Kose 
Date:   Mon Sep 26 17:58:43 2016 +0300

tdf#97164 Add text for visualition of percent symbol.

Change-Id: I31dc1a7a4ed0bc0e760e10c1a2ff52660a258e12
Signed-off-by: Gulsah Kose 
Reviewed-on: https://gerrit.libreoffice.org/29299
Reviewed-by: Takeshi Abe 
Tested-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 8b1e215..f6f8291 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -662,6 +662,9 @@ void Test::testMiscEquivalent()
 
 // tdf#88320
 ParseAndCompare("A_1,B_2", "A_{1},B_2", "Comma between a digit and 
non-digit delimits subscript");
+
+//tdf#97164
+ParseAndCompare("100 %", "100\"%\"", "Percent symbol at the end");
 }
 
 void Test::testParser()
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index f04b177..eeea617 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -655,7 +655,7 @@ void SmParser::NextToken()
 m_aCurToken.cMathChar  = '\0';
 m_aCurToken.nGroup = TG::NONE;
 m_aCurToken.nLevel = 5;
-m_aCurToken.aText.clear();
+m_aCurToken.aText  ="%";
 m_aCurToken.nRow   = m_Row;
 m_aCurToken.nCol   = nTmpStart - m_nColOff;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-09-19 Thread Takeshi Abe
 starmath/qa/extras/mmlexport-test.cxx |   12 
 starmath/source/mathmlexport.cxx  |   16 
 starmath/source/mathmlexport.hxx  |1 +
 3 files changed, 29 insertions(+)

New commits:
commit 3a8035bcb6cf081572d86813021bbccab265a935
Author: Takeshi Abe 
Date:   Mon Sep 19 09:26:41 2016 +0900

tdf#97049 Export "intd" to MathML

Change-Id: Ie1fc33e18958e73d4876b2b5daceec127011c3cc
Reviewed-on: https://gerrit.libreoffice.org/29003
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/extras/mmlexport-test.cxx 
b/starmath/qa/extras/mmlexport-test.cxx
index f13ee9d..3a2d222 100644
--- a/starmath/qa/extras/mmlexport-test.cxx
+++ b/starmath/qa/extras/mmlexport-test.cxx
@@ -35,9 +35,11 @@ public:
 virtual void setUp() override;
 virtual void tearDown() override;
 
+void testTdf97049();
 void testTdf101022();
 
 CPPUNIT_TEST_SUITE(MathMLExportTest);
+CPPUNIT_TEST(testTdf97049);
 CPPUNIT_TEST(testTdf101022);
 CPPUNIT_TEST_SUITE_END();
 
@@ -85,6 +87,16 @@ xmlDocPtr MathMLExportTest::exportAndParse()
 return pDoc;
 }
 
+void MathMLExportTest::testTdf97049()
+{
+mxDocShell->SetText("intd {{1 over x} dx}");
+xmlDocPtr pDoc = exportAndParse();
+assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]", "stretchy", 
"true");
+auto aContent = getXPathContent(pDoc, 
"/m:math/m:semantics/m:mrow/m:mo[1]");
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength());
+CPPUNIT_ASSERT_EQUAL(sal_Unicode(0x222B), aContent[0]);
+}
+
 void MathMLExportTest::testTdf101022()
 {
 #define CHECK_MATHVARIANT(capital, small) do\
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 0567181..2aab226 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -811,6 +811,11 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int 
/*nLevel*/)
 AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL);
 pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, 
true, false);
 }
+else if (pNode->GetType() == NDYNINTSYMBOL)
+{
+AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
+pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MO, 
true, false);
+}
 else
 {
 // Export NMATHIDENT and NPLACE symbols as  elements:
@@ -1456,6 +1461,13 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int 
nLevel)
 }
 }
 
+void SmXMLExport::ExportDynIntegral(const SmDynIntegralNode *pNode, int nLevel)
+{
+SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, true, true);
+ExportNodes(pNode->Symbol(), nLevel+1);
+ExportNodes(pNode->Body(), nLevel+1);
+}
+
 void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
 {
 if (!pNode)
@@ -1520,6 +1532,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int 
nLevel)
 case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in 
the XML engine.
 case NMATHIDENT :
 case NPLACE:
+case NDYNINTSYMBOL:
 ExportMath(pNode, nLevel);
 break;
 case NBINHOR:
@@ -1561,6 +1574,9 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int 
nLevel)
 case NBLANK:
 ExportBlank(pNode, nLevel);
 break;
+case NDYNINT:
+ExportDynIntegral(static_cast(pNode), 
nLevel);
+break;
default:
 SAL_WARN("starmath", "Warning: failed to export a node?");
 break;
diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx
index 4581db8..19a29cb 100644
--- a/starmath/source/mathmlexport.hxx
+++ b/starmath/source/mathmlexport.hxx
@@ -92,6 +92,7 @@ protected:
 void ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel);
 void ExportMatrix(const SmNode *pNode, int nLevel);
 void ExportBlank(const SmNode *pNode, int nLevel);
+void ExportDynIntegral(const SmDynIntegralNode *pNode, int nLevel);
 
 public:
 SmXMLExport(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-05-22 Thread Regina Henschel
 starmath/qa/extras/mmlimport-test.cxx |2 +-
 starmath/source/mathmlimport.cxx  |   19 +++
 2 files changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 66a953bf3aa6cb1abd55380d846accd68981537a
Author: Regina Henschel 
Date:   Sat May 21 21:32:47 2016 +0200

tdf#99984 render inferred mrow as group {}

In case an element has no content, but has got an SmXMLRowContext,
an empty group {} is inserted. The result is, that empty table
cells are rendered without error, so that files, which use a
mtable element to arrange things, no longer break on import.

Change-Id: Iae158226e6478f2f9f397b8485044860ee8767c2
Reviewed-on: https://gerrit.libreoffice.org/25273
Tested-by: Jenkins 
Reviewed-by: jan iversen 

diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index f9f1405..846ea87 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -108,7 +108,7 @@ void Test::testMaction()
 void Test::testtdf99556()
 {
 
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf99556-1.mml"));
-OUString sExpected("sqrt");
+OUString sExpected("sqrt { {} }");
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 971d349..5be0526 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2249,14 +2249,25 @@ void SmXMLRowContext_Impl::EndElement()
 return;
 }
 }
-else //Multiple newlines result in empty row elements
+else
 {
-aRelationArray.resize(1);
+// The elements msqrt, mstyle, merror, menclose, mpadded, mphantom, 
mtd, and math
+// treat their content as a single inferred mrow in case their content 
is empty.
+// Here an empty group {} is used to catch those cases and transform 
them without error
+// to StarMath.
+aRelationArray.resize(2);
 SmToken aToken;
-aToken.cMathChar = '\0';
+aToken.cMathChar = MS_LBRACE;
 aToken.nLevel = 5;
-aToken.eType = TNEWLINE;
+aToken.eType = TLGROUP;
+aToken.aText = "{";
 aRelationArray[0] = new SmLineNode(aToken);
+
+aToken.cMathChar = MS_RBRACE;
+aToken.nLevel = 0;
+aToken.eType = TRGROUP;
+aToken.aText = "}";
+aRelationArray[1] = new SmLineNode(aToken);
 }
 
 SmToken aDummy;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-05-19 Thread Takeshi Abe
 starmath/qa/cppunit/mock-visitor.hxx |3 +++
 starmath/source/parse.cxx|   10 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)

New commits:
commit ab25d7cfec956b6c31551ee5c00bd6bcae4b0bb5
Author: Takeshi Abe 
Date:   Thu May 19 12:32:40 2016 +0900

starmath: Assign the proper token to SmTableNode

... for a similar motivation with b43b79648f4fbcd815092268d1b7a5af9e278f52.

Change-Id: I9fc42fc8e34958295eeec5759c072c8259fc38b6
Reviewed-on: https://gerrit.libreoffice.org/25122
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/starmath/qa/cppunit/mock-visitor.hxx 
b/starmath/qa/cppunit/mock-visitor.hxx
index 79e5784..aa1639e 100644
--- a/starmath/qa/cppunit/mock-visitor.hxx
+++ b/starmath/qa/cppunit/mock-visitor.hxx
@@ -22,6 +22,9 @@ public:
 void Visit( SmTableNode* pNode ) override {
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTableNode should have type NTABLE",
  NTABLE, pNode->GetType());
+auto eTT = pNode->GetToken().eType;
+CPPUNIT_ASSERT_MESSAGE("The type of SmTableNode's token should be 
either TEND, TBINOM, or TSTACK",
+   eTT == TEND || eTT == TBINOM || eTT == TSTACK);
 VisitChildren( pNode );
 }
 
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 1c88da9..591404a 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2156,6 +2156,7 @@ void SmParser::DoBinom()
 
 void SmParser::DoStack()
 {
+std::unique_ptr pSNode(new SmTableNode(m_aCurToken));
 NextToken();
 if (m_aCurToken.eType == TLGROUP)
 {
@@ -2178,15 +2179,10 @@ void SmParser::DoStack()
 if (m_aCurToken.eType != TRGROUP)
 Error(PE_RGROUP_EXPECTED);
 
-NextToken();
-
-//We need to let the table node know it context
-//it's used in SmNodeToTextVisitor
-SmToken aTok = m_aCurToken;
-aTok.eType = TSTACK;
-std::unique_ptr pSNode(new SmTableNode(aTok));
 pSNode->SetSubNodes(ExpressionArray);
 m_aNodeStack.push_front(std::move(pSNode));
+
+NextToken();
 }
 else
 Error(PE_LGROUP_EXPECTED);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-05-13 Thread Caolán McNamara
 starmath/qa/extras/data/tdf99556-1.mml |3 +++
 starmath/qa/extras/mmlimport-test.cxx  |   10 ++
 starmath/source/mathmlimport.cxx   |   10 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit eb2da27e0834925d449373593fb650db49671adf
Author: Caolán McNamara 
Date:   Fri May 13 13:03:55 2016 +0100

Resolves: tdf#99556 if the num of arguments is not 1 infer a raw

not just if the num of arguments is > 1

Change-Id: If0cae16cc52685315708ac3b2b8456ede7c1a6ce

diff --git a/starmath/qa/extras/data/tdf99556-1.mml 
b/starmath/qa/extras/data/tdf99556-1.mml
new file mode 100644
index 000..0eae8b2
--- /dev/null
+++ b/starmath/qa/extras/data/tdf99556-1.mml
@@ -0,0 +1,3 @@
+http://www.w3.org/1998/Math/MathML";>
+
+
diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 6a81acf..f9f1405 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -32,11 +32,13 @@ public:
 void testSimple();
 void testNsPrefixMath();
 void testMaction();
+void testtdf99556();
 
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testSimple);
 CPPUNIT_TEST(testNsPrefixMath);
 CPPUNIT_TEST(testMaction);
+CPPUNIT_TEST(testtdf99556);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -103,6 +105,14 @@ void Test::testMaction()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
+void Test::testtdf99556()
+{
+
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf99556-1.mml"));
+OUString sExpected("sqrt");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
+}
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index fe76543..a5537dd 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -794,7 +794,7 @@ void SmXMLEncloseContext_Impl::EndElement()
 contents are treated as a single "inferred " containing its
 arguments
 */
-if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
+if (GetSmImport().GetNodeStack().size() - nElementCount != 1)
 SmXMLRowContext_Impl::EndElement();
 }
 
@@ -863,7 +863,7 @@ void SmXMLStyleContext_Impl::EndElement()
 arguments
 */
 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-if (rNodeStack.size() - nElementCount > 1)
+if (rNodeStack.size() - nElementCount != 1)
 SmXMLRowContext_Impl::EndElement();
 aStyleHelper.ApplyAttrs();
 }
@@ -887,7 +887,7 @@ void SmXMLPaddedContext_Impl::EndElement()
 contents are treated as a single "inferred " containing its
 arguments
 */
-if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
+if (GetSmImport().GetNodeStack().size() - nElementCount != 1)
 SmXMLRowContext_Impl::EndElement();
 }
 
@@ -910,7 +910,7 @@ void SmXMLPhantomContext_Impl::EndElement()
 contents are treated as a single "inferred " containing its
 arguments
 */
-if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
+if (GetSmImport().GetNodeStack().size() - nElementCount != 1)
 SmXMLRowContext_Impl::EndElement();
 
 SmToken aToken;
@@ -2158,7 +2158,7 @@ void SmXMLSqrtContext_Impl::EndElement()
 contents are treated as a single "inferred " containing its
 arguments
 */
-if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
+if (GetSmImport().GetNodeStack().size() - nElementCount != 1)
 SmXMLRowContext_Impl::EndElement();
 
 SmToken aToken;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-05-12 Thread Takeshi Abe
 starmath/qa/cppunit/mock-visitor.hxx |2 ++
 starmath/source/parse.cxx|6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

New commits:
commit b43b79648f4fbcd815092268d1b7a5af9e278f52
Author: Takeshi Abe 
Date:   Thu May 12 12:41:09 2016 +0900

starmath: SmMatrixNode should have the node TMATRIX

... rather than the one after its closing brace.
So far having an arbitrary node is OK for SmMatrixNode
because existing code does not refer to it, but it is
saner to keep relevant nodes in the syntax tree.

Change-Id: Ia5412454c996eedde1545cd8a2f323eb95593eb9
Reviewed-on: https://gerrit.libreoffice.org/24909
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/mock-visitor.hxx 
b/starmath/qa/cppunit/mock-visitor.hxx
index 63134ca..79e5784 100644
--- a/starmath/qa/cppunit/mock-visitor.hxx
+++ b/starmath/qa/cppunit/mock-visitor.hxx
@@ -94,6 +94,8 @@ public:
 void Visit( SmMatrixNode* pNode ) override {
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode should have type NMATRIX",
  NMATRIX, pNode->GetType());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode's token should be of type 
TMATRIX",
+ TMATRIX, pNode->GetToken().eType);
 VisitChildren( pNode );
 }
 
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 8ff4ab4..7ccf442 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2194,6 +2194,7 @@ void SmParser::DoStack()
 
 void SmParser::DoMatrix()
 {
+std::unique_ptr pMNode(new SmMatrixNode(m_aCurToken));
 NextToken();
 if (m_aCurToken.eType == TLGROUP)
 {
@@ -2240,12 +2241,11 @@ void SmParser::DoMatrix()
 if (m_aCurToken.eType != TRGROUP)
 Error(PE_RGROUP_EXPECTED);
 
-NextToken();
-
-std::unique_ptr pMNode(new SmMatrixNode(m_aCurToken));
 pMNode->SetSubNodes(ExpressionArray);
 pMNode->SetRowCol(r, c);
 m_aNodeStack.push_front(std::move(pMNode));
+
+NextToken();
 }
 else
 Error(PE_LGROUP_EXPECTED);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-04-27 Thread Takeshi Abe
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |3 +++
 starmath/source/parse.cxx   |8 
 2 files changed, 11 insertions(+)

New commits:
commit 615e3502c5217585501dac27318a2f22847a5605
Author: Takeshi Abe 
Date:   Wed Apr 20 20:00:32 2016 +0900

Resolves: tdf#88320 parsing fails with a subscript number

... ending with comma and followed by non-space.

Change-Id: Ia00c662e31940270690c64e1840417436565a6c7
Reviewed-on: https://gerrit.libreoffice.org/24260
Tested-by: Jenkins 
Reviewed-by: Takeshi Abe 

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index b0dfaf5..ffa3f59 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -658,6 +658,9 @@ void Test::testMiscEquivalent()
 // check non-BMP Unicode char
 ParseAndCompare("{\xf0\x9d\x91\x8e}", "\xf0\x9d\x91\x8e", "non-BMP 
variable in brace");
 ParseAndCompare("{ \xf0\x9d\x91\x8e }", "\xf0\x9d\x91\x8e", "non-BMP 
variable in brace");
+
+// tdf#88320
+ParseAndCompare("A_1,B_2", "A_{1},B_2", "Comma between a digit and 
non-digit delimits subscript");
 }
 
 void Test::testParser()
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index ada838a..6a7d76b 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -460,6 +460,14 @@ void SmParser::NextToken()
 }
 else if (aRes.TokenType & KParseType::ANY_NUMBER)
 {
+assert(aRes.EndPos > 0);
+if ( m_aBufferString[aRes.EndPos-1] == ',' &&
+ aRes.EndPos < nBufLen &&
+ aCC.getType( m_aBufferString, aRes.EndPos ) != 
UnicodeType::SPACE_SEPARATOR )
+{
+// Comma followed by a non-space char is unlikely for 
decimal/thousands separator.
+--aRes.EndPos;
+}
 sal_Int32 n = aRes.EndPos - nRealStart;
 OSL_ENSURE( n >= 0, "length < 0" );
 m_aCurToken.eType  = TNUMBER;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-08-11 Thread Takeshi Abe
 starmath/qa/extras/mmlimport-test.cxx |6 +++---
 starmath/source/node.cxx  |9 ++---
 2 files changed, 5 insertions(+), 10 deletions(-)

New commits:
commit 9fbf4fd5292f6a3c28a092f7bb02541ceb61351f
Author: Takeshi Abe 
Date:   Sun Aug 9 23:08:28 2015 +0900

Related: tdf#75171 wrong "italic" happens on importing MathML

As of 4f294a90877d2f91bb88c7d6cd5b74e8e546a025, a SmTextNode can be
the sole child of a SmLineNode without being wrapped in a SmExpressionNode.

Change-Id: I3779eb90e216a70566c1151a9b8cb91a9fa36519
Reviewed-on: https://gerrit.libreoffice.org/17613
Reviewed-by: Regina Henschel 
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 3effb31..d0cccd7 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -85,21 +85,21 @@ void Test::tearDown()
 void Test::testSimple()
 {
 loadURL(getURLFromSrc("starmath/qa/extras/data/simple.mml"));
-OUString sExpected("left ( {italic \"a\" + italic \"b\"} right )^italic 
\"2\"");
+OUString sExpected("left ( {a + b} right )^2");
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
 void Test::testNsPrefixMath()
 {
 loadURL(getURLFromSrc("starmath/qa/extras/data/ns-prefix-math.mml"));
-OUString sExpected("left ( {italic \"a\" + italic \"b\"} right )^italic 
\"2\"");
+OUString sExpected("left ( {a + b} right )^2");
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
 void Test::testMaction()
 {
 loadURL(getURLFromSrc("starmath/qa/extras/data/maction.mml"));
-OUString sExpected("matrix {italic \"1\" ## italic \"2\" ## italic 
\"3\"}");
+OUString sExpected("matrix {1 ## 2 ## 3}");
 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
 }
 
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 9e66810..f8a7ae1 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -2367,13 +2367,8 @@ void SmTextNode::CreateTextFromNode(OUString &rText)
 (pResult->GetNumSubNodes() == 1) )
 {
 pResult = pResult->GetSubNode(0);
-if ( (pResult->GetType() == NEXPRESSION) &&
-(pResult->GetNumSubNodes() == 1) )
-{
-pResult = pResult->GetSubNode(0);
-if (pResult->GetType() == NTEXT)
-bQuoted=false;
-}
+if (pResult->GetType() == NTEXT)
+bQuoted=false;
 }
 }
 delete pTable;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-02-27 Thread Takeshi Abe
 starmath/qa/extras/data/maction.mml   |   10 
 starmath/qa/extras/mmlimport-test.cxx |9 
 starmath/source/mathmlimport.cxx  |   70 +++---
 starmath/source/mathmlimport.hxx  |6 ++
 4 files changed, 89 insertions(+), 6 deletions(-)

New commits:
commit fe43c9227bd77c6471126b2553820c14b4721d6f
Author: Takeshi Abe 
Date:   Tue Feb 24 13:55:58 2015 +0900

starmath: render the selected subexpression of MathML's 

... specified by the selection attribute.
For its expected behavior, see the section  in MathML 1.01:


Change-Id: I70c1b2cfe1afec730f3e67ba0938bbaf8ada8e23
Reviewed-on: https://gerrit.libreoffice.org/14600
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/starmath/qa/extras/data/maction.mml 
b/starmath/qa/extras/data/maction.mml
new file mode 100644
index 000..3650087
--- /dev/null
+++ b/starmath/qa/extras/data/maction.mml
@@ -0,0 +1,10 @@
+
+http://www.w3.org/1998/Math/MathML";>
+  
+ 
+100
+020
+003
+ 
+  
+
diff --git a/starmath/qa/extras/mmlimport-test.cxx 
b/starmath/qa/extras/mmlimport-test.cxx
index 2fbeda7..adf80aa 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -30,9 +30,11 @@ public:
 virtual void tearDown() SAL_OVERRIDE;
 
 void testSimple();
+void testMaction();
 
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testSimple);
+CPPUNIT_TEST(testMaction);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -83,6 +85,13 @@ void Test::testSimple()
 loadURL(getURLFromSrc("starmath/qa/extras/data/simple.mml"));
 }
 
+void Test::testMaction()
+{
+loadURL(getURLFromSrc("starmath/qa/extras/data/maction.mml"));
+OUString sExpected("matrix {italic \"1\" ## italic \"2\" ## italic 
\"3\"}");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, 
mxDocShell->GetText());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 488797e..8a42baf 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -1756,12 +1756,16 @@ public:
 
 class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
 {
+size_t mnSelection; // 1-based
+
 public:
 SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
 const OUString& rLName) :
 SmXMLRowContext_Impl(rImport,nPrefix,rLName)
+  , mnSelection(1)
 {}
 
+void StartElement(const uno::Reference 
&xAttrList) SAL_OVERRIDE;
 void EndElement() SAL_OVERRIDE;
 };
 
@@ -1957,6 +1961,13 @@ static const SvXMLTokenMapEntry aColorTokenMap[] =
 XML_TOKEN_MAP_END
 };
 
+static const SvXMLTokenMapEntry aActionAttrTokenMap[] =
+{
+{ XML_NAMESPACE_MATH,   XML_SELECTION,  XML_TOK_SELECTION },
+XML_TOKEN_MAP_END
+};
+
+
 const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
 {
 if (!pPresLayoutElemTokenMap)
@@ -2022,6 +2033,12 @@ const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
 return *pColorTokenMap;
 }
 
+const SvXMLTokenMap& SmXMLImport::GetActionAttrTokenMap()
+{
+if (!pActionAttrTokenMap)
+pActionAttrTokenMap = new SvXMLTokenMap(aActionAttrTokenMap);
+return *pActionAttrTokenMap;
+}
 
 
 SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
@@ -2589,18 +2606,58 @@ void SmXMLMultiScriptsContext_Impl::EndElement()
 ProcessSubSupPairs(bHasPrescripts);
 }
 
-void SmXMLActionContext_Impl::EndElement()
+void SmXMLActionContext_Impl::StartElement(const 
uno::Reference & xAttrList)
 {
-/*For now we will just assume that the
- selected attribute is one, and then just display
- that expression alone, i.e. remove all expect the
- first pushed one*/
+sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+for (sal_Int16 i=0;igetNameByIndex(i);
+OUString aLocalName;
+sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+GetKeyByAttrName(sAttrName,&aLocalName);
 
+OUString sValue = xAttrList->getValueByIndex(i);
+const SvXMLTokenMap &rAttrTokenMap =
+GetSmImport().GetActionAttrTokenMap();
+switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+{
+case XML_TOK_SELECTION:
+{
+sal_uInt32 n = sValue.toUInt32();
+if (n > 0) mnSelection = static_cast(n);
+}
+break;
+default:
+break;
+}
+}
+}
+
+void SmXMLActionContext_Impl::EndElement()
+{
 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-for (auto i=rNodeStack.size()-nElementCount;i > 1;i--)
+auto nSize = rNodeStack.size();
+if (nSize <= nElementCount) {
+// not compliant to maction's specification, e.g., no subexpressions
+return;
+}
+assert(mnSelection > 0);
+if

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

2014-11-26 Thread Takeshi Abe
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |4 ++--
 starmath/source/visitors.cxx|   24 
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit ede5d170ea25c7983ed890075d9d5479aaa08d88
Author: Takeshi Abe 
Date:   Mon Nov 24 10:34:13 2014 +0900

fdo#70185: Correct and reenable SmNodeToTextVisitor's test case

This fixes the order of handling csub/csup changed at 
80de3c0fe6b191f6d528ae1142737e2561b12ccd.

Change-Id: I1b5ad39b367e1933f8a17ce8126feed4d996f662
Reviewed-on: https://gerrit.libreoffice.org/13086
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 09d1d6c..6940f19 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -221,8 +221,8 @@ void Test::SimpleOperators()
 parseandparseagain("sum{a}", "Sum");
 parseandparseagain("prod{a}", "Product");
 parseandparseagain("coprod{a}", "Coproduct");
-//FIXMEparseandparseagain("int from {r_0} to {r_t} a", "Upper and lower 
bounds shown with integral (from & to)");
-//FIXMEParseAndCheck("int csup {r_0} csub {r_t} a", "int csup { r rsub 0 } 
csub { r rsub t } a ", "Upper and lower bounds shown with integral (csub & 
csup)");
+parseandparseagain("int from {r_0} to {r_t} a", "Upper and lower bounds 
shown with integral (from & to)");
+ParseAndCheck("int csup {r_0} csub {r_t} a", "int csup { r _ 0 } csub { r 
_ t } a ", "Upper and lower bounds shown with integral (csub & csup)");
 //FIXMEParseAndCheck("sum csup { size 8 { x - 1 } } csub { size 8 a } b ", 
"sum csup { size 8 { x - 1 } } csub { size 8 a } b ", "Sum with sized upper and 
lower bounds");
 parseandparseagain("int{a}", "Integral");
 parseandparseagain("iint{a}", "Double integral");
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index b0bf0df..60f6127 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2238,21 +2238,21 @@ void SmNodeToTextVisitor::Visit( SmOperNode* pNode )
 LineToText( pChild );
 Append( "} " );
 }
-if( ( pChild = pSubSup->GetSubSup( CSUB ) ) ) {
+if( ( pChild = pSubSup->GetSubSup( CSUP ) ) ) {
 Separate( );
 if (pSubSup->IsUseLimits())
-Append( "from { " );
+Append( "to { " );
 else
-Append( "csub { " );
+Append( "csup { " );
 LineToText( pChild );
 Append( "} " );
 }
-if( ( pChild = pSubSup->GetSubSup( CSUP ) ) ) {
+if( ( pChild = pSubSup->GetSubSup( CSUB ) ) ) {
 Separate( );
 if (pSubSup->IsUseLimits())
-Append( "to { " );
+Append( "from { " );
 else
-Append( "csup { " );
+Append( "csub { " );
 LineToText( pChild );
 Append( "} " );
 }
@@ -2428,20 +2428,20 @@ void SmNodeToTextVisitor::Visit( SmSubSupNode* pNode )
 Append( "_ " );
 LineToText( pChild );
 }
-if( ( pChild = pNode->GetSubSup( CSUB ) ) ) {
+if( ( pChild = pNode->GetSubSup( CSUP ) ) ) {
 Separate( );
 if (pNode->IsUseLimits())
-Append( "from " );
+Append( "to " );
 else
-Append( "csub " );
+Append( "csup " );
 LineToText( pChild );
 }
-if( ( pChild = pNode->GetSubSup( CSUP ) ) ) {
+if( ( pChild = pNode->GetSubSup( CSUB ) ) ) {
 Separate( );
 if (pNode->IsUseLimits())
-Append( "to " );
+Append( "from " );
 else
-Append( "csup " );
+Append( "csub " );
 LineToText( pChild );
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-27 Thread Caolán McNamara
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |1 +
 starmath/source/parse.cxx   |8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 501e5b98ad39156cac465a161709ad38b89e3d63
Author: Caolán McNamara 
Date:   Tue May 27 11:26:54 2014 +0100

Resolves: fdo#77831 use classic token rules for user-defined char (%foo)

Change-Id: Iebae064986ad722d445c8d654e39e338e104f021

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx 
b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index e5c8626..09d1d6c 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -232,6 +232,7 @@ void Test::SimpleOperators()
 parseandparseagain("llint a", "Double curved integral");
 parseandparseagain("lllint a", "Triple curved integral");
 parseandparseagain("prod from {i=1} to {n} {(i+1)}", "Product with range");
+ParseAndCheck("%Ux2135", "%Ux2135", "fdo#77831");
 }
 
 void Test::SimpleAttributes()
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index a1338e9..2a3fba1 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -375,6 +375,12 @@ const sal_Int32 coContFlags =
 (coStartFlags & ~KParseTokens::IGNORE_LEADING_WS)
 | KParseTokens::TWO_DOUBLE_QUOTES_BREAK_STRING;
 
+// user-defined char continuing characters may be any alphanumeric or dot.
+const sal_Int32 coUserDefinedCharContFlags =
+((KParseTokens::ANY_LETTER_OR_NUMBER | KParseTokens::IGNORE_LEADING_WS | 
KParseTokens::ASC_DOT)
+& ~KParseTokens::IGNORE_LEADING_WS)
+| KParseTokens::TWO_DOUBLE_QUOTES_BREAK_STRING;
+
 // First character for numbers, may be any numeric or dot
 const sal_Int32 coNumStartFlags =
 KParseTokens::ASC_DIGIT |
@@ -644,7 +650,7 @@ void SmParser::NextToken()
 m_aBufferString, rnEndPos,
 KParseTokens::ANY_LETTER,
 aEmptyStr,
-coContFlags,
+coUserDefinedCharContFlags,
 aEmptyStr );
 
 sal_Int32 nTmpStart = rnEndPos + 
aTmpRes.LeadingWhiteSpace;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits