LuckRafly commited on
Commit
a4f2c84
1 Parent(s): 2db9fa0

Upload 478 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +4 -0
  2. poppler-23.11.0/Library/bin/Lerc.dll +0 -0
  3. poppler-23.11.0/Library/bin/cairo.dll +3 -0
  4. poppler-23.11.0/Library/bin/charset.dll +0 -0
  5. poppler-23.11.0/Library/bin/deflate.dll +0 -0
  6. poppler-23.11.0/Library/bin/expat.dll +0 -0
  7. poppler-23.11.0/Library/bin/fontconfig-1.dll +0 -0
  8. poppler-23.11.0/Library/bin/freetype.dll +0 -0
  9. poppler-23.11.0/Library/bin/iconv.dll +0 -0
  10. poppler-23.11.0/Library/bin/jpeg8.dll +0 -0
  11. poppler-23.11.0/Library/bin/lcms2.dll +0 -0
  12. poppler-23.11.0/Library/bin/libcrypto-3-x64.dll +3 -0
  13. poppler-23.11.0/Library/bin/libcurl.dll +0 -0
  14. poppler-23.11.0/Library/bin/libexpat.dll +0 -0
  15. poppler-23.11.0/Library/bin/liblzma.dll +0 -0
  16. poppler-23.11.0/Library/bin/libpng16.dll +0 -0
  17. poppler-23.11.0/Library/bin/libssh2.dll +0 -0
  18. poppler-23.11.0/Library/bin/libtiff.dll +0 -0
  19. poppler-23.11.0/Library/bin/libzstd.dll +0 -0
  20. poppler-23.11.0/Library/bin/openjp2.dll +0 -0
  21. poppler-23.11.0/Library/bin/pdfattach.exe +0 -0
  22. poppler-23.11.0/Library/bin/pdfdetach.exe +0 -0
  23. poppler-23.11.0/Library/bin/pdffonts.exe +0 -0
  24. poppler-23.11.0/Library/bin/pdfimages.exe +0 -0
  25. poppler-23.11.0/Library/bin/pdfinfo.exe +0 -0
  26. poppler-23.11.0/Library/bin/pdfseparate.exe +0 -0
  27. poppler-23.11.0/Library/bin/pdftocairo.exe +0 -0
  28. poppler-23.11.0/Library/bin/pdftohtml.exe +0 -0
  29. poppler-23.11.0/Library/bin/pdftoppm.exe +0 -0
  30. poppler-23.11.0/Library/bin/pdftops.exe +0 -0
  31. poppler-23.11.0/Library/bin/pdftotext.exe +0 -0
  32. poppler-23.11.0/Library/bin/pdfunite.exe +0 -0
  33. poppler-23.11.0/Library/bin/pixman-1-0.dll +0 -0
  34. poppler-23.11.0/Library/bin/poppler-cpp.dll +0 -0
  35. poppler-23.11.0/Library/bin/poppler-glib.dll +0 -0
  36. poppler-23.11.0/Library/bin/poppler.dll +3 -0
  37. poppler-23.11.0/Library/bin/tiff.dll +0 -0
  38. poppler-23.11.0/Library/bin/zlib.dll +0 -0
  39. poppler-23.11.0/Library/bin/zstd.dll +0 -0
  40. poppler-23.11.0/Library/bin/zstd.exe +0 -0
  41. poppler-23.11.0/Library/include/poppler/Annot.h +1784 -0
  42. poppler-23.11.0/Library/include/poppler/AnnotStampImageHelper.h +68 -0
  43. poppler-23.11.0/Library/include/poppler/Array.h +92 -0
  44. poppler-23.11.0/Library/include/poppler/BBoxOutputDev.h +54 -0
  45. poppler-23.11.0/Library/include/poppler/CMap.h +128 -0
  46. poppler-23.11.0/Library/include/poppler/CachedFile.h +149 -0
  47. poppler-23.11.0/Library/include/poppler/CairoFontEngine.h +143 -0
  48. poppler-23.11.0/Library/include/poppler/CairoOutputDev.h +537 -0
  49. poppler-23.11.0/Library/include/poppler/CairoRescaleBox.h +60 -0
  50. poppler-23.11.0/Library/include/poppler/Catalog.h +321 -0
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ poppler-23.11.0/Library/bin/cairo.dll filter=lfs diff=lfs merge=lfs -text
37
+ poppler-23.11.0/Library/bin/libcrypto-3-x64.dll filter=lfs diff=lfs merge=lfs -text
38
+ poppler-23.11.0/Library/bin/poppler.dll filter=lfs diff=lfs merge=lfs -text
39
+ poppler-23.11.0/Library/lib/poppler.lib filter=lfs diff=lfs merge=lfs -text
poppler-23.11.0/Library/bin/Lerc.dll ADDED
Binary file (520 kB). View file
 
poppler-23.11.0/Library/bin/cairo.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d41677d426dff76abe58600bfac9e7c845f6f0da9042eb7c22b64a3d5e533da
3
+ size 1016320
poppler-23.11.0/Library/bin/charset.dll ADDED
Binary file (11.8 kB). View file
 
poppler-23.11.0/Library/bin/deflate.dll ADDED
Binary file (171 kB). View file
 
poppler-23.11.0/Library/bin/expat.dll ADDED
Binary file (402 kB). View file
 
poppler-23.11.0/Library/bin/fontconfig-1.dll ADDED
Binary file (283 kB). View file
 
poppler-23.11.0/Library/bin/freetype.dll ADDED
Binary file (671 kB). View file
 
poppler-23.11.0/Library/bin/iconv.dll ADDED
Binary file (938 kB). View file
 
poppler-23.11.0/Library/bin/jpeg8.dll ADDED
Binary file (803 kB). View file
 
poppler-23.11.0/Library/bin/lcms2.dll ADDED
Binary file (548 kB). View file
 
poppler-23.11.0/Library/bin/libcrypto-3-x64.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2108d58bcd283f875a4f4c9c4d6c25ba2ac7fef1d0a7c22ba957403033f96e03
3
+ size 6194176
poppler-23.11.0/Library/bin/libcurl.dll ADDED
Binary file (567 kB). View file
 
poppler-23.11.0/Library/bin/libexpat.dll ADDED
Binary file (402 kB). View file
 
poppler-23.11.0/Library/bin/liblzma.dll ADDED
Binary file (155 kB). View file
 
poppler-23.11.0/Library/bin/libpng16.dll ADDED
Binary file (195 kB). View file
 
poppler-23.11.0/Library/bin/libssh2.dll ADDED
Binary file (244 kB). View file
 
poppler-23.11.0/Library/bin/libtiff.dll ADDED
Binary file (483 kB). View file
 
poppler-23.11.0/Library/bin/libzstd.dll ADDED
Binary file (651 kB). View file
 
poppler-23.11.0/Library/bin/openjp2.dll ADDED
Binary file (353 kB). View file
 
poppler-23.11.0/Library/bin/pdfattach.exe ADDED
Binary file (22.5 kB). View file
 
poppler-23.11.0/Library/bin/pdfdetach.exe ADDED
Binary file (27.6 kB). View file
 
poppler-23.11.0/Library/bin/pdffonts.exe ADDED
Binary file (25.1 kB). View file
 
poppler-23.11.0/Library/bin/pdfimages.exe ADDED
Binary file (51.7 kB). View file
 
poppler-23.11.0/Library/bin/pdfinfo.exe ADDED
Binary file (65 kB). View file
 
poppler-23.11.0/Library/bin/pdfseparate.exe ADDED
Binary file (24.1 kB). View file
 
poppler-23.11.0/Library/bin/pdftocairo.exe ADDED
Binary file (168 kB). View file
 
poppler-23.11.0/Library/bin/pdftohtml.exe ADDED
Binary file (116 kB). View file
 
poppler-23.11.0/Library/bin/pdftoppm.exe ADDED
Binary file (48.1 kB). View file
 
poppler-23.11.0/Library/bin/pdftops.exe ADDED
Binary file (48.1 kB). View file
 
poppler-23.11.0/Library/bin/pdftotext.exe ADDED
Binary file (56.8 kB). View file
 
poppler-23.11.0/Library/bin/pdfunite.exe ADDED
Binary file (37.4 kB). View file
 
poppler-23.11.0/Library/bin/pixman-1-0.dll ADDED
Binary file (586 kB). View file
 
poppler-23.11.0/Library/bin/poppler-cpp.dll ADDED
Binary file (157 kB). View file
 
poppler-23.11.0/Library/bin/poppler-glib.dll ADDED
Binary file (408 kB). View file
 
poppler-23.11.0/Library/bin/poppler.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2252a2476bf23c24d65fed0fe0d12ee314feb9d935d6379c2838cd3c49b1a89
3
+ size 5005824
poppler-23.11.0/Library/bin/tiff.dll ADDED
Binary file (483 kB). View file
 
poppler-23.11.0/Library/bin/zlib.dll ADDED
Binary file (89.1 kB). View file
 
poppler-23.11.0/Library/bin/zstd.dll ADDED
Binary file (651 kB). View file
 
poppler-23.11.0/Library/bin/zstd.exe ADDED
Binary file (152 kB). View file
 
