summaryrefslogtreecommitdiffstats
path: root/vcl/source/filter/ipdf/pdfread.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-21 13:23:58 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-21 14:29:14 +0100
commit17407f808ed0ca5d65a98da186f7e2ab60dc641b (patch)
treeda019d31c00f0d9c7b32933be98f6ef647111530 /vcl/source/filter/ipdf/pdfread.cxx
parentAvoid undefined floating -> integer conversion in TIFF import (diff)
downloadcore-17407f808ed0ca5d65a98da186f7e2ab60dc641b.tar.gz
core-17407f808ed0ca5d65a98da186f7e2ab60dc641b.zip
Turn on clang-format for these files
I (tried to) keep these files consistent locally with astyle in the past, switching to clang-format makes sure that the recent problem with introducing inconsistencies in these files doesn't happen again. (On the flip side, it's great to see that now others also touch this PDF/pdfium code. :-) ) Change-Id: I6065eab77c584197a82fe48e7d3e81b445106efd Reviewed-on: https://gerrit.libreoffice.org/51701 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source/filter/ipdf/pdfread.cxx')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx49
1 files changed, 22 insertions, 27 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 1c1c330045fe..572a4c2f6831 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -25,7 +25,6 @@ using namespace com::sun::star;
namespace
{
-
#if HAVE_FEATURE_PDFIUM
/// Callback class to be used with FPDF_SaveWithVersion().
@@ -33,7 +32,8 @@ struct CompatibleWriter : public FPDF_FILEWRITE
{
public:
CompatibleWriter();
- static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData, unsigned long nSize);
+ static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData,
+ unsigned long nSize);
SvMemoryStream m_aStream;
};
@@ -44,7 +44,8 @@ CompatibleWriter::CompatibleWriter()
FPDF_FILEWRITE::WriteBlock = CompatibleWriter::WriteBlockCallback;
}
-int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData, unsigned long nSize)
+int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData,
+ unsigned long nSize)
{
auto pImpl = static_cast<CompatibleWriter*>(pFileWrite);
pImpl->m_aStream.WriteBytes(pData, nSize);
@@ -52,15 +53,11 @@ int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void*
}
/// Convert to inch, then assume 96 DPI.
-double pointToPixel(double fPoint)
-{
- return fPoint / 72 * 96;
-}
+double pointToPixel(double fPoint) { return fPoint / 72 * 96; }
/// Does PDF to bitmap conversion using pdfium.
-size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
- sal_uInt64 nPos, sal_uInt64 nSize,
- const size_t nFirstPage = 0, int nPages = 1)
+size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps, sal_uInt64 nPos,
+ sal_uInt64 nSize, const size_t nFirstPage = 0, int nPages = 1)
{
FPDF_LIBRARY_CONFIG aConfig;
aConfig.version = 2;
@@ -75,7 +72,8 @@ size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
aInBuffer.WriteStream(rStream, nSize);
// Load the buffer using pdfium.
- FPDF_DOCUMENT pPdfDocument = FPDF_LoadMemDocument(aInBuffer.GetData(), aInBuffer.GetSize(), /*password=*/nullptr);
+ FPDF_DOCUMENT pPdfDocument
+ = FPDF_LoadMemDocument(aInBuffer.GetData(), aInBuffer.GetSize(), /*password=*/nullptr);
if (!pPdfDocument)
return 0;
@@ -99,7 +97,8 @@ size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
const FPDF_DWORD nColor = FPDFPage_HasTransparency(pPdfPage) ? 0x00000000 : 0xFFFFFFFF;
FPDFBitmap_FillRect(pPdfBitmap, 0, 0, nPageWidth, nPageHeight, nColor);
- FPDF_RenderPageBitmap(pPdfBitmap, pPdfPage, /*start_x=*/0, /*start_y=*/0, nPageWidth, nPageHeight, /*rotate=*/0, /*flags=*/0);
+ FPDF_RenderPageBitmap(pPdfBitmap, pPdfPage, /*start_x=*/0, /*start_y=*/0, nPageWidth,
+ nPageHeight, /*rotate=*/0, /*flags=*/0);
// Save the buffer as a bitmap.
Bitmap aBitmap(Size(nPageWidth, nPageHeight), 24);
@@ -139,7 +138,8 @@ bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize)
if (nRead < 8)
return false;
- if (aFirstBytes[0] != '%' || aFirstBytes[1] != 'P' || aFirstBytes[2] != 'D' || aFirstBytes[3] != 'F' || aFirstBytes[4] != '-')
+ if (aFirstBytes[0] != '%' || aFirstBytes[1] != 'P' || aFirstBytes[2] != 'D'
+ || aFirstBytes[3] != 'F' || aFirstBytes[4] != '-')
return false;
sal_Int32 nMajor = OString(aFirstBytes[5]).toInt32();
@@ -149,8 +149,8 @@ bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize)
/// Takes care of transparently downgrading the version of the PDF stream in
/// case it's too new for our PDF export.
-bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
- sal_uInt64 nPos, sal_uInt64 nSize)
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 nPos,
+ sal_uInt64 nSize)
{
bool bCompatible = isCompatible(rInStream, nPos, nSize);
rInStream.Seek(nPos);
@@ -172,7 +172,8 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
aInBuffer.WriteStream(rInStream, nSize);
// Load the buffer using pdfium.
- FPDF_DOCUMENT pPdfDocument = FPDF_LoadMemDocument(aInBuffer.GetData(), aInBuffer.GetSize(), /*password=*/nullptr);
+ FPDF_DOCUMENT pPdfDocument
+ = FPDF_LoadMemDocument(aInBuffer.GetData(), aInBuffer.GetSize(), /*password=*/nullptr);
if (!pPdfDocument)
return false;
@@ -191,29 +192,25 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
return rOutStream.good();
}
#else
-size_t generatePreview(SvStream&, std::vector<Bitmap>&,
- sal_uInt64 nPos, sal_uInt64 nSize,
- size_t nFirstPage = 0, int nLastPage = 0)
+size_t generatePreview(SvStream&, std::vector<Bitmap>&, sal_uInt64 nPos, sal_uInt64 nSize,
+ size_t nFirstPage = 0, int nLastPage = 0)
{
return false;
}
-bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
- sal_uInt64 nPos, sal_uInt64 nSize)
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 nPos,
+ sal_uInt64 nSize)
{
rInStream.Seek(nPos);
rOutStream.WriteStream(rInStream, nSize);
return rOutStream.good();
}
#endif // HAVE_FEATURE_PDFIUM
-
}
namespace vcl
{
-
-bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
- css::uno::Sequence<sal_Int8>& rPdfData,
+bool ImportPDF(SvStream& rStream, Bitmap& rBitmap, css::uno::Sequence<sal_Int8>& rPdfData,
sal_uInt64 nPos, sal_uInt64 nSize)
{
// Get the preview of the first page.
@@ -236,7 +233,6 @@ bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
return true;
}
-
bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
{
uno::Sequence<sal_Int8> aPdfData;
@@ -246,7 +242,6 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
rGraphic.setPdfData(aPdfData);
return bRet;
}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */