summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2020-12-02 00:12:05 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-09 15:21:09 +0100
commit6e0f18d7d523c62236a1968c36b4e0cc8586ac34 (patch)
tree1c66fcd04921df2fd71765401641ceacf1f8bd2b /starmath
parente04bf67bba3a6410f49fd311fe499456c2f9dc7d (diff)
Begining of support for &entityname for mathml.
Change-Id: I03ce79ed74088db3c1f6c1f87d7a75160ff19a30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107038 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/Library_sm.mk1
-rw-r--r--starmath/source/mathmlattr.hxx1
-rw-r--r--starmath/source/mathmlimport.cxx6
-rw-r--r--starmath/source/xparsmlbase.cxx40
-rw-r--r--starmath/source/xparsmlbase.hxx46
5 files changed, 94 insertions, 0 deletions
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index a63b506783e1..cc3dab8875e7 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
starmath/source/document \
starmath/source/edit \
starmath/source/format \
+ starmath/source/xparsmlbase \
starmath/source/mathmlattr \
starmath/source/mathmlexport \
starmath/source/mathmlimport \
diff --git a/starmath/source/mathmlattr.hxx b/starmath/source/mathmlattr.hxx
index 104495d2c878..fba6f3bc4195 100644
--- a/starmath/source/mathmlattr.hxx
+++ b/starmath/source/mathmlattr.hxx
@@ -13,6 +13,7 @@
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <tools/fract.hxx>
+#include "xparsmlbase.hxx"
// MathML 3: 2.1.5.1 Syntax notation used in the MathML specification
// <https://www.w3.org/TR/MathML/chapter2.html#id.2.1.5.1>
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 5fa4a96ad406..c06d0043dee7 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -268,11 +268,17 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent(const Reference<io::XInputStrea
Reference<css::xml::sax::XFastParser> xFastParser(xFilter, UNO_QUERY);
Reference<css::xml::sax::XFastDocumentHandler> xFastDocHandler(xFilter, UNO_QUERY);
if (xFastParser)
+ {
+ xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntitiesNames,
+ starmathdatabase::icustomMathmlHtmlEntitiesValues);
xFastParser->parseStream(aParserInput);
+ }
else if (xFastDocHandler)
{
Reference<css::xml::sax::XFastParser> xParser
= css::xml::sax::FastParser::create(rxContext);
+ xParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntitiesNames,
+ starmathdatabase::icustomMathmlHtmlEntitiesValues);
xParser->setFastDocumentHandler(xFastDocHandler);
xParser->parseStream(aParserInput);
}
diff --git a/starmath/source/xparsmlbase.cxx b/starmath/source/xparsmlbase.cxx
new file mode 100644
index 000000000000..8fbf6f9117f3
--- /dev/null
+++ b/starmath/source/xparsmlbase.cxx
@@ -0,0 +1,40 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "xparsmlbase.hxx"
+
+static OUString icustomMathmlHtmlEntitiesNamesData[2] = { u"sigma", u"infin" };
+
+static OUString icustomMathmlHtmlEntitiesValuesData[2] = { u"\u03C3", u"\u221E" };
+
+const ::css::uno::Sequence<::rtl::OUString>
+ starmathdatabase::icustomMathmlHtmlEntitiesNames(icustomMathmlHtmlEntitiesNamesData, 2);
+
+const ::css::uno::Sequence<::rtl::OUString>
+ starmathdatabase::icustomMathmlHtmlEntitiesValues(icustomMathmlHtmlEntitiesValuesData, 2);
+
+/*
+#include "xparsmlbase.hxx"
+
+const com::sun::star::uno::Sequence<OUString> starmathdatabase::icustomMathmlHtmlEntitiesNames
+ = { { OUString::createFromAscii("sigma") }, { OUString::createFromAscii("infin") } };
+
+const com::sun::star::uno::Sequence<OUString> starmathdatabase::icustomMathmlHtmlEntitiesValues
+ = { { OUString("\u03C3!", 2, RTL_TEXTENCODING_UTF8) },
+ { OUString("\u221E!", 2, RTL_TEXTENCODING_UTF8) } };
+ */
diff --git a/starmath/source/xparsmlbase.hxx b/starmath/source/xparsmlbase.hxx
new file mode 100644
index 000000000000..4bca389a4961
--- /dev/null
+++ b/starmath/source/xparsmlbase.hxx
@@ -0,0 +1,46 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef XPARSEMLBASE
+#define XPARSEMLBASE
+
+#include <com/sun/star/uno/Sequence.hxx>
+namespace starmathdatabase
+{
+/**
+ * w3 documentation has been used for this.
+ * See: https://www.w3.org/2003/entities/2007/htmlmathml-f.ent
+ * Copyright 1998 - 2011 W3C.
+ * We allow the import of HTML5 entities because are compatible with mathml
+ * and ill formated are expected.
+ * On export only mathml entities are allowed.
+ */
+/**
+ * Entity names for mathml. Example: &infin;
+ * Must be in sync with customMathmlHtmlEntitiesNames.
+ */
+const extern ::css::uno::Sequence<::rtl::OUString> icustomMathmlHtmlEntitiesNames;
+/**
+ * Entity values for mathml. Example: &infin; -> "\u8734";
+ * Must be in sync with customMathmlHtmlEntitiesNames.
+ */
+const extern ::css::uno::Sequence<::rtl::OUString> icustomMathmlHtmlEntitiesValues;
+};
+
+#endif /*XPARSEMLBASE*/