LibreOffice Module vcl (master) 1
PDFiumLibrary.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
11#pragma once
12
13#include <memory>
14
15#include <com/sun/star/util/DateTime.hpp>
16
17#include <vcl/dllapi.h>
22#include <rtl/ustring.hxx>
23#include <tools/color.hxx>
24#include <tools/gen.hxx>
25#include <vcl/checksum.hxx>
26#include <vcl/Scanline.hxx>
38
39class SvMemoryStream;
40
41namespace vcl::pdf
42{
43inline constexpr OStringLiteral constDictionaryKeyTitle = "T";
44inline constexpr OStringLiteral constDictionaryKeyContents = "Contents";
45inline constexpr OStringLiteral constDictionaryKeyPopup = "Popup";
46inline constexpr OStringLiteral constDictionaryKeyModificationDate = "M";
47inline constexpr OStringLiteral constDictionaryKeyInteriorColor = "IC";
48
49class PDFiumBitmap;
50class PDFiumDocument;
52
54{
55public:
56 virtual ~PDFium() = default;
57
58 virtual const OUString& getLastError() const = 0;
59
60 virtual std::unique_ptr<PDFiumDocument> openDocument(const void* pData, int nSize,
61 const OString& rPassword)
62 = 0;
65 virtual std::unique_ptr<PDFiumBitmap> createBitmap(int& nWidth, int& nHeight, int nAlpha) = 0;
66};
67
68class PDFiumPage;
69
71{
72public:
73 virtual ~PDFiumBitmap() = default;
74 virtual void fillRect(int left, int top, int width, int height, sal_uInt32 nColor) = 0;
75 virtual void renderPageBitmap(PDFiumDocument* pDoc, PDFiumPage* pPage, int nStartX, int nStartY,
76 int nSizeX, int nSizeY)
77 = 0;
78 virtual ConstScanline getBuffer() = 0;
79 virtual int getStride() = 0;
80 virtual int getWidth() = 0;
81 virtual int getHeight() = 0;
82 virtual PDFBitmapType getFormat() = 0;
83};
84
86{
87public:
88 virtual ~PDFiumAnnotation() = default;
91 virtual bool hasKey(OString const& rKey) = 0;
92 virtual PDFObjectType getValueType(OString const& rKey) = 0;
93 virtual OUString getString(OString const& rKey) = 0;
94 virtual std::unique_ptr<PDFiumAnnotation> getLinked(OString const& rKey) = 0;
95 virtual int getObjectCount() = 0;
96 virtual std::unique_ptr<PDFiumPageObject> getObject(int nIndex) = 0;
97 virtual std::vector<std::vector<basegfx::B2DPoint>> getInkStrokes() = 0;
98 virtual std::vector<basegfx::B2DPoint> getVertices() = 0;
99 virtual Color getColor() = 0;
100 virtual Color getInteriorColor() = 0;
101 virtual float getBorderWidth() = 0;
103 virtual size_t getAttachmentPointsCount() = 0;
104 virtual std::vector<basegfx::B2DPoint> getAttachmentPoints(size_t nIndex) = 0;
105 virtual std::vector<basegfx::B2DPoint> getLineGeometry() = 0;
107 virtual float getFontSize(PDFiumDocument* pDoc) = 0;
108 virtual OUString getFormFieldAlternateName(PDFiumDocument* pDoc) = 0;
109 virtual int getFormFieldFlags(PDFiumDocument* pDoc) = 0;
111 PDFAnnotAActionType eEvent)
112 = 0;
113 virtual OUString getFormFieldValue(PDFiumDocument* pDoc) = 0;
114};
115
116class PDFiumTextPage;
117
119{
120public:
121 virtual ~PDFiumPathSegment() = default;
122 virtual basegfx::B2DPoint getPoint() const = 0;
123 virtual bool isClosed() const = 0;
124 virtual PDFSegmentType getType() const = 0;
125};
126
128{
129public:
130 virtual ~PDFiumPageObject() = default;
131
133 virtual OUString getText(std::unique_ptr<PDFiumTextPage> const& pTextPage) = 0;
134
135 virtual int getFormObjectCount() = 0;
136 virtual std::unique_ptr<PDFiumPageObject> getFormObject(int nIndex) = 0;
137
140 virtual double getFontSize() = 0;
141 virtual OUString getFontName() = 0;
143 virtual Color getFillColor() = 0;
144 virtual Color getStrokeColor() = 0;
145 virtual double getStrokeWidth() = 0;
146 // Path
147 virtual int getPathSegmentCount() = 0;
148 virtual std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) = 0;
149 virtual Size getImageSize(PDFiumPage& rPage) = 0;
150 virtual std::unique_ptr<PDFiumBitmap> getImageBitmap() = 0;
151 virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
152};
153
155{
156public:
157 virtual ~PDFiumSearchHandle() = default;
158
159 virtual bool findNext() = 0;
160 virtual bool findPrev() = 0;
161 virtual int getSearchResultIndex() = 0;
162 virtual int getSearchCount() = 0;
163};
164
166{
167public:
168 virtual ~PDFiumTextPage() = default;
169
170 virtual int countChars() = 0;
171 virtual unsigned int getUnicode(int index) = 0;
172 virtual std::unique_ptr<PDFiumSearchHandle>
173 findStart(const OUString& rFindWhat, PDFFindFlags nFlags, sal_Int32 nStartIndex) = 0;
174
176 virtual basegfx::B2DRectangle getCharBox(int nIndex, double fPageHeight) = 0;
177};
178
180{
181public:
182 virtual ~PDFiumPage() = default;
183
184 virtual int getObjectCount() = 0;
185 virtual std::unique_ptr<PDFiumPageObject> getObject(int nIndex) = 0;
186
187 virtual int getAnnotationCount() = 0;
188 virtual int getAnnotationIndex(std::unique_ptr<PDFiumAnnotation> const& rAnnotation) = 0;
189
190 virtual std::unique_ptr<PDFiumAnnotation> getAnnotation(int nIndex) = 0;
191
192 virtual std::unique_ptr<PDFiumTextPage> getTextPage() = 0;
193
195 virtual BitmapChecksum getChecksum(int nMDPPerm) = 0;
196
197 virtual double getWidth() = 0;
198 virtual double getHeight() = 0;
199
200 virtual bool hasTransparency() = 0;
201
202 virtual bool hasLinks() = 0;
203
204 virtual void onAfterLoadPage(PDFiumDocument* pDoc) = 0;
205};
206
209{
210public:
211 virtual ~PDFiumSignature() = default;
212
213 virtual std::vector<int> getByteRange() = 0;
214 virtual int getDocMDPPermission() = 0;
215 virtual std::vector<unsigned char> getContents() = 0;
216 virtual OString getSubFilter() = 0;
217 virtual OUString getReason() = 0;
218 virtual css::util::DateTime getTime() = 0;
219};
220
222{
223public:
224 virtual ~PDFiumDocument() = default;
225
226 // Page size in points
227 virtual basegfx::B2DSize getPageSize(int nIndex) = 0;
228 virtual int getPageCount() = 0;
229 virtual int getSignatureCount() = 0;
230 virtual int getFileVersion() = 0;
231 virtual bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion) = 0;
232
233 virtual std::unique_ptr<PDFiumPage> openPage(int nIndex) = 0;
234 virtual std::unique_ptr<PDFiumSignature> getSignature(int nIndex) = 0;
235 virtual std::vector<unsigned int> getTrailerEnds() = 0;
236};
237
239{
240 static std::shared_ptr<PDFium>& get();
241};
242
243// Tools
244
245VCL_DLLPUBLIC OUString convertPdfDateToISO8601(std::u16string_view rInput);
246
247} // namespace vcl::pdf
248
249/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:27
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
virtual float getBorderWidth()=0
virtual size_t getAttachmentPointsCount()=0
virtual PDFAnnotationSubType getSubType()=0
virtual int getObjectCount()=0
virtual Color getColor()=0
virtual OUString getFormFieldAlternateName(PDFiumDocument *pDoc)=0
virtual OUString getFormFieldValue(PDFiumDocument *pDoc)=0
virtual float getFontSize(PDFiumDocument *pDoc)=0
virtual std::vector< basegfx::B2DPoint > getVertices()=0
virtual std::unique_ptr< PDFiumPageObject > getObject(int nIndex)=0
virtual PDFFormFieldType getFormFieldType(PDFiumDocument *pDoc)=0
virtual std::vector< basegfx::B2DPoint > getLineGeometry()=0
virtual basegfx::B2DSize getBorderCornerRadius()=0
virtual int getFormFieldFlags(PDFiumDocument *pDoc)=0
virtual PDFObjectType getValueType(OString const &rKey)=0
virtual OUString getString(OString const &rKey)=0
virtual OUString getFormAdditionalActionJavaScript(PDFiumDocument *pDoc, PDFAnnotAActionType eEvent)=0
virtual Color getInteriorColor()=0
virtual basegfx::B2DRectangle getRectangle()=0
virtual std::vector< basegfx::B2DPoint > getAttachmentPoints(size_t nIndex)=0
virtual std::unique_ptr< PDFiumAnnotation > getLinked(OString const &rKey)=0
virtual ~PDFiumAnnotation()=default
virtual std::vector< std::vector< basegfx::B2DPoint > > getInkStrokes()=0
virtual bool hasKey(OString const &rKey)=0
virtual int getStride()=0
virtual void renderPageBitmap(PDFiumDocument *pDoc, PDFiumPage *pPage, int nStartX, int nStartY, int nSizeX, int nSizeY)=0
virtual void fillRect(int left, int top, int width, int height, sal_uInt32 nColor)=0
virtual ~PDFiumBitmap()=default
virtual int getHeight()=0
virtual ConstScanline getBuffer()=0
virtual int getWidth()=0
virtual PDFBitmapType getFormat()=0
virtual int getFileVersion()=0
virtual bool saveWithVersion(SvMemoryStream &rStream, int nFileVersion)=0
virtual ~PDFiumDocument()=default
virtual std::vector< unsigned int > getTrailerEnds()=0
virtual basegfx::B2DSize getPageSize(int nIndex)=0
virtual std::unique_ptr< PDFiumSignature > getSignature(int nIndex)=0
virtual int getSignatureCount()=0
virtual int getPageCount()=0
virtual std::unique_ptr< PDFiumPage > openPage(int nIndex)=0
virtual Color getStrokeColor()=0
virtual ~PDFiumPageObject()=default
virtual double getStrokeWidth()=0
virtual std::unique_ptr< PDFiumBitmap > getImageBitmap()=0
virtual bool getDrawMode(PDFFillMode &eFillMode, bool &bStroke)=0
virtual std::unique_ptr< PDFiumPageObject > getFormObject(int nIndex)=0
virtual basegfx::B2DHomMatrix getMatrix()=0
virtual std::unique_ptr< PDFiumPathSegment > getPathSegment(int index)=0
virtual int getFormObjectCount()=0
virtual int getPathSegmentCount()=0
virtual PDFPageObjectType getType()=0
virtual basegfx::B2DRectangle getBounds()=0
virtual double getFontSize()=0
virtual Color getFillColor()=0
virtual OUString getFontName()=0
virtual PDFTextRenderMode getTextRenderMode()=0
virtual Size getImageSize(PDFiumPage &rPage)=0
virtual OUString getText(std::unique_ptr< PDFiumTextPage > const &pTextPage)=0
virtual double getHeight()=0
virtual void onAfterLoadPage(PDFiumDocument *pDoc)=0
virtual std::unique_ptr< PDFiumPageObject > getObject(int nIndex)=0
virtual bool hasTransparency()=0
virtual std::unique_ptr< PDFiumAnnotation > getAnnotation(int nIndex)=0
virtual ~PDFiumPage()=default
virtual double getWidth()=0
virtual BitmapChecksum getChecksum(int nMDPPerm)=0
Get bitmap checksum of the page, without annotations/commenting.
virtual int getObjectCount()=0
virtual int getAnnotationCount()=0
virtual int getAnnotationIndex(std::unique_ptr< PDFiumAnnotation > const &rAnnotation)=0
virtual std::unique_ptr< PDFiumTextPage > getTextPage()=0
virtual bool hasLinks()=0
virtual PDFSegmentType getType() const =0
virtual bool isClosed() const =0
virtual basegfx::B2DPoint getPoint() const =0
virtual ~PDFiumPathSegment()=default
virtual int getSearchResultIndex()=0
virtual int getSearchCount()=0
virtual ~PDFiumSearchHandle()=default
Represents one digital signature, as exposed by PDFium.
virtual ~PDFiumSignature()=default
virtual OString getSubFilter()=0
virtual OUString getReason()=0
virtual std::vector< int > getByteRange()=0
virtual css::util::DateTime getTime()=0
virtual int getDocMDPPermission()=0
virtual std::vector< unsigned char > getContents()=0
virtual unsigned int getUnicode(int index)=0
virtual std::unique_ptr< PDFiumSearchHandle > findStart(const OUString &rFindWhat, PDFFindFlags nFlags, sal_Int32 nStartIndex)=0
virtual basegfx::B2DRectangle getCharBox(int nIndex, double fPageHeight)=0
Returned rect is no longer upside down and is in mm100.
virtual int countChars()=0
virtual ~PDFiumTextPage()=default
virtual std::unique_ptr< PDFiumBitmap > createBitmap(int &nWidth, int &nHeight, int nAlpha)=0
createBitmap can reduce requested size to possible value
virtual ~PDFium()=default
virtual const OUString & getLastError() const =0
virtual std::unique_ptr< PDFiumDocument > openDocument(const void *pData, int nSize, const OString &rPassword)=0
virtual PDFErrorType getLastErrorCode()=0
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr OStringLiteral constDictionaryKeyPopup
constexpr OStringLiteral constDictionaryKeyInteriorColor
constexpr OStringLiteral constDictionaryKeyTitle
constexpr OStringLiteral constDictionaryKeyContents
constexpr OStringLiteral constDictionaryKeyModificationDate
OUString convertPdfDateToISO8601(std::u16string_view rInput)
Definition: PDFiumTools.cxx:15