poppler-23.11.0/Library/include/poppler/Annot.h ADDED
@@ -0,0 +1,1784 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // Annot.h
4
+ //
5
+ // Copyright 2000-2003 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ //========================================================================
10
+ //
11
+ // Modified under the Poppler project - http://poppler.freedesktop.org
12
+ //
13
+ // All changes made under the Poppler project to this file are licensed
14
+ // under GPL version 2 or later
15
+ //
16
+ // Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
17
+ // Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
18
+ // Copyright (C) 2007-2011, 2013, 2015, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
19
+ // Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
20
+ // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
21
+ // Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
22
+ // Copyright (C) 2008 Pino Toscano <pino@kde.org>
23
+ // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
24
+ // Copyright (C) 2009-2011, 2013, 2016-2023 Albert Astals Cid <aacid@kde.org>
25
+ // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
26
+ // Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com>
27
+ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
28
+ // Copyright (C) 2013, 2017, 2023 Adrian Johnson <ajohnson@redneon.com>
29
+ // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
30
+ // Copyright (C) 2018 Dileep Sankhla <sankhla.dileep96@gmail.com>
31
+ // Copyright (C) 2018-2020 Tobias Deiminger <haxtibal@posteo.de>
32
+ // Copyright (C) 2018, 2020, 2022 Oliver Sander <oliver.sander@tu-dresden.de>
33
+ // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
34
+ // Copyright (C) 2019 Umang Malik <umang99m@gmail.com>
35
+ // Copyright (C) 2019 João Netto <joaonetto901@gmail.com>
36
+ // Copyright (C) 2020 Nelson Benítez León <nbenitezl@gmail.com>
37
+ // Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden
38
+ // Copyright (C) 2020 Katarina Behrens <Katarina.Behrens@cib.de>
39
+ // Copyright (C) 2020 Thorsten Behrens <Thorsten.Behrens@CIB.de>
40
+ // Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>.
41
+ // Copyright (C) 2021 Zachary Travis <ztravis@everlaw.com>
42
+ // Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>
43
+ // Copyright (C) 2021 Georgiy Sgibnev <georgiy@sgibnev.com>. Work sponsored by lab50.net.
44
+ // Copyright (C) 2022 Martin <martinbts@gmx.net>
45
+ //
46
+ // To see a description of the changes please see the Changelog file that
47
+ // came with your tarball or type make ChangeLog if you are building from git
48
+ //
49
+ //========================================================================
50
+
51
+ #ifndef ANNOT_H
52
+ #define ANNOT_H
53
+
54
+ #include <memory>
55
+ #include <atomic>
56
+ #include <mutex>
57
+ #include <vector>
58
+
59
+ #include "AnnotStampImageHelper.h"
60
+ #include "Object.h"
61
+ #include "poppler_private_export.h"
62
+
63
+ class XRef;
64
+ class Gfx;
65
+ class CharCodeToUnicode;
66
+ class GfxFont;
67
+ class GfxResources;
68
+ class Page;
69
+ class PDFDoc;
70
+ class Form;
71
+ class FormWidget;
72
+ class FormField;
73
+ class FormFieldButton;
74
+ class FormFieldText;
75
+ class FormFieldChoice;
76
+ class FormFieldSignature;
77
+ class PDFRectangle;
78
+ class Movie;
79
+ class LinkAction;
80
+ class Sound;
81
+ class FileSpec;
82
+
83
+ enum AnnotLineEndingStyle
84
+ {
85
+ annotLineEndingSquare, // Square
86
+ annotLineEndingCircle, // Circle
87
+ annotLineEndingDiamond, // Diamond
88
+ annotLineEndingOpenArrow, // OpenArrow
89
+ annotLineEndingClosedArrow, // ClosedArrow
90
+ annotLineEndingNone, // None
91
+ annotLineEndingButt, // Butt
92
+ annotLineEndingROpenArrow, // ROpenArrow
93
+ annotLineEndingRClosedArrow, // RClosedArrow
94
+ annotLineEndingSlash // Slash
95
+ };
96
+
97
+ enum AnnotExternalDataType
98
+ {
99
+ annotExternalDataMarkupUnknown,
100
+ annotExternalDataMarkup3D // Markup3D
101
+ };
102
+
103
+ enum class VariableTextQuadding
104
+ {
105
+ leftJustified,
106
+ centered,
107
+ rightJustified
108
+ };
109
+
110
+ //------------------------------------------------------------------------
111
+ // AnnotCoord
112
+ //------------------------------------------------------------------------
113
+
114
+ class AnnotCoord
115
+ {
116
+ public:
117
+ AnnotCoord() : x(0), y(0) { }
118
+ AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
119
+
120
+ double getX() const { return x; }
121
+ double getY() const { return y; }
122
+
123
+ protected:
124
+ double x, y;
125
+ };
126
+
127
+ //------------------------------------------------------------------------
128
+ // AnnotPath
129
+ //------------------------------------------------------------------------
130
+
131
+ class POPPLER_PRIVATE_EXPORT AnnotPath
132
+ {
133
+ public:
134
+ AnnotPath();
135
+ explicit AnnotPath(Array *array);
136
+ explicit AnnotPath(std::vector<AnnotCoord> &&coords);
137
+ ~AnnotPath();
138
+
139
+ AnnotPath(const AnnotPath &) = delete;
140
+ AnnotPath &operator=(const AnnotPath &other) = delete;
141
+
142
+ double getX(int coord) const;
143
+ double getY(int coord) const;
144
+ AnnotCoord *getCoord(int coord);
145
+ int getCoordsLength() const { return coords.size(); }
146
+
147
+ protected:
148
+ std::vector<AnnotCoord> coords;
149
+
150
+ void parsePathArray(Array *array);
151
+ };
152
+
153
+ //------------------------------------------------------------------------
154
+ // AnnotCalloutLine
155
+ //------------------------------------------------------------------------
156
+
157
+ class POPPLER_PRIVATE_EXPORT AnnotCalloutLine
158
+ {
159
+ public:
160
+ AnnotCalloutLine(double x1, double y1, double x2, double y2);
161
+ virtual ~AnnotCalloutLine();
162
+
163
+ AnnotCalloutLine(const AnnotCalloutLine &) = delete;
164
+ AnnotCalloutLine &operator=(const AnnotCalloutLine &other) = delete;
165
+
166
+ double getX1() const { return coord1.getX(); }
167
+ double getY1() const { return coord1.getY(); }
168
+ double getX2() const { return coord2.getX(); }
169
+ double getY2() const { return coord2.getY(); }
170
+
171
+ protected:
172
+ AnnotCoord coord1, coord2;
173
+ };
174
+
175
+ //------------------------------------------------------------------------
176
+ // AnnotCalloutMultiLine
177
+ //------------------------------------------------------------------------
178
+
179
+ class POPPLER_PRIVATE_EXPORT AnnotCalloutMultiLine : public AnnotCalloutLine
180
+ {
181
+ public:
182
+ AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, double x3, double y3);
183
+ ~AnnotCalloutMultiLine() override;
184
+
185
+ double getX3() const { return coord3.getX(); }
186
+ double getY3() const { return coord3.getY(); }
187
+
188
+ protected:
189
+ AnnotCoord coord3;
190
+ };
191
+
192
+ //------------------------------------------------------------------------
193
+ // AnnotBorderEffect
194
+ //------------------------------------------------------------------------
195
+
196
+ class AnnotBorderEffect
197
+ {
198
+ public:
199
+ enum AnnotBorderEffectType
200
+ {
201
+ borderEffectNoEffect, // S
202
+ borderEffectCloudy // C
203
+ };
204
+
205
+ explicit AnnotBorderEffect(Dict *dict);
206
+
207
+ AnnotBorderEffectType getEffectType() const { return effectType; }
208
+ double getIntensity() const { return intensity; }
209
+
210
+ private:
211
+ AnnotBorderEffectType effectType; // S (Default S)
212
+ double intensity; // I (Default 0)
213
+ };
214
+
215
+ //------------------------------------------------------------------------
216
+ // AnnotQuadrilateral
217
+ //------------------------------------------------------------------------
218
+
219
+ class POPPLER_PRIVATE_EXPORT AnnotQuadrilaterals
220
+ {
221
+ public:
222
+ class POPPLER_PRIVATE_EXPORT AnnotQuadrilateral
223
+ {
224
+ public:
225
+ AnnotQuadrilateral();
226
+ AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
227
+
228
+ AnnotCoord coord1, coord2, coord3, coord4;
229
+ };
230
+
231
+ AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
232
+ AnnotQuadrilaterals(std::unique_ptr<AnnotQuadrilateral[]> &&quads, int quadsLength);
233
+ ~AnnotQuadrilaterals();
234
+
235
+ AnnotQuadrilaterals(const AnnotQuadrilaterals &) = delete;
236
+ AnnotQuadrilaterals &operator=(const AnnotQuadrilaterals &other) = delete;
237
+
238
+ double getX1(int quadrilateral);
239
+ double getY1(int quadrilateral);
240
+ double getX2(int quadrilateral);
241
+ double getY2(int quadrilateral);
242
+ double getX3(int quadrilateral);
243
+ double getY3(int quadrilateral);
244
+ double getX4(int quadrilateral);
245
+ double getY4(int quadrilateral);
246
+ int getQuadrilateralsLength() const { return quadrilateralsLength; }
247
+
248
+ protected:
249
+ std::unique_ptr<AnnotQuadrilateral[]> quadrilaterals;
250
+ int quadrilateralsLength;
251
+ };
252
+
253
+ //------------------------------------------------------------------------
254
+ // AnnotBorder
255
+ //------------------------------------------------------------------------
256
+
257
+ class POPPLER_PRIVATE_EXPORT AnnotBorder
258
+ {
259
+ public:
260
+ enum AnnotBorderType
261
+ {
262
+ typeArray,
263
+ typeBS
264
+ };
265
+
266
+ enum AnnotBorderStyle
267
+ {
268
+ borderSolid, // Solid
269
+ borderDashed, // Dashed
270
+ borderBeveled, // Beveled
271
+ borderInset, // Inset
272
+ borderUnderlined // Underlined
273
+ };
274
+
275
+ virtual ~AnnotBorder();
276
+
277
+ AnnotBorder(const AnnotBorder &) = delete;
278
+ AnnotBorder &operator=(const AnnotBorder &other) = delete;
279
+
280
+ virtual void setWidth(double new_width) { width = new_width; }
281
+
282
+ virtual AnnotBorderType getType() const = 0;
283
+ virtual double getWidth() const { return width; }
284
+ virtual const std::vector<double> &getDash() const { return dash; }
285
+ virtual AnnotBorderStyle getStyle() const { return style; }
286
+
287
+ virtual Object writeToObject(XRef *xref) const = 0;
288
+ virtual std::unique_ptr<AnnotBorder> copy() const = 0;
289
+
290
+ protected:
291
+ AnnotBorder();
292
+
293
+ bool parseDashArray(Object *dashObj);
294
+
295
+ AnnotBorderType type;
296
+ double width;
297
+ static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H.
298
+ std::vector<double> dash;
299
+ AnnotBorderStyle style;
300
+ };
301
+
302
+ //------------------------------------------------------------------------
303
+ // AnnotBorderArray
304
+ //------------------------------------------------------------------------
305
+
306
+ class POPPLER_PRIVATE_EXPORT AnnotBorderArray : public AnnotBorder
307
+ {
308
+ public:
309
+ AnnotBorderArray();
310
+ explicit AnnotBorderArray(Array *array);
311
+
312
+ void setHorizontalCorner(double hc) { horizontalCorner = hc; }
313
+ void setVerticalCorner(double vc) { verticalCorner = vc; }
314
+
315
+ double getHorizontalCorner() const { return horizontalCorner; }
316
+ double getVerticalCorner() const { return verticalCorner; }
317
+
318
+ std::unique_ptr<AnnotBorder> copy() const override;
319
+
320
+ private:
321
+ AnnotBorderType getType() const override { return typeArray; }
322
+ Object writeToObject(XRef *xref) const override;
323
+
324
+ double horizontalCorner; // (Default 0)
325
+ double verticalCorner; // (Default 0)
326
+ // double width; // (Default 1) (inherited from AnnotBorder)
327
+ };
328
+
329
+ //------------------------------------------------------------------------
330
+ // AnnotBorderBS
331
+ //------------------------------------------------------------------------
332
+
333
+ class AnnotBorderBS : public AnnotBorder
334
+ {
335
+ public:
336
+ AnnotBorderBS();
337
+ explicit AnnotBorderBS(Dict *dict);
338
+
339
+ private:
340
+ AnnotBorderType getType() const override { return typeBS; }
341
+ Object writeToObject(XRef *xref) const override;
342
+
343
+ const char *getStyleName() const;
344
+
345
+ std::unique_ptr<AnnotBorder> copy() const override;
346
+
347
+ // double width; // W (Default 1) (inherited from AnnotBorder)
348
+ // AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder)
349
+ // double *dash; // D (Default [3]) (inherited from AnnotBorder)
350
+ };
351
+
352
+ //------------------------------------------------------------------------
353
+ // AnnotColor
354
+ //------------------------------------------------------------------------
355
+
356
+ class POPPLER_PRIVATE_EXPORT AnnotColor
357
+ {
358
+ public:
359
+ enum AnnotColorSpace
360
+ {
361
+ colorTransparent = 0,
362
+ colorGray = 1,
363
+ colorRGB = 3,
364
+ colorCMYK = 4
365
+ };
366
+
367
+ AnnotColor();
368
+ explicit AnnotColor(double gray);
369
+ AnnotColor(double r, double g, double b);
370
+ AnnotColor(double c, double m, double y, double k);
371
+ explicit AnnotColor(Array *array, int adjust = 0);
372
+
373
+ void adjustColor(int adjust);
374
+
375
+ AnnotColorSpace getSpace() const { return (AnnotColorSpace)length; }
376
+ const double *getValues() const { return values; }
377
+
378
+ Object writeToObject(XRef *xref) const;
379
+
380
+ private:
381
+ double values[4];
382
+ int length;
383
+ };
384
+
385
+ //------------------------------------------------------------------------
386
+ // DefaultAppearance
387
+ //------------------------------------------------------------------------
388
+
389
+ class POPPLER_PRIVATE_EXPORT DefaultAppearance
390
+ {
391
+ public:
392
+ DefaultAppearance(Object &&fontNameA, double fontPtSizeA, std::unique_ptr<AnnotColor> &&fontColorA);
393
+ explicit DefaultAppearance(const GooString *da);
394
+ void setFontName(Object &&fontNameA);
395
+ const Object &getFontName() const { return fontName; }
396
+ void setFontPtSize(double fontPtSizeA);
397
+ double getFontPtSize() const { return fontPtSize; }
398
+ void setFontColor(std::unique_ptr<AnnotColor> fontColorA);
399
+ const AnnotColor *getFontColor() const { return fontColor.get(); }
400
+ std::string toAppearanceString() const;
401
+
402
+ DefaultAppearance(const DefaultAppearance &) = delete;
403
+ DefaultAppearance &operator=(const DefaultAppearance &) = delete;
404
+
405
+ private:
406
+ Object fontName;
407
+ double fontPtSize;
408
+ std::unique_ptr<AnnotColor> fontColor;
409
+ };
410
+
411
+ //------------------------------------------------------------------------
412
+ // AnnotIconFit
413
+ //------------------------------------------------------------------------
414
+
415
+ class AnnotIconFit
416
+ {
417
+ public:
418
+ enum AnnotIconFitScaleWhen
419
+ {
420
+ scaleAlways, // A
421
+ scaleBigger, // B
422
+ scaleSmaller, // S
423
+ scaleNever // N
424
+ };
425
+
426
+ enum AnnotIconFitScale
427
+ {
428
+ scaleAnamorphic, // A
429
+ scaleProportional // P
430
+ };
431
+
432
+ explicit AnnotIconFit(Dict *dict);
433
+
434
+ AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; }
435
+ AnnotIconFitScale getScale() { return scale; }
436
+ double getLeft() { return left; }
437
+ double getBottom() { return bottom; }
438
+ bool getFullyBounds() { return fullyBounds; }
439
+
440
+ protected:
441
+ AnnotIconFitScaleWhen scaleWhen; // SW (Default A)
442
+ AnnotIconFitScale scale; // S (Default P)
443
+ double left; // A (Default [0.5 0.5]
444
+ double bottom; // Only if scale is P
445
+ bool fullyBounds; // FB (Default false)
446
+ };
447
+
448
+ //------------------------------------------------------------------------
449
+ // AnnotAppearance
450
+ //------------------------------------------------------------------------
451
+
452
+ class AnnotAppearance
453
+ {
454
+ public:
455
+ enum AnnotAppearanceType
456
+ {
457
+ appearNormal,
458
+ appearRollover,
459
+ appearDown
460
+ };
461
+
462
+ AnnotAppearance(PDFDoc *docA, Object *dict);
463
+ ~AnnotAppearance();
464
+
465
+ // State is ignored if no subdictionary is present
466
+ Object getAppearanceStream(AnnotAppearanceType type, const char *state);
467
+
468
+ // Access keys in normal appearance subdictionary (N)
469
+ std::unique_ptr<GooString> getStateKey(int i);
470
+ int getNumStates();
471
+
472
+ // Removes all associated streams in the xref table. Caller is required to
473
+ // reset parent annotation's AP and AS after this call.
474
+ void removeAllStreams();
475
+
476
+ // Test if this AnnotAppearance references the specified stream
477
+ bool referencesStream(Ref refToStream);
478
+
479
+ private:
480
+ static bool referencesStream(const Object *stateObj, Ref refToStream);
481
+ void removeStream(Ref refToStream);
482
+ void removeStateStreams(const Object *state);
483
+
484
+ protected:
485
+ PDFDoc *doc;
486
+ Object appearDict; // Annotation's AP
487
+ };
488
+
489
+ //------------------------------------------------------------------------
490
+ // AnnotAppearanceCharacs
491
+ //------------------------------------------------------------------------
492
+
493
+ class POPPLER_PRIVATE_EXPORT AnnotAppearanceCharacs
494
+ {
495
+ public:
496
+ enum AnnotAppearanceCharacsTextPos
497
+ {
498
+ captionNoIcon, // 0
499
+ captionNoCaption, // 1
500
+ captionBelow, // 2
501
+ captionAbove, // 3
502
+ captionRight, // 4
503
+ captionLeft, // 5
504
+ captionOverlaid // 6
505
+ };
506
+
507
+ explicit AnnotAppearanceCharacs(Dict *dict);
508
+ ~AnnotAppearanceCharacs();
509
+
510
+ AnnotAppearanceCharacs(const AnnotAppearanceCharacs &) = delete;
511
+ AnnotAppearanceCharacs &operator=(const AnnotAppearanceCharacs &) = delete;
512
+
513
+ int getRotation() const { return rotation; }
514
+ const AnnotColor *getBorderColor() const { return borderColor.get(); }
515
+ void setBorderColor(std::unique_ptr<AnnotColor> &&color) { borderColor = std::move(color); }
516
+ const AnnotColor *getBackColor() const { return backColor.get(); }
517
+ void setBackColor(std::unique_ptr<AnnotColor> &&color) { backColor = std::move(color); }
518
+ const GooString *getNormalCaption() const { return normalCaption.get(); }
519
+ const GooString *getRolloverCaption() { return rolloverCaption.get(); }
520
+ const GooString *getAlternateCaption() { return alternateCaption.get(); }
521
+ const AnnotIconFit *getIconFit() { return iconFit.get(); }
522
+ AnnotAppearanceCharacsTextPos getPosition() const { return position; }
523
+
524
+ std::unique_ptr<AnnotAppearanceCharacs> copy() const;
525
+
526
+ protected:
527
+ int rotation; // R (Default 0)
528
+ std::unique_ptr<AnnotColor> borderColor; // BC
529
+ std::unique_ptr<AnnotColor> backColor; // BG
530
+ std::unique_ptr<GooString> normalCaption; // CA
531
+ std::unique_ptr<GooString> rolloverCaption; // RC
532
+ std::unique_ptr<GooString> alternateCaption; // AC
533
+ // I
534
+ // RI
535
+ // IX
536
+ std::unique_ptr<AnnotIconFit> iconFit; // IF
537
+ AnnotAppearanceCharacsTextPos position; // TP (Default 0)
538
+ };
539
+
540
+ //------------------------------------------------------------------------
541
+ // AnnotAppearanceBBox
542
+ //------------------------------------------------------------------------
543
+
544
+ class AnnotAppearanceBBox
545
+ {
546
+ public:
547
+ explicit AnnotAppearanceBBox(PDFRectangle *rect);
548
+
549
+ void setBorderWidth(double w) { borderWidth = w; }
550
+
551
+ // The following functions operate on coords relative to [origX origY]
552
+ void extendTo(double x, double y);
553
+ void getBBoxRect(double bbox[4]) const;
554
+
555
+ // Get boundaries in page coordinates
556
+ double getPageXMin() const;
557
+ double getPageYMin() const;
558
+ double getPageXMax() const;
559
+ double getPageYMax() const;
560
+
561
+ private:
562
+ double origX, origY, borderWidth;
563
+ double minX, minY, maxX, maxY;
564
+ };
565
+
566
+ //------------------------------------------------------------------------
567
+ // AnnotAppearanceBuilder
568
+ //------------------------------------------------------------------------
569
+ class Matrix;
570
+
571
+ class AnnotAppearanceBuilder
572
+ {
573
+ public:
574
+ AnnotAppearanceBuilder();
575
+ ~AnnotAppearanceBuilder();
576
+
577
+ AnnotAppearanceBuilder(const AnnotAppearanceBuilder &) = delete;
578
+ AnnotAppearanceBuilder &operator=(const AnnotAppearanceBuilder &) = delete;
579
+
580
+ void setDrawColor(const AnnotColor *color, bool fill);
581
+ void setLineStyleForBorder(const AnnotBorder *border);
582
+ void setTextFont(const Object &fontName, double fontSize);
583
+ void drawCircle(double cx, double cy, double r, bool fill);
584
+ void drawEllipse(double cx, double cy, double rx, double ry, bool fill, bool stroke);
585
+ void drawCircleTopLeft(double cx, double cy, double r);
586
+ void drawCircleBottomRight(double cx, double cy, double r);
587
+ void drawLineEnding(AnnotLineEndingStyle endingStyle, double x, double y, double size, bool fill, const Matrix &m);
588
+ void drawLineEndSquare(double x, double y, double size, bool fill, const Matrix &m);
589
+ void drawLineEndCircle(double x, double y, double size, bool fill, const Matrix &m);
590
+ void drawLineEndDiamond(double x, double y, double size, bool fill, const Matrix &m);
591
+ void drawLineEndArrow(double x, double y, double size, int orientation, bool isOpen, bool fill, const Matrix &m);
592
+ void drawLineEndSlash(double x, double y, double size, const Matrix &m);
593
+ void drawFieldBorder(const FormField *field, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect);
594
+ bool drawFormField(const FormField *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
595
+ const GooString *appearState, XRef *xref, Dict *resourcesDict);
596
+ static double lineEndingXShorten(AnnotLineEndingStyle endingStyle, double size);
597
+ static double lineEndingXExtendBBox(AnnotLineEndingStyle endingStyle, double size);
598
+ void writeString(const std::string &str);
599
+
600
+ void append(const char *text);
601
+ void appendf(const char *fmt, ...) GOOSTRING_FORMAT;
602
+
603
+ const GooString *buffer() const;
604
+
605
+ private:
606
+ enum DrawTextFlags
607
+ {
608
+ NoDrawTextFlags = 0,
609
+ MultilineDrawTextFlag = 1,
610
+ EmitMarkedContentDrawTextFlag = 2,
611
+ ForceZapfDingbatsDrawTextFlag = 4,
612
+ TurnTextToStarsDrawTextFlag = 8
613
+ };
614
+
615
+ bool drawListBox(const FormFieldChoice *fieldChoice, const AnnotBorder *border, const PDFRectangle *rect, const GooString *da, const GfxResources *resources, VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict);
616
+ bool drawFormFieldButton(const FormFieldButton *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
617
+ const GooString *appearState, XRef *xref, Dict *resourcesDict);
618
+ bool drawFormFieldText(const FormFieldText *fieldText, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, XRef *xref,
619
+ Dict *resourcesDict);
620
+ bool drawFormFieldChoice(const FormFieldChoice *fieldChoice, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
621
+ XRef *xref, Dict *resourcesDict);
622
+ bool drawSignatureFieldText(const FormFieldSignature *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
623
+ XRef *xref, Dict *resourcesDict);
624
+ void drawSignatureFieldText(const GooString &text, const Form *form, const DefaultAppearance &da, const AnnotBorder *border, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict, double leftMargin, bool centerVertically,
625
+ bool centerHorizontally);
626
+ bool drawText(const GooString *text, const Form *form, const GooString *da, const GfxResources *resources, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
627
+ const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags = NoDrawTextFlags, const int nCombs = 0);
628
+ void drawArrowPath(double x, double y, const Matrix &m, int orientation = 1);
629
+
630
+ GooString *appearBuf;
631
+ };
632
+
633
+ //------------------------------------------------------------------------
634
+ // Annot
635
+ //------------------------------------------------------------------------
636
+
637
+ class POPPLER_PRIVATE_EXPORT Annot
638
+ {
639
+ friend class Annots;
640
+ friend class Page;
641
+
642
+ public:
643
+ enum AnnotFlag
644
+ {
645
+ flagUnknown = 0x0000,
646
+ flagInvisible = 0x0001,
647
+ flagHidden = 0x0002,
648
+ flagPrint = 0x0004,
649
+ flagNoZoom = 0x0008,
650
+ flagNoRotate = 0x0010,
651
+ flagNoView = 0x0020,
652
+ flagReadOnly = 0x0040,
653
+ flagLocked = 0x0080,
654
+ flagToggleNoView = 0x0100,
655
+ flagLockedContents = 0x0200
656
+ };
657
+
658
+ enum AnnotSubtype
659
+ {
660
+ typeUnknown, // 0
661
+ typeText, // Text 1
662
+ typeLink, // Link 2
663
+ typeFreeText, // FreeText 3
664
+ typeLine, // Line 4
665
+ typeSquare, // Square 5
666
+ typeCircle, // Circle 6
667
+ typePolygon, // Polygon 7
668
+ typePolyLine, // PolyLine 8
669
+ typeHighlight, // Highlight 9
670
+ typeUnderline, // Underline 10
671
+ typeSquiggly, // Squiggly 11
672
+ typeStrikeOut, // StrikeOut 12
673
+ typeStamp, // Stamp 13
674
+ typeCaret, // Caret 14
675
+ typeInk, // Ink 15
676
+ typePopup, // Popup 16
677
+ typeFileAttachment, // FileAttachment 17
678
+ typeSound, // Sound 18
679
+ typeMovie, // Movie 19
680
+ typeWidget, // Widget 20
681
+ typeScreen, // Screen 21
682
+ typePrinterMark, // PrinterMark 22
683
+ typeTrapNet, // TrapNet 23
684
+ typeWatermark, // Watermark 24
685
+ type3D, // 3D 25
686
+ typeRichMedia // RichMedia 26
687
+ };
688
+
689
+ /**
690
+ * Describes the additional actions of a screen or widget annotation.
691
+ */
692
+ enum AdditionalActionsType
693
+ {
694
+ actionCursorEntering, ///< Performed when the cursor enters the annotation's active area
695
+ actionCursorLeaving, ///< Performed when the cursor exists the annotation's active area
696
+ actionMousePressed, ///< Performed when the mouse button is pressed inside the annotation's active area
697
+ actionMouseReleased, ///< Performed when the mouse button is released inside the annotation's active area
698
+ actionFocusIn, ///< Performed when the annotation receives the input focus
699
+ actionFocusOut, ///< Performed when the annotation loses the input focus
700
+ actionPageOpening, ///< Performed when the page containing the annotation is opened
701
+ actionPageClosing, ///< Performed when the page containing the annotation is closed
702
+ actionPageVisible, ///< Performed when the page containing the annotation becomes visible
703
+ actionPageInvisible ///< Performed when the page containing the annotation becomes invisible
704
+ };
705
+
706
+ enum FormAdditionalActionsType
707
+ {
708
+ actionFieldModified, ///< Performed when the when the user modifies the field
709
+ actionFormatField, ///< Performed before the field is formatted to display its value
710
+ actionValidateField, ///< Performed when the field value changes
711
+ actionCalculateField, ///< Performed when the field needs to be recalculated
712
+ };
713
+
714
+ Annot(PDFDoc *docA, PDFRectangle *rectA);
715
+ Annot(PDFDoc *docA, Object &&dictObject);
716
+ Annot(PDFDoc *docA, Object &&dictObject, const Object *obj);
717
+ bool isOk() { return ok; }
718
+
719
+ void incRefCnt();
720
+ void decRefCnt();
721
+
722
+ virtual void draw(Gfx *gfx, bool printing);
723
+ // Get the resource dict of the appearance stream
724
+ virtual Object getAppearanceResDict();
725
+
726
+ bool match(const Ref *refA) const { return ref == *refA; }
727
+
728
+ double getXMin();
729
+ double getYMin();
730
+ double getXMax();
731
+ double getYMax();
732
+
733
+ void setRect(const PDFRectangle *rect);
734
+ void setRect(double x1, double y1, double x2, double y2);
735
+
736
+ // Sets the annot contents to new_content
737
+ // new_content should never be NULL
738
+ virtual void setContents(std::unique_ptr<GooString> &&new_content);
739
+ void setName(GooString *new_name);
740
+ void setModified(GooString *new_modified);
741
+ void setFlags(unsigned int new_flags);
742
+
743
+ void setBorder(std::unique_ptr<AnnotBorder> &&new_border);
744
+ void setColor(std::unique_ptr<AnnotColor> &&new_color);
745
+
746
+ void setAppearanceState(const char *state);
747
+
748
+ // getters
749
+ PDFDoc *getDoc() const { return doc; }
750
+ bool getHasRef() const { return hasRef; }
751
+ Ref getRef() const { return ref; }
752
+ const Object &getAnnotObj() const { return annotObj; }
753
+ AnnotSubtype getType() const { return type; }
754
+ const PDFRectangle &getRect() const { return *rect; }
755
+ void getRect(double *x1, double *y1, double *x2, double *y2) const;
756
+ const GooString *getContents() const { return contents.get(); }
757
+ int getPageNum() const { return page; }
758
+ const GooString *getName() const { return name.get(); }
759
+ const GooString *getModified() const { return modified.get(); }
760
+ unsigned int getFlags() const { return flags; }
761
+ Object getAppearance() const;
762
+ void setNewAppearance(Object &&newAppearance);
763
+ AnnotAppearance *getAppearStreams() const { return appearStreams.get(); }
764
+ const GooString *getAppearState() const { return appearState.get(); }
765
+ AnnotBorder *getBorder() const { return border.get(); }
766
+ AnnotColor *getColor() const { return color.get(); }
767
+ int getTreeKey() const { return treeKey; }
768
+
769
+ int getId() { return ref.num; }
770
+
771
+ // Check if point is inside the annot rectangle.
772
+ bool inRect(double x, double y) const;
773
+
774
+ // If newFontNeeded is not null, it will contain whether the given font has glyphs to represent the needed text
775
+ static void layoutText(const GooString *text, GooString *outBuf, int *i, const GfxFont &font, double *width, double widthLimit, int *charCount, bool noReencode, bool *newFontNeeded = nullptr);
776
+
777
+ private:
778
+ void readArrayNum(Object *pdfArray, int key, double *value);
779
+ // write vStr[i:j[ in appearBuf
780
+
781
+ void initialize(PDFDoc *docA, Dict *dict);
782
+ void setPage(int pageIndex, bool updateP); // Called by Page::addAnnot and Annots ctor
783
+
784
+ protected:
785
+ virtual ~Annot();
786
+ virtual void removeReferencedObjects(); // Called by Page::removeAnnot
787
+ Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Dict *resDict);
788
+ Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Object &&resDictObject); // overload to support incRef/decRef
789
+ Dict *createResourcesDict(const char *formName, Object &&formStream, const char *stateName, double opacity, const char *blendMode);
790
+ bool isVisible(bool printing);
791
+ int getRotation() const;
792
+
793
+ // Updates the field key of the annotation dictionary
794
+ // and sets M to the current time
795
+ void update(const char *key, Object &&value);
796
+
797
+ // Delete appearance streams and reset appearance state
798
+ virtual void invalidateAppearance();
799
+
800
+ Object annotObj;
801
+
802
+ std::atomic_int refCnt;
803
+
804
+ // required data
805
+ AnnotSubtype type; // Annotation type
806
+ std::unique_ptr<PDFRectangle> rect; // Rect
807
+
808
+ // optional data
809
+ std::unique_ptr<GooString> contents; // Contents
810
+ std::unique_ptr<GooString> name; // NM
811
+ std::unique_ptr<GooString> modified; // M
812
+ int page; // P
813
+ unsigned int flags; // F (must be a 32 bit unsigned int)
814
+ std::unique_ptr<AnnotAppearance> appearStreams; // AP
815
+ Object appearance; // a reference to the Form XObject stream
816
+ // for the normal appearance
817
+ std::unique_ptr<AnnotAppearanceBBox> appearBBox; // BBox of generated appearance
818
+ std::unique_ptr<GooString> appearState; // AS
819
+ int treeKey; // Struct Parent;
820
+ Object oc; // OC
821
+
822
+ PDFDoc *doc;
823
+ Ref ref; // object ref identifying this annotation
824
+ std::unique_ptr<AnnotBorder> border; // Border, BS
825
+ std::unique_ptr<AnnotColor> color; // C
826
+ bool ok;
827
+
828
+ bool hasRef;
829
+ mutable std::recursive_mutex mutex;
830
+
831
+ bool hasBeenUpdated = false;
832
+ };
833
+
834
+ //------------------------------------------------------------------------
835
+ // AnnotPopup
836
+ //------------------------------------------------------------------------
837
+
838
+ class POPPLER_PRIVATE_EXPORT AnnotPopup : public Annot
839
+ {
840
+ public:
841
+ AnnotPopup(PDFDoc *docA, PDFRectangle *rect);
842
+ AnnotPopup(PDFDoc *docA, Object &&dictObject, const Object *obj);
843
+ ~AnnotPopup() override;
844
+
845
+ bool hasParent() const { return parentRef != Ref::INVALID(); }
846
+ void setParent(Annot *parentA);
847
+ bool getOpen() const { return open; }
848
+ void setOpen(bool openA);
849
+
850
+ protected:
851
+ void initialize(PDFDoc *docA, Dict *dict);
852
+
853
+ Ref parentRef; // Parent
854
+ bool open; // Open
855
+ };
856
+
857
+ //------------------------------------------------------------------------
858
+ // AnnotMarkup
859
+ //------------------------------------------------------------------------
860
+
861
+ class POPPLER_PRIVATE_EXPORT AnnotMarkup : public Annot
862
+ {
863
+ public:
864
+ enum AnnotMarkupReplyType
865
+ {
866
+ replyTypeR, // R
867
+ replyTypeGroup // Group
868
+ };
869
+
870
+ AnnotMarkup(PDFDoc *docA, PDFRectangle *rect);
871
+ AnnotMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj);
872
+ ~AnnotMarkup() override;
873
+
874
+ // getters
875
+ const GooString *getLabel() const { return label.get(); }
876
+ AnnotPopup *getPopup() const { return popup.get(); }
877
+ double getOpacity() const { return opacity; }
878
+ // getRC
879
+ const GooString *getDate() const { return date.get(); }
880
+ bool isInReplyTo() const { return inReplyTo != Ref::INVALID(); }
881
+ int getInReplyToID() const { return inReplyTo.num; }
882
+ const GooString *getSubject() const { return subject.get(); }
883
+ AnnotMarkupReplyType getReplyTo() const { return replyTo; }
884
+ AnnotExternalDataType getExData() const { return exData; }
885
+
886
+ // The annotation takes the ownership of new_popup
887
+ void setPopup(std::unique_ptr<AnnotPopup> &&new_popup);
888
+ void setLabel(std::unique_ptr<GooString> &&new_label);
889
+ void setOpacity(double opacityA);
890
+ void setDate(GooString *new_date);
891
+
892
+ protected:
893
+ void removeReferencedObjects() override;
894
+
895
+ std::unique_ptr<GooString> label; // T (Default author)
896
+ std::unique_ptr<AnnotPopup> popup; // Popup
897
+ double opacity; // CA (Default 1.0)
898
+ // RC
899
+ std::unique_ptr<GooString> date; // CreationDate
900
+ Ref inReplyTo; // IRT
901
+ std::unique_ptr<GooString> subject; // Subj
902
+ AnnotMarkupReplyType replyTo; // RT (Default R)
903
+ // this object is overridden by the custom intent fields defined in some
904
+ // annotation types.
905
+ // GooString *intent; // IT
906
+ AnnotExternalDataType exData; // ExData
907
+
908
+ private:
909
+ void initialize(PDFDoc *docA, Dict *dict);
910
+ };
911
+
912
+ //------------------------------------------------------------------------
913
+ // AnnotText
914
+ //------------------------------------------------------------------------
915
+
916
+ class POPPLER_PRIVATE_EXPORT AnnotText : public AnnotMarkup
917
+ {
918
+ public:
919
+ enum AnnotTextState
920
+ {
921
+ stateUnknown,
922
+ // Marked state model
923
+ stateMarked, // Marked
924
+ stateUnmarked, // Unmarked
925
+ // Review state model
926
+ stateAccepted, // Accepted
927
+ stateRejected, // Rejected
928
+ stateCancelled, // Cancelled
929
+ stateCompleted, // Completed
930
+ stateNone // None
931
+ };
932
+
933
+ AnnotText(PDFDoc *docA, PDFRectangle *rect);
934
+ AnnotText(PDFDoc *docA, Object &&dictObject, const Object *obj);
935
+ ~AnnotText() override;
936
+
937
+ void draw(Gfx *gfx, bool printing) override;
938
+
939
+ // getters
940
+ bool getOpen() const { return open; }
941
+ const GooString *getIcon() const { return icon.get(); }
942
+ AnnotTextState getState() const { return state; }
943
+
944
+ void setOpen(bool openA);
945
+ void setIcon(GooString *new_icon);
946
+
947
+ private:
948
+ void initialize(PDFDoc *docA, Dict *dict);
949
+
950
+ bool open; // Open (Default false)
951
+ std::unique_ptr<GooString> icon; // Name (Default Note)
952
+ AnnotTextState state; // State (Default Umarked if
953
+ // StateModel Marked
954
+ // None if StareModel Review)
955
+ };
956
+
957
+ //------------------------------------------------------------------------
958
+ // AnnotMovie
959
+ //------------------------------------------------------------------------
960
+
961
+ class POPPLER_PRIVATE_EXPORT AnnotMovie : public Annot
962
+ {
963
+ public:
964
+ AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA);
965
+ AnnotMovie(PDFDoc *docA, Object &&dictObject, const Object *obj);
966
+ ~AnnotMovie() override;
967
+
968
+ void draw(Gfx *gfx, bool printing) override;
969
+
970
+ const GooString *getTitle() const { return title.get(); }
971
+ Movie *getMovie() { return movie.get(); }
972
+
973
+ private:
974
+ void initialize(PDFDoc *docA, Dict *dict);
975
+
976
+ std::unique_ptr<GooString> title; // T
977
+ std::unique_ptr<Movie> movie; // Movie + A
978
+ };
979
+
980
+ //------------------------------------------------------------------------
981
+ // AnnotScreen
982
+ //------------------------------------------------------------------------
983
+
984
+ class POPPLER_PRIVATE_EXPORT AnnotScreen : public Annot
985
+ {
986
+ public:
987
+ AnnotScreen(PDFDoc *docA, PDFRectangle *rect);
988
+ AnnotScreen(PDFDoc *docA, Object &&dictObject, const Object *obj);
989
+ ~AnnotScreen() override;
990
+
991
+ const GooString *getTitle() const { return title.get(); }
992
+
993
+ AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); }
994
+ LinkAction *getAction() { return action.get(); } // The caller should not delete the result
995
+ std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type);
996
+
997
+ private:
998
+ void initialize(PDFDoc *docA, Dict *dict);
999
+
1000
+ std::unique_ptr<GooString> title; // T
1001
+
1002
+ std::unique_ptr<AnnotAppearanceCharacs> appearCharacs; // MK
1003
+
1004
+ std::unique_ptr<LinkAction> action; // A
1005
+ Object additionalActions; // AA
1006
+ };
1007
+
1008
+ //------------------------------------------------------------------------
1009
+ // AnnotLink
1010
+ //------------------------------------------------------------------------
1011
+
1012
+ class AnnotLink : public Annot
1013
+ {
1014
+ public:
1015
+ enum AnnotLinkEffect
1016
+ {
1017
+ effectNone, // N
1018
+ effectInvert, // I
1019
+ effectOutline, // O
1020
+ effectPush // P
1021
+ };
1022
+
1023
+ AnnotLink(PDFDoc *docA, PDFRectangle *rect);
1024
+ AnnotLink(PDFDoc *docA, Object &&dictObject, const Object *obj);
1025
+ ~AnnotLink() override;
1026
+
1027
+ void draw(Gfx *gfx, bool printing) override;
1028
+
1029
+ // getters
1030
+ LinkAction *getAction() const { return action.get(); }
1031
+ AnnotLinkEffect getLinkEffect() const { return linkEffect; }
1032
+ AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
1033
+
1034
+ protected:
1035
+ void initialize(PDFDoc *docA, Dict *dict);
1036
+
1037
+ std::unique_ptr<LinkAction> action; // A, Dest
1038
+ AnnotLinkEffect linkEffect; // H (Default I)
1039
+ // Dict *uriAction; // PA
1040
+
1041
+ std::unique_ptr<AnnotQuadrilaterals> quadrilaterals; // QuadPoints
1042
+ };
1043
+
1044
+ //------------------------------------------------------------------------
1045
+ // AnnotFreeText
1046
+ //------------------------------------------------------------------------
1047
+
1048
+ class POPPLER_PRIVATE_EXPORT AnnotFreeText : public AnnotMarkup
1049
+ {
1050
+ public:
1051
+ enum AnnotFreeTextIntent
1052
+ {
1053
+ intentFreeText, // FreeText
1054
+ intentFreeTextCallout, // FreeTextCallout
1055
+ intentFreeTextTypeWriter // FreeTextTypeWriter
1056
+ };
1057
+
1058
+ static const double undefinedFontPtSize;
1059
+
1060
+ AnnotFreeText(PDFDoc *docA, PDFRectangle *rect);
1061
+ AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj);
1062
+ ~AnnotFreeText() override;
1063
+
1064
+ void draw(Gfx *gfx, bool printing) override;
1065
+ Object getAppearanceResDict() override;
1066
+ void setContents(std::unique_ptr<GooString> &&new_content) override;
1067
+
1068
+ void setDefaultAppearance(const DefaultAppearance &da);
1069
+ void setQuadding(VariableTextQuadding new_quadding);
1070
+ void setStyleString(GooString *new_string);
1071
+ void setCalloutLine(AnnotCalloutLine *line);
1072
+ void setIntent(AnnotFreeTextIntent new_intent);
1073
+
1074
+ // getters
1075
+ std::unique_ptr<DefaultAppearance> getDefaultAppearance() const;
1076
+ VariableTextQuadding getQuadding() const { return quadding; }
1077
+ // return rc
1078
+ const GooString *getStyleString() const { return styleString.get(); }
1079
+ AnnotCalloutLine *getCalloutLine() const { return calloutLine.get(); }
1080
+ AnnotFreeTextIntent getIntent() const { return intent; }
1081
+ AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1082
+ PDFRectangle *getRectangle() const { return rectangle.get(); }
1083
+ AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1084
+
1085
+ protected:
1086
+ void initialize(PDFDoc *docA, Dict *dict);
1087
+ void generateFreeTextAppearance();
1088
+
1089
+ // required
1090
+ std::unique_ptr<GooString> appearanceString; // DA
1091
+
1092
+ // optional
1093
+ VariableTextQuadding quadding; // Q (Default 0)
1094
+ // RC
1095
+ std::unique_ptr<GooString> styleString; // DS
1096
+ std::unique_ptr<AnnotCalloutLine> calloutLine; // CL
1097
+ AnnotFreeTextIntent intent; // IT
1098
+ std::unique_ptr<AnnotBorderEffect> borderEffect; // BE
1099
+ std::unique_ptr<PDFRectangle> rectangle; // RD
1100
+ // inherited from Annot
1101
+ // AnnotBorderBS border; // BS
1102
+ AnnotLineEndingStyle endStyle; // LE (Default None)
1103
+ };
1104
+
1105
+ //------------------------------------------------------------------------
1106
+ // AnnotLine
1107
+ //------------------------------------------------------------------------
1108
+
1109
+ class POPPLER_PRIVATE_EXPORT AnnotLine : public AnnotMarkup
1110
+ {
1111
+ public:
1112
+ enum AnnotLineIntent
1113
+ {
1114
+ intentLineArrow, // LineArrow
1115
+ intentLineDimension // LineDimension
1116
+ };
1117
+
1118
+ enum AnnotLineCaptionPos
1119
+ {
1120
+ captionPosInline, // Inline
1121
+ captionPosTop // Top
1122
+ };
1123
+
1124
+ AnnotLine(PDFDoc *docA, PDFRectangle *rect);
1125
+ AnnotLine(PDFDoc *docA, Object &&dictObject, const Object *obj);
1126
+ ~AnnotLine() override;
1127
+
1128
+ void draw(Gfx *gfx, bool printing) override;
1129
+ Object getAppearanceResDict() override;
1130
+ void setContents(std::unique_ptr<GooString> &&new_content) override;
1131
+
1132
+ void setVertices(double x1, double y1, double x2, double y2);
1133
+ void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
1134
+ void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1135
+ void setLeaderLineLength(double len);
1136
+ void setLeaderLineExtension(double len);
1137
+ void setCaption(bool new_cap);
1138
+ void setIntent(AnnotLineIntent new_intent);
1139
+
1140
+ // getters
1141
+ AnnotLineEndingStyle getStartStyle() const { return startStyle; }
1142
+ AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1143
+ AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1144
+ double getLeaderLineLength() const { return leaderLineLength; }
1145
+ double getLeaderLineExtension() const { return leaderLineExtension; }
1146
+ bool getCaption() const { return caption; }
1147
+ AnnotLineIntent getIntent() const { return intent; }
1148
+ double getLeaderLineOffset() const { return leaderLineOffset; }
1149
+ AnnotLineCaptionPos getCaptionPos() const { return captionPos; }
1150
+ Dict *getMeasure() const { return measure; }
1151
+ double getCaptionTextHorizontal() const { return captionTextHorizontal; }
1152
+ double getCaptionTextVertical() const { return captionTextVertical; }
1153
+ double getX1() const { return coord1->getX(); }
1154
+ double getY1() const { return coord1->getY(); }
1155
+ double getX2() const { return coord2->getX(); }
1156
+ double getY2() const { return coord2->getY(); }
1157
+
1158
+ protected:
1159
+ void initialize(PDFDoc *docA, Dict *dict);
1160
+ void generateLineAppearance();
1161
+
1162
+ // required
1163
+ std::unique_ptr<AnnotCoord> coord1;
1164
+ std::unique_ptr<AnnotCoord> coord2;
1165
+
1166
+ // optional
1167
+ // inherited from Annot
1168
+ // AnnotBorderBS border; // BS
1169
+ AnnotLineEndingStyle startStyle; // LE (Default [/None /None])
1170
+ AnnotLineEndingStyle endStyle; //
1171
+ std::unique_ptr<AnnotColor> interiorColor; // IC
1172
+ double leaderLineLength; // LL (Default 0)
1173
+ double leaderLineExtension; // LLE (Default 0)
1174
+ bool caption; // Cap (Default false)
1175
+ AnnotLineIntent intent; // IT
1176
+ double leaderLineOffset; // LLO
1177
+ AnnotLineCaptionPos captionPos; // CP (Default Inline)
1178
+ Dict *measure; // Measure
1179
+ double captionTextHorizontal; // CO (Default [0, 0])
1180
+ double captionTextVertical; //
1181
+ };
1182
+
1183
+ //------------------------------------------------------------------------
1184
+ // AnnotTextMarkup
1185
+ //------------------------------------------------------------------------
1186
+
1187
+ class POPPLER_PRIVATE_EXPORT AnnotTextMarkup : public AnnotMarkup
1188
+ {
1189
+ public:
1190
+ AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1191
+ AnnotTextMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj);
1192
+ ~AnnotTextMarkup() override;
1193
+
1194
+ void draw(Gfx *gfx, bool printing) override;
1195
+
1196
+ // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut
1197
+ void setType(AnnotSubtype new_type);
1198
+
1199
+ void setQuadrilaterals(AnnotQuadrilaterals *quadPoints);
1200
+
1201
+ AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
1202
+
1203
+ protected:
1204
+ void initialize(PDFDoc *docA, Dict *dict);
1205
+
1206
+ std::unique_ptr<AnnotQuadrilaterals> quadrilaterals; // QuadPoints
1207
+
1208
+ private:
1209
+ bool shouldCreateApperance(Gfx *gfx) const;
1210
+ };
1211
+
1212
+ //------------------------------------------------------------------------
1213
+ // AnnotStamp
1214
+ //------------------------------------------------------------------------
1215
+
1216
+ class POPPLER_PRIVATE_EXPORT AnnotStamp : public AnnotMarkup
1217
+ {
1218
+ public:
1219
+ AnnotStamp(PDFDoc *docA, PDFRectangle *rect);
1220
+ AnnotStamp(PDFDoc *docA, Object &&dictObject, const Object *obj);
1221
+ ~AnnotStamp() override;
1222
+
1223
+ void draw(Gfx *gfx, bool printing) override;
1224
+
1225
+ void setIcon(GooString *new_icon);
1226
+
1227
+ void setCustomImage(AnnotStampImageHelper *stampImageHelperA);
1228
+
1229
+ void clearCustomImage();
1230
+
1231
+ // getters
1232
+ const GooString *getIcon() const { return icon.get(); }
1233
+
1234
+ private:
1235
+ void initialize(PDFDoc *docA, Dict *dict);
1236
+ void generateStampDefaultAppearance();
1237
+ void generateStampCustomAppearance();
1238
+
1239
+ std::unique_ptr<GooString> icon; // Name (Default Draft)
1240
+ AnnotStampImageHelper *stampImageHelper;
1241
+ Ref updatedAppearanceStream;
1242
+ };
1243
+
1244
+ //------------------------------------------------------------------------
1245
+ // AnnotGeometry
1246
+ //------------------------------------------------------------------------
1247
+
1248
+ class POPPLER_PRIVATE_EXPORT AnnotGeometry : public AnnotMarkup
1249
+ {
1250
+ public:
1251
+ AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1252
+ AnnotGeometry(PDFDoc *docA, Object &&dictObject, const Object *obj);
1253
+ ~AnnotGeometry() override;
1254
+
1255
+ void draw(Gfx *gfx, bool printing) override;
1256
+
1257
+ void setType(AnnotSubtype new_type); // typeSquare or typeCircle
1258
+ void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1259
+
1260
+ // getters
1261
+ AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1262
+ AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1263
+ PDFRectangle *getGeometryRect() const { return geometryRect.get(); }
1264
+
1265
+ private:
1266
+ void initialize(PDFDoc *docA, Dict *dict);
1267
+
1268
+ std::unique_ptr<AnnotColor> interiorColor; // IC
1269
+ std::unique_ptr<AnnotBorderEffect> borderEffect; // BE
1270
+ std::unique_ptr<PDFRectangle> geometryRect; // RD (combined with Rect)
1271
+ };
1272
+
1273
+ //------------------------------------------------------------------------
1274
+ // AnnotPolygon
1275
+ //------------------------------------------------------------------------
1276
+
1277
+ class POPPLER_PRIVATE_EXPORT AnnotPolygon : public AnnotMarkup
1278
+ {
1279
+ public:
1280
+ enum AnnotPolygonIntent
1281
+ {
1282
+ polygonCloud, // PolygonCloud
1283
+ polylineDimension, // PolyLineDimension
1284
+ polygonDimension // PolygonDimension
1285
+ };
1286
+
1287
+ AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1288
+ AnnotPolygon(PDFDoc *docA, Object &&dictObject, const Object *obj);
1289
+ ~AnnotPolygon() override;
1290
+
1291
+ void draw(Gfx *gfx, bool printing) override;
1292
+ void generatePolyLineAppearance(AnnotAppearanceBuilder *appearBuilder);
1293
+ void setType(AnnotSubtype new_type); // typePolygon or typePolyLine
1294
+ void setVertices(AnnotPath *path);
1295
+ void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
1296
+ void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1297
+ void setIntent(AnnotPolygonIntent new_intent);
1298
+
1299
+ // getters
1300
+ AnnotPath *getVertices() const { return vertices.get(); }
1301
+ AnnotLineEndingStyle getStartStyle() const { return startStyle; }
1302
+ AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1303
+ AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1304
+ AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1305
+ AnnotPolygonIntent getIntent() const { return intent; }
1306
+
1307
+ private:
1308
+ void initialize(PDFDoc *docA, Dict *dict);
1309
+
1310
+ // required
1311
+ std::unique_ptr<AnnotPath> vertices; // Vertices
1312
+
1313
+ // optional
1314
+ AnnotLineEndingStyle startStyle; // LE (Default [/None /None])
1315
+ AnnotLineEndingStyle endStyle; //
1316
+ // inherited from Annot
1317
+ // AnnotBorderBS border; // BS
1318
+ std::unique_ptr<AnnotColor> interiorColor; // IC
1319
+ std::unique_ptr<AnnotBorderEffect> borderEffect; // BE
1320
+ AnnotPolygonIntent intent; // IT
1321
+ // Measure
1322
+ };
1323
+
1324
+ //------------------------------------------------------------------------
1325
+ // AnnotCaret
1326
+ //------------------------------------------------------------------------
1327
+
1328
+ class POPPLER_PRIVATE_EXPORT AnnotCaret : public AnnotMarkup
1329
+ {
1330
+ public:
1331
+ enum AnnotCaretSymbol
1332
+ {
1333
+ symbolNone, // None
1334
+ symbolP // P
1335
+ };
1336
+
1337
+ AnnotCaret(PDFDoc *docA, PDFRectangle *rect);
1338
+ AnnotCaret(PDFDoc *docA, Object &&dictObject, const Object *obj);
1339
+ ~AnnotCaret() override;
1340
+
1341
+ void setSymbol(AnnotCaretSymbol new_symbol);
1342
+
1343
+ // getters
1344
+ AnnotCaretSymbol getSymbol() const { return symbol; }
1345
+ PDFRectangle *getCaretRect() const { return caretRect.get(); }
1346
+
1347
+ private:
1348
+ void initialize(PDFDoc *docA, Dict *dict);
1349
+
1350
+ AnnotCaretSymbol symbol; // Sy (Default None)
1351
+ std::unique_ptr<PDFRectangle> caretRect; // RD (combined with Rect)
1352
+ };
1353
+
1354
+ //------------------------------------------------------------------------
1355
+ // AnnotInk
1356
+ //------------------------------------------------------------------------
1357
+
1358
+ class POPPLER_PRIVATE_EXPORT AnnotInk : public AnnotMarkup
1359
+ {
1360
+ public:
1361
+ AnnotInk(PDFDoc *docA, PDFRectangle *rect);
1362
+ AnnotInk(PDFDoc *docA, Object &&dictObject, const Object *obj);
1363
+ ~AnnotInk() override;
1364
+
1365
+ void draw(Gfx *gfx, bool printing) override;
1366
+
1367
+ void setInkList(AnnotPath **paths, int n_paths);
1368
+
1369
+ // getters
1370
+ AnnotPath **getInkList() const { return inkList; }
1371
+ int getInkListLength() const { return inkListLength; }
1372
+
1373
+ private:
1374
+ void initialize(PDFDoc *docA, Dict *dict);
1375
+ void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array);
1376
+ void parseInkList(Array *src_array);
1377
+ void freeInkList();
1378
+
1379
+ // required
1380
+ AnnotPath **inkList; // InkList
1381
+ int inkListLength;
1382
+
1383
+ // optional
1384
+ // inherited from Annot
1385
+ // AnnotBorderBS border; // BS
1386
+ };
1387
+
1388
+ //------------------------------------------------------------------------
1389
+ // AnnotFileAttachment
1390
+ //------------------------------------------------------------------------
1391
+
1392
+ class AnnotFileAttachment : public AnnotMarkup
1393
+ {
1394
+ public:
1395
+ AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename);
1396
+ AnnotFileAttachment(PDFDoc *docA, Object &&dictObject, const Object *obj);
1397
+ ~AnnotFileAttachment() override;
1398
+
1399
+ void draw(Gfx *gfx, bool printing) override;
1400
+
1401
+ // getters
1402
+ Object *getFile() { return &file; }
1403
+ const GooString *getName() const { return name.get(); }
1404
+
1405
+ private:
1406
+ void initialize(PDFDoc *docA, Dict *dict);
1407
+
1408
+ // required
1409
+ Object file; // FS
1410
+
1411
+ // optional
1412
+ std::unique_ptr<GooString> name; // Name
1413
+ };
1414
+
1415
+ //------------------------------------------------------------------------
1416
+ // AnnotSound
1417
+ //------------------------------------------------------------------------
1418
+
1419
+ class AnnotSound : public AnnotMarkup
1420
+ {
1421
+ public:
1422
+ AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA);
1423
+ AnnotSound(PDFDoc *docA, Object &&dictObject, const Object *obj);
1424
+ ~AnnotSound() override;
1425
+
1426
+ void draw(Gfx *gfx, bool printing) override;
1427
+
1428
+ // getters
1429
+ Sound *getSound() { return sound.get(); }
1430
+ const GooString *getName() const { return name.get(); }
1431
+
1432
+ private:
1433
+ void initialize(PDFDoc *docA, Dict *dict);
1434
+
1435
+ // required
1436
+ std::unique_ptr<Sound> sound; // Sound
1437
+
1438
+ // optional
1439
+ std::unique_ptr<GooString> name; // Name
1440
+ };
1441
+
1442
+ //------------------------------------------------------------------------
1443
+ // AnnotWidget
1444
+ //------------------------------------------------------------------------
1445
+
1446
+ class POPPLER_PRIVATE_EXPORT AnnotWidget : public Annot
1447
+ {
1448
+ public:
1449
+ enum AnnotWidgetHighlightMode
1450
+ {
1451
+ highlightModeNone, // N
1452
+ highlightModeInvert, // I
1453
+ highlightModeOutline, // O
1454
+ highlightModePush // P,T
1455
+ };
1456
+
1457
+ AnnotWidget(PDFDoc *docA, Object &&dictObject, const Object *obj);
1458
+ AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj, FormField *fieldA);
1459
+ ~AnnotWidget() override;
1460
+
1461
+ void draw(Gfx *gfx, bool printing) override;
1462
+ void invalidateAppearance() override;
1463
+
1464
+ void generateFieldAppearance();
1465
+ void updateAppearanceStream();
1466
+
1467
+ AnnotWidgetHighlightMode getMode() { return mode; }
1468
+ AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); }
1469
+ void setAppearCharacs(std::unique_ptr<AnnotAppearanceCharacs> &&appearCharacsA) { appearCharacs = std::move(appearCharacsA); }
1470
+ LinkAction *getAction() { return action.get(); } // The caller should not delete the result
1471
+ std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type);
1472
+ std::unique_ptr<LinkAction> getFormAdditionalAction(FormAdditionalActionsType type);
1473
+ Dict *getParent() { return parent; }
1474
+
1475
+ bool setFormAdditionalAction(FormAdditionalActionsType type, const std::string &js);
1476
+
1477
+ void setField(FormField *f) { field = f; };
1478
+
1479
+ private:
1480
+ void initialize(PDFDoc *docA, Dict *dict);
1481
+
1482
+ Form *form;
1483
+ FormField *field; // FormField object for this annotation
1484
+ AnnotWidgetHighlightMode mode; // H (Default I)
1485
+ std::unique_ptr<AnnotAppearanceCharacs> appearCharacs; // MK
1486
+ std::unique_ptr<LinkAction> action; // A
1487
+ Object additionalActions; // AA
1488
+ // inherited from Annot
1489
+ // AnnotBorderBS border; // BS
1490
+ Dict *parent; // Parent
1491
+ Ref updatedAppearanceStream; // {-1,-1} if updateAppearanceStream has never been called
1492
+ };
1493
+
1494
+ //------------------------------------------------------------------------
1495
+ // Annot3D
1496
+ //------------------------------------------------------------------------
1497
+
1498
+ class Annot3D : public Annot
1499
+ {
1500
+ class Activation
1501
+ {
1502
+ public:
1503
+ enum ActivationATrigger
1504
+ {
1505
+ aTriggerUnknown,
1506
+ aTriggerPageOpened, // PO
1507
+ aTriggerPageVisible, // PV
1508
+ aTriggerUserAction // XA
1509
+ };
1510
+
1511
+ enum ActivationAState
1512
+ {
1513
+ aStateUnknown,
1514
+ aStateEnabled, // I
1515
+ aStateDisabled // L
1516
+ };
1517
+
1518
+ enum ActivationDTrigger
1519
+ {
1520
+ dTriggerUnknown,
1521
+ dTriggerPageClosed, // PC
1522
+ dTriggerPageInvisible, // PI
1523
+ dTriggerUserAction // XD
1524
+ };
1525
+
1526
+ enum ActivationDState
1527
+ {
1528
+ dStateUnknown,
1529
+ dStateUninstantiaded, // U
1530
+ dStateInstantiated, // I
1531
+ dStateLive // L
1532
+ };
1533
+
1534
+ explicit Activation(Dict *dict);
1535
+
1536
+ private:
1537
+ ActivationATrigger aTrigger; // A (Default XA)
1538
+ ActivationAState aState; // AIS (Default L)
1539
+ ActivationDTrigger dTrigger; // D (Default PI)
1540
+ ActivationDState dState; // DIS (Default U)
1541
+ bool displayToolbar; // TB (Default true)
1542
+ bool displayNavigation; // NP (Default false);
1543
+ };
1544
+
1545
+ public:
1546
+ Annot3D(PDFDoc *docA, PDFRectangle *rect);
1547
+ Annot3D(PDFDoc *docA, Object &&dictObject, const Object *obj);
1548
+ ~Annot3D() override;
1549
+
1550
+ // getters
1551
+
1552
+ private:
1553
+ void initialize(PDFDoc *docA, Dict *dict);
1554
+
1555
+ std::unique_ptr<Activation> activation; // 3DA
1556
+ };
1557
+
1558
+ //------------------------------------------------------------------------
1559
+ // AnnotRichMedia
1560
+ //------------------------------------------------------------------------
1561
+
1562
+ class POPPLER_PRIVATE_EXPORT AnnotRichMedia : public Annot
1563
+ {
1564
+ public:
1565
+ class POPPLER_PRIVATE_EXPORT Params
1566
+ {
1567
+ public:
1568
+ explicit Params(Dict *dict);
1569
+ ~Params();
1570
+
1571
+ Params(const Params &) = delete;
1572
+ Params &operator=(const Params &) = delete;
1573
+
1574
+ const GooString *getFlashVars() const;
1575
+
1576
+ private:
1577
+ // optional
1578
+ std::unique_ptr<GooString> flashVars; // FlashVars
1579
+ };
1580
+
1581
+ class POPPLER_PRIVATE_EXPORT Instance
1582
+ {
1583
+ public:
1584
+ enum Type
1585
+ {
1586
+ type3D, // 3D
1587
+ typeFlash, // Flash
1588
+ typeSound, // Sound
1589
+ typeVideo // Video
1590
+ };
1591
+
1592
+ explicit Instance(Dict *dict);
1593
+ ~Instance();
1594
+
1595
+ Instance(const Instance &) = delete;
1596
+ Instance &operator=(const Instance &) = delete;
1597
+
1598
+ Type getType() const;
1599
+ Params *getParams() const;
1600
+
1601
+ private:
1602
+ // optional
1603
+ Type type; // Subtype
1604
+ std::unique_ptr<Params> params; // Params
1605
+ };
1606
+
1607
+ class POPPLER_PRIVATE_EXPORT Configuration
1608
+ {
1609
+ public:
1610
+ enum Type
1611
+ {
1612
+ type3D, // 3D
1613
+ typeFlash, // Flash
1614
+ typeSound, // Sound
1615
+ typeVideo // Video
1616
+ };
1617
+
1618
+ explicit Configuration(Dict *dict);
1619
+ ~Configuration();
1620
+
1621
+ Configuration(const Configuration &) = delete;
1622
+ Configuration &operator=(const Configuration &) = delete;
1623
+
1624
+ Type getType() const;
1625
+ const GooString *getName() const;
1626
+ int getInstancesCount() const;
1627
+ Instance *getInstance(int index) const;
1628
+
1629
+ private:
1630
+ // optional
1631
+ Type type; // Subtype
1632
+ std::unique_ptr<GooString> name; // Name
1633
+ Instance **instances; // Instances
1634
+ int nInstances;
1635
+ };
1636
+
1637
+ class Content;
1638
+
1639
+ class POPPLER_PRIVATE_EXPORT Asset
1640
+ {
1641
+ public:
1642
+ Asset();
1643
+ ~Asset();
1644
+
1645
+ Asset(const Asset &) = delete;
1646
+ Asset &operator=(const Asset &) = delete;
1647
+
1648
+ const GooString *getName() const;
1649
+ Object *getFileSpec() const;
1650
+
1651
+ private:
1652
+ friend class AnnotRichMedia::Content;
1653
+
1654
+ std::unique_ptr<GooString> name;
1655
+ Object fileSpec;
1656
+ };
1657
+
1658
+ class POPPLER_PRIVATE_EXPORT Content
1659
+ {
1660
+ public:
1661
+ explicit Content(Dict *dict);
1662
+ ~Content();
1663
+
1664
+ Content(const Content &) = delete;
1665
+ Content &operator=(const Content &) = delete;
1666
+
1667
+ int getConfigurationsCount() const;
1668
+ Configuration *getConfiguration(int index) const;
1669
+
1670
+ int getAssetsCount() const;
1671
+ Asset *getAsset(int index) const;
1672
+
1673
+ private:
1674
+ // optional
1675
+ Configuration **configurations; // Configurations
1676
+ int nConfigurations;
1677
+
1678
+ Asset **assets; // Assets
1679
+ int nAssets;
1680
+ };
1681
+
1682
+ class POPPLER_PRIVATE_EXPORT Activation
1683
+ {
1684
+ public:
1685
+ enum Condition
1686
+ {
1687
+ conditionPageOpened, // PO
1688
+ conditionPageVisible, // PV
1689
+ conditionUserAction // XA
1690
+ };
1691
+
1692
+ explicit Activation(Dict *dict);
1693
+
1694
+ Condition getCondition() const;
1695
+
1696
+ private:
1697
+ // optional
1698
+ Condition condition;
1699
+ };
1700
+
1701
+ class POPPLER_PRIVATE_EXPORT Deactivation
1702
+ {
1703
+ public:
1704
+ enum Condition
1705
+ {
1706
+ conditionPageClosed, // PC
1707
+ conditionPageInvisible, // PI
1708
+ conditionUserAction // XD
1709
+ };
1710
+
1711
+ explicit Deactivation(Dict *dict);
1712
+
1713
+ Condition getCondition() const;
1714
+
1715
+ private:
1716
+ // optional
1717
+ Condition condition;
1718
+ };
1719
+
1720
+ class POPPLER_PRIVATE_EXPORT Settings
1721
+ {
1722
+ public:
1723
+ explicit Settings(Dict *dict);
1724
+ ~Settings();
1725
+
1726
+ Settings(const Settings &) = delete;
1727
+ Settings &operator=(const Settings &) = delete;
1728
+
1729
+ Activation *getActivation() const;
1730
+ Deactivation *getDeactivation() const;
1731
+
1732
+ private:
1733
+ // optional
1734
+ std::unique_ptr<Activation> activation;
1735
+ std::unique_ptr<Deactivation> deactivation;
1736
+ };
1737
+
1738
+ AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect);
1739
+ AnnotRichMedia(PDFDoc *docA, Object &&dictObject, const Object *obj);
1740
+ ~AnnotRichMedia() override;
1741
+
1742
+ Content *getContent() const;
1743
+
1744
+ Settings *getSettings() const;
1745
+
1746
+ private:
1747
+ void initialize(PDFDoc *docA, Dict *dict);
1748
+
1749
+ // required
1750
+ std::unique_ptr<Content> content; // RichMediaContent
1751
+
1752
+ // optional
1753
+ std::unique_ptr<Settings> settings; // RichMediaSettings
1754
+ };
1755
+
1756
+ //------------------------------------------------------------------------
1757
+ // Annots
1758
+ //------------------------------------------------------------------------
1759
+
1760
+ class POPPLER_PRIVATE_EXPORT Annots
1761
+ {
1762
+ public:
1763
+ // Build a list of Annot objects and call setPage on them
1764
+ Annots(PDFDoc *docA, int page, Object *annotsObj);
1765
+
1766
+ ~Annots();
1767
+
1768
+ Annots(const Annots &) = delete;
1769
+ Annots &operator=(const Annots &) = delete;
1770
+
1771
+ const std::vector<Annot *> &getAnnots() { return annots; }
1772
+
1773
+ void appendAnnot(Annot *annot);
1774
+ bool removeAnnot(Annot *annot);
1775
+
1776
+ private:
1777
+ Annot *createAnnot(Object &&dictObject, const Object *obj);
1778
+ Annot *findAnnot(Ref *ref);
1779
+
1780
+ PDFDoc *doc;
1781
+ std::vector<Annot *> annots;
1782
+ };
1783
+
1784
+ #endif
poppler-23.11.0/Library/include/poppler/AnnotStampImageHelper.h ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // AnnotStampImageHelper.h
4
+ //
5
+ // Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>
6
+ // Copyright (C) 2021 Albert Astals Cid <aacid@kde.org>
7
+ //
8
+ // Licensed under GPLv2 or later
9
+ //
10
+ //========================================================================
11
+
12
+ #ifndef ANNOTSTAMPIMAGEHELPER_H
13
+ #define ANNOTSTAMPIMAGEHELPER_H
14
+
15
+ #include "Object.h"
16
+
17
+ class PDFDoc;
18
+
19
+ enum ColorSpace
20
+ {
21
+ DeviceGray,
22
+ DeviceRGB,
23
+ DeviceCMYK
24
+ };
25
+
26
+ /**
27
+ * This class is used only to load Image XObjects into stamp annotations. It takes in
28
+ * the image parameters in its constructors and creates a new Image XObject that gets
29
+ * added to the XRef table, so that the annotations that would like to use it be able
30
+ * to get its ref number.
31
+ *
32
+ * To have transparency in the image, you should first try to create the soft
33
+ * mask of the image, by creating a AnnotStampImageHelper object giving it the soft
34
+ * image data normally. You would then need to pass in the created soft mask Image XObject
35
+ * ref to the actual image you'd like to be created by this helper class.
36
+ */
37
+ class POPPLER_PRIVATE_EXPORT AnnotStampImageHelper
38
+ {
39
+ public:
40
+ AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength);
41
+ AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength, Ref softMaskRef);
42
+ ~AnnotStampImageHelper() { }
43
+
44
+ // Returns the ref to the created Image XObject
45
+ Ref getRef() const { return ref; }
46
+
47
+ // Returns the width of the image
48
+ int getWidth() const { return width; }
49
+ // Returns the height of the image
50
+ int getHeight() const { return height; }
51
+
52
+ // Removes the created Image XObject as well as its soft mask from the XRef Table
53
+ void removeAnnotStampImageObject();
54
+
55
+ private:
56
+ void initialize(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength);
57
+
58
+ PDFDoc *doc;
59
+
60
+ Object imgObj;
61
+ Ref ref;
62
+ Ref sMaskRef;
63
+
64
+ int width;
65
+ int height;
66
+ };
67
+
68
+ #endif
poppler-23.11.0/Library/include/poppler/Array.h ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // Array.h
4
+ //
5
+ // Copyright 1996-2003 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ //========================================================================
10
+ //
11
+ // Modified under the Poppler project - http://poppler.freedesktop.org
12
+ //
13
+ // All changes made under the Poppler project to this file are licensed
14
+ // under GPL version 2 or later
15
+ //
16
+ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
17
+ // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
18
+ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
19
+ // Copyright (C) 2017-2019, 2021 Albert Astals Cid <aacid@kde.org>
20
+ // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
21
+ // Copyright (C) 2018, 2019 Adam Reichold <adam.reichold@t-online.de>
22
+ //
23
+ // To see a description of the changes please see the Changelog file that
24
+ // came with your tarball or type make ChangeLog if you are building from git
25
+ //
26
+ //========================================================================
27
+
28
+ #ifndef ARRAY_H
29
+ #define ARRAY_H
30
+
31
+ #include <atomic>
32
+ #include <mutex>
33
+ #include <vector>
34
+
35
+ #include "poppler-config.h"
36
+ #include "poppler_private_export.h"
37
+ #include "Object.h"
38
+
39
+ class XRef;
40
+
41
+ //------------------------------------------------------------------------
42
+ // Array
43
+ //------------------------------------------------------------------------
44
+
45
+ class POPPLER_PRIVATE_EXPORT Array
46
+ {
47
+ public:
48
+ // Constructor.
49
+ explicit Array(XRef *xrefA);
50
+
51
+ // Destructor.
52
+ ~Array();
53
+
54
+ Array(const Array &) = delete;
55
+ Array &operator=(const Array &) = delete;
56
+
57
+ // Get number of elements.
58
+ int getLength() const { return elems.size(); }
59
+
60
+ // Copy array with new xref
61
+ Array *copy(XRef *xrefA) const;
62
+
63
+ Array *deepCopy() const;
64
+
65
+ // Add an element
66
+ // elem becomes a dead object after this call
67
+ void add(Object &&elem);
68
+
69
+ // Remove an element by position
70
+ void remove(int i);
71
+
72
+ // Accessors.
73
+ Object get(int i, int recursion = 0) const;
74
+ // Same as above but if the returned object is a fetched Ref returns such Ref in returnRef, otherwise returnRef is Ref::INVALID()
75
+ Object get(int i, Ref *returnRef, int recursion = 0) const;
76
+ const Object &getNF(int i) const;
77
+ bool getString(int i, GooString *string) const;
78
+
79
+ private:
80
+ friend class Object; // for incRef/decRef
81
+
82
+ // Reference counting.
83
+ int incRef() { return ++ref; }
84
+ int decRef() { return --ref; }
85
+
86
+ XRef *xref; // the xref table for this PDF file
87
+ std::vector<Object> elems; // array of elements
88
+ std::atomic_int ref; // reference count
89
+ mutable std::recursive_mutex mutex;
90
+ };
91
+
92
+ #endif
poppler-23.11.0/Library/include/poppler/BBoxOutputDev.h ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // BBoxOutputDev.cc
4
+ //
5
+ // This file is licensed under the GPLv2 or later
6
+ //
7
+ // Copyright 2020 sgerwk <sgerwk@aol.com>
8
+ //
9
+ //========================================================================
10
+
11
+ #include <PDFDoc.h>
12
+ #include <GfxState.h>
13
+ #include <OutputDev.h>
14
+
15
+ class POPPLER_PRIVATE_EXPORT BBoxOutputDev : public OutputDev
16
+ {
17
+ public:
18
+ bool upsideDown() override { return false; }
19
+ bool useDrawChar() override { return true; }
20
+ bool interpretType3Chars() override { return false; }
21
+
22
+ BBoxOutputDev();
23
+ BBoxOutputDev(bool text, bool vector, bool raster);
24
+ BBoxOutputDev(bool text, bool vector, bool raster, bool lwidth);
25
+ void endPage() override;
26
+ void stroke(GfxState *state) override;
27
+ void fill(GfxState *state) override;
28
+ void eoFill(GfxState *state) override;
29
+ void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) override;
30
+ void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override;
31
+ void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override;
32
+ void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override;
33
+ void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
34
+ bool maskInterpolate) override;
35
+
36
+ double getX1() const;
37
+ double getY1() const;
38
+ double getX2() const;
39
+ double getY2() const;
40
+ double getHasGraphics() const;
41
+
42
+ private:
43
+ PDFRectangle bb;
44
+ bool hasGraphics;
45
+
46
+ bool text;
47
+ bool vector;
48
+ bool raster;
49
+ bool lwidth;
50
+
51
+ void updatePoint(PDFRectangle *bbA, double x, double y, const GfxState *state);
52
+ void updatePath(PDFRectangle *bbA, const GfxPath *path, const GfxState *state);
53
+ void updateImage(PDFRectangle *bbA, const GfxState *state);
54
+ };
poppler-23.11.0/Library/include/poppler/CMap.h ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // CMap.h
4
+ //
5
+ // Copyright 2001-2003 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ //========================================================================
10
+ //
11
+ // Modified under the Poppler project - http://poppler.freedesktop.org
12
+ //
13
+ // All changes made under the Poppler project to this file are licensed
14
+ // under GPL version 2 or later
15
+ //
16
+ // Copyright (C) 2008 Koji Otani <sho@bbr.jp>
17
+ // Copyright (C) 2009, 2018-2020, 2022 Albert Astals Cid <aacid@kde.org>
18
+ // Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com>
19
+ // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
20
+ //
21
+ // To see a description of the changes please see the Changelog file that
22
+ // came with your tarball or type make ChangeLog if you are building from git
23
+ //
24
+ //========================================================================
25
+
26
+ #ifndef CMAP_H
27
+ #define CMAP_H
28
+
29
+ #include <array>
30
+ #include <atomic>
31
+ #include <memory>
32
+
33
+ #include "poppler-config.h"
34
+ #include "CharTypes.h"
35
+
36
+ class GooString;
37
+ class Object;
38
+ struct CMapVectorEntry;
39
+ class CMapCache;
40
+ class Stream;
41
+
42
+ //------------------------------------------------------------------------
43
+
44
+ class CMap
45
+ {
46
+ public:
47
+ // Parse a CMap from <obj>, which can be a name or a stream. Sets
48
+ // the initial reference count to 1. Returns NULL on failure.
49
+ static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Object *obj);
50
+
51
+ // Create the CMap specified by <collection> and <cMapName>. Sets
52
+ // the initial reference count to 1. Returns NULL on failure.
53
+ static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, const GooString *cMapNameA);
54
+
55
+ // Parse a CMap from <str>. Sets the initial reference count to 1.
56
+ // Returns NULL on failure.
57
+ static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Stream *str);
58
+
59
+ ~CMap();
60
+
61
+ CMap(const CMap &) = delete;
62
+ CMap &operator=(const CMap &) = delete;
63
+
64
+ // Return collection name (<registry>-<ordering>).
65
+ const GooString *getCollection() const { return collection; }
66
+
67
+ const GooString *getCMapName() const { return cMapName; }
68
+
69
+ // Return true if this CMap matches the specified <collectionA>, and
70
+ // <cMapNameA>.
71
+ bool match(const GooString *collectionA, const GooString *cMapNameA);
72
+
73
+ // Return the CID corresponding to the character code starting at
74
+ // <s>, which contains <len> bytes. Sets *<c> to the char code, and
75
+ // *<nUsed> to the number of bytes used by the char code.
76
+ CID getCID(const char *s, int len, CharCode *c, int *nUsed);
77
+
78
+ // Return the writing mode (0=horizontal, 1=vertical).
79
+ int getWMode() const { return wMode; }
80
+
81
+ void setReverseMap(unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
82
+
83
+ private:
84
+ void parse2(CMapCache *cache, int (*getCharFunc)(void *), void *data);
85
+ CMap(GooString *collectionA, GooString *cMapNameA);
86
+ CMap(GooString *collectionA, GooString *cMapNameA, int wModeA);
87
+ void useCMap(CMapCache *cache, const char *useName);
88
+ void useCMap(CMapCache *cache, Object *obj);
89
+ void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
90
+ void addCIDs(unsigned int start, unsigned int end, unsigned int nBytes, CID firstCID);
91
+ void freeCMapVector(CMapVectorEntry *vec);
92
+ void setReverseMapVector(unsigned int startCode, CMapVectorEntry *vec, unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
93
+
94
+ GooString *collection;
95
+ GooString *cMapName;
96
+ bool isIdent; // true if this CMap is an identity mapping,
97
+ // or is based on one (via usecmap)
98
+ int wMode; // writing mode (0=horizontal, 1=vertical)
99
+ CMapVectorEntry *vector; // vector for first byte (NULL for
100
+ // identity CMap)
101
+ };
102
+
103
+ //------------------------------------------------------------------------
104
+
105
+ #define cMapCacheSize 4
106
+
107
+ class CMapCache
108
+ {
109
+ public:
110
+ CMapCache();
111
+ ~CMapCache() = default;
112
+
113
+ CMapCache(const CMapCache &) = delete;
114
+ CMapCache &operator=(const CMapCache &) = delete;
115
+
116
+ // Get the <cMapName> CMap for the specified character collection.
117
+ // Increments its reference count; there will be one reference for
118
+ // the cache plus one for the caller of this function.
119
+ // Stream is a stream containing the CMap, can be NULL and
120
+ // this means the CMap will be searched in the CMap files
121
+ // Returns NULL on failure.
122
+ std::shared_ptr<CMap> getCMap(const GooString *collection, const GooString *cMapName);
123
+
124
+ private:
125
+ std::array<std::shared_ptr<CMap>, cMapCacheSize> cache;
126
+ };
127
+
128
+ #endif
poppler-23.11.0/Library/include/poppler/CachedFile.h ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // CachedFile.h
4
+ //
5
+ // Caching files support.
6
+ //
7
+ // This file is licensed under the GPLv2 or later
8
+ //
9
+ // Copyright 2009 Stefan Thomas <thomas@eload24.com>
10
+ // Copyright 2010 Hib Eris <hib@hiberis.nl>
11
+ // Copyright 2010, 2018-2020, 2022 Albert Astals Cid <aacid@kde.org>
12
+ //
13
+ //========================================================================
14
+
15
+ #ifndef CACHEDFILE_H
16
+ #define CACHEDFILE_H
17
+
18
+ #include "poppler-config.h"
19
+ #include "poppler_private_export.h"
20
+
21
+ #include "Object.h"
22
+ #include "Stream.h"
23
+
24
+ #include <vector>
25
+
26
+ //------------------------------------------------------------------------
27
+
28
+ #define CachedFileChunkSize 8192 // This should be a multiple of cachedStreamBufSize
29
+
30
+ class GooString;
31
+ class CachedFileLoader;
32
+
33
+ //------------------------------------------------------------------------
34
+ // CachedFile
35
+ //
36
+ // CachedFile gives FILE-like access to a document at a specified URI.
37
+ // In the constructor, you specify a CachedFileLoader that handles loading
38
+ // the data from the document. The CachedFile requests no more data then it
39
+ // needs from the CachedFileLoader.
40
+ //------------------------------------------------------------------------
41
+
42
+ class POPPLER_PRIVATE_EXPORT CachedFile
43
+ {
44
+
45
+ friend class CachedFileWriter;
46
+
47
+ public:
48
+ explicit CachedFile(CachedFileLoader *cacheLoader);
49
+
50
+ CachedFile(const CachedFile &) = delete;
51
+ CachedFile &operator=(const CachedFile &) = delete;
52
+
53
+ unsigned int getLength() const { return length; }
54
+ long int tell();
55
+ int seek(long int offset, int origin);
56
+ size_t read(void *ptr, size_t unitsize, size_t count);
57
+ size_t write(const char *ptr, size_t size, size_t fromByte);
58
+ int cache(const std::vector<ByteRange> &ranges);
59
+
60
+ // Reference counting.
61
+ void incRefCnt();
62
+ void decRefCnt();
63
+
64
+ private:
65
+ ~CachedFile();
66
+
67
+ enum ChunkState
68
+ {
69
+ chunkStateNew = 0,
70
+ chunkStateLoaded
71
+ };
72
+
73
+ typedef struct
74
+ {
75
+ ChunkState state;
76
+ char data[CachedFileChunkSize];
77
+ } Chunk;
78
+
79
+ int cache(size_t offset, size_t length);
80
+
81
+ CachedFileLoader *loader;
82
+
83
+ size_t length;
84
+ size_t streamPos;
85
+
86
+ std::vector<Chunk> *chunks;
87
+
88
+ int refCnt; // reference count
89
+ };
90
+
91
+ //------------------------------------------------------------------------
92
+ // CachedFileWriter
93
+ //
94
+ // CachedFileWriter handles sequential writes to a CachedFile.
95
+ // On construction, you specify the CachedFile and the chunks of it to which data
96
+ // should be written.
97
+ //------------------------------------------------------------------------
98
+
99
+ class POPPLER_PRIVATE_EXPORT CachedFileWriter
100
+ {
101
+
102
+ public:
103
+ // Construct a CachedFile Writer.
104
+ // The caller is responsible for deleting the cachedFile and chunksA.
105
+ CachedFileWriter(CachedFile *cachedFile, std::vector<int> *chunksA);
106
+
107
+ ~CachedFileWriter();
108
+
109
+ // Writes size bytes from ptr to cachedFile, returns number of bytes written.
110
+ size_t write(const char *ptr, size_t size);
111
+
112
+ private:
113
+ CachedFile *cachedFile;
114
+ std::vector<int> *chunks;
115
+ std::vector<int>::iterator it;
116
+ size_t offset;
117
+ };
118
+
119
+ //------------------------------------------------------------------------
120
+ // CachedFileLoader
121
+ //
122
+ // CachedFileLoader is an abstact class that specifies the interface for
123
+ // loadng data from an URI into a CachedFile.
124
+ //------------------------------------------------------------------------
125
+
126
+ class POPPLER_PRIVATE_EXPORT CachedFileLoader
127
+ {
128
+
129
+ public:
130
+ CachedFileLoader() = default;
131
+ virtual ~CachedFileLoader();
132
+
133
+ CachedFileLoader(const CachedFileLoader &) = delete;
134
+ CachedFileLoader &operator=(const CachedFileLoader &) = delete;
135
+
136
+ // Initializes the file load.
137
+ // Returns the length of the file.
138
+ // The caller is responsible for deleting cachedFile.
139
+ virtual size_t init(CachedFile *cachedFile) = 0;
140
+
141
+ // Loads specified byte ranges and passes it to the writer to store them.
142
+ // Returns 0 on success, Anything but 0 on failure.
143
+ // The caller is responsible for deleting the writer.
144
+ virtual int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer) = 0;
145
+ };
146
+
147
+ //------------------------------------------------------------------------
148
+
149
+ #endif
poppler-23.11.0/Library/include/poppler/CairoFontEngine.h ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // CairoFontEngine.h
4
+ //
5
+ // Copyright 2003 Glyph & Cog, LLC
6
+ // Copyright 2004 Red Hat, Inc
7
+ //
8
+ //========================================================================
9
+
10
+ //========================================================================
11
+ //
12
+ // Modified under the Poppler project - http://poppler.freedesktop.org
13
+ //
14
+ // All changes made under the Poppler project to this file are licensed
15
+ // under GPL version 2 or later
16
+ //
17
+ // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
18
+ // Copyright (C) 2005, 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org>
19
+ // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
20
+ // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
21
+ // Copyright (C) 2008, 2017, 2022 Adrian Johnson <ajohnson@redneon.com>
22
+ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
23
+ // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
24
+ // Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de>
25
+ // Copyright (C) 2022 Marek Kasik <mkasik@redhat.com>
26
+ //
27
+ // To see a description of the changes please see the Changelog file that
28
+ // came with your tarball or type make ChangeLog if you are building from git
29
+ //
30
+ //========================================================================
31
+
32
+ #ifndef CAIROFONTENGINE_H
33
+ #define CAIROFONTENGINE_H
34
+
35
+ #include <memory>
36
+ #include <mutex>
37
+ #include <unordered_map>
38
+ #include <vector>
39
+
40
+ #include "poppler-config.h"
41
+ #include <cairo-ft.h>
42
+
43
+ #include "GfxFont.h"
44
+ #include "PDFDoc.h"
45
+
46
+ class CairoFontEngine;
47
+
48
+ class CairoFont
49
+ {
50
+ public:
51
+ CairoFont(Ref refA, cairo_font_face_t *cairo_font_faceA, std::vector<int> &&codeToGIDA, bool substituteA, bool printingA);
52
+ virtual ~CairoFont();
53
+ CairoFont(const CairoFont &) = delete;
54
+ CairoFont &operator=(const CairoFont &other) = delete;
55
+
56
+ virtual bool matches(Ref &other, bool printing);
57
+ cairo_font_face_t *getFontFace();
58
+ unsigned long getGlyph(CharCode code, const Unicode *u, int uLen);
59
+ double getSubstitutionCorrection(const std::shared_ptr<GfxFont> &gfxFont);
60
+
61
+ bool isSubstitute() { return substitute; }
62
+
63
+ Ref getRef() { return ref; }
64
+
65
+ protected:
66
+ Ref ref;
67
+ cairo_font_face_t *cairo_font_face;
68
+
69
+ std::vector<int> codeToGID;
70
+
71
+ bool substitute;
72
+ bool printing;
73
+ };
74
+
75
+ //------------------------------------------------------------------------
76
+
77
+ struct FreeTypeFontFace
78
+ {
79
+ FT_Face face;
80
+ cairo_font_face_t *cairo_font_face;
81
+ };
82
+
83
+ class CairoFreeTypeFont : public CairoFont
84
+ {
85
+ public:
86
+ static CairoFreeTypeFont *create(const std::shared_ptr<GfxFont> &gfxFont, XRef *xref, FT_Library lib, CairoFontEngine *fontEngine, bool useCIDs);
87
+ ~CairoFreeTypeFont() override;
88
+
89
+ private:
90
+ CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face, std::vector<int> &&codeToGID, bool substitute);
91
+
92
+ static std::optional<FreeTypeFontFace> getFreeTypeFontFace(CairoFontEngine *fontEngine, FT_Library lib, const std::string &filename, std::vector<unsigned char> &&data);
93
+ };
94
+
95
+ //------------------------------------------------------------------------
96
+
97
+ class CairoType3Font : public CairoFont
98
+ {
99
+ public:
100
+ static CairoType3Font *create(const std::shared_ptr<GfxFont> &gfxFont, PDFDoc *doc, CairoFontEngine *fontEngine, bool printing, XRef *xref);
101
+ ~CairoType3Font() override;
102
+
103
+ bool matches(Ref &other, bool printing) override;
104
+
105
+ private:
106
+ CairoType3Font(Ref ref, cairo_font_face_t *cairo_font_face, std::vector<int> &&codeToGIDA, bool printing, XRef *xref);
107
+ };
108
+
109
+ //------------------------------------------------------------------------
110
+
111
+ //------------------------------------------------------------------------
112
+ // CairoFontEngine
113
+ //------------------------------------------------------------------------
114
+
115
+ class CairoFontEngine
116
+ {
117
+ public:
118
+ // Create a font engine.
119
+ explicit CairoFontEngine(FT_Library libA);
120
+ ~CairoFontEngine();
121
+ CairoFontEngine(const CairoFontEngine &) = delete;
122
+ CairoFontEngine &operator=(const CairoFontEngine &other) = delete;
123
+
124
+ std::shared_ptr<CairoFont> getFont(const std::shared_ptr<GfxFont> &gfxFont, PDFDoc *doc, bool printing, XRef *xref);
125
+
126
+ static std::optional<FreeTypeFontFace> getExternalFontFace(FT_Library ftlib, const std::string &filename);
127
+
128
+ private:
129
+ FT_Library lib;
130
+ bool useCIDs;
131
+ mutable std::mutex mutex;
132
+
133
+ // Cache of CairoFont for current document
134
+ // Most recently used is at the end of the vector.
135
+ static const size_t cairoFontCacheSize = 64;
136
+ std::vector<std::shared_ptr<CairoFont>> fontCache;
137
+
138
+ // Global cache of cairo_font_face_t for external font files.
139
+ static std::unordered_map<std::string, FreeTypeFontFace> fontFileCache;
140
+ static std::recursive_mutex fontFileCacheMutex;
141
+ };
142
+
143
+ #endif
poppler-23.11.0/Library/include/poppler/CairoOutputDev.h ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // CairoOutputDev.h
4
+ //
5
+ // Copyright 2003 Glyph & Cog, LLC
6
+ // Copyright 2004 Red Hat, INC
7
+ //
8
+ //========================================================================
9
+
10
+ //========================================================================
11
+ //
12
+ // Modified under the Poppler project - http://poppler.freedesktop.org
13
+ //
14
+ // All changes made under the Poppler project to this file are licensed
15
+ // under GPL version 2 or later
16
+ //
17
+ // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
18
+ // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
19
+ // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
20
+ // Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org>
21
+ // Copyright (C) 2008, 2009, 2011-2017, 2022, 2023 Adrian Johnson <ajohnson@redneon.com>
22
+ // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
23
+ // Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
24
+ // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
25
+ // Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
26
+ // Copyright (C) 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org>
27
+ // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
28
+ // Copyright (C) 2020 Michal <sudolskym@gmail.com>
29
+ // Copyright (C) 2021 Christian Persch <chpe@src.gnome.org>
30
+ // Copyright (C) 2022 Marek Kasik <mkasik@redhat.com>
31
+ //
32
+ // To see a description of the changes please see the Changelog file that
33
+ // came with your tarball or type make ChangeLog if you are building from git
34
+ //
35
+ //========================================================================
36
+
37
+ #ifndef CAIROOUTPUTDEV_H
38
+ #define CAIROOUTPUTDEV_H
39
+
40
+ #include <unordered_set>
41
+
42
+ #include <cairo-ft.h>
43
+ #include "OutputDev.h"
44
+ #include "TextOutputDev.h"
45
+ #include "GfxState.h"
46
+ #include "StructElement.h"
47
+ #include "StructTreeRoot.h"
48
+ #include "Annot.h"
49
+ #include "Link.h"
50
+
51
+ class PDFDoc;
52
+ class GfxState;
53
+ class GfxPath;
54
+ class Gfx8BitFont;
55
+ struct GfxRGB;
56
+ class CairoFontEngine;
57
+ class CairoFont;
58
+
59
+ //------------------------------------------------------------------------
60
+
61
+ //------------------------------------------------------------------------
62
+ // CairoImage
63
+ //------------------------------------------------------------------------
64
+ class CairoImage
65
+ {
66
+ public:
67
+ // Constructor.
68
+ CairoImage(double x1, double y1, double x2, double y2);
69
+
70
+ // Destructor.
71
+ ~CairoImage();
72
+
73
+ CairoImage(const CairoImage &) = delete;
74
+ CairoImage &operator=(const CairoImage &) = delete;
75
+
76
+ // Set the image cairo surface
77
+ void setImage(cairo_surface_t *image);
78
+
79
+ // Get the image cairo surface
80
+ cairo_surface_t *getImage() const { return image; }
81
+
82
+ // Get the image rectangle
83
+ void getRect(double *xa1, double *ya1, double *xa2, double *ya2)
84
+ {
85
+ *xa1 = x1;
86
+ *ya1 = y1;
87
+ *xa2 = x2;
88
+ *ya2 = y2;
89
+ }
90
+
91
+ private:
92
+ cairo_surface_t *image; // image cairo surface
93
+ double x1, y1; // upper left corner
94
+ double x2, y2; // lower right corner
95
+ };
96
+
97
+ //------------------------------------------------------------------------
98
+ // CairoOutputDev
99
+ //------------------------------------------------------------------------
100
+
101
+ class CairoOutputDev : public OutputDev
102
+ {
103
+ public:
104
+ // Constructor.
105
+ CairoOutputDev();
106
+
107
+ // Destructor.
108
+ ~CairoOutputDev() override;
109
+
110
+ //----- get info about output device
111
+
112
+ // Does this device use upside-down coordinates?
113
+ // (Upside-down means (0,0) is the top left corner of the page.)
114
+ bool upsideDown() override { return true; }
115
+
116
+ // Does this device use drawChar() or drawString()?
117
+ bool useDrawChar() override { return true; }
118
+
119
+ // Does this device use tilingPatternFill()? If this returns false,
120
+ // tiling pattern fills will be reduced to a series of other drawing
121
+ // operations.
122
+ bool useTilingPatternFill() override { return true; }
123
+
124
+ // Does this device use functionShadedFill(), axialShadedFill(), and
125
+ // radialShadedFill()? If this returns false, these shaded fills
126
+ // will be reduced to a series of other drawing operations.
127
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
128
+ bool useShadedFills(int type) override { return type <= 7; }
129
+ #else
130
+ bool useShadedFills(int type) override { return type > 1 && type < 4; }
131
+ #endif
132
+
133
+ // Does this device use FillColorStop()?
134
+ bool useFillColorStop() override { return true; }
135
+
136
+ // Does this device use beginType3Char/endType3Char? Otherwise,
137
+ // text in Type 3 fonts will be drawn with drawChar/drawString.
138
+ bool interpretType3Chars() override { return false; }
139
+
140
+ // Does this device need to clip pages to the crop box even when the
141
+ // box is the crop box?
142
+ bool needClipToCropBox() override { return true; }
143
+
144
+ //----- initialization and control
145
+
146
+ // Start a page.
147
+ void startPage(int pageNum, GfxState *state, XRef *xref) override;
148
+
149
+ // End a page.
150
+ void endPage() override;
151
+
152
+ // Must be called before last call to endPage()
153
+ void emitStructTree();
154
+
155
+ void beginForm(Object *obj, Ref id) override;
156
+ void endForm(Object *obj, Ref id) override;
157
+
158
+ //----- save/restore graphics state
159
+ void saveState(GfxState *state) override;
160
+ void restoreState(GfxState *state) override;
161
+
162
+ //----- update graphics state
163
+ void updateAll(GfxState *state) override;
164
+ void setDefaultCTM(const double *ctm) override;
165
+ void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override;
166
+ void updateLineDash(GfxState *state) override;
167
+ void updateFlatness(GfxState *state) override;
168
+ void updateLineJoin(GfxState *state) override;
169
+ void updateLineCap(GfxState *state) override;
170
+ void updateMiterLimit(GfxState *state) override;
171
+ void updateLineWidth(GfxState *state) override;
172
+ void updateFillColor(GfxState *state) override;
173
+ void updateStrokeColor(GfxState *state) override;
174
+ void updateFillOpacity(GfxState *state) override;
175
+ void updateStrokeOpacity(GfxState *state) override;
176
+ void updateFillColorStop(GfxState *state, double offset) override;
177
+ void updateBlendMode(GfxState *state) override;
178
+
179
+ //----- update text state
180
+ void updateFont(GfxState *state) override;
181
+
182
+ //----- path painting
183
+ void stroke(GfxState *state) override;
184
+ void fill(GfxState *state) override;
185
+ void eoFill(GfxState *state) override;
186
+ void clipToStrokePath(GfxState *state) override;
187
+ bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override;
188
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
189
+ bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;
190
+ #endif
191
+ bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
192
+ bool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override;
193
+ bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override;
194
+ bool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override;
195
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
196
+ bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override;
197
+ bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;
198
+ #endif
199
+
200
+ //----- path clipping
201
+ void clip(GfxState *state) override;
202
+ void eoClip(GfxState *state) override;
203
+
204
+ //----- text drawing
205
+ void beginString(GfxState *state, const GooString *s) override;
206
+ void endString(GfxState *state) override;
207
+ void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) override;
208
+ void beginActualText(GfxState *state, const GooString *text) override;
209
+ void endActualText(GfxState *state) override;
210
+
211
+ bool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, const Unicode *u, int uLen) override;
212
+ void endType3Char(GfxState *state) override;
213
+ void beginTextObject(GfxState *state) override;
214
+ void endTextObject(GfxState *state) override;
215
+
216
+ void beginMarkedContent(const char *name, Dict *properties) override;
217
+ void endMarkedContent(GfxState *state) override;
218
+
219
+ //----- image drawing
220
+ void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override;
221
+ void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix) override;
222
+ void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override;
223
+ void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg);
224
+ void drawImageMaskRegular(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg);
225
+
226
+ void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override;
227
+ void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
228
+ bool maskInterpolate) override;
229
+
230
+ void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override;
231
+
232
+ //----- transparency groups and soft masks
233
+ void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override;
234
+ void endTransparencyGroup(GfxState * /*state*/) override;
235
+ void popTransparencyGroup();
236
+ void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override;
237
+ void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override;
238
+ void clearSoftMask(GfxState * /*state*/) override;
239
+
240
+ //----- Type 3 font operators
241
+ void type3D0(GfxState *state, double wx, double wy) override;
242
+ void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) override;
243
+
244
+ //----- special access
245
+
246
+ // Called to indicate that a new PDF document has been loaded.
247
+ void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = nullptr);
248
+
249
+ // Called to prepare this output dev for rendering CairoType3Font.
250
+ void startType3Render(GfxState *state, XRef *xref);
251
+
252
+ bool isReverseVideo() { return false; }
253
+
254
+ void setCairo(cairo_t *cr);
255
+ void setTextPage(TextPage *text);
256
+ void setPrinting(bool printingA)
257
+ {
258
+ printing = printingA;
259
+ needFontUpdate = true;
260
+ }
261
+ void copyAntialias(cairo_t *cr, cairo_t *source_cr);
262
+ void setLogicalStructure(bool logStruct) { this->logicalStruct = logStruct; }
263
+
264
+ enum Type3RenderType
265
+ {
266
+ Type3RenderNone,
267
+ Type3RenderMask,
268
+ Type3RenderColor
269
+ };
270
+ void setType3RenderType(Type3RenderType state) { t3_render_state = state; }
271
+ void getType3GlyphWidth(double *wx, double *wy)
272
+ {
273
+ *wx = t3_glyph_wx;
274
+ *wy = t3_glyph_wy;
275
+ }
276
+ bool hasType3GlyphBBox() { return t3_glyph_has_bbox; }
277
+ double *getType3GlyphBBox() { return t3_glyph_bbox; }
278
+ bool type3GlyphHasColor() { return t3_glyph_has_color; }
279
+
280
+ protected:
281
+ void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path);
282
+ cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
283
+ void getScaledSize(const cairo_matrix_t *matrix, int orig_width, int orig_height, int *scaledWidth, int *scaledHeight);
284
+ cairo_filter_t getFilterForSurface(cairo_surface_t *image, bool interpolate);
285
+ bool getStreamData(Stream *str, char **buffer, int *length);
286
+ void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
287
+ void fillToStrokePathClip(GfxState *state);
288
+ void alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double *y);
289
+ AnnotLink *findLinkObject(const StructElement *elem);
290
+ void quadToCairoRect(AnnotQuadrilaterals *quads, int idx, double destPageHeight, cairo_rectangle_t *rect);
291
+ bool appendLinkDestRef(GooString *s, const LinkDest *dest);
292
+ void appendLinkDestXY(GooString *s, const LinkDest *dest, double destPageHeight);
293
+ bool beginLinkTag(AnnotLink *annotLink);
294
+ bool beginLink(const StructElement *linkElem);
295
+ void getStructElemAttributeString(const StructElement *elem);
296
+ int getContentElementStructParents(const StructElement *element);
297
+ bool checkIfStructElementNeeded(const StructElement *element);
298
+ void emitStructElement(const StructElement *elem);
299
+ void startFirstPage(int pageNum, GfxState *state, XRef *xrefA);
300
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
301
+ bool setMimeDataForJBIG2Globals(Stream *str, cairo_surface_t *image);
302
+ #endif
303
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
304
+ bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
305
+ #endif
306
+ static void textStringToQuotedUtf8(const GooString *text, GooString *s);
307
+ bool isPDF();
308
+
309
+ std::optional<GfxRGB> fill_color, stroke_color;
310
+ cairo_pattern_t *fill_pattern, *stroke_pattern;
311
+ double fill_opacity;
312
+ double stroke_opacity;
313
+ bool stroke_adjust;
314
+ bool adjusted_stroke_width;
315
+ bool align_stroke_coords;
316
+ std::shared_ptr<CairoFont> currentFont;
317
+ XRef *xref;
318
+
319
+ struct StrokePathClip
320
+ {
321
+ GfxPath *path;
322
+ cairo_matrix_t ctm;
323
+ double line_width;
324
+ double *dashes;
325
+ int dash_count;
326
+ double dash_offset;
327
+ cairo_line_cap_t cap;
328
+ cairo_line_join_t join;
329
+ double miter;
330
+ int ref_count;
331
+ } *strokePathClip;
332
+
333
+ PDFDoc *doc; // the current document
334
+
335
+ static FT_Library ft_lib;
336
+ static std::once_flag ft_lib_once_flag;
337
+
338
+ CairoFontEngine *fontEngine;
339
+ bool fontEngine_owner;
340
+
341
+ cairo_t *cairo;
342
+ cairo_matrix_t orig_matrix;
343
+ bool needFontUpdate; // set when the font needs to be updated
344
+ bool printing;
345
+ bool use_show_text_glyphs;
346
+ bool text_matrix_valid;
347
+ cairo_glyph_t *glyphs;
348
+ int glyphCount;
349
+ cairo_text_cluster_t *clusters;
350
+ int clusterCount;
351
+ char *utf8;
352
+ int utf8Count;
353
+ int utf8Max;
354
+ cairo_path_t *textClipPath;
355
+ bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
356
+ Type3RenderType t3_render_state;
357
+ double t3_glyph_wx, t3_glyph_wy;
358
+ bool t3_glyph_has_bbox;
359
+ bool t3_glyph_has_color;
360
+ bool has_color;
361
+ double t3_glyph_bbox[4];
362
+ bool prescaleImages;
363
+ bool logicalStruct;
364
+ bool firstPage;
365
+ int pdfPageNum; // page number of the PDF file
366
+ int cairoPageNum; // page number in cairo output
367
+ std::vector<std::string> markedContentStack;
368
+ std::vector<Annot *> annotations;
369
+ std::set<std::string> emittedDestinations;
370
+ std::map<int, int> pdfPageToCairoPageMap;
371
+
372
+ TextPage *textPage; // text for the current page
373
+ ActualText *actualText;
374
+
375
+ cairo_pattern_t *group;
376
+ cairo_pattern_t *shape;
377
+ cairo_pattern_t *mask;
378
+ cairo_matrix_t mask_matrix;
379
+ cairo_t *cairo_shape;
380
+ int knockoutCount;
381
+ struct ColorSpaceStack
382
+ {
383
+ bool knockout;
384
+ GfxColorSpace *cs;
385
+ cairo_matrix_t group_matrix;
386
+ struct ColorSpaceStack *next;
387
+ } *groupColorSpaceStack;
388
+
389
+ struct SaveStateElement
390
+ {
391
+ // These patterns hold a reference
392
+ cairo_pattern_t *fill_pattern;
393
+ cairo_pattern_t *stroke_pattern;
394
+ double fill_opacity;
395
+ double stroke_opacity;
396
+ cairo_pattern_t *mask; // can be null
397
+ cairo_matrix_t mask_matrix;
398
+ Ref fontRef;
399
+ };
400
+ std::vector<SaveStateElement> saveStateStack;
401
+
402
+ std::map<Ref, std::map<std::string, std::unique_ptr<LinkDest>>> destsMap;
403
+ std::map<Ref, int> pdfPageRefToCairoPageNumMap;
404
+ std::vector<int> structParentsStack;
405
+ int currentStructParents;
406
+
407
+ struct StructParentsMcidHash
408
+ {
409
+ size_t operator()(std::pair<int, int> x) const { return x.first << 16 | x.second; }
410
+ };
411
+ std::unordered_set<std::pair<int, int>, StructParentsMcidHash> mcidEmitted; // <structParent, MCID>
412
+
413
+ std::unordered_set<const StructElement *> structElementNeeded;
414
+ };
415
+
416
+ //------------------------------------------------------------------------
417
+ // CairoImageOutputDev
418
+ //------------------------------------------------------------------------
419
+
420
+ // XXX: this should ideally not inherit from CairoOutputDev but use it instead perhaps
421
+ class CairoImageOutputDev : public CairoOutputDev
422
+ {
423
+ public:
424
+ // Constructor.
425
+ CairoImageOutputDev();
426
+
427
+ // Destructor.
428
+ ~CairoImageOutputDev() override;
429
+
430
+ //----- get info about output device
431
+
432
+ // Does this device use upside-down coordinates?
433
+ // (Upside-down means (0,0) is the top left corner of the page.)
434
+ bool upsideDown() override { return true; }
435
+
436
+ // Does this device use drawChar() or drawString()?
437
+ bool useDrawChar() override { return false; }
438
+
439
+ // Does this device use tilingPatternFill()? If this returns false,
440
+ // tiling pattern fills will be reduced to a series of other drawing
441
+ // operations.
442
+ bool useTilingPatternFill() override { return true; }
443
+
444
+ // Does this device use functionShadedFill(), axialShadedFill(), and
445
+ // radialShadedFill()? If this returns false, these shaded fills
446
+ // will be reduced to a series of other drawing operations.
447
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
448
+ bool useShadedFills(int type) override { return type <= 7; }
449
+ #else
450
+ bool useShadedFills(int type) override { return type < 4; }
451
+ #endif
452
+
453
+ // Does this device use FillColorStop()?
454
+ bool useFillColorStop() override { return false; }
455
+
456
+ // Does this device use beginType3Char/endType3Char? Otherwise,
457
+ // text in Type 3 fonts will be drawn with drawChar/drawString.
458
+ bool interpretType3Chars() override { return false; }
459
+
460
+ // Does this device need non-text content?
461
+ bool needNonText() override { return true; }
462
+
463
+ //----- save/restore graphics state
464
+ void saveState(GfxState *state) override { }
465
+ void restoreState(GfxState *state) override { }
466
+
467
+ //----- update graphics state
468
+ void updateAll(GfxState *state) override { }
469
+ void setDefaultCTM(const double *ctm) override { }
470
+ void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override { }
471
+ void updateLineDash(GfxState *state) override { }
472
+ void updateFlatness(GfxState *state) override { }
473
+ void updateLineJoin(GfxState *state) override { }
474
+ void updateLineCap(GfxState *state) override { }
475
+ void updateMiterLimit(GfxState *state) override { }
476
+ void updateLineWidth(GfxState *state) override { }
477
+ void updateFillColor(GfxState *state) override { }
478
+ void updateStrokeColor(GfxState *state) override { }
479
+ void updateFillOpacity(GfxState *state) override { }
480
+ void updateStrokeOpacity(GfxState *state) override { }
481
+ void updateBlendMode(GfxState *state) override { }
482
+
483
+ //----- update text state
484
+ void updateFont(GfxState *state) override { }
485
+
486
+ //----- path painting
487
+ void stroke(GfxState *state) override { }
488
+ void fill(GfxState *state) override { }
489
+ void eoFill(GfxState *state) override { }
490
+ void clipToStrokePath(GfxState *state) override { }
491
+ bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override { return true; }
492
+ bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override { return true; }
493
+ bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override { return true; }
494
+
495
+ //----- path clipping
496
+ void clip(GfxState *state) override { }
497
+ void eoClip(GfxState *state) override { }
498
+
499
+ //----- image drawing
500
+ void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override;
501
+ void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override;
502
+ void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
503
+ bool maskInterpolate) override;
504
+ void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override;
505
+ void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix) override;
506
+ void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override { }
507
+
508
+ //----- transparency groups and soft masks
509
+ void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override { }
510
+ void endTransparencyGroup(GfxState * /*state*/) override { }
511
+ void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override { }
512
+ void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override { }
513
+ void clearSoftMask(GfxState * /*state*/) override { }
514
+
515
+ //----- Image list
516
+ // By default images are not rendred
517
+ void setImageDrawDecideCbk(bool (*cbk)(int img_id, void *data), void *data)
518
+ {
519
+ imgDrawCbk = cbk;
520
+ imgDrawCbkData = data;
521
+ }
522
+ // Iterate through list of images.
523
+ int getNumImages() const { return numImages; }
524
+ CairoImage *getImage(int i) const { return images[i]; }
525
+
526
+ private:
527
+ void saveImage(CairoImage *image);
528
+ void getBBox(GfxState *state, int width, int height, double *x1, double *y1, double *x2, double *y2);
529
+
530
+ CairoImage **images;
531
+ int numImages;
532
+ int size;
533
+ bool (*imgDrawCbk)(int img_id, void *data);
534
+ void *imgDrawCbkData;
535
+ };
536
+
537
+ #endif
poppler-23.11.0/Library/include/poppler/CairoRescaleBox.h ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright © 2009 Mozilla Corporation
3
+ *
4
+ * Permission to use, copy, modify, distribute, and sell this software and its
5
+ * documentation for any purpose is hereby granted without fee, provided that
6
+ * the above copyright notice appear in all copies and that both that
7
+ * copyright notice and this permission notice appear in supporting
8
+ * documentation, and that the name of Mozilla Corporation not be used in
9
+ * advertising or publicity pertaining to distribution of the software without
10
+ * specific, written prior permission. Mozilla Corporation makes no
11
+ * representations about the suitability of this software for any purpose. It
12
+ * is provided "as is" without express or implied warranty.
13
+ *
14
+ * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
16
+ * SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20
+ * OF THIS SOFTWARE.
21
+ *
22
+ * Author: Jeff Muizelaar, Mozilla Corp.
23
+ */
24
+
25
+ //========================================================================
26
+ //
27
+ // Modified under the Poppler project - http://poppler.freedesktop.org
28
+ //
29
+ // All changes made under the Poppler project to this file are licensed
30
+ // under GPL version 2 or later
31
+ //
32
+ // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
33
+ // Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
34
+ //
35
+ // To see a description of the changes please see the Changelog file that
36
+ // came with your tarball or type make ChangeLog if you are building from git
37
+ //
38
+ //========================================================================
39
+
40
+ #ifndef CAIRO_RESCALE_BOX_H
41
+ #define CAIRO_RESCALE_BOX_H
42
+
43
+ #include <cairo.h>
44
+
45
+ class CairoRescaleBox
46
+ {
47
+ public:
48
+ CairoRescaleBox() {};
49
+ virtual ~CairoRescaleBox() {};
50
+
51
+ CairoRescaleBox(const CairoRescaleBox &) = delete;
52
+ CairoRescaleBox &operator=(const CairoRescaleBox &) = delete;
53
+
54
+ virtual bool downScaleImage(unsigned orig_width, unsigned orig_height, signed scaled_width, signed scaled_height, unsigned short int start_column, unsigned short int start_row, unsigned short int width, unsigned short int height,
55
+ cairo_surface_t *dest_surface);
56
+
57
+ virtual void getRow(int row_num, uint32_t *row_data) = 0;
58
+ };
59
+
60
+ #endif /* CAIRO_RESCALE_BOX_H */
poppler-23.11.0/Library/include/poppler/Catalog.h ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //========================================================================
2
+ //
3
+ // Catalog.h
4
+ //
5
+ // Copyright 1996-2007 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ //========================================================================
10
+ //
11
+ // Modified under the Poppler project - http://poppler.freedesktop.org
12
+ //
13
+ // All changes made under the Poppler project to this file are licensed
14
+ // under GPL version 2 or later
15
+ //
16
+ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
17
+ // Copyright (C) 2005, 2007, 2009-2011, 2013, 2017-2023 Albert Astals Cid <aacid@kde.org>
18
+ // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
19
+ // Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net>
20
+ // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
21
+ // Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org>
22
+ // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
23
+ // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
24
+ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
25
+ // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com>
26
+ // Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com>
27
+ // Copyright (C) 2013 José Aliste <jaliste@src.gnome.org>
28
+ // Copyright (C) 2016 Masamichi Hosoda <trueroad@trueroad.jp>
29
+ // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
30
+ // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
31
+ // Copyright (C) 2020 Oliver Sander <oliver.sander@tu-dresden.de>
32
+ // Copyright (C) 2020 Katarina Behrens <Katarina.Behrens@cib.de>
33
+ // Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden
34
+ // Copyright (C) 2021 RM <rm+git@arcsin.org>
35
+ //
36
+ // To see a description of the changes please see the Changelog file that
37
+ // came with your tarball or type make ChangeLog if you are building from git
38
+ //
39
+ //========================================================================
40
+
41
+ #ifndef CATALOG_H
42
+ #define CATALOG_H
43
+
44
+ #include "poppler-config.h"
45
+ #include "poppler_private_export.h"
46
+ #include "Object.h"
47
+ #include "Link.h"
48
+
49
+ #include <memory>
50
+ #include <optional>
51
+ #include <vector>
52
+
53
+ class PDFDoc;
54
+ class XRef;
55
+ class Object;
56
+ class Page;
57
+ class PageAttrs;
58
+ struct Ref;
59
+ class PageLabelInfo;
60
+ class Form;
61
+ class OCGs;
62
+ class ViewerPreferences;
63
+ class FileSpec;
64
+ class StructTreeRoot;
65
+
66
+ //------------------------------------------------------------------------
67
+ // NameTree
68
+ //------------------------------------------------------------------------
69
+
70
+ class POPPLER_PRIVATE_EXPORT NameTree
71
+ {
72
+ public:
73
+ NameTree();
74
+ ~NameTree();
75
+
76
+ NameTree(const NameTree &) = delete;
77
+ NameTree &operator=(const NameTree &) = delete;
78
+
79
+ void init(XRef *xref, Object *tree);
80
+ Object lookup(const GooString *name);
81
+ int numEntries() { return length; };
82
+ // iterator accessor, note it returns a pointer to the internal object, do not free nor delete it
83
+ Object *getValue(int i);
84
+ const GooString *getName(int i) const;
85
+
86
+ private:
87
+ struct Entry
88
+ {
89
+ Entry(Array *array, int index);
90
+ ~Entry();
91
+ GooString name;
92
+ Object value;
93
+ static int cmpEntry(const void *voidEntry, const void *voidOtherEntry);
94
+ static int cmp(const void *key, const void *entry);
95
+ };
96
+
97
+ void parse(const Object *tree, RefRecursionChecker &seen);
98
+ void addEntry(Entry *entry);
99
+
100
+ XRef *xref;
101
+ Entry **entries;
102
+ int size, length; // size is the number of entries in
103
+ // the array of Entry*
104
+ // length is the number of real Entry
105
+ };
106
+
107
+ //------------------------------------------------------------------------
108
+ // Catalog
109
+ //------------------------------------------------------------------------
110
+
111
+ class POPPLER_PRIVATE_EXPORT Catalog
112
+ {
113
+ public:
114
+ // Constructor.
115
+ explicit Catalog(PDFDoc *docA);
116
+
117
+ // Destructor.
118
+ ~Catalog();
119
+
120
+ Catalog(const Catalog &) = delete;
121
+ Catalog &operator=(const Catalog &) = delete;
122
+
123
+ // Is catalog valid?
124
+ bool isOk() { return ok; }
125
+
126
+ // Get number of pages.
127
+ int getNumPages();
128
+
129
+ // Get a page.
130
+ Page *getPage(int i);
131
+
132
+ // Get the reference for a page object.
133
+ Ref *getPageRef(int i);
134
+
135
+ // Return base URI, or NULL if none.
136
+ const std::optional<std::string> &getBaseURI() const { return baseURI; }
137
+
138
+ // Return the contents of the metadata stream, or NULL if there is
139
+ // no metadata.
140
+ std::unique_ptr<GooString> readMetadata();
141
+
142
+ // Return the structure tree root object.
143
+ StructTreeRoot *getStructTreeRoot();
144
+
145
+ // Return values from the MarkInfo dictionary as flags in a bitfield.
146
+ enum MarkInfoFlags
147
+ {
148
+ markInfoNull = 1 << 0,
149
+ markInfoMarked = 1 << 1,
150
+ markInfoUserProperties = 1 << 2,
151
+ markInfoSuspects = 1 << 3,
152
+ };
153
+ unsigned int getMarkInfo();
154
+
155
+ // Find a page, given its object ID. Returns page number, or 0 if
156
+ // not found.
157
+ int findPage(const Ref pageRef);
158
+
159
+ // Find a named destination. Returns the link destination, or
160
+ // NULL if <name> is not a destination.
161
+ std::unique_ptr<LinkDest> findDest(const GooString *name);
162
+
163
+ Object *getDests();
164
+
165
+ // Get the number of named destinations in name-dict
166
+ int numDests();
167
+
168
+ // Get the i'th named destination name in name-dict
169
+ const char *getDestsName(int i);
170
+
171
+ // Get the i'th named destination link destination in name-dict
172
+ std::unique_ptr<LinkDest> getDestsDest(int i);
173
+
174
+ // Get the number of named destinations in name-tree
175
+ int numDestNameTree() { return getDestNameTree()->numEntries(); }
176
+
177
+ // Get the i'th named destination name in name-tree
178
+ const GooString *getDestNameTreeName(int i) { return getDestNameTree()->getName(i); }
179
+
180
+ // Get the i'th named destination link destination in name-tree
181
+ std::unique_ptr<LinkDest> getDestNameTreeDest(int i);
182
+
183
+ // Get the number of embedded files
184
+ int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
185
+
186
+ // Get the i'th file embedded (at the Document level) in the document
187
+ std::unique_ptr<FileSpec> embeddedFile(int i);
188
+
189
+ // Is there an embedded file with the given name?
190
+ bool hasEmbeddedFile(const std::string &fileName);
191
+
192
+ // Adds and embeddedFile
193
+ // If there is already an existing embedded file with the given fileName
194
+ // it gets replaced, if that's not what you want check hasEmbeddedFile first
195
+ void addEmbeddedFile(GooFile *file, const std::string &fileName);
196
+
197
+ // Get the number of javascript scripts
198
+ int numJS() { return getJSNameTree()->numEntries(); }
199
+ const GooString *getJSName(int i) { return getJSNameTree()->getName(i); }
200
+
201
+ // Get the i'th JavaScript script (at the Document level) in the document
202
+ GooString *getJS(int i);
203
+
204
+ // Convert between page indices and page labels.
205
+ bool labelToIndex(GooString *label, int *index);
206
+ bool indexToLabel(int index, GooString *label);
207
+
208
+ Object *getOutline();
209
+ // returns the existing outline or new one if it doesn't exist
210
+ Object *getCreateOutline();
211
+
212
+ Object *getAcroForm() { return &acroForm; }
213
+ void addFormToAcroForm(const Ref formRef);
214
+ void removeFormFromAcroForm(const Ref formRef);
215
+ void setAcroFormModified();
216
+
217
+ OCGs *getOptContentConfig() { return optContent; }
218
+
219
+ int getPDFMajorVersion() const { return catalogPdfMajorVersion; }
220
+ int getPDFMinorVersion() const { return catalogPdfMinorVersion; }
221
+
222
+ enum FormType
223
+ {
224
+ NoForm,
225
+ AcroForm,
226
+ XfaForm
227
+ };
228
+
229
+ FormType getFormType();
230
+ // This can return nullptr if the document is in a very damaged state
231
+ Form *getCreateForm();
232
+ Form *getForm();
233
+
234
+ ViewerPreferences *getViewerPreferences();
235
+
236
+ enum PageMode
237
+ {
238
+ pageModeNone,
239
+ pageModeOutlines,
240
+ pageModeThumbs,
241
+ pageModeFullScreen,
242
+ pageModeOC,
243
+ pageModeAttach,
244
+ pageModeNull
245
+ };
246
+ enum PageLayout
247
+ {
248
+ pageLayoutNone,
249
+ pageLayoutSinglePage,
250
+ pageLayoutOneColumn,
251
+ pageLayoutTwoColumnLeft,
252
+ pageLayoutTwoColumnRight,
253
+ pageLayoutTwoPageLeft,
254
+ pageLayoutTwoPageRight,
255
+ pageLayoutNull
256
+ };
257
+
258
+ // Returns the page mode.
259
+ PageMode getPageMode();
260
+ PageLayout getPageLayout();
261
+
262
+ enum DocumentAdditionalActionsType
263
+ {
264
+ actionCloseDocument, ///< Performed before closing the document
265
+ actionSaveDocumentStart, ///< Performed before saving the document
266
+ actionSaveDocumentFinish, ///< Performed after saving the document
267
+ actionPrintDocumentStart, ///< Performed before printing the document
268
+ actionPrintDocumentFinish, ///< Performed after printing the document
269
+ };
270
+
271
+ std::unique_ptr<LinkAction> getAdditionalAction(DocumentAdditionalActionsType type);
272
+
273
+ private:
274
+ // Get page label info.
275
+ PageLabelInfo *getPageLabelInfo();
276
+
277
+ PDFDoc *doc;
278
+ XRef *xref; // the xref table for this PDF file
279
+ std::vector<std::pair<std::unique_ptr<Page>, Ref>> pages;
280
+ std::vector<Object> *pagesList;
281
+ std::vector<Ref> *pagesRefList;
282
+ std::vector<PageAttrs *> *attrsList;
283
+ std::vector<int> *kidsIdxList;
284
+ Form *form;
285
+ ViewerPreferences *viewerPrefs;
286
+ int numPages; // number of pages
287
+ Object dests; // named destination dictionary
288
+ Object names; // named names dictionary
289
+ NameTree *destNameTree; // named destination name-tree
290
+ NameTree *embeddedFileNameTree; // embedded file name-tree
291
+ NameTree *jsNameTree; // Java Script name-tree
292
+ std::optional<std::string> baseURI; // base URI for URI-type links
293
+ Object metadata; // metadata stream
294
+ StructTreeRoot *structTreeRoot; // structure tree root
295
+ unsigned int markInfo; // Flags from MarkInfo dictionary
296
+ Object outline; // outline dictionary
297
+ Object acroForm; // AcroForm dictionary
298
+ Object viewerPreferences; // ViewerPreference dictionary
299
+ OCGs *optContent; // Optional Content groups
300
+ bool ok; // true if catalog is valid
301
+ PageLabelInfo *pageLabelInfo; // info about page labels
302
+ PageMode pageMode; // page mode
303
+ PageLayout pageLayout; // page layout
304
+ Object additionalActions; // page additional actions
305
+
306
+ bool cachePageTree(int page); // Cache first <page> pages.
307
+ Object *findDestInTree(Object *tree, GooString *name, Object *obj);
308
+
309
+ Object *getNames();
310
+ NameTree *getDestNameTree();
311
+ NameTree *getEmbeddedFileNameTree();
312
+ NameTree *getJSNameTree();
313
+ std::unique_ptr<LinkDest> createLinkDest(Object *obj);
314
+
315
+ int catalogPdfMajorVersion = -1;
316
+ int catalogPdfMinorVersion = -1;
317
+
318
+ mutable std::recursive_mutex mutex;
319
+ };
320
+
321
+ #endif