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>
36
37class SvMemoryStream;
38
39namespace vcl::pdf
40{
41inline constexpr OStringLiteral constDictionaryKeyTitle = "T";
42inline constexpr OStringLiteral constDictionaryKeyContents = "Contents";
43inline constexpr OStringLiteral constDictionaryKeyPopup = "Popup";
44inline constexpr OStringLiteral constDictionaryKeyModificationDate = "M";
45inline constexpr OStringLiteral constDictionaryKeyInteriorColor = "IC";
46
47class PDFiumBitmap;
48class PDFiumDocument;
50
52{
53public:
54 virtual ~PDFium() = default;
55
56 virtual const OUString& getLastError() const = 0;
57
58 virtual std::unique_ptr<PDFiumDocument> openDocument(const void* pData, int nSize,
59 const OString& rPassword)
60 = 0;
62 virtual std::unique_ptr<PDFiumBitmap> createBitmap(int nWidth, int nHeight, int nAlpha) = 0;
63};
64
65class PDFiumPage;
66
68{
69public:
70 virtual ~PDFiumBitmap() = default;
71 virtual void fillRect(int left, int top, int width, int height, sal_uInt32 nColor) = 0;
72 virtual void renderPageBitmap(PDFiumDocument* pDoc, PDFiumPage* pPage, int nStartX, int nStartY,
73 int nSizeX, int nSizeY)
74 = 0;
75 virtual ConstScanline getBuffer() = 0;
76 virtual int getStride() = 0;
77 virtual int getWidth() = 0;
78 virtual int getHeight() = 0;
79 virtual PDFBitmapType getFormat() = 0;
80};
81
83{
84public:
85 virtual ~PDFiumAnnotation() = default;
88 virtual bool hasKey(OString const& rKey) = 0;
89 virtual PDFObjectType getValueType(OString const& rKey) = 0;
90 virtual OUString getString(OString const& rKey) = 0;
91 virtual std::unique_ptr<PDFiumAnnotation> getLinked(OString const& rKey) = 0;
92 virtual int getObjectCount() = 0;
93 virtual std::unique_ptr<PDFiumPageObject> getObject(int nIndex) = 0;
94 virtual std::vector<std::vector<basegfx::B2DPoint>> getInkStrokes() = 0;
95 virtual std::vector<basegfx::B2DPoint> getVertices() = 0;
96 virtual Color getColor() = 0;
97 virtual Color getInteriorColor() = 0;
98 virtual float getBorderWidth() = 0;
100 virtual size_t getAttachmentPointsCount() = 0;
101 virtual std::vector<basegfx::B2DPoint> getAttachmentPoints(size_t nIndex) = 0;
102 virtual std::vector<basegfx::B2DPoint> getLineGeometry() = 0;
103};
104
105class PDFiumTextPage;
106
108{
109public:
110 virtual ~PDFiumPathSegment() = default;
111 virtual basegfx::B2DPoint getPoint() const = 0;
112 virtual bool isClosed() const = 0;
113 virtual PDFSegmentType getType() const = 0;
114};
115
117{
118public:
119 virtual ~PDFiumPageObject() = default;
120
122 virtual OUString getText(std::unique_ptr<PDFiumTextPage> const& pTextPage) = 0;
123
124 virtual int getFormObjectCount() = 0;
125 virtual std::unique_ptr<PDFiumPageObject> getFormObject(int nIndex) = 0;
126
129 virtual double getFontSize() = 0;
130 virtual OUString getFontName() = 0;
132 virtual Color getFillColor() = 0;
133 virtual Color getStrokeColor() = 0;
134 virtual double getStrokeWidth() = 0;
135 // Path
136 virtual int getPathSegmentCount() = 0;
137 virtual std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) = 0;
138 virtual Size getImageSize(PDFiumPage& rPage) = 0;
139 virtual std::unique_ptr<PDFiumBitmap> getImageBitmap() = 0;
140 virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
141};
142
144{
145public:
146 virtual ~PDFiumSearchHandle() = default;
147
148 virtual bool findNext() = 0;
149 virtual bool findPrev() = 0;
150 virtual int getSearchResultIndex() = 0;
151 virtual int getSearchCount() = 0;
152};
153
155{
156public:
157 virtual ~PDFiumTextPage() = default;
158
159 virtual int countChars() = 0;
160 virtual unsigned int getUnicode(int index) = 0;
161 virtual std::unique_ptr<PDFiumSearchHandle>
162 findStart(const OUString& rFindWhat, PDFFindFlags nFlags, sal_Int32 nStartIndex) = 0;
163
165 virtual basegfx::B2DRectangle getCharBox(int nIndex, double fPageHeight) = 0;
166};
167
169{
170public:
171 virtual ~PDFiumPage() = default;
172
173 virtual int getObjectCount() = 0;
174 virtual std::unique_ptr<PDFiumPageObject> getObject(int nIndex) = 0;
175
176 virtual int getAnnotationCount() = 0;
177 virtual int getAnnotationIndex(std::unique_ptr<PDFiumAnnotation> const& rAnnotation) = 0;
178
179 virtual std::unique_ptr<PDFiumAnnotation> getAnnotation(int nIndex) = 0;
180
181 virtual std::unique_ptr<PDFiumTextPage> getTextPage() = 0;
182
184 virtual BitmapChecksum getChecksum(int nMDPPerm) = 0;
185
186 virtual double getWidth() = 0;
187 virtual double getHeight() = 0;
188
189 virtual bool hasTransparency() = 0;
190
191 virtual bool hasLinks() = 0;
192};
193
196{
197public:
198 virtual ~PDFiumSignature() = default;
199
200 virtual std::vector<int> getByteRange() = 0;
201 virtual int getDocMDPPermission() = 0;
202 virtual std::vector<unsigned char> getContents() = 0;
203 virtual OString getSubFilter() = 0;
204 virtual OUString getReason() = 0;
205 virtual css::util::DateTime getTime() = 0;
206};
207
209{
210public:
211 virtual ~PDFiumDocument() = default;
212
213 // Page size in points
214 virtual basegfx::B2DSize getPageSize(int nIndex) = 0;
215 virtual int getPageCount() = 0;
216 virtual int getSignatureCount() = 0;
217 virtual int getFileVersion() = 0;
218 virtual bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion) = 0;
219
220 virtual std::unique_ptr<PDFiumPage> openPage(int nIndex) = 0;
221 virtual std::unique_ptr<PDFiumSignature> getSignature(int nIndex) = 0;
222 virtual std::vector<unsigned int> getTrailerEnds() = 0;
223};
224
226{
227 static std::shared_ptr<PDFium>& get();
228};
229
230// Tools
231
232VCL_DLLPUBLIC OUString convertPdfDateToISO8601(OUString const& rInput);
233
234} // namespace vcl::pdf
235
236/* 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 std::vector< basegfx::B2DPoint > getVertices()=0
virtual std::unique_ptr< PDFiumPageObject > getObject(int nIndex)=0
virtual std::vector< basegfx::B2DPoint > getLineGeometry()=0
virtual basegfx::B2DSize getBorderCornerRadius()=0
virtual PDFObjectType getValueType(OString const &rKey)=0
virtual OUString getString(OString const &rKey)=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 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
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
OUString convertPdfDateToISO8601(OUString const &rInput)
Definition: PDFiumTools.cxx:15
constexpr OStringLiteral constDictionaryKeyInteriorColor
constexpr OStringLiteral constDictionaryKeyTitle
constexpr OStringLiteral constDictionaryKeyContents
constexpr OStringLiteral constDictionaryKeyModificationDate