include/tools/color.hxx | 2 +-
tools/source/generic/color.cxx | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
New commits:
commit 4149201b099487c5b46d7015b0c174dfff1841ec
Author: Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Apr 28 11:41:48 2022 +0200
Commit: Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Apr 28 16:08:03 2022 +0200
use more string_view in tools::Color
Change-Id: I0203aff3af19d3994af5325538520469ab2900ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133541
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 5fcf840edfe6..0cf6e122eb90 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -391,7 +391,7 @@ public:
* rgb
* If fails returns Color().
*/
- static Color STRtoRGB(const OUString& colorname);
+ static Color STRtoRGB(std::u16string_view colorname);
/** Color space conversion tools
* @param nHue
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 0493b5250f62..1c740f03df03 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -159,30 +159,30 @@ Color Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat,
sal_uInt16 nBri )
return Color( cR, cG, cB );
}
-Color Color::STRtoRGB(const OUString& colorname)
+Color Color::STRtoRGB(std::u16string_view colorname)
{
Color col;
- if(colorname.isEmpty()) return col;
+ if(colorname.empty()) return col;
- switch(colorname.getLength()){
+ switch(colorname.size()){
case 7:
- col.mValue = o3tl::toUInt32(colorname.subView(1,6), 16);
+ col.mValue = o3tl::toUInt32(colorname.substr(1,6), 16);
break;
case 6:
- col.mValue = colorname.toUInt32(16);
+ col.mValue = o3tl::toUInt32(colorname, 16);
break;
case 4:
{
sal_Unicode data[6] = { colorname[1], colorname[1], colorname[2],
colorname[2], colorname[3], colorname[3]
};
- col.mValue = OUString(data,6).toUInt32(16);
+ col.mValue = o3tl::toUInt32(std::u16string_view(data,6), 16);
break;
}
case 3:
{
sal_Unicode data[6] = { colorname[0], colorname[0], colorname[1],
colorname[1], colorname[2], colorname[2]
};
- col.mValue = OUString(data,6).toUInt32(16);
+ col.mValue = o3tl::toUInt32(std::u16string_view(data,6), 16);
break;
}
default: