diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-29 14:16:33 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-29 20:15:14 +0200 |
commit | 65167c708afb475aa628b8289e78a48abdf37119 (patch) | |
tree | 201d9614a0a270979decf6882faf3da38cc0f795 /starmath | |
parent | a7e52282e36987f4ca6bed968e87ada6849b10e8 (diff) |
SM disable localized characters on element parsing
The special character tokens are localized character names! This
means that at least in German the %mu wasn't replaced in the
example, as the parser expected %my. So tell the parser to expect
non-localized input. And share it for all the parsing.
Change-Id: I4c3c0f35eb61c37a2101b51b445e7cc888a1f429
Reviewed-on: https://gerrit.libreoffice.org/73172
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/ElementsDockingWindow.hxx | 3 | ||||
-rw-r--r-- | starmath/source/ElementsDockingWindow.cxx | 88 |
2 files changed, 48 insertions, 43 deletions
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx index aaa992b97f77..fe86ebd422f6 100644 --- a/starmath/inc/ElementsDockingWindow.hxx +++ b/starmath/inc/ElementsDockingWindow.hxx @@ -31,6 +31,7 @@ class SmDocShell; class SmNode; +class SmParser; class SmElement { @@ -107,7 +108,7 @@ class SmElementsControl : public Control bool m_bFirstPaintAfterLayout; rtl::Reference<AccessibleSmElementsControl> m_xAccessible; - void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText); + void addElement(SmParser &rParser, const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText); void addElements(const SmElementDescr aElementsArray[], sal_uInt16 size); SmElement* current() const; void setCurrentElement(sal_uInt16); diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 45bfb7541099..7491e71823b1 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -863,10 +863,11 @@ void SmElementsControl::DoScroll(long nDelta) Invalidate(); } -void SmElementsControl::addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText) +void SmElementsControl::addElement(SmParser &rParser, const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText) { - assert(maElementList.size() <= SAL_MAX_UINT16); - auto pNode = SmParser().ParseExpression(aElementVisual); + // SAL_MAX_UINT16 is invalid, zero is the scrollbar + assert(maElementList.size() < SAL_MAX_UINT16 - 2); + auto pNode = rParser.ParseExpression(aElementVisual); pNode->Prepare(maFormat, *mpDocShell, 0); pNode->SetSize(Fraction(10,8)); @@ -895,6 +896,9 @@ void SmElementsControl::setElementSetId(const char* pSetId) void SmElementsControl::addElements(const SmElementDescr aElementsArray[], sal_uInt16 aElementsArraySize) { + SmParser aParser; + aParser.SetImportSymbolNames(true); + for (sal_uInt16 i = 0; i < aElementsArraySize ; i++) { const char* pElement = aElementsArray[i].first; @@ -904,86 +908,86 @@ void SmElementsControl::addElements(const SmElementDescr aElementsArray[], sal_u } else { OUString aElement(OUString::createFromAscii(pElement)); if (aElement == RID_NEWLINE) - addElement(OUString(u"\u21B5"), aElement, SmResId(pElementHelp)); + addElement(aParser, OUString(u"\u21B5"), aElement, SmResId(pElementHelp)); else if (aElement == RID_SBLANK) - addElement("\"`\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"`\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_BLANK) - addElement("\"~\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"~\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_PHANTOMX) - addElement("\"" + SmResId(STR_HIDE) +"\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_HIDE) +"\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_BOLDX) - addElement("bold B", aElement, SmResId(pElementHelp)); + addElement(aParser, "bold B", aElement, SmResId(pElementHelp)); else if (aElement == RID_ITALX) - addElement("ital I", aElement, SmResId(pElementHelp)); + addElement(aParser, "ital I", aElement, SmResId(pElementHelp)); else if (aElement == RID_SIZEXY) - addElement("\"" + SmResId(STR_SIZE) + "\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_SIZE) + "\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_FONTXY) - addElement("\"" + SmResId(STR_FONT) + "\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_FONT) + "\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_BLACK) - addElement("color black { \"" + SmResId(STR_BLACK) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color black { \"" + SmResId(STR_BLACK) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_BLUE) - addElement("color blue { \"" + SmResId(STR_BLUE) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color blue { \"" + SmResId(STR_BLUE) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_GREEN) - addElement("color green { \"" + SmResId(STR_GREEN) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color green { \"" + SmResId(STR_GREEN) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_RED) - addElement("color red { \"" + SmResId(STR_RED) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color red { \"" + SmResId(STR_RED) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_CYAN) - addElement("color cyan { \"" + SmResId(STR_CYAN) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color cyan { \"" + SmResId(STR_CYAN) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_MAGENTA) - addElement("color magenta { \"" + SmResId(STR_MAGENTA) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color magenta { \"" + SmResId(STR_MAGENTA) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_YELLOW) - addElement("color yellow { \"" + SmResId(STR_YELLOW) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color yellow { \"" + SmResId(STR_YELLOW) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_GRAY) - addElement("color gray { \"" + SmResId(STR_GRAY) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color gray { \"" + SmResId(STR_GRAY) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_LIME) - addElement("color lime { \"" + SmResId(STR_LIME) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color lime { \"" + SmResId(STR_LIME) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_MAROON) - addElement("color maroon { \"" + SmResId(STR_MAROON) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color maroon { \"" + SmResId(STR_MAROON) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_NAVY) - addElement("color navy { \"" + SmResId(STR_NAVY) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color navy { \"" + SmResId(STR_NAVY) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_OLIVE) - addElement("color olive { \"" + SmResId(STR_OLIVE) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color olive { \"" + SmResId(STR_OLIVE) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_PURPLE) - addElement("color purple { \"" + SmResId(STR_PURPLE) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color purple { \"" + SmResId(STR_PURPLE) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_SILVER) - addElement("color silver { \"" + SmResId(STR_SILVER) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color silver { \"" + SmResId(STR_SILVER) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_COLORX_TEAL) - addElement("color teal { \"" + SmResId(STR_TEAL) + "\" }", aElement, SmResId(pElementHelp)); + addElement(aParser, "color teal { \"" + SmResId(STR_TEAL) + "\" }", aElement, SmResId(pElementHelp)); else if (aElement == RID_ALIGNLX) - addElement("\"" + SmResId(STR_ALIGN_LEFT) + "\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_ALIGN_LEFT) + "\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_ALIGNCX) - addElement("\"" + SmResId(STR_ALIGN_CENTER) + "\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_ALIGN_CENTER) + "\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_ALIGNRX) - addElement("\"" + SmResId(STR_ALIGN_RIGHT) + "\"", aElement, SmResId(pElementHelp)); + addElement(aParser, "\"" + SmResId(STR_ALIGN_RIGHT) + "\"", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRPARENTX) - addElement("left ( binom{<?>}{<?>} right ) ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left ( binom{<?>}{<?>} right ) ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRBRACKETX) - addElement("left [ binom{<?>}{<?>} right ] ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left [ binom{<?>}{<?>} right ] ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRDBRACKETX) - addElement("left ldbracket binom{<?>}{<?>} right rdbracket ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left ldbracket binom{<?>}{<?>} right rdbracket ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRBRACEX) - addElement("left lbrace binom{<?>}{<?>} right rbrace ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left lbrace binom{<?>}{<?>} right rbrace ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRANGLEX) - addElement("left langle binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left langle binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRCEILX) - addElement("left lceil binom{<?>}{<?>} right rceil ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left lceil binom{<?>}{<?>} right rceil ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRFLOORX) - addElement("left lfloor binom{<?>}{<?>} right rfloor ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left lfloor binom{<?>}{<?>} right rfloor ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRLINEX) - addElement("left lline binom{<?>}{<?>} right rline ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left lline binom{<?>}{<?>} right rline ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLRDLINEX) - addElement("left ldline binom{<?>}{<?>} right rdline ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left ldline binom{<?>}{<?>} right rdline ", aElement, SmResId(pElementHelp)); else if (aElement == RID_SLMRANGLEXY) - addElement("left langle binom{<?>}{<?>} mline binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); + addElement(aParser, "left langle binom{<?>}{<?>} mline binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); else if (aElement == RID_XOVERBRACEY) - addElement("{<?><?><?>} overbrace {<?>} ", aElement, SmResId(pElementHelp)); + addElement(aParser, "{<?><?><?>} overbrace {<?>} ", aElement, SmResId(pElementHelp)); else if (aElement == RID_XUNDERBRACEY) - addElement("{<?><?><?>} underbrace {<?>} ", aElement, SmResId(pElementHelp)); + addElement(aParser, "{<?><?><?>} underbrace {<?>} ", aElement, SmResId(pElementHelp)); else - addElement(aElement, aElement, pElementHelp ? SmResId(pElementHelp) : ""); + addElement(aParser, aElement, aElement, pElementHelp ? SmResId(pElementHelp) : ""); } } } |