[Libreoffice-commits] core.git: vcl/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 18 20:17:43 UTC 2021


 vcl/source/pdf/XmpMetadata.cxx |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 90f872b4c9eac6ea1955876ff292a962f95577dd
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 18 15:18:26 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Jun 18 22:17:06 2021 +0200

    Simplify a std::string_view construction
    
    ...and combine three calls to SvStream::WriteOString into one.
    
    Despite its name, SvStream::WriteOString takes a std::string_view, but which
    cannot be constructed from a u8"..." char8_t string literal.  Besides the
    OStringLiteral detour, other fixes could have been a
    reinterpret_cast<char const *> (but which would have defeated constexpr'ness of
    the std::string_view construction) or a plain "..." char string literal with
    the UTF-8 encoding of \uFEFF spelled out as \0xEF\xBB\xBF.
    
    Change-Id: I029f061134381a67516cbc4b0479942684c80c20
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117461
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx
index e1a6ecf02ce5..156e849f4097 100644
--- a/vcl/source/pdf/XmpMetadata.cxx
+++ b/vcl/source/pdf/XmpMetadata.cxx
@@ -35,9 +35,8 @@ void XmpMetadata::write()
     mpMemoryStream = std::make_unique<SvMemoryStream>(4096 /*Initial*/, 64 /*Resize*/);
 
     // Header
-    mpMemoryStream->WriteOString("<?xpacket begin=\"");
-    mpMemoryStream->WriteOString(OUStringToOString(u"\xFEFF", RTL_TEXTENCODING_UTF8));
-    mpMemoryStream->WriteOString("\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n");
+    mpMemoryStream->WriteOString(
+        OStringLiteral(u8"<?xpacket begin=\"\uFEFF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n"));
 
     {
         tools::XmlWriter aXmlWriter(mpMemoryStream.get());


More information about the Libreoffice-commits mailing list