bump product version to 7.6.3.2-android
[LibreOffice.git] / include / vcl / filter / PDFiumLibrary.hxx
blob9c278d281a1c9b1c9f6290ee51a686a92d1786d2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 */
11 #pragma once
13 #include <memory>
15 #include <com/sun/star/util/DateTime.hpp>
17 #include <vcl/dllapi.h>
18 #include <basegfx/vector/b2dsize.hxx>
19 #include <basegfx/range/b2drectangle.hxx>
20 #include <basegfx/point/b2dpoint.hxx>
21 #include <basegfx/matrix/b2dhommatrix.hxx>
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>
27 #include <vcl/pdf/PDFAnnotationSubType.hxx>
28 #include <vcl/pdf/PDFPageObjectType.hxx>
29 #include <vcl/pdf/PDFSegmentType.hxx>
30 #include <vcl/pdf/PDFBitmapType.hxx>
31 #include <vcl/pdf/PDFObjectType.hxx>
32 #include <vcl/pdf/PDFTextRenderMode.hxx>
33 #include <vcl/pdf/PDFFillMode.hxx>
34 #include <vcl/pdf/PDFFindFlags.hxx>
35 #include <vcl/pdf/PDFErrorType.hxx>
36 #include <vcl/pdf/PDFFormFieldType.hxx>
37 #include <vcl/pdf/PDFAnnotAActionType.hxx>
39 class SvMemoryStream;
41 namespace vcl::pdf
43 inline constexpr OStringLiteral constDictionaryKeyTitle = "T";
44 inline constexpr OStringLiteral constDictionaryKeyContents = "Contents";
45 inline constexpr OStringLiteral constDictionaryKeyPopup = "Popup";
46 inline constexpr OStringLiteral constDictionaryKeyModificationDate = "M";
47 inline constexpr OStringLiteral constDictionaryKeyInteriorColor = "IC";
49 class PDFiumBitmap;
50 class PDFiumDocument;
51 class PDFiumPageObject;
53 class VCL_DLLPUBLIC PDFium
55 public:
56 virtual ~PDFium() = default;
58 virtual const OUString& getLastError() const = 0;
60 virtual std::unique_ptr<PDFiumDocument> openDocument(const void* pData, int nSize,
61 const OString& rPassword)
62 = 0;
63 virtual PDFErrorType getLastErrorCode() = 0;
64 /// createBitmap can reduce requested size to possible value
65 virtual std::unique_ptr<PDFiumBitmap> createBitmap(int& nWidth, int& nHeight, int nAlpha) = 0;
68 class PDFiumPage;
70 class VCL_DLLPUBLIC PDFiumBitmap
72 public:
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;
85 class VCL_DLLPUBLIC PDFiumAnnotation
87 public:
88 virtual ~PDFiumAnnotation() = default;
89 virtual PDFAnnotationSubType getSubType() = 0;
90 virtual basegfx::B2DRectangle getRectangle() = 0;
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;
102 virtual basegfx::B2DSize getBorderCornerRadius() = 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;
106 virtual PDFFormFieldType getFormFieldType(PDFiumDocument* pDoc) = 0;
107 virtual float getFontSize(PDFiumDocument* pDoc) = 0;
108 virtual OUString getFormFieldAlternateName(PDFiumDocument* pDoc) = 0;
109 virtual int getFormFieldFlags(PDFiumDocument* pDoc) = 0;
110 virtual OUString getFormAdditionalActionJavaScript(PDFiumDocument* pDoc,
111 PDFAnnotAActionType eEvent)
112 = 0;
113 virtual OUString getFormFieldValue(PDFiumDocument* pDoc) = 0;
116 class PDFiumTextPage;
118 class VCL_DLLPUBLIC PDFiumPathSegment
120 public:
121 virtual ~PDFiumPathSegment() = default;
122 virtual basegfx::B2DPoint getPoint() const = 0;
123 virtual bool isClosed() const = 0;
124 virtual PDFSegmentType getType() const = 0;
127 class VCL_DLLPUBLIC PDFiumPageObject
129 public:
130 virtual ~PDFiumPageObject() = default;
132 virtual PDFPageObjectType getType() = 0;
133 virtual OUString getText(std::unique_ptr<PDFiumTextPage> const& pTextPage) = 0;
135 virtual int getFormObjectCount() = 0;
136 virtual std::unique_ptr<PDFiumPageObject> getFormObject(int nIndex) = 0;
138 virtual basegfx::B2DHomMatrix getMatrix() = 0;
139 virtual basegfx::B2DRectangle getBounds() = 0;
140 virtual double getFontSize() = 0;
141 virtual OUString getFontName() = 0;
142 virtual PDFTextRenderMode getTextRenderMode() = 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;
154 class VCL_DLLPUBLIC PDFiumSearchHandle
156 public:
157 virtual ~PDFiumSearchHandle() = default;
159 virtual bool findNext() = 0;
160 virtual bool findPrev() = 0;
161 virtual int getSearchResultIndex() = 0;
162 virtual int getSearchCount() = 0;
165 class VCL_DLLPUBLIC PDFiumTextPage
167 public:
168 virtual ~PDFiumTextPage() = default;
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;
175 /// Returned rect is no longer upside down and is in mm100.
176 virtual basegfx::B2DRectangle getCharBox(int nIndex, double fPageHeight) = 0;
179 class VCL_DLLPUBLIC PDFiumPage
181 public:
182 virtual ~PDFiumPage() = default;
184 virtual int getObjectCount() = 0;
185 virtual std::unique_ptr<PDFiumPageObject> getObject(int nIndex) = 0;
187 virtual int getAnnotationCount() = 0;
188 virtual int getAnnotationIndex(std::unique_ptr<PDFiumAnnotation> const& rAnnotation) = 0;
190 virtual std::unique_ptr<PDFiumAnnotation> getAnnotation(int nIndex) = 0;
192 virtual std::unique_ptr<PDFiumTextPage> getTextPage() = 0;
194 /// Get bitmap checksum of the page, without annotations/commenting.
195 virtual BitmapChecksum getChecksum(int nMDPPerm) = 0;
197 virtual double getWidth() = 0;
198 virtual double getHeight() = 0;
200 virtual bool hasTransparency() = 0;
202 virtual bool hasLinks() = 0;
204 virtual void onAfterLoadPage(PDFiumDocument* pDoc) = 0;
207 /// Represents one digital signature, as exposed by PDFium.
208 class VCL_DLLPUBLIC PDFiumSignature
210 public:
211 virtual ~PDFiumSignature() = default;
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;
221 class VCL_DLLPUBLIC PDFiumDocument
223 public:
224 virtual ~PDFiumDocument() = default;
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;
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;
238 struct VCL_DLLPUBLIC PDFiumLibrary final
240 static std::shared_ptr<PDFium>& get();
243 // Tools
245 VCL_DLLPUBLIC OUString convertPdfDateToISO8601(std::u16string_view rInput);
247 } // namespace vcl::pdf
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */