vcl/inc/pdf/pdfcompat.hxx | 2 +- vcl/source/filter/ipdf/pdfcompat.cxx | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-)
New commits: commit 865237bc3d646500a26f6ebb0487ce06332bab87 Author: Dr. David Alan Gilbert <[email protected]> AuthorDate: Sun May 25 01:46:29 2025 +0100 Commit: David Gilbert <[email protected]> CommitDate: Fri Jun 13 22:05:09 2025 +0200 tdf#162826: vcl: ipdf: Clean up isCompatible isCompatible takes parameters for where to look and the length of the stream, but always gets called for start/end. Simplify. Change-Id: I438590d196b6c7392bebc19e7787386f43a88db5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185756 Reviewed-by: David Gilbert <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx index 610924f5e672..35634f6982a9 100644 --- a/vcl/inc/pdf/pdfcompat.hxx +++ b/vcl/inc/pdf/pdfcompat.hxx @@ -23,7 +23,7 @@ inline double pointToPixel(const double fPoint, const double fResolutionDPI) } /// Decide if PDF data is old enough to be compatible. -bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize); +bool isCompatible(SvStream& rInStream); /// Converts to highest supported format version (currently 1.6). /// Usually used to deal with missing referenced objects in the diff --git a/vcl/source/filter/ipdf/pdfcompat.cxx b/vcl/source/filter/ipdf/pdfcompat.cxx index 124aa4e9acee..50a9010a4917 100644 --- a/vcl/source/filter/ipdf/pdfcompat.cxx +++ b/vcl/source/filter/ipdf/pdfcompat.cxx @@ -18,14 +18,11 @@ namespace vcl::pdf { /// Decide if PDF data is old enough to be compatible. -bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize) +bool isCompatible(SvStream& rInStream) { - if (nSize < 8) - return false; - // %PDF-x.y sal_uInt8 aFirstBytes[8]; - rInStream.Seek(nPos); + rInStream.Seek(STREAM_SEEK_TO_BEGIN); sal_uLong nRead = rInStream.ReadBytes(aFirstBytes, 8); if (nRead < 8) return false; @@ -117,13 +114,11 @@ bool getCompatibleStream( SvStream& rInStream, SvStream& rOutStream, const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler) { - sal_uInt64 nPos = STREAM_SEEK_TO_BEGIN; - sal_uInt64 nSize = STREAM_SEEK_TO_END; - bool bCompatible = isCompatible(rInStream, nPos, nSize); - rInStream.Seek(nPos); + bool bCompatible = isCompatible(rInStream); + rInStream.Seek(STREAM_SEEK_TO_BEGIN); if (bCompatible) // Not converting. - rOutStream.WriteStream(rInStream, nSize); + rOutStream.WriteStream(rInStream, STREAM_SEEK_TO_END); else convertToHighestSupported(rInStream, rOutStream, xInteractionHandler);
