summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-03-04 11:23:07 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-03-04 12:03:15 +0100
commita400cdb4555d32e9648dae32c01296a075843bd1 (patch)
treef5f2f1b497720cf7ba23d5d78f1fc36c443cbdcf /hwpfilter
parentae6591d8dc2c1a705a1cc4cb102ff1d8cbe9d311 (diff)
Change hcolor2str to return OUString
Change-Id: I9d2a34a2cc20df20453aa048c32f619a8e17ae72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130956 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/hcode.cxx7
-rw-r--r--hwpfilter/source/hcode.h2
-rw-r--r--hwpfilter/source/hwpreader.cxx19
3 files changed, 14 insertions, 14 deletions
diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index c8cc6c13b15e..3e9b08086f23 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1237,7 +1237,7 @@ hchar_string kstr2hstr(uchar const* src)
/* Convert a combination of a color index value and a shade value to the color value of LibreOffice */
-char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar)
+OUString hcolor2str(uchar color, uchar shade, bool bIsChar)
{
unsigned short red,green,blue;
@@ -1289,8 +1289,9 @@ char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar)
break;
}
- sprintf(buf,"#%02x%02x%02x", red, green, blue);
- return buf;
+ char buf[8];
+ int n = std::max(sprintf(buf, "#%02x%02x%02x", red, green, blue), 0);
+ return OUString::createFromAscii(std::string_view(buf, n));
}
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index df77061a1736..0f8362e0128a 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -64,7 +64,7 @@ DLLEXPORT ::std::string urltowin(const char *src);
/**
* color인덱스 값과 음영값을 조합하여 스타오피스의 color로 변환
*/
-DLLEXPORT char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar = false);
+DLLEXPORT OUString hcolor2str(uchar color, uchar shade, bool bIsChar = false);
DLLEXPORT OUString base64_encode_string( const uchar *buf, unsigned int len );
DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 9397b827b6c4..b51607cb3294 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -1334,10 +1334,10 @@ void HwpReader::parseCharShape(CharShape const * cshape)
}
if (cshape->color[1] != 0)
padd("fo:color", sXML_CDATA,
- ascii(hcolor2str(cshape->color[1], 100, buf, true)));
+ hcolor2str(cshape->color[1], 100, true));
if (cshape->shade != 0)
padd("style:text-background-color", sXML_CDATA,
- ascii(hcolor2str(cshape->color[0], cshape->shade, buf)));
+ hcolor2str(cshape->color[0], cshape->shade));
if (cshape->attr & 0x01)
{
padd("fo:font-style", sXML_CDATA, "italic");
@@ -1426,7 +1426,7 @@ void HwpReader::parseParaShape(ParaShape const * pshape)
if( pshape->shade > 0 )
{
padd("fo:background-color", sXML_CDATA,
- ascii(hcolor2str(0, pshape->shade, buf)));
+ hcolor2str(0, pshape->shade));
}
if( pshape->pagebreak & 0x02 || pshape->pagebreak & 0x04)
@@ -1974,8 +1974,8 @@ void HwpReader::makeTableStyle(Table *tbl)
}
if(cl->shade != 0)
padd("fo:background-color", sXML_CDATA,
- ascii(hcolor2str(sal::static_int_cast<uchar>(cl->color),
- sal::static_int_cast<uchar>(cl->shade), buf)));
+ hcolor2str(sal::static_int_cast<uchar>(cl->color),
+ sal::static_int_cast<uchar>(cl->shade)));
rstartEl("style:properties", mxList);
mxList->clear();
@@ -2368,9 +2368,9 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
}
}
if(cell->shade != 0)
- padd("fo:background-color", sXML_CDATA, ascii(hcolor2str(
+ padd("fo:background-color", sXML_CDATA, hcolor2str(
sal::static_int_cast<uchar>(cell->color),
- sal::static_int_cast<uchar>(cell->shade), buf)));
+ sal::static_int_cast<uchar>(cell->shade)));
}
rstartEl("style:properties", mxList);
mxList->clear();
@@ -2592,10 +2592,9 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle)
}
if(cell->shade != 0)
padd("fo:background-color", sXML_CDATA,
- ascii(hcolor2str(
+ hcolor2str(
sal::static_int_cast<uchar>(cell->color),
- sal::static_int_cast<uchar>(cell->shade),
- buf)));
+ sal::static_int_cast<uchar>(cell->shade)));
}
else if( fstyle->boxtype == 'E' )
{