diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-09-07 22:19:55 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-09-08 08:15:47 +0200 |
commit | 18fb42136ffccaf9057db62b2eb7aa48bd4cfdd3 (patch) | |
tree | 01750612d1a62771e8304c3cdc4499f9f6ff28eb /vcl | |
parent | 9db379b0b7dded5e9a4523ce48dac928979aab70 (diff) |
Simplify PDFWriterImpl::appendLiteralStringEncrypt, taking std::string_view
Change-Id: If2a0a9abbc8951ce64b89659f455edd280893860
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102205
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 17 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 4 |
2 files changed, 8 insertions, 13 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4d2e94540614..e955bb9b7842 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -23,6 +23,7 @@ #include <math.h> #include <algorithm> +#include <string_view> #include <lcms2.h> @@ -1521,30 +1522,24 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt rOutBuffer.append( ">" ); } -inline void PDFWriterImpl::appendLiteralStringEncrypt( OStringBuffer const & rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ) +inline void PDFWriterImpl::appendLiteralStringEncrypt( std::string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ) { rOutBuffer.append( "(" ); - sal_Int32 nChars = rInString.getLength(); + sal_Int32 nChars = rInString.size(); //check for encryption, if ok, encrypt the string, then convert with appndLiteralString if( m_aContext.Encryption.Encrypt() ) { m_vEncryptionBuffer.resize(nChars); //encrypt the string in a buffer, then append it enableStringEncryption( nInObjectNumber ); - rtl_cipher_encodeARCFOUR( m_aCipher, rInString.getStr(), nChars, m_vEncryptionBuffer.data(), nChars ); + rtl_cipher_encodeARCFOUR( m_aCipher, rInString.data(), nChars, m_vEncryptionBuffer.data(), nChars ); appendLiteralString( reinterpret_cast<char*>(m_vEncryptionBuffer.data()), nChars, rOutBuffer ); } else - appendLiteralString( rInString.getStr(), nChars , rOutBuffer ); + appendLiteralString( rInString.data(), nChars , rOutBuffer ); rOutBuffer.append( ")" ); } -inline void PDFWriterImpl::appendLiteralStringEncrypt( const OString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ) -{ - OStringBuffer aBufferString( rInString ); - appendLiteralStringEncrypt( aBufferString, nInObjectNumber, rOutBuffer); -} - void PDFWriterImpl::appendLiteralStringEncrypt( const OUString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer, rtl_TextEncoding nEnc ) { OString aBufferString( OUStringToOString( rInString, nEnc ) ); @@ -5188,7 +5183,7 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() aLine.append( " 0 obj\n" "<</Type/OutputIntent/S/GTS_PDFA1/OutputConditionIdentifier"); - appendLiteralStringEncrypt( OUStringLiteral(u"sRGB IEC61966-2.1") ,nOIObject, aLine ); + appendLiteralStringEncrypt( std::string_view("sRGB IEC61966-2.1") ,nOIObject, aLine ); aLine.append("/DestOutputProfile "); aLine.append( nICCObject ); aLine.append( " 0 R>>\nendobj\n\n" ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index b5d86a2d2486..e4ef7177b9c3 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -23,6 +23,7 @@ #include <list> #include <unordered_map> #include <memory> +#include <string_view> #include <vector> #include <pdf/ResourceDict.hxx> @@ -795,8 +796,7 @@ i12626 void appendUnicodeTextStringEncrypt( const OUString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ); void appendLiteralStringEncrypt( const OUString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer, rtl_TextEncoding nEnc = RTL_TEXTENCODING_ASCII_US ); - void appendLiteralStringEncrypt( const OString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ); - void appendLiteralStringEncrypt( OStringBuffer const & rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ); + void appendLiteralStringEncrypt( std::string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer ); /* creates fonts and subsets that will be emitted later */ void registerGlyph(const GlyphItem* pGlyph, const PhysicalFontFace* pFont, const std::vector<sal_Ucs>& rCodeUnits, sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject); |