diff options
author | dante <dante19031999@gmail.com> | 2020-12-19 18:39:54 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-26 08:21:58 +0100 |
commit | 9f6dfd50cb03b6511d4f711d284e1b75783d0b8b (patch) | |
tree | d40480227b9b07f574aa11ef26b53707f4bd6cb5 /starmath/source | |
parent | 86707f3595c282f80b5e09558a23b539446daca2 (diff) |
Improve handle of custom XML entities
Since 7.1 hasn't been released yet there's still time to change it before having to be scared about backguards compatibility.
This way:
- It is more efficient than passing two arguments
- On definition it is simpler since both are declarated on same point.
So it is simpler to not loose sync between lists.
- Code is less long.
- Thanks to an idea proposed by Stephan Bergmann on other commit.
Change-Id: I16305a304c98eb8d4e11507c7938002da546778b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108028
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/mathmlimport.cxx | 6 | ||||
-rw-r--r-- | starmath/source/xparsmlbase.cxx | 14 | ||||
-rw-r--r-- | starmath/source/xparsmlbase.hxx | 11 |
3 files changed, 17 insertions, 14 deletions
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 04c4bc6b8837..fd27d226a948 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -270,16 +270,14 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent(const Reference<io::XInputStrea Reference<css::xml::sax::XFastDocumentHandler> xFastDocHandler(xFilter, UNO_QUERY); if (xFastParser) { - xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntitiesNames, - starmathdatabase::icustomMathmlHtmlEntitiesValues); + xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); 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->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); xParser->setFastDocumentHandler(xFastDocHandler); xParser->parseStream(aParserInput); } diff --git a/starmath/source/xparsmlbase.cxx b/starmath/source/xparsmlbase.cxx index b8bb6c7fc329..b699e7935fbe 100644 --- a/starmath/source/xparsmlbase.cxx +++ b/starmath/source/xparsmlbase.cxx @@ -18,6 +18,7 @@ */ #include "xparsmlbase.hxx" +/* static OUString icustomMathmlHtmlEntitiesNamesData[2125] = { // clang-format off u"AElig", @@ -4277,11 +4278,16 @@ static OUString icustomMathmlHtmlEntitiesValuesData[2125] = { u"\u200C" // clang-format on }; +*/ -const ::css::uno::Sequence<::rtl::OUString> - starmathdatabase::icustomMathmlHtmlEntitiesNames(icustomMathmlHtmlEntitiesNamesData, 2125); +static ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> icustomMathmlHtmlEntitiesData[2] = { + // clang-format off + { u"infin", u"\u221E" }, + { u"sigma", u"\u03C3" } + // clang-format on +}; -const ::css::uno::Sequence<::rtl::OUString> - starmathdatabase::icustomMathmlHtmlEntitiesValues(icustomMathmlHtmlEntitiesValuesData, 2125); +const ::css::uno::Sequence<::css::beans::Pair<OUString, OUString>> + starmathdatabase::icustomMathmlHtmlEntities(icustomMathmlHtmlEntitiesData, 2); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/xparsmlbase.hxx b/starmath/source/xparsmlbase.hxx index f9b58de7ca89..6603d23293db 100644 --- a/starmath/source/xparsmlbase.hxx +++ b/starmath/source/xparsmlbase.hxx @@ -21,6 +21,7 @@ #define XPARSEMLBASE #include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/Pair.hpp> namespace starmathdatabase { /** @@ -32,16 +33,14 @@ namespace starmathdatabase * On export only mathml entities are allowed. * Some documentation: https://www.w3.org/TR/MathML3/chapter7.html */ + /** * Entity names for mathml. Example: ∞ + * These ones are to be used on import. * Must be in sync with customMathmlHtmlEntitiesNames. */ -const extern ::css::uno::Sequence<::rtl::OUString> icustomMathmlHtmlEntitiesNames; -/** - * Entity values for mathml. Example: ∞ -> "\u8734"; - * Must be in sync with customMathmlHtmlEntitiesNames. - */ -const extern ::css::uno::Sequence<::rtl::OUString> icustomMathmlHtmlEntitiesValues; +const extern ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>> + icustomMathmlHtmlEntities; }; #endif /*XPARSEMLBASE*/ |