diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-02-13 19:00:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-13 19:48:22 +0100 |
commit | 71fa2bc2061168b9a74cdb4b0428b00ea902666f (patch) | |
tree | 79a33be2bd71f2c9eef73947db8f861ef33d13f5 /starmath/source | |
parent | 02e4f6c44295004f5c7201a7aa2744fd0518ba9d (diff) |
no need to allocate these return values on the heap
Change-Id: I4fd440c79c388527183a84676b2f32930f3bf8ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110845
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/mathml/mathmlexport.cxx | 2 | ||||
-rw-r--r-- | starmath/source/mathml/mathmlimport.cxx | 8 | ||||
-rw-r--r-- | starmath/source/mathml/starmathdatabase.cxx | 56 | ||||
-rw-r--r-- | starmath/source/visitors.cxx | 4 |
4 files changed, 29 insertions, 41 deletions
diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 56eb78cacab5..c70ef936ea9f 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -1148,7 +1148,7 @@ void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel) { nc = pNode->GetToken().aText.toUInt32(16); OUString sssStr - = OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML(nc)->pIdent); + = OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML(nc).pIdent); AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, sssStr); } break; diff --git a/starmath/source/mathml/mathmlimport.cxx b/starmath/source/mathml/mathmlimport.cxx index 3c2f0e5aa2bf..9c455d5be86d 100644 --- a/starmath/source/mathml/mathmlimport.cxx +++ b/starmath/source/mathml/mathmlimport.cxx @@ -678,12 +678,12 @@ void SmXMLContext_Helper::ApplyAttrs() } if (!sColor.isEmpty()) { - std::unique_ptr<SmColorTokenTableEntry> aSmColorTokenTableEntry; + SmColorTokenTableEntry aSmColorTokenTableEntry; aSmColorTokenTableEntry = starmathdatabase::Identify_ColorName_HTML(sColor); - if (aSmColorTokenTableEntry->eType == TRGB) + if (aSmColorTokenTableEntry.eType == TRGB) aSmColorTokenTableEntry = starmathdatabase::Identify_Color_Parser( - sal_uInt32(aSmColorTokenTableEntry->cColor)); - if (aSmColorTokenTableEntry->eType != TERROR) + sal_uInt32(aSmColorTokenTableEntry.cColor)); + if (aSmColorTokenTableEntry.eType != TERROR) { aToken = aSmColorTokenTableEntry; std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); diff --git a/starmath/source/mathml/starmathdatabase.cxx b/starmath/source/mathml/starmathdatabase.cxx index f358a37be72c..d2c54931ffff 100644 --- a/starmath/source/mathml/starmathdatabase.cxx +++ b/starmath/source/mathml/starmathdatabase.cxx @@ -695,60 +695,51 @@ const SmColorTokenTableEntry starmathdatabase::aColorTokenTableMATHML[] = { const SmColorTokenTableEntry starmathdatabase::aColorTokenTableERROR[] = { { "", TERROR, COL_SM_BLACK } }; -std::unique_ptr<SmColorTokenTableEntry> starmathdatabase::Identify_Color_Parser(sal_uInt32 cColor) +SmColorTokenTableEntry starmathdatabase::Identify_Color_Parser(sal_uInt32 cColor) { for (auto i = std::begin(aColorTokenTableParse); i < std::end(aColorTokenTableParse); ++i) if (i->equals(cColor)) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; for (auto i = std::begin(aColorTokenTableDVIPS); i < std::end(aColorTokenTableDVIPS); ++i) if (i->equals(cColor)) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; if ((cColor & 0x00FFFFFF) == cColor) - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGB, cColor)); + return SmColorTokenTableEntry("", TRGB, cColor); else - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGBA, cColor)); + return SmColorTokenTableEntry("", TRGBA, cColor); } -std::unique_ptr<SmColorTokenTableEntry> starmathdatabase::Identify_Color_HTML(sal_uInt32 cColor) +SmColorTokenTableEntry starmathdatabase::Identify_Color_HTML(sal_uInt32 cColor) { for (auto i = std::begin(aColorTokenTableHTML); i < std::end(aColorTokenTableHTML); ++i) if (i->equals(cColor)) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; if ((cColor & 0x00FFFFFF) == cColor) - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGB, cColor)); + return SmColorTokenTableEntry("", TRGB, cColor); else - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGBA, cColor)); + return SmColorTokenTableEntry("", TRGBA, cColor); } -std::unique_ptr<SmColorTokenTableEntry> starmathdatabase::Identify_Color_MATHML(sal_uInt32 cColor) +SmColorTokenTableEntry starmathdatabase::Identify_Color_MATHML(sal_uInt32 cColor) { for (auto i = std::begin(aColorTokenTableMATHML); i < std::end(aColorTokenTableMATHML); ++i) if (i->equals(cColor)) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; if ((cColor & 0x00FFFFFF) == cColor) - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGB, cColor)); + return SmColorTokenTableEntry("", TRGB, cColor); else - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGBA, cColor)); + return SmColorTokenTableEntry("", TRGBA, cColor); } -std::unique_ptr<SmColorTokenTableEntry> -starmathdatabase::Identify_Color_DVIPSNAMES(sal_uInt32 cColor) +SmColorTokenTableEntry starmathdatabase::Identify_Color_DVIPSNAMES(sal_uInt32 cColor) { for (auto i = std::begin(aColorTokenTableDVIPS); i < std::end(aColorTokenTableDVIPS); ++i) if (i->equals(cColor)) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; if ((cColor & 0x00FFFFFF) == cColor) - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGB, cColor)); + return SmColorTokenTableEntry("", TRGB, cColor); else - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TRGBA, cColor)); + return SmColorTokenTableEntry("", TRGBA, cColor); } const SmColorTokenTableEntry* starmathdatabase::Identify_ColorName_Parser(const OUString& colorname) @@ -765,27 +756,24 @@ const SmColorTokenTableEntry* starmathdatabase::Identify_ColorName_Parser(const } return &aColorTokenTableERROR[0]; } -std::unique_ptr<SmColorTokenTableEntry> -starmathdatabase::Identify_ColorName_HTML(const OUString& colorname) +SmColorTokenTableEntry starmathdatabase::Identify_ColorName_HTML(const OUString& colorname) { if (colorname.isEmpty()) - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TERROR, COL_SM_BLACK)); + return SmColorTokenTableEntry("", TERROR, COL_SM_BLACK); if (colorname[0] == '#') { Color col = Color::STRtoRGB(colorname); - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry("", TRGB, col)); + return SmColorTokenTableEntry("", TRGB, col); } for (auto i = std::begin(aColorTokenTableHTML); i < std::end(aColorTokenTableHTML); ++i) { sal_Int32 matches = colorname.compareToIgnoreAsciiCaseAscii(i->pIdent); if (matches == 0) - return std::unique_ptr<SmColorTokenTableEntry>(new SmColorTokenTableEntry(i)); + return i; if (matches < 0) break; } - return std::unique_ptr<SmColorTokenTableEntry>( - new SmColorTokenTableEntry("", TERROR, COL_SM_BLACK)); + return SmColorTokenTableEntry("", TERROR, COL_SM_BLACK); } const SmColorTokenTableEntry* starmathdatabase::Identify_ColorName_DVIPSNAMES(const OUString& colorname) diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index c2926f32e062..e1e79c324198 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -2137,14 +2137,14 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode ) case TDVIPSNAMESCOL: Append(u"color dvip "); nc = pNode->GetToken().aText.toUInt32(16); - Append( starmathdatabase::Identify_Color_Parser( nc )->pIdent ); + Append( starmathdatabase::Identify_Color_Parser( nc ).pIdent ); break; case THTMLCOL: case TMATHMLCOL: case TICONICCOL: Append(u"color "); nc = pNode->GetToken().aText.toUInt32(16); - Append( starmathdatabase::Identify_Color_Parser( nc )->pIdent ); + Append( starmathdatabase::Identify_Color_Parser( nc ).pIdent ); break; case TRGB: nc = pNode->GetToken().aText.toUInt32(16); |