comphelper/source/xml/xmltools.cxx | 14 ++++++++++++++ include/comphelper/xmltools.hxx | 2 ++ include/oox/export/drawingml.hxx | 2 -- oox/source/export/drawingml.cxx | 19 ++----------------- oox/source/ole/vbaexport.cxx | 28 +++------------------------- 5 files changed, 21 insertions(+), 44 deletions(-)
New commits: commit c85d8064cb67552e3ddcc73099769af09d7d0edd Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Date: Mon Dec 11 14:38:54 2017 +0100 Move generateGUIDString to comphelper and remove duplicate method Change-Id: Ic513a780f3b9b526c3abd0f273ad9c230ffbb373 Reviewed-on: https://gerrit.libreoffice.org/46233 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/comphelper/source/xml/xmltools.cxx b/comphelper/source/xml/xmltools.cxx index b1fcc6a5b59a..ace7d2661e3b 100644 --- a/comphelper/source/xml/xmltools.cxx +++ b/comphelper/source/xml/xmltools.cxx @@ -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: */ diff --git a/include/comphelper/xmltools.hxx b/include/comphelper/xmltools.hxx index 5f5bec9b94ad..85915ec47f9a 100644 --- a/include/comphelper/xmltools.hxx +++ b/include/comphelper/xmltools.hxx @@ -20,6 +20,8 @@ namespace comphelper namespace xml { COMPHELPER_DLLPUBLIC OString makeXMLChaff(); + COMPHELPER_DLLPUBLIC OString generateGUIDString(); + } } diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 276e18d0bcc2..69d1d6657fad 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -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 ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index eb19a286e587..f500036e1282 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -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(), diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx index cd26bf486615..4aeff993b926 100644 --- a/oox/source/ole/vbaexport.cxx +++ b/oox/source/ole/vbaexport.cxx @@ -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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits