vcl/source/gdi/pdfwriter_impl.cxx | 49 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-)
New commits: commit dc5fb0217f18a9003769f1e1a7e5234ef5fe60d5 Author: Michael Weghorn <[email protected]> AuthorDate: Sat Sep 27 01:09:26 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Sun Sep 28 12:15:53 2025 +0200 vcl pdfwriter: Address some (suppressed) loplugin:stringadd errors Address some of the logplugin:stringadd errors in vcl/source/gdi/pdfwriter_impl.cxx, like /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:581:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 581 | aCreationMetaDateString.append(char('0' + ((aDT.Year / 100) % 10))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:582:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 582 | aCreationMetaDateString.append(char('0' + ((aDT.Year / 10) % 10))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:583:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 583 | aCreationMetaDateString.append(char('0' + ((aDT.Year) % 10))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:584:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 584 | aCreationMetaDateString.append("-"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:585:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 585 | aCreationMetaDateString.append(char('0' + ((aDT.Month / 10) % 10))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:586:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 586 | aCreationMetaDateString.append(char('0' + ((aDT.Month) % 10))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/michi/development/git/libreoffice/vcl/source/gdi/pdfwriter_impl.cxx:587:5: error: simplify by merging with the preceding assign/append [loplugin:stringadd] 587 | aCreationMetaDateString.append("-"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Such errors are currently suppressed with a TODO to handle those, but could be seen with this temporary local change in addition, in order to temporarily enable the plugin for this file: diff --git a/compilerplugins/clang/stringadd.cxx b/compilerplugins/clang/stringadd.cxx index 60e61f04a8bb..25fc55019c10 100644 --- a/compilerplugins/clang/stringadd.cxx +++ b/compilerplugins/clang/stringadd.cxx @@ -62,9 +62,6 @@ public: // TODO the += depends on the result of the preceding assign, so can't merge if (fn == SRCDIR "/editeng/source/misc/svxacorr.cxx") return false; - // TODO this file has a boatload of buffer appends' and I don't feel like fixing them all now - if (fn == SRCDIR "/vcl/source/gdi/pdfwriter_impl.cxx") - return false; return true; } In computeDocumentIdentifier, use OStringChar, based on the suggestions in [1] and [2]. There are more of such plugin errors still left to address, so leave the exception in place for now. [1] https://gerrit.libreoffice.org/c/core/+/191122/1..10/vcl/source/gdi/pdfwriter_impl.cxx#b581 [2] https://lists.freedesktop.org/archives/libreoffice/2025-September/093812.html Change-Id: If3f99c379157a2a2a6fac07116a0362fba62d944 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191557 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index faafe3241d81..f1276245a4d6 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -577,25 +577,26 @@ void computeDocumentIdentifier(std::vector<sal_uInt8>& o_rIdentifier, // to use the localtime notation only // according to a recommendation in XMP Specification (Jan 2004, page 75) // the Acrobat way seems the right approach - aCreationMetaDateString.append(char('0' + ((aDT.Year / 1000) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Year / 100) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Year / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Year) % 10))); - aCreationMetaDateString.append("-"); - aCreationMetaDateString.append(char('0' + ((aDT.Month / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Month) % 10))); - aCreationMetaDateString.append("-"); - aCreationMetaDateString.append(char('0' + ((aDT.Day / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Day) % 10))); - aCreationMetaDateString.append("T"); - aCreationMetaDateString.append(char('0' + ((aDT.Hours / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Hours) % 10))); - aCreationMetaDateString.append(":"); - aCreationMetaDateString.append(char('0' + ((aDT.Minutes / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Minutes) % 10))); - aCreationMetaDateString.append(":"); - aCreationMetaDateString.append(char('0' + ((aDT.Seconds / 10) % 10))); - aCreationMetaDateString.append(char('0' + ((aDT.Seconds) % 10))); + aCreationMetaDateString.append( + OStringChar(char('0' + ((aDT.Year / 1000) % 10))) + + OStringChar(char('0' + ((aDT.Year / 100) % 10))) + + OStringChar(char('0' + ((aDT.Year / 10) % 10))) + + OStringChar(char('0' + ((aDT.Year) % 10))) + + OStringChar('-') + + OStringChar(char('0' + ((aDT.Month / 10) % 10))) + + OStringChar(char('0' + ((aDT.Month) % 10))) + + OStringChar('-') + + OStringChar(char('0' + ((aDT.Day / 10) % 10))) + + OStringChar(char('0' + ((aDT.Day) % 10))) + + OStringChar('T') + + OStringChar(char('0' + ((aDT.Hours / 10) % 10))) + + OStringChar(char('0' + ((aDT.Hours) % 10))) + + OStringChar(':') + + OStringChar(char('0' + ((aDT.Minutes / 10) % 10))) + + OStringChar(char('0' + ((aDT.Minutes) % 10))) + + OStringChar(':') + + OStringChar(char('0' + ((aDT.Seconds / 10) % 10))) + + OStringChar(char('0' + ((aDT.Seconds) % 10)))); sal_uInt32 nDelta = 0; if (aGMT.Seconds > aTVal.Seconds) @@ -614,11 +615,11 @@ void computeDocumentIdentifier(std::vector<sal_uInt8>& o_rIdentifier, } if (nDelta) { - aCreationMetaDateString.append(char('0' + ((nDelta / 36000) % 10))); - aCreationMetaDateString.append(char('0' + ((nDelta / 3600) % 10))); - aCreationMetaDateString.append(":"); - aCreationMetaDateString.append(char('0' + ((nDelta / 600) % 6))); - aCreationMetaDateString.append(char('0' + ((nDelta / 60) % 10))); + aCreationMetaDateString.append(OStringChar(char('0' + ((nDelta / 36000) % 10))) + + OStringChar(char('0' + ((nDelta / 3600) % 10))) + + OStringChar(':') + + OStringChar(char('0' + ((nDelta / 600) % 6))) + + OStringChar(char('0' + ((nDelta / 60) % 10)))); } aID.append(i_rCString1.getStr(), i_rCString1.getLength());
