Move generateGUIDString to comphelper

and remove duplicate method

Change-Id: Ic513a780f3b9b526c3abd0f273ad9c230ffbb373
Reviewed-on: https://gerrit.libreoffice.org/46233
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
Samuel Mehrbrodt
2017-12-11 14:38:54 +01:00
parent ac3d194db5
commit c85d8064cb
5 changed files with 21 additions and 44 deletions

View File

@@ -9,6 +9,7 @@
#include <comphelper/xmltools.hxx>
#include <rtl/random.h>
#include <rtl/uuid.h>
#include <vector>
using namespace com::sun::star;
@@ -91,6 +92,19 @@ namespace comphelper
return OString(reinterpret_cast<const sal_Char*>(&aChaff[0]), nLength);
}
OString generateGUIDString()
{
sal_uInt8 aSeq[16];
rtl_createUuid(aSeq, nullptr, true);
char str[39];
sprintf(str, "{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
aSeq[0], aSeq[1], aSeq[2], aSeq[3], aSeq[4], aSeq[5], aSeq[6], aSeq[7], aSeq[8],
aSeq[9], aSeq[10], aSeq[11], aSeq[12], aSeq[13], aSeq[14], aSeq[15]);
return OString(str, SAL_N_ELEMENTS(str));
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -20,6 +20,8 @@ namespace comphelper
namespace xml
{
COMPHELPER_DLLPUBLIC OString makeXMLChaff();
COMPHELPER_DLLPUBLIC OString generateGUIDString();
}
}

View File

@@ -230,8 +230,6 @@ public:
static void ResetCounters();
static OString GetUUID();
static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, css::awt::FontDescriptor& rFontDesc );
static sal_uInt32 ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );

View File

@@ -76,6 +76,7 @@
#include <com/sun/star/style/CaseMap.hpp>
#include <comphelper/storagehelper.hxx>
#include <comphelper/xmltools.hxx>
#include <o3tl/any.hxx>
#include <tools/stream.hxx>
#include <unotools/fontdefs.hxx>
@@ -1757,22 +1758,6 @@ OUString DrawingML::GetFieldValue( const css::uno::Reference< css::text::XTextRa
return aFieldValue;
}
OString DrawingML::GetUUID()
{
sal_uInt8 aSeq[16];
rtl_createUuid(aSeq, nullptr, true);
char str[39];
sprintf(str, "{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
aSeq[0], aSeq[1], aSeq[2], aSeq[3],
aSeq[4], aSeq[5],
aSeq[6], aSeq[7],
aSeq[8], aSeq[9],
aSeq[10], aSeq[11], aSeq[12], aSeq[13], aSeq[14], aSeq[15]);
return OString(str, SAL_N_ELEMENTS(str));
}
void DrawingML::WriteRun( const Reference< XTextRange >& rRun,
bool& rbOverridingCharHeight, sal_Int32& rnCharHeight)
{
@@ -1822,7 +1807,7 @@ void DrawingML::WriteRun( const Reference< XTextRange >& rRun,
{
if( bWriteField )
{
OString sUUID(GetUUID());
OString sUUID(comphelper::xml::generateGUIDString());
mpFS->startElementNS( XML_a, XML_fld,
XML_id, sUUID.getStr(),
XML_type, OUStringToOString( sFieldValue, RTL_TEXTENCODING_UTF8 ).getStr(),

View File

@@ -31,9 +31,8 @@
#include <sot/storage.hxx>
#include <rtl/uuid.h>
#include <comphelper/string.hxx>
#include <comphelper/xmltools.hxx>
#define USE_UTF8_CODEPAGE 0
#if USE_UTF8_CODEPAGE
@@ -88,28 +87,6 @@ OUString createHexStringFromDigit(sal_uInt8 nDigit)
return aString.toAsciiUpperCase();
}
OUString createGuidStringFromInt(sal_uInt8 const nGuid[16])
{
OUStringBuffer aBuffer;
aBuffer.append('{');
for(size_t i = 0; i < 16; ++i)
{
aBuffer.append(createHexStringFromDigit(nGuid[i]));
if(i == 3|| i == 5 || i == 7 || i == 9 )
aBuffer.append('-');
}
aBuffer.append('}');
OUString aString = aBuffer.makeStringAndClear();
return aString.toAsciiUpperCase();
}
OUString generateGUIDString()
{
sal_uInt8 nGuid[16];
rtl_createUuid(nGuid, nullptr, true);
return createGuidStringFromInt(nGuid);
}
}
VBACompressionChunk::VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, std::size_t nChunkSize)
@@ -877,7 +854,8 @@ void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::contain
// section 2.3.1.2 ProjectId
exportString(rStrm, "ID=\"");
OUString aProjectID = generateGUIDString();
OUString aProjectID
= OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_UTF8);
exportString(rStrm, aProjectID);
exportString(rStrm, "\"\r\n");