LibreOffice Module vcl (master) 1
pdfread.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
11#define INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
12
13#include <vector>
14#include <tools/gen.hxx>
15#include <tools/stream.hxx>
16#include <tools/color.hxx>
17#include <vcl/graph.hxx>
19#include <com/sun/star/util/DateTime.hpp>
20
23
24namespace com::sun::star::uno
25{
26template <typename> class Sequence;
27}
28class Bitmap;
29
30namespace vcl
31{
33VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, int nSize,
34 std::vector<BitmapEx>& rBitmaps, size_t nFirstPage = 0,
35 int nPages = 1, const basegfx::B2DTuple* pSizeHint = nullptr);
36
40 std::shared_ptr<VectorGraphicData>& rVectorGraphicData);
41
43VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
44
45// When inserting a PDF file as an image or pasting PDF data from the clipboard, at least on a
46// Retina iMac, the resulting rendered image does not look sharp without this surprisingly large
47// extra scaling factor. Exact reasons unknown. And it isn't enough to have it be just 2 (which is
48// the actual Retina factor on my iMac). Possibly the fuzziness is related to what Pdfium uses to
49// render text.
50
51// Also, look at CountDPIScaleFactor() in vcl/source/window/window.cxx. The GetDPIScaleFactor() API
52// lies on macOS even more than it does on other platforms, it claims that the DPI scale factor is
53// always 1. But in fact most Macs nowadays have a HiDPI ("Retina") display. But we can't just "fix"
54// things by making GetDPIScaleFactor() always return 2 on macOS, even if that wouldn't be any more
55// wrong, because that then causes other regressions that I have no time to look into now.
56
57#ifdef MACOSX
58constexpr int PDF_INSERT_MAGIC_SCALE_FACTOR = 8;
59#else
61#endif
62
64{
65 OUString maAuthor;
66 OUString maText;
67
69 css::util::DateTime maDateTime;
70
72
74 std::shared_ptr<pdf::PDFAnnotationMarker> mpMarker;
75};
76
78{
80 // Size in HMM
82
83 std::vector<PDFGraphicAnnotation> maAnnotations;
84
85public:
86 PDFGraphicResult(Graphic aGraphic, Size const& rSize,
87 std::vector<PDFGraphicAnnotation> aAnnotations)
88 : maGraphic(std::move(aGraphic))
89 , maSize(rSize)
90 , maAnnotations(std::move(aAnnotations))
91 {
92 }
93
94 const Graphic& GetGraphic() const { return maGraphic; }
95 const Size& GetSize() const { return maSize; }
96 const std::vector<PDFGraphicAnnotation>& GetAnnotations() const { return maAnnotations; }
97};
98
101VCL_DLLPUBLIC size_t ImportPDFUnloaded(const OUString& rURL,
102 std::vector<PDFGraphicResult>& rGraphics);
103}
104
105#endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Size & GetSize() const
Definition: pdfread.hxx:95
const Graphic & GetGraphic() const
Definition: pdfread.hxx:94
std::vector< PDFGraphicAnnotation > maAnnotations
Definition: pdfread.hxx:83
PDFGraphicResult(Graphic aGraphic, Size const &rSize, std::vector< PDFGraphicAnnotation > aAnnotations)
Definition: pdfread.hxx:86
const std::vector< PDFGraphicAnnotation > & GetAnnotations() const
Definition: pdfread.hxx:96
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
size_t RenderPDFBitmaps(const void *pBuffer, int nSize, std::vector< BitmapEx > &rBitmaps, const size_t nFirstPage, int nPages, const basegfx::B2DTuple *pSizeHint)
Fills the rBitmaps vector with rendered pages.
Definition: pdfread.cxx:26
bool ImportPDF(SvStream &rStream, Graphic &rGraphic)
Imports a PDF stream into rGraphic.
Definition: pdfread.cxx:142
bool importPdfVectorGraphicData(SvStream &rStream, std::shared_ptr< VectorGraphicData > &rVectorGraphicData)
Imports a PDF stream as a VectorGraphicData.
Definition: pdfread.cxx:126
constexpr int PDF_INSERT_MAGIC_SCALE_FACTOR
Definition: pdfread.hxx:60
size_t ImportPDFUnloaded(const OUString &rURL, std::vector< PDFGraphicResult > &rGraphics)
Import PDF as Graphic images (1 per page), but not loaded yet.
Definition: pdfread.cxx:335
basegfx::B2DRectangle maRectangle
Definition: pdfread.hxx:68
pdf::PDFAnnotationSubType meSubType
Definition: pdfread.hxx:73
css::util::DateTime maDateTime
Definition: pdfread.hxx:69
std::shared_ptr< pdf::PDFAnnotationMarker > mpMarker
Definition: pdfread.hxx:74