[Libreoffice-commits] core.git: starmath/inc starmath/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Feb 13 18:48:58 UTC 2021


 starmath/inc/mathml/starmathdatabase.hxx    |   10 ++---
 starmath/source/mathml/mathmlexport.cxx     |    2 -
 starmath/source/mathml/mathmlimport.cxx     |    8 ++--
 starmath/source/mathml/starmathdatabase.cxx |   56 +++++++++++-----------------
 starmath/source/visitors.cxx                |    4 +-
 5 files changed, 34 insertions(+), 46 deletions(-)

New commits:
commit 71fa2bc2061168b9a74cdb4b0428b00ea902666f
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Feb 13 19:00:00 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Feb 13 19:48:22 2021 +0100

    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 at collabora.co.uk>

diff --git a/starmath/inc/mathml/starmathdatabase.hxx b/starmath/inc/mathml/starmathdatabase.hxx
index b40a932809a4..cf8cf8b3b9d1 100644
--- a/starmath/inc/mathml/starmathdatabase.hxx
+++ b/starmath/inc/mathml/starmathdatabase.hxx
@@ -263,7 +263,7 @@ SmToken Identify_Postfix_SmXMLOperatorContext_Impl(sal_Unicode cChar);
   * @param cColor
   * @param parser color
   */
-std::unique_ptr<SmColorTokenTableEntry> Identify_Color_Parser(sal_uInt32 cColor);
+SmColorTokenTableEntry Identify_Color_Parser(sal_uInt32 cColor);
 
 /**
   * Identifies color from color code cColor.
@@ -271,7 +271,7 @@ std::unique_ptr<SmColorTokenTableEntry> Identify_Color_Parser(sal_uInt32 cColor)
   * @param cColor
   * @param parser color
   */
-std::unique_ptr<SmColorTokenTableEntry> Identify_Color_HTML(sal_uInt32 cColor);
+SmColorTokenTableEntry Identify_Color_HTML(sal_uInt32 cColor);
 
 /**
   * Identifies color from color code cColor.
@@ -283,7 +283,7 @@ std::unique_ptr<SmColorTokenTableEntry> Identify_Color_HTML(sal_uInt32 cColor);
   * @param cColor
   * @param parser color
   */
-std::unique_ptr<SmColorTokenTableEntry> Identify_Color_MATHML(sal_uInt32 cColor);
+SmColorTokenTableEntry Identify_Color_MATHML(sal_uInt32 cColor);
 
 /**
   * Identifies color from color code cColor.
@@ -291,7 +291,7 @@ std::unique_ptr<SmColorTokenTableEntry> Identify_Color_MATHML(sal_uInt32 cColor)
   * @param cColor
   * @param parser color
   */
-std::unique_ptr<SmColorTokenTableEntry> Identify_Color_DVIPSNAMES(sal_uInt32 cColor);
+SmColorTokenTableEntry Identify_Color_DVIPSNAMES(sal_uInt32 cColor);
 
 /**
   * Identifies color from color name.
@@ -315,7 +315,7 @@ const SmColorTokenTableEntry* Identify_ColorName_Parser(const OUString& colornam
   * @param cColor
   * @param parser color
   */
-std::unique_ptr<SmColorTokenTableEntry> Identify_ColorName_HTML(const OUString& colorname);
+SmColorTokenTableEntry Identify_ColorName_HTML(const OUString& colorname);
 
 /**
   * Identifies color from color name.
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);


More information about the Libreoffice-commits mailing list