/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * 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/. */ #include "mathmlattr.hxx" #include static sal_Int32 ParseMathMLUnsignedNumber(const OUString &rStr, Fraction& rUN) { auto nLen = rStr.getLength(); sal_Int32 nDecimalPoint = -1; sal_Int32 nIdx; for (nIdx = 0; nIdx < nLen; nIdx++) { auto cD = rStr[nIdx]; if (cD == u'.') { if (nDecimalPoint >= 0) return -1; nDecimalPoint = nIdx; continue; } if (cD < u'0' || u'9' < cD) break; } if (nIdx == 0 || (nIdx == 1 && nDecimalPoint == 0)) return -1; rUN = Fraction(rStr.copy(0, nIdx).toDouble()); return nIdx; } static sal_Int32 ParseMathMLNumber(const OUString &rStr, Fraction& rN) { if (rStr.isEmpty()) return -1; bool bNegative = (rStr[0] == '-'); sal_Int32 nOffset = bNegative ? 1 : 0; auto nIdx = ParseMathMLUnsignedNumber(rStr.copy(nOffset), rN); if (nIdx <= 0 || !rN.IsValid()) return -1; if (bNegative) rN *= -1; return nOffset + nIdx; } sal_Int32 ParseMathMLAttributeLengthValue(const OUString &rStr, MathMLAttributeLengthValue& rV) { auto nIdx = ParseMathMLNumber(rStr, rV.aNumber); if (nIdx <= 0) return -1; OUString sRest = rStr.copy(nIdx); if (sRest.isEmpty()) { rV.eUnit = MathMLLengthUnit::None; return nIdx; } if (sRest.startsWith("em")) { rV.eUnit = MathMLLengthUnit::Em; return nIdx + 2; } if (sRest.startsWith("ex")) { rV.eUnit = MathMLLengthUnit::Ex; return nIdx + 2; } if (sRest.startsWith("px")) { rV.eUnit = MathMLLengthUnit::Px; return nIdx + 2; } if (sRest.startsWith("in")) { rV.eUnit = MathMLLengthUnit::In; return nIdx + 2; } if (sRest.startsWith("cm")) { rV.eUnit = MathMLLengthUnit::Cm; return nIdx + 2; } if (sRest.startsWith("mm")) { rV.eUnit = MathMLLengthUnit::Mm; return nIdx + 2; } if (sRest.startsWith("pt")) { rV.eUnit = MathMLLengthUnit::Pt; return nIdx + 2; } if (sRest.startsWith("pc")) { rV.eUnit = MathMLLengthUnit::Pc; return nIdx + 2; } if (sRest[0] == u'%') { rV.eUnit = MathMLLengthUnit::Percent; return nIdx + 2; } return nIdx; } bool GetMathMLMathvariantValue(const OUString &rStr, MathMLMathvariantValue& rV) { 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} }; auto it = aMap.find(rStr); if (it != aMap.end()) { rV = it->second; return true; } return false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ ro/collabora/cp-6.0-29 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2019-08-27loplugin:constmethod in sfx2Noel Grandin
2019-06-16Reload Notebookbar, when customization is being done.Sumit Chauhan
2019-03-29tdf#42949 Fix IWYU warnings in include/sfx2/[n-r]*Gabor Kelemen
2019-01-23loplugin:constparams in sfx2Noel Grandin
2018-12-31Provide keyboard navigation to Shortcuts tool box and Hamburger menu inJim Raykowski
2018-10-29tdf#120874 Don't show menubar in other windows when one is closedSamuel Mehrbrodt
2018-02-22Move include/sfx2/notebookbar/NotebookbarContextControl.hxx to include/vcl/Stephan Bergmann
2017-10-24loplugin:finalclasses in sfx2..svlNoel Grandin
2017-07-21loplugin:constparams in sfx2Noel Grandin
2017-06-26ChangedUIEventListener is refcounted, mustn't be helt by unique_ptrStephan Bergmann
2017-06-21loplugin:unusedfields in sfx2 part1Noel Grandin
2017-06-12cleanup unused css/frame/* includesJochen Nitschke
2017-04-22Notebookbar: better tab placing for the NotebookbarTabControlSzymon Kłos
2017-03-16tdf#103355 Working menu after closing slideshowSzymon Kłos
2017-03-15tdf#105040 Notebookbar: added shortcuts toolboxSzymon Kłos
2017-02-19tdf#103355 Hide Notebookbar during slide showSzymon Kłos
2016-10-05Remove _TYPED suffix from tools/link.hxx macrosStephan Bergmann
2016-09-26tdf#102063 Notebookbar wont appear on launchSzymon Kłos
2016-08-25GSoC notebookbar: hiding menubarSzymon Kłos
2016-08-25GSoC notebookbar: container with context supportSzymon Kłos
2016-08-22GSoC: tdf#101249 Toolbar Mode switchingSzymon Kłos
2016-08-16GSoC notebookbar: multiple .ui implementationsSzymon Kłos
2016-07-22GSoC notebookbar: file menuSzymon Kłos
2016-07-07loplugin:passstuffbyref also for {css::uno,rtl}::ReferenceStephan Bergmann
2016-06-28notebookbar: added slide transition tabSzymon Kłos
2016-06-27GSoC notebookbar: switching tabs depending on contextSzymon Kłos
2016-06-03notebookbar: load ui for the start centerSzymon Kłos
2016-03-30notebookbar: Trying to use the SfxChildWindow for it does not work too well.Jan Holesovsky
2016-03-30notebookbar: Instantiate the notebookbar via sfx2 infrastructure.Szymon Kłos