summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-31 20:51:38 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-01 09:10:51 +0200
commitf1779fcef6535edf53d194fbd366de232653f189 (patch)
tree5f860ebef3edae8b19f1198d844086a6313fa2a4 /vcl/source
parent3595b8037d9d00fe5fa45f79dd19a032fc5f0ba5 (diff)
vcl pdfread: clean up not needed HAVE_FEATURE_PDFIUM ifdefs
Towards completely avoiding the HAVE_FEATURE_PDFIUM ifdef forest. Change-Id: Ide634f14087ec18e5ab8186be21def0698ddbd5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113428 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx40
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx57
-rw-r--r--vcl/source/pdf/PDFiumTools.cxx73
3 files changed, 81 insertions, 89 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index c51d350e3dda..86adec409f90 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -9,11 +9,7 @@
#include <vcl/pdfread.hxx>
-#include <config_features.h>
-
-#if HAVE_FEATURE_PDFIUM
#include <tools/UnitConversion.hxx>
-#endif
#include <vcl/graph.hxx>
#include <bitmap/BitmapWriteAccess.hxx>
@@ -27,8 +23,6 @@ using namespace com::sun::star;
namespace
{
-#if HAVE_FEATURE_PDFIUM
-
/// Convert to inch, then assume 96 DPI.
inline double pointToPixel(const double fPoint, const double fResolutionDPI)
{
@@ -96,14 +90,6 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream)
return rOutStream.good();
}
-#else
-bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream)
-{
- rInStream.Seek(STREAM_SEEK_TO_BEGIN);
- rOutStream.WriteStream(rInStream, STREAM_SEEK_TO_END);
- return rOutStream.good();
-}
-#endif // HAVE_FEATURE_PDFIUM
BinaryDataContainer createBinaryDataContainer(SvStream& rStream)
{
@@ -131,9 +117,12 @@ namespace vcl
size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& rBitmaps,
const size_t nFirstPage, int nPages, const basegfx::B2DTuple* pSizeHint)
{
-#if HAVE_FEATURE_PDFIUM
const double fResolutionDPI = 96;
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+ if (!pPdfium)
+ {
+ return 0;
+ }
// Load the buffer using pdfium.
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = pPdfium->openDocument(pBuffer, nSize);
@@ -217,15 +206,6 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r
}
return rBitmaps.size();
-#else
- (void)pBuffer;
- (void)nSize;
- (void)rBitmaps;
- (void)nFirstPage;
- (void)nPages;
- (void)pSizeHint;
- return 0;
-#endif // HAVE_FEATURE_PDFIUM
}
bool importPdfVectorGraphicData(SvStream& rStream,
@@ -253,7 +233,6 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
return true;
}
-#if HAVE_FEATURE_PDFIUM
namespace
{
basegfx::B2DPoint convertFromPDFInternalToHMM(basegfx::B2DSize const& rInputPoint,
@@ -431,11 +410,9 @@ findAnnotations(const std::unique_ptr<vcl::pdf::PDFiumPage>& pPage, basegfx::B2D
}
} // end anonymous namespace
-#endif
size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rGraphics)
{
-#if HAVE_FEATURE_PDFIUM
std::unique_ptr<SvStream> xStream(
::utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ | StreamMode::SHARE_DENYNONE));
@@ -448,6 +425,10 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
auto pGfxLink = std::make_shared<GfxLink>(aDataContainer, GfxLinkType::NativePdf);
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+ if (!pPdfium)
+ {
+ return 0;
+ }
// Load the buffer using pdfium.
auto pPdfDocument = pPdfium->openDocument(pGfxLink->GetData(), pGfxLink->GetDataSize());
@@ -487,11 +468,6 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
}
return rGraphics.size();
-#else
- (void)rURL;
- (void)rGraphics;
- return 0;
-#endif // HAVE_FEATURE_PDFIUM
}
}
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 53bf57e3aa8a..e8951c476648 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -411,63 +411,6 @@ public:
};
}
-OUString convertPdfDateToISO8601(OUString const& rInput)
-{
- if (rInput.getLength() < 6)
- return OUString();
-
- OUString prefix = rInput.copy(0, 2);
- if (prefix != "D:")
- return OUString();
-
- OUString sYear = rInput.copy(2, 4);
-
- OUString sMonth("01");
- if (rInput.getLength() >= 8)
- sMonth = rInput.copy(6, 2);
-
- OUString sDay("01");
- if (rInput.getLength() >= 10)
- sDay = rInput.copy(8, 2);
-
- OUString sHours("00");
- if (rInput.getLength() >= 12)
- sHours = rInput.copy(10, 2);
-
- OUString sMinutes("00");
- if (rInput.getLength() >= 14)
- sMinutes = rInput.copy(12, 2);
-
- OUString sSeconds("00");
- if (rInput.getLength() >= 16)
- sSeconds = rInput.copy(14, 2);
-
- OUString sTimeZoneMark("Z");
- if (rInput.getLength() >= 17)
- sTimeZoneMark = rInput.copy(16, 1);
-
- OUString sTimeZoneHours("00");
- OUString sTimeZoneMinutes("00");
- if ((sTimeZoneMark == "+" || sTimeZoneMark == "-") && rInput.getLength() >= 22)
- {
- OUString sTimeZoneSeparator = rInput.copy(19, 1);
- if (sTimeZoneSeparator == "'")
- {
- sTimeZoneHours = rInput.copy(17, 2);
- sTimeZoneMinutes = rInput.copy(20, 2);
- }
- }
-
- OUString sTimeZoneString;
- if (sTimeZoneMark == "+" || sTimeZoneString == "-")
- sTimeZoneString = sTimeZoneMark + sTimeZoneHours + ":" + sTimeZoneMinutes;
- else if (sTimeZoneMark == "Z")
- sTimeZoneString = sTimeZoneMark;
-
- return sYear + "-" + sMonth + "-" + sDay + "T" + sHours + ":" + sMinutes + ":" + sSeconds
- + sTimeZoneString;
-}
-
PDFiumImpl::PDFiumImpl()
{
FPDF_LIBRARY_CONFIG aConfig;
diff --git a/vcl/source/pdf/PDFiumTools.cxx b/vcl/source/pdf/PDFiumTools.cxx
new file mode 100644
index 000000000000..f6428f02b167
--- /dev/null
+++ b/vcl/source/pdf/PDFiumTools.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <vcl/filter/PDFiumLibrary.hxx>
+
+namespace vcl::pdf
+{
+OUString convertPdfDateToISO8601(OUString const& rInput)
+{
+ if (rInput.getLength() < 6)
+ return OUString();
+
+ OUString prefix = rInput.copy(0, 2);
+ if (prefix != "D:")
+ return OUString();
+
+ OUString sYear = rInput.copy(2, 4);
+
+ OUString sMonth("01");
+ if (rInput.getLength() >= 8)
+ sMonth = rInput.copy(6, 2);
+
+ OUString sDay("01");
+ if (rInput.getLength() >= 10)
+ sDay = rInput.copy(8, 2);
+
+ OUString sHours("00");
+ if (rInput.getLength() >= 12)
+ sHours = rInput.copy(10, 2);
+
+ OUString sMinutes("00");
+ if (rInput.getLength() >= 14)
+ sMinutes = rInput.copy(12, 2);
+
+ OUString sSeconds("00");
+ if (rInput.getLength() >= 16)
+ sSeconds = rInput.copy(14, 2);
+
+ OUString sTimeZoneMark("Z");
+ if (rInput.getLength() >= 17)
+ sTimeZoneMark = rInput.copy(16, 1);
+
+ OUString sTimeZoneHours("00");
+ OUString sTimeZoneMinutes("00");
+ if ((sTimeZoneMark == "+" || sTimeZoneMark == "-") && rInput.getLength() >= 22)
+ {
+ OUString sTimeZoneSeparator = rInput.copy(19, 1);
+ if (sTimeZoneSeparator == "'")
+ {
+ sTimeZoneHours = rInput.copy(17, 2);
+ sTimeZoneMinutes = rInput.copy(20, 2);
+ }
+ }
+
+ OUString sTimeZoneString;
+ if (sTimeZoneMark == "+" || sTimeZoneString == "-")
+ sTimeZoneString = sTimeZoneMark + sTimeZoneHours + ":" + sTimeZoneMinutes;
+ else if (sTimeZoneMark == "Z")
+ sTimeZoneString = sTimeZoneMark;
+
+ return sYear + "-" + sMonth + "-" + sDay + "T" + sHours + ":" + sMinutes + ":" + sSeconds
+ + sTimeZoneString;
+}
+} // end vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */