download.lst                                   |    4 
 external/pdfium/Library_pdfium.mk              |   84 ++++-----
 external/pdfium/README                         |    2 
 external/pdfium/UnpackedTarball_pdfium.mk      |   19 --
 external/pdfium/build.patch.1                  |  229 ++++++++++++++-----------
 external/pdfium/c++20-comparison.patch         |   12 -
 external/pdfium/configs/build_config.h         |  132 --------------
 external/pdfium/inc/pch/precompiled_pdfium.hxx |   58 ++----
 external/pdfium/msvc2017.patch.1               |   15 +
 svx/source/svdraw/svdpdf.cxx                   |    4 
 10 files changed, 233 insertions(+), 326 deletions(-)

New commits:
commit 2e04f804b5f82770435f250873f07b3384d95504
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed May 24 20:13:48 2023 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:37 2023 +0200

    Update pdfium to 5778
    
    - external/pdfium/abseil-trivial.patch is no longer needed, upstream
      does what we did previously
    
    - external/pdfium/build.patch.1: re-generate with 'patch -p1' + 'git
      diff'
    
    - external/pdfium/include.patch is no longer needed, upstream does what
      we did previously
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152244
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit dc69e7c52f12f57197f26b56c968139186d4ed5b)
    
    Change-Id: I39a6f721e436aa53914bbf43b78ac7d86e5eac59

diff --git a/download.lst b/download.lst
index 3eafd39191af..8b5d876b4f4e 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
1a625b25562fb4c25c8bf4660c704111cdd306b8934b94dcd9b89329909ede55
-PDFIUM_TARBALL := pdfium-5636.tar.bz2
+PDFIUM_SHA256SUM := 
b1052ff24e9ffb11af017c444bb0f6ad508d64c9a0fb88cacb0e8210245dde06
+PDFIUM_TARBALL := pdfium-5778.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index 0e83455ee165..136ebd7bf7e5 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -286,6 +286,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfunc \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_basedcs \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_indexedcs \
+    UnpackedTarball/pdfium/core/fpdfapi/parser/object_tree_traversal_util \
 ))
 
 # fpdfdoc
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index dc2c13449e15..07004e8de71d 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -11,7 +11,6 @@ pdfium_patches :=
 pdfium_patches += ubsan.patch
 # Fixes build on our baseline.
 pdfium_patches += build.patch.1
-pdfium_patches += include.patch.1
 pdfium_patches += msvc2017.patch.1
 # Avoids Windows 8 build dependency.
 pdfium_patches += windows7.patch.1
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 6fe994f00a2c..909149d1d3ad 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -1,8 +1,66 @@
+-*- Mode: diff -*-
+diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp 
b/core/fpdfapi/font/cpdf_cidfont.cpp
+index f5a51b24e..8b308d0a6 100644
+--- a/core/fpdfapi/font/cpdf_cidfont.cpp
++++ b/core/fpdfapi/font/cpdf_cidfont.cpp
+@@ -755,7 +755,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, 
bool* pVertGlyph) {
+         uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
+             FT_ENCODING_APPLE_ROMAN, name_unicode);
+         index = maccode ? FT_Get_Char_Index(face, maccode)
+-                        : FT_Get_Name_Index(face, name);
++                        : FT_Get_Name_Index(face, const_cast<char*>(name));
+       }
+       if (index == 0 || index == 0xffff)
+         return charcode ? static_cast<int>(charcode) : -1;
+diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp 
b/core/fpdfapi/font/cpdf_truetypefont.cpp
+index 0a59b54eb..a96e11759 100644
+--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
++++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
+@@ -91,7 +91,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
+               FT_ENCODING_APPLE_ROMAN,
+               m_Encoding.UnicodeFromCharCode(charcode));
+           if (!maccode) {
+-            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+           } else {
+             m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
+           }
+@@ -105,7 +105,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
+         continue;
+       }
+-      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+       if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
+         continue;
+ 
+diff --git a/core/fpdfapi/font/cpdf_type1font.cpp 
b/core/fpdfapi/font/cpdf_type1font.cpp
+index 55510e7d7..2f13f00b8 100644
+--- a/core/fpdfapi/font/cpdf_type1font.cpp
++++ b/core/fpdfapi/font/cpdf_type1font.cpp
+@@ -263,7 +263,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
+                                           static_cast<uint32_t>(charcode));
+       if (name) {
+         m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+       } else {
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(
+             m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
+@@ -294,7 +294,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
+       continue;
+ 
+     m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+     if (m_GlyphIndex[charcode] != 0)
+       continue;
+ 
 diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
-index 323de4ffc..f11a0b0ad 100644
+index 228a0c137..bf512beb3 100644
 --- a/core/fpdfdoc/cpdf_metadata.cpp
 +++ b/core/fpdfdoc/cpdf_metadata.cpp
-@@ -74,7 +74,7 @@ std::vector<UnsupportedFeature> 
CPDF_Metadata::CheckForSharedForm() const {
+@@ -77,7 +77,7 @@ std::vector<UnsupportedFeature> 
CPDF_Metadata::CheckForSharedForm() const {
    CFX_XMLParser parser(stream);
    std::unique_ptr<CFX_XMLDocument> doc = parser.Parse();
    if (!doc)
@@ -11,32 +69,6 @@ index 323de4ffc..f11a0b0ad 100644
  
    std::vector<UnsupportedFeature> unsupported;
    CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
-diff --git a/third_party/base/span.h b/third_party/base/span.h
-index ec9f9903f..1c17ad091 100644
---- a/third_party/base/span.h
-+++ b/third_party/base/span.h
-@@ -208,7 +208,7 @@ class span {
-   // Conversions from spans of compatible types: this allows a span<T> to be
-   // seamlessly used as a span<const T>, but not the other way around.
-   template <typename U, typename = internal::EnableIfLegalSpanConversion<U, 
T>>
--  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
-+  span(const span<U>& other) : span(other.data(), other.size()) {}
-   span& operator=(const span& other) noexcept {
-     if (this != &other) {
-       ReleaseEmptySpan();
-diff --git a/third_party/base/span.h b/third_party/base/span.h
-index 0fb627ba8..dda1fc8bc 100644
---- a/third_party/base/span.h
-+++ b/third_party/base/span.h
-@@ -204,7 +204,7 @@ class span {
-   // size()|.
-   template <typename Container,
-             typename = internal::EnableIfSpanCompatibleContainer<Container, 
T>>
--  constexpr span(Container& container)
-+  span(Container& container)
-       : span(container.data(), container.size()) {}
-   template <
-       typename Container,
 --- a/core/fxge/dib/cfx_cmyk_to_srgb.cpp       2020-09-10 17:32:37.165872018 
+0200
 +++ b/core/fxge/dib/cfx_cmyk_to_srgb.cpp       2020-09-10 17:33:15.870395738 
+0200
 @@ -1740,10 +1740,12 @@
@@ -53,10 +85,10 @@ index 0fb627ba8..dda1fc8bc 100644
    uint8_t r;
    uint8_t g;
 diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp 
b/core/fxcodec/jpx/cjpx_decoder.cpp
-index d8875786c..bc019ebe1 100644
+index 9391d61ab..490ce2230 100644
 --- a/core/fxcodec/jpx/cjpx_decoder.cpp
 +++ b/core/fxcodec/jpx/cjpx_decoder.cpp
-@@ -73,7 +73,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
+@@ -75,7 +75,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
    if (!data.b)
      return absl::nullopt;
  
@@ -66,10 +98,10 @@ index d8875786c..bc019ebe1 100644
  
  void sycc_to_rgb(int offset,
 diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
-index 8b3a72700..ea1db23f4 100644
+index a2a44df39..d6cedee46 100644
 --- a/core/fxge/cfx_font.cpp
 +++ b/core/fxge/cfx_font.cpp
-@@ -47,25 +47,9 @@ struct OUTLINE_PARAMS {
+@@ -48,25 +48,9 @@ struct OUTLINE_PARAMS {
  // TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be
  // available to all users in the future, remove FreeMMVar() and use
  // FT_Done_MM_Var() directly.
@@ -96,10 +128,10 @@ index 8b3a72700..ea1db23f4 100644
  
  FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) 
{
 diff --git a/third_party/base/numerics/safe_conversions_impl.h 
b/third_party/base/numerics/safe_conversions_impl.h
-index 4d8a7b7d9..d14c6dc06 100644
+index 44c921a14..0152a89b7 100644
 --- a/third_party/base/numerics/safe_conversions_impl.h
 +++ b/third_party/base/numerics/safe_conversions_impl.h
-@@ -88,7 +88,7 @@ constexpr typename std::make_unsigned<T>::type 
SafeUnsignedAbs(T value) {
+@@ -89,7 +89,7 @@ constexpr typename std::make_unsigned<T>::type 
SafeUnsignedAbs(T value) {
  
  // TODO(jschuh): Switch to std::is_constant_evaluated() once C++20 is 
supported.
  // Alternately, the usage could be restructured for "consteval if" in C++23.
@@ -108,57 +140,28 @@ index 4d8a7b7d9..d14c6dc06 100644
  
  // TODO(jschuh): Debug builds don't reliably propagate constants, so we 
restrict
  // some accelerated runtime paths to release builds until this can be forced
---- pdfium/core/fpdfapi/font/cpdf_cidfont.cpp.orig     2022-05-20 
09:25:52.066728467 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_cidfont.cpp  2022-05-20 09:25:56.146736531 
+0000
-@@ -738,7 +738,7 @@
-         uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
-             FT_ENCODING_APPLE_ROMAN, name_unicode);
-         index = maccode ? FT_Get_Char_Index(face, maccode)
--                        : FT_Get_Name_Index(face, name);
-+                        : FT_Get_Name_Index(face, const_cast<char*>(name));
-       }
-       if (index == 0 || index == 0xffff)
-         return charcode ? static_cast<int>(charcode) : -1;
---- pdfium/core/fpdfapi/font/cpdf_type1font.cpp.orig   2022-05-20 
09:26:59.090862058 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_type1font.cpp        2022-05-20 
09:27:33.810932435 +0000
-@@ -260,7 +260,7 @@
-                                           static_cast<uint32_t>(charcode));
-       if (name) {
-         m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
--        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
-+        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
-       } else {
-         m_GlyphIndex[charcode] = FT_Get_Char_Index(
-             m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
-@@ -291,7 +291,7 @@
-       continue;
- 
-     m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
--    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
-+    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
-     if (m_GlyphIndex[charcode] != 0)
-       continue;
- 
---- pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp.orig        2022-05-20 
09:26:12.066767996 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp     2022-05-20 
09:26:46.690836923 +0000
-@@ -90,7 +90,7 @@
-               FT_ENCODING_APPLE_ROMAN,
-               m_Encoding.UnicodeFromCharCode(charcode));
-           if (!maccode) {
--            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
-+            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
-           } else {
-             m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
-           }
-@@ -104,7 +104,7 @@
-         m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
-         continue;
-       }
--      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
-+      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
-       if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
-         continue;
+diff --git a/third_party/base/span.h b/third_party/base/span.h
+index ed2a3c8de..87493861c 100644
+--- a/third_party/base/span.h
++++ b/third_party/base/span.h
+@@ -211,7 +211,7 @@ class TRIVIAL_ABI GSL_POINTER span {
+ #else
+   template <typename Container,
+             typename = internal::EnableIfSpanCompatibleContainer<Container, 
T>>
+-  constexpr span(Container& container)
++  span(Container& container)
+       : span(container.data(), container.size()) {}
+ #endif
  
+@@ -225,7 +225,7 @@ class TRIVIAL_ABI GSL_POINTER span {
+   // Conversions from spans of compatible types: this allows a span<T> to be
+   // seamlessly used as a span<const T>, but not the other way around.
+   template <typename U, typename = internal::EnableIfLegalSpanConversion<U, 
T>>
+-  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
++  span(const span<U>& other) : span(other.data(), other.size()) {}
+   span& operator=(const span& other) noexcept {
+     if (this != &other) {
+       ReleaseEmptySpan();
 diff --git a/third_party/libopenjpeg/openjpeg.c 
b/third_party/libopenjpeg/openjpeg.c
 index 29d3ee528..d5c7a1bc9 100644
 --- a/third_party/libopenjpeg/openjpeg.c
diff --git a/external/pdfium/include.patch.1 b/external/pdfium/include.patch.1
deleted file mode 100644
index 2d123017e049..000000000000
--- a/external/pdfium/include.patch.1
+++ /dev/null
@@ -1,11 +0,0 @@
---- pdfium/constants/annotation_flags.h.orig   2023-06-26 14:53:05.531326301 
+0200
-+++ pdfium/constants/annotation_flags.h        2023-06-26 14:53:10.921369624 
+0200
-@@ -5,6 +5,8 @@
- #ifndef CONSTANTS_ANNOTATION_FLAGS_H_
- #define CONSTANTS_ANNOTATION_FLAGS_H_
- 
-+#include <stdint.h>
-+
- namespace pdfium {
- namespace annotation_flags {
- 
commit 380ab5b7232cd3a2c377697af9cc86a4702cf975
Author:     Miklos Vajna <[email protected]>
AuthorDate: Fri Mar 10 17:21:42 2023 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:37 2023 +0200

    Update pdfium to 5636
    
    Some changes in the bundled libtiff, but it seems that would be for XFA
    which we disable, so it doesn't affect us.
    
    Change-Id: Ibadeecf20daec342fbfef6d1e89bd17f5f0095e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148652
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 47afcad0d599009c38b4597c27558ec2af58b7f8)

diff --git a/download.lst b/download.lst
index 86dcb38fa388..3eafd39191af 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
9fae5f8b3b90a4f7ca663f741e232e1e4c3f098fb7a18b0ad52e74ae172cf16c
-PDFIUM_TARBALL := pdfium-5522.tar.bz2
+PDFIUM_SHA256SUM := 
1a625b25562fb4c25c8bf4660c704111cdd306b8934b94dcd9b89329909ede55
+PDFIUM_TARBALL := pdfium-5636.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index 315b5d81ec12..6258e8036360 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -310,6 +310,8 @@
 #include <core/fxcrt/fileaccess_iface.h>
 #include <core/fxcrt/fixed_try_alloc_zeroed_data_vector.h>
 #include <core/fxcrt/fixed_uninit_data_vector.h>
+#include <core/fxcrt/fixed_zeroed_data_vector.h>
+#include <core/fxcrt/fx_2d_size.h>
 #include <core/fxcrt/fx_bidi.h>
 #include <core/fxcrt/fx_codepage.h>
 #include <core/fxcrt/fx_coordinates.h>
commit f36e4e8d2a948d519149101bcbb7fcf1b51b549d
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Jan 12 20:12:37 2023 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:37 2023 +0200

    Update pdfium to 5522
    
    The internal libpng 1.6 is now dropped, but that doesn't really affect
    us.
    
    Change-Id: I777c024c76c17689c20bbe6453467ba5fb22baba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145417
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 04fd7d0f53faa08c608034707ca4a459a162712d)

diff --git a/download.lst b/download.lst
index 213606f6ab90..86dcb38fa388 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
7db59b1e91f2bc0ab4c5e19d1a4f881e6a47dbb0d3b7e980a7358225b12a0f35
-PDFIUM_TARBALL := pdfium-5408.tar.bz2
+PDFIUM_SHA256SUM := 
9fae5f8b3b90a4f7ca663f741e232e1e4c3f098fb7a18b0ad52e74ae172cf16c
+PDFIUM_TARBALL := pdfium-5522.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
commit 7d7ca3e9938a3e97cc3f63c2d75f7067cdfaf1f5
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Nov 9 13:19:49 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:37 2023 +0200

    Update pdfium to 5408
    
    - drop cg-instead-of-carbon.patch.1, no longer needed after
      https://pdfium-review.googlesource.com/c/pdfium/+/99753
    
    - drop AndroidNDK19.patch.1, no longer needed after
      https://pdfium-review.googlesource.com/c/pdfium/+/96530
    
    - drop gcc-c++20-comparison.patch, no longer needed after
      
<https://pdfium.googlesource.com/pdfium/+/065698acf82962a3168a0d56bb1d5964bc593d00>
      "Fix interaction between RetainPtr<T> and transparent comparisons" since
      chromium/5321
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142474
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 5a69fd3052bb638857f30a4cfd5913634275d23d)
    
    Change-Id: I1f861dd8a3d490400bb39c108bd4e767a2f45d30

diff --git a/download.lst b/download.lst
index 7766130853f4..213606f6ab90 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
ecb9c2a0d777196949994946e3f24ed251ae5d3db8a9fa1e2827ef857151db13
-PDFIUM_TARBALL := pdfium-5298.tar.bz2
+PDFIUM_SHA256SUM := 
7db59b1e91f2bc0ab4c5e19d1a4f881e6a47dbb0d3b7e980a7358225b12a0f35
+PDFIUM_TARBALL := pdfium-5408.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index 8f072939e736..0e83455ee165 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -237,9 +237,9 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/render/charposlist \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_devicebuffer \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_docrenderdata \
-    UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imageloader \
+    UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_imageloader \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imagerenderer \
-    UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_pagerendercache \
+    UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_pageimagecache \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_progressiverenderer \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_rendercontext \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_renderoptions \
@@ -563,17 +563,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
 
 # pdfium_base
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/page_allocator
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/spin_lock 
\
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_alloc
 \
     UnpackedTarball/pdfium/third_party/base/debug/alias \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/oom_callback
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_bucket
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_oom
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_page
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_root_base
 \
-    
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/random \
     UnpackedTarball/pdfium/third_party/base/memory/aligned_memory \
 ))
 
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 67d68133da27..dc2c13449e15 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -32,17 +32,7 @@ $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
     mv third_party/bigint/BigIntegerUtils.cc 
third_party/bigint/BigIntegerUtils.cpp && \
     mv third_party/bigint/BigUnsigned.cc third_party/bigint/BigUnsigned.cpp && 
\
     mv third_party/bigint/BigUnsignedInABase.cc 
third_party/bigint/BigUnsignedInABase.cpp && \
-    mv 
third_party/base/allocator/partition_allocator/address_space_randomization.cc 
third_party/base/allocator/partition_allocator/address_space_randomization.cpp 
&& \
-    mv third_party/base/allocator/partition_allocator/page_allocator.cc 
third_party/base/allocator/partition_allocator/page_allocator.cpp && \
-    mv third_party/base/allocator/partition_allocator/partition_alloc.cc 
third_party/base/allocator/partition_allocator/partition_alloc.cpp && \
-    mv third_party/base/allocator/partition_allocator/spin_lock.cc 
third_party/base/allocator/partition_allocator/spin_lock.cpp && \
     mv third_party/base/debug/alias.cc third_party/base/debug/alias.cpp && \
-    mv third_party/base/allocator/partition_allocator/oom_callback.cc 
third_party/base/allocator/partition_allocator/oom_callback.cpp && \
-    mv third_party/base/allocator/partition_allocator/partition_bucket.cc 
third_party/base/allocator/partition_allocator/partition_bucket.cpp && \
-    mv third_party/base/allocator/partition_allocator/partition_oom.cc 
third_party/base/allocator/partition_allocator/partition_oom.cpp && \
-    mv third_party/base/allocator/partition_allocator/partition_page.cc 
third_party/base/allocator/partition_allocator/partition_page.cpp && \
-    mv third_party/base/allocator/partition_allocator/partition_root_base.cc 
third_party/base/allocator/partition_allocator/partition_root_base.cpp && \
-    mv third_party/base/allocator/partition_allocator/random.cc 
third_party/base/allocator/partition_allocator/random.cpp && \
     mv third_party/base/memory/aligned_memory.cc 
third_party/base/memory/aligned_memory.cpp && \
     mv third_party/base/win/win_util.cc third_party/base/win/win_util.cpp && \
     mv third_party/libopenjpeg/opj_malloc.cc 
third_party/libopenjpeg/opj_malloc.cpp && \
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 96ba9e6efb1f..6fe994f00a2c 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -172,16 +172,3 @@ index 29d3ee528..d5c7a1bc9 100644
          OPJ_BOOL strict)
  {
      if (p_codec) {
-diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp 
b/core/fpdfapi/parser/cpdf_data_avail.cpp
-index a17ec0353..3b024ac91 100644
---- a/core/fpdfapi/parser/cpdf_data_avail.cpp
-+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
-@@ -902,7 +902,7 @@ CPDF_DataAvail::DocAvailStatus 
CPDF_DataAvail::CheckResources(
-   CPDF_PageObjectAvail* resource_avail =
-       m_PagesResourcesAvail
-           .insert(std::make_pair(
--              resources,
-+              resources.Get(),
-               std::make_unique<CPDF_PageObjectAvail>(
-                   GetValidator(), m_pDocument.Get(), resources.Get())))
-           .first->second.get();
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index cdfdca0083f8..315b5d81ec12 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which 
presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-05-06 11:57:12 using:
+ Generated on 2022-11-08 17:05:53 using:
  ./bin/update_pch external/pdfium pdfium --cutoff=1 --exclude:system 
--include:module --include:local
 
  If after updating build fails, use the following command to locate 
conflicting headers:
@@ -31,7 +31,6 @@
 #include <agg_vcgen_stroke.h>
 #include <algorithm>
 #include <array>
-#include <atomic>
 #include <cassert>
 #include <cfloat>
 #include <climits>
@@ -127,11 +126,13 @@
 #include <core/fpdfapi/page/cpdf_graphicstates.h>
 #include <core/fpdfapi/page/cpdf_iccprofile.h>
 #include <core/fpdfapi/page/cpdf_image.h>
+#include <core/fpdfapi/page/cpdf_imageloader.h>
 #include <core/fpdfapi/page/cpdf_imageobject.h>
 #include <core/fpdfapi/page/cpdf_indexedcs.h>
 #include <core/fpdfapi/page/cpdf_meshstream.h>
 #include <core/fpdfapi/page/cpdf_occontext.h>
 #include <core/fpdfapi/page/cpdf_page.h>
+#include <core/fpdfapi/page/cpdf_pageimagecache.h>
 #include <core/fpdfapi/page/cpdf_pagemodule.h>
 #include <core/fpdfapi/page/cpdf_pageobject.h>
 #include <core/fpdfapi/page/cpdf_pageobjectholder.h>
@@ -189,9 +190,7 @@
 #include <core/fpdfapi/render/charposlist.h>
 #include <core/fpdfapi/render/cpdf_devicebuffer.h>
 #include <core/fpdfapi/render/cpdf_docrenderdata.h>
-#include <core/fpdfapi/render/cpdf_imageloader.h>
 #include <core/fpdfapi/render/cpdf_imagerenderer.h>
-#include <core/fpdfapi/render/cpdf_pagerendercache.h>
 #include <core/fpdfapi/render/cpdf_pagerendercontext.h>
 #include <core/fpdfapi/render/cpdf_progressiverenderer.h>
 #include <core/fpdfapi/render/cpdf_rendercontext.h>
@@ -309,6 +308,8 @@
 #include <core/fxcrt/css/cfx_cssvaluelistparser.h>
 #include <core/fxcrt/data_vector.h>
 #include <core/fxcrt/fileaccess_iface.h>
+#include <core/fxcrt/fixed_try_alloc_zeroed_data_vector.h>
+#include <core/fxcrt/fixed_uninit_data_vector.h>
 #include <core/fxcrt/fx_bidi.h>
 #include <core/fxcrt/fx_codepage.h>
 #include <core/fxcrt/fx_coordinates.h>
@@ -461,22 +462,6 @@
 #include <third_party/agg23/agg_rasterizer_scanline_aa.h>
 #include <third_party/agg23/agg_renderer_scanline.h>
 #include <third_party/agg23/agg_scanline_u.h>
-#include 
<third_party/base/allocator/partition_allocator/address_space_randomization.h>
-#include <third_party/base/allocator/partition_allocator/oom.h>
-#include <third_party/base/allocator/partition_allocator/oom_callback.h>
-#include <third_party/base/allocator/partition_allocator/page_allocator.h>
-#include 
<third_party/base/allocator/partition_allocator/page_allocator_internal.h>
-#include <third_party/base/allocator/partition_allocator/partition_alloc.h>
-#include 
<third_party/base/allocator/partition_allocator/partition_alloc_check.h>
-#include 
<third_party/base/allocator/partition_allocator/partition_alloc_constants.h>
-#include <third_party/base/allocator/partition_allocator/partition_bucket.h>
-#include 
<third_party/base/allocator/partition_allocator/partition_direct_map_extent.h>
-#include <third_party/base/allocator/partition_allocator/partition_oom.h>
-#include <third_party/base/allocator/partition_allocator/partition_page.h>
-#include <third_party/base/allocator/partition_allocator/partition_root_base.h>
-#include <third_party/base/allocator/partition_allocator/random.h>
-#include <third_party/base/allocator/partition_allocator/spin_lock.h>
-#include <third_party/base/bits.h>
 #include <third_party/base/check.h>
 #include <third_party/base/check_op.h>
 #include <third_party/base/compiler_specific.h>
commit 6b46ab335d457e04ded3bd2a3a5dc75de0cd5482
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Sep 13 20:26:53 2022 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 5298
    
    pdfium_arm64.patch.1 is now upstreamed as
    <https://pdfium-review.googlesource.com/c/pdfium/+/96010>.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139876
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit c97c60f70e9e6de594f7e0e0b85f17944c640dcf)
    
    Change-Id: Iafb1ba480161429094db5446ab50314068ae4cfc

diff --git a/download.lst b/download.lst
index 23fb842285f7..7766130853f4 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
04e0e3f90589250c1fa97cec543af6f5e6c8c2daa377d614ec1f04b061b86651
-PDFIUM_TARBALL := pdfium-5187.tar.bz2
+PDFIUM_SHA256SUM := 
ecb9c2a0d777196949994946e3f24ed251ae5d3db8a9fa1e2827ef857151db13
+PDFIUM_TARBALL := pdfium-5298.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index 5da615312764..8f072939e736 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -237,7 +237,6 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/render/charposlist \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_devicebuffer \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_docrenderdata \
-    UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imagecacheentry \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imageloader \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imagerenderer \
     UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_pagerendercache \
@@ -406,10 +405,8 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssoutputtextbuf \
     UnpackedTarball/pdfium/core/fxcrt/cfx_datetime \
     UnpackedTarball/pdfium/core/fxcrt/bytestring \
-    UnpackedTarball/pdfium/core/fxcrt/cfx_binarybuf \
     UnpackedTarball/pdfium/core/fxcrt/cfx_bitstream \
     UnpackedTarball/pdfium/core/fxcrt/cfx_utf8decoder \
-    UnpackedTarball/pdfium/core/fxcrt/cfx_widetextbuf \
     UnpackedTarball/pdfium/core/fxcrt/fx_random \
     UnpackedTarball/pdfium/core/fxcrt/fx_string \
     UnpackedTarball/pdfium/core/fxcrt/widestring \
@@ -417,9 +414,14 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxcrt/fx_codepage \
     UnpackedTarball/pdfium/core/fxcrt/fx_number \
     UnpackedTarball/pdfium/core/fxcrt/cfx_utf8encoder \
-    UnpackedTarball/pdfium/core/fxcrt/cfx_readonlymemorystream \
     UnpackedTarball/pdfium/core/fxcrt/observed_ptr \
     UnpackedTarball/pdfium/core/fxcrt/string_data_template \
+    UnpackedTarball/pdfium/core/fxcrt/binary_buffer \
+    UnpackedTarball/pdfium/core/fxcrt/cfx_read_only_span_stream \
+    UnpackedTarball/pdfium/core/fxcrt/cfx_read_only_string_stream \
+    UnpackedTarball/pdfium/core/fxcrt/cfx_read_only_vector_stream \
+    UnpackedTarball/pdfium/core/fxcrt/fx_memory_malloc \
+    UnpackedTarball/pdfium/core/fxcrt/widetext_buffer \
 ))
 
 # fxge
@@ -527,6 +529,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
 # third_party/abseil-cpp
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     
UnpackedTarball/pdfium/third_party/abseil-cpp/absl/types/bad_optional_access \
+    
UnpackedTarball/pdfium/third_party/abseil-cpp/absl/types/bad_variant_access \
 ))
 
 # third_party/fx_libopenjpeg
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 482e072432f0..67d68133da27 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -46,7 +46,8 @@ $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
     mv third_party/base/memory/aligned_memory.cc 
third_party/base/memory/aligned_memory.cpp && \
     mv third_party/base/win/win_util.cc third_party/base/win/win_util.cpp && \
     mv third_party/libopenjpeg/opj_malloc.cc 
third_party/libopenjpeg/opj_malloc.cpp && \
-    mv third_party/abseil-cpp/absl/types/bad_optional_access.cc 
third_party/abseil-cpp/absl/types/bad_optional_access.cpp \
+    mv third_party/abseil-cpp/absl/types/bad_optional_access.cc 
third_party/abseil-cpp/absl/types/bad_optional_access.cpp && \
+    mv third_party/abseil-cpp/absl/types/bad_variant_access.cc 
third_party/abseil-cpp/absl/types/bad_variant_access.cpp \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 4d488eafb04e..96ba9e6efb1f 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -12,18 +12,18 @@ index 323de4ffc..f11a0b0ad 100644
    std::vector<UnsupportedFeature> unsupported;
    CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
 diff --git a/third_party/base/span.h b/third_party/base/span.h
-index 0fb627ba8..f71c362e2 100644
+index ec9f9903f..1c17ad091 100644
 --- a/third_party/base/span.h
 +++ b/third_party/base/span.h
-@@ -214,7 +214,7 @@ class span {
+@@ -208,7 +208,7 @@ class span {
    // Conversions from spans of compatible types: this allows a span<T> to be
    // seamlessly used as a span<const T>, but not the other way around.
    template <typename U, typename = internal::EnableIfLegalSpanConversion<U, 
T>>
 -  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
 +  span(const span<U>& other) : span(other.data(), other.size()) {}
-   span& operator=(const span& other) noexcept = default;
-   ~span() noexcept {
-     if (!size_) {
+   span& operator=(const span& other) noexcept {
+     if (this != &other) {
+       ReleaseEmptySpan();
 diff --git a/third_party/base/span.h b/third_party/base/span.h
 index 0fb627ba8..dda1fc8bc 100644
 --- a/third_party/base/span.h
diff --git a/external/pdfium/c++20-comparison.patch 
b/external/pdfium/c++20-comparison.patch
index 638497f6aee4..d26fe66ad8b7 100644
--- a/external/pdfium/c++20-comparison.patch
+++ b/external/pdfium/c++20-comparison.patch
@@ -10,4 +10,4 @@
 +  bool operator!=(const FxPartitionAllocAllocator& that) const { return 
false; }
  };
  
- // Used to put backing store for std::vector<> and such
+ // Used to put backing store for std::vector<> and such into the
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index 92d3c4cd2421..cdfdca0083f8 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -54,6 +54,7 @@
 #include <stack>
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string>
@@ -188,7 +189,6 @@
 #include <core/fpdfapi/render/charposlist.h>
 #include <core/fpdfapi/render/cpdf_devicebuffer.h>
 #include <core/fpdfapi/render/cpdf_docrenderdata.h>
-#include <core/fpdfapi/render/cpdf_imagecacheentry.h>
 #include <core/fpdfapi/render/cpdf_imageloader.h>
 #include <core/fpdfapi/render/cpdf_imagerenderer.h>
 #include <core/fpdfapi/render/cpdf_pagerendercache.h>
@@ -274,18 +274,18 @@
 #include <core/fxcodec/scanlinedecoder.h>
 #include <core/fxcrt/autonuller.h>
 #include <core/fxcrt/autorestorer.h>
+#include <core/fxcrt/binary_buffer.h>
 #include <core/fxcrt/bytestring.h>
-#include <core/fxcrt/cfx_binarybuf.h>
 #include <core/fxcrt/cfx_bitstream.h>
 #include <core/fxcrt/cfx_datetime.h>
-#include <core/fxcrt/cfx_fixedbufgrow.h>
 #include <core/fxcrt/cfx_memorystream.h>
-#include <core/fxcrt/cfx_readonlymemorystream.h>
+#include <core/fxcrt/cfx_read_only_span_stream.h>
+#include <core/fxcrt/cfx_read_only_string_stream.h>
+#include <core/fxcrt/cfx_read_only_vector_stream.h>
 #include <core/fxcrt/cfx_seekablestreamproxy.h>
 #include <core/fxcrt/cfx_timer.h>
 #include <core/fxcrt/cfx_utf8decoder.h>
 #include <core/fxcrt/cfx_utf8encoder.h>
-#include <core/fxcrt/cfx_widetextbuf.h>
 #include <core/fxcrt/css/cfx_css.h>
 #include <core/fxcrt/css/cfx_csscolorvalue.h>
 #include <core/fxcrt/css/cfx_csscomputedstyle.h>
@@ -307,6 +307,7 @@
 #include <core/fxcrt/css/cfx_cssvalue.h>
 #include <core/fxcrt/css/cfx_cssvaluelist.h>
 #include <core/fxcrt/css/cfx_cssvaluelistparser.h>
+#include <core/fxcrt/data_vector.h>
 #include <core/fxcrt/fileaccess_iface.h>
 #include <core/fxcrt/fx_bidi.h>
 #include <core/fxcrt/fx_codepage.h>
@@ -328,12 +329,14 @@
 #include <core/fxcrt/pauseindicator_iface.h>
 #include <core/fxcrt/retain_ptr.h>
 #include <core/fxcrt/scoped_set_insertion.h>
+#include <core/fxcrt/small_buffer.h>
 #include <core/fxcrt/span_util.h>
 #include <core/fxcrt/stl_util.h>
 #include <core/fxcrt/string_data_template.h>
 #include <core/fxcrt/string_pool_template.h>
 #include <core/fxcrt/unowned_ptr.h>
 #include <core/fxcrt/widestring.h>
+#include <core/fxcrt/widetext_buffer.h>
 #include <core/fxcrt/xml/cfx_xmlchardata.h>
 #include <core/fxcrt/xml/cfx_xmldocument.h>
 #include <core/fxcrt/xml/cfx_xmlelement.h>
commit b065006a4e8e2cdfe2636377ef67c3f4cd955f8d
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Jul 19 20:01:06 2022 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 5187
    
    build.patch.1 is extended to avoid:
    
    > 
C:/lo/master/workdir/UnpackedTarball/pdfium/third_party/libopenjpeg/openjpeg.c(438):
 error C2491: 'opj_decoder_set_strict_mode': definition of dllimport function 
not allowed
    
    and also is extended to avoid:
    
    > /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:2028:5: note: 
  no known conversion for argument 1 from 
‘std::pair<fxcrt::RetainPtr<CPDF_Object>, std::unique_ptr<CPDF_PageObjectAvail> 
>::first_type {aka fxcrt::RetainPtr<CPDF_Object>}’ to ‘const CPDF_Object* 
const&’
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137238
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 92914312cfb36a86ceb6308a2966f033152fd927)
    
    Change-Id: Icacc05627a8612b33d6445685d26470e7c757b8e

diff --git a/download.lst b/download.lst
index 3b947532f994..23fb842285f7 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
eaf4ce9fad32b5d951c524139df23119b66c67720057defb97acab2dfb2582ac
-PDFIUM_TARBALL := pdfium-5058.tar.bz2
+PDFIUM_SHA256SUM := 
04e0e3f90589250c1fa97cec543af6f5e6c8c2daa377d614ec1f04b061b86651
+PDFIUM_TARBALL := pdfium-5187.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index c17675aa78e9..5da615312764 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -477,6 +477,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxge/dib/cfx_cmyk_to_srgb \
     UnpackedTarball/pdfium/core/fxge/text_char_pos \
     UnpackedTarball/pdfium/core/fxge/cfx_face \
+    UnpackedTarball/pdfium/core/fxge/cfx_defaultrenderdevice \
     UnpackedTarball/pdfium/core/fxge/calculate_pitch \
 ))
 
@@ -530,30 +531,31 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
 
 # third_party/fx_libopenjpeg
 $(eval $(call gb_Library_add_generated_cobjects,pdfium,\
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/bio \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/cio \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/dwt \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/event \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/function_list \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/image \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/invert \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/j2k \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/jp2 \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/mct \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/mqc \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/openjpeg \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/opj_clock \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/pi \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/thread \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/t1 \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/t2 \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/tcd \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/tgt \
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/sparse_array \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/bio \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/cio \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/dwt \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/event \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/function_list \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/image \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/invert \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/j2k \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/jp2 \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/mct \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/mqc \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/openjpeg \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/opj_clock \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/pi \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/thread \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/t1 \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/t2 \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/tcd \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/tgt \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/sparse_array \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/ht_dec \
 ))
 
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
-    UnpackedTarball/pdfium/third_party/libopenjpeg20/opj_malloc \
+    UnpackedTarball/pdfium/third_party/libopenjpeg/opj_malloc \
 ))
 
 # pdfium_base
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 6f02c007069d..482e072432f0 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -45,7 +45,7 @@ $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
     mv third_party/base/allocator/partition_allocator/random.cc 
third_party/base/allocator/partition_allocator/random.cpp && \
     mv third_party/base/memory/aligned_memory.cc 
third_party/base/memory/aligned_memory.cpp && \
     mv third_party/base/win/win_util.cc third_party/base/win/win_util.cpp && \
-    mv third_party/libopenjpeg20/opj_malloc.cc 
third_party/libopenjpeg20/opj_malloc.cpp && \
+    mv third_party/libopenjpeg/opj_malloc.cc 
third_party/libopenjpeg/opj_malloc.cpp && \
     mv third_party/abseil-cpp/absl/types/bad_optional_access.cc 
third_party/abseil-cpp/absl/types/bad_optional_access.cpp \
 ))
 
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 4988718ecd02..4d488eafb04e 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -159,3 +159,29 @@ index 4d8a7b7d9..d14c6dc06 100644
        if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
          continue;
  
+diff --git a/third_party/libopenjpeg/openjpeg.c 
b/third_party/libopenjpeg/openjpeg.c
+index 29d3ee528..d5c7a1bc9 100644
+--- a/third_party/libopenjpeg/openjpeg.c
++++ b/third_party/libopenjpeg/openjpeg.c
+@@ -433,7 +433,7 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t 
*p_codec,
+     return OPJ_FALSE;
+ }
+ 
+-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t 
*p_codec,
++OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
+         OPJ_BOOL strict)
+ {
+     if (p_codec) {
+diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp 
b/core/fpdfapi/parser/cpdf_data_avail.cpp
+index a17ec0353..3b024ac91 100644
+--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
++++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
+@@ -902,7 +902,7 @@ CPDF_DataAvail::DocAvailStatus 
CPDF_DataAvail::CheckResources(
+   CPDF_PageObjectAvail* resource_avail =
+       m_PagesResourcesAvail
+           .insert(std::make_pair(
+-              resources,
++              resources.Get(),
+               std::make_unique<CPDF_PageObjectAvail>(
+                   GetValidator(), m_pDocument.Get(), resources.Get())))
+           .first->second.get();
commit d84068e5dcf0fc8f09055b7c1431411469f3be3c
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu May 19 20:24:18 2022 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 5058
    
    Which started to use require __builtin_is_constant_evaluated(), which
    our baseline doesn't have, so patch that out for now.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134648
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 6a599ff57fb878c07353d93b476706acda6058f3)
    
    Change-Id: Idd1923291a933209d18bb677d011c9353c8f8c4d

diff --git a/download.lst b/download.lst
index d5c73ec81f0d..3b947532f994 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
563842a02657daee3a162b769fb42ae436782c839a5ac5d22d04c4e5664970e1
-PDFIUM_TARBALL := pdfium-4933.tar.bz2
+PDFIUM_SHA256SUM := 
eaf4ce9fad32b5d951c524139df23119b66c67720057defb97acab2dfb2582ac
+PDFIUM_TARBALL := pdfium-5058.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index aef51bcc9350..c17675aa78e9 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -40,14 +40,11 @@ $(eval $(call 
gb_Library_set_generated_cxx_suffix,pdfium,cpp))
 # pdfium
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annot \
-    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annothandlermgr \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annotiteration \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_baannot \
-    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_baannothandler \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_formfillenvironment \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_pageview \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_widget \
-    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_widgethandler \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_dataavail \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_ext \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_flatten \
@@ -56,7 +53,6 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fpdfsdk/fpdf_structtree \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_sysfontinfo \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_transformpage \
-    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_actionhandler \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annotiterator \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_customaccess \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_filewriteadapter \
@@ -73,7 +69,6 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fpdfsdk/fpdf_save \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_text \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_view \
-    UnpackedTarball/pdfium/fpdfsdk/ipdfsdk_annothandler \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_pauseadapter \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_interactiveform \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_renderpage \
@@ -84,6 +79,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
        UnpackedTarball/pdfium/constants/page_object \
        UnpackedTarball/pdfium/constants/stream_dict_common \
        UnpackedTarball/pdfium/constants/transparency \
+       UnpackedTarball/pdfium/constants/font_encodings \
 ))
 
 # fdrm
@@ -262,7 +258,6 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/font/cfx_stockfontarray \
     UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_cid2unicodemap \
     UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_cmap \
-    UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_cmapmanager \
     UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_cmapparser \
     UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_fontglobals \
     UnpackedTarball/pdfium/core/fpdfapi/font/cpdf_tounicodemap \
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 0eeb18aa1e32..4988718ecd02 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -95,3 +95,67 @@ index 8b3a72700..ea1db23f4 100644
  }
  
  FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) 
{
+diff --git a/third_party/base/numerics/safe_conversions_impl.h 
b/third_party/base/numerics/safe_conversions_impl.h
+index 4d8a7b7d9..d14c6dc06 100644
+--- a/third_party/base/numerics/safe_conversions_impl.h
++++ b/third_party/base/numerics/safe_conversions_impl.h
+@@ -88,7 +88,7 @@ constexpr typename std::make_unsigned<T>::type 
SafeUnsignedAbs(T value) {
+ 
+ // TODO(jschuh): Switch to std::is_constant_evaluated() once C++20 is 
supported.
+ // Alternately, the usage could be restructured for "consteval if" in C++23.
+-#define IsConstantEvaluated() (__builtin_is_constant_evaluated())
++#define IsConstantEvaluated() (false)
+ 
+ // TODO(jschuh): Debug builds don't reliably propagate constants, so we 
restrict
+ // some accelerated runtime paths to release builds until this can be forced
+--- pdfium/core/fpdfapi/font/cpdf_cidfont.cpp.orig     2022-05-20 
09:25:52.066728467 +0000
++++ pdfium/core/fpdfapi/font/cpdf_cidfont.cpp  2022-05-20 09:25:56.146736531 
+0000
+@@ -738,7 +738,7 @@
+         uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
+             FT_ENCODING_APPLE_ROMAN, name_unicode);
+         index = maccode ? FT_Get_Char_Index(face, maccode)
+-                        : FT_Get_Name_Index(face, name);
++                        : FT_Get_Name_Index(face, const_cast<char*>(name));
+       }
+       if (index == 0 || index == 0xffff)
+         return charcode ? static_cast<int>(charcode) : -1;
+--- pdfium/core/fpdfapi/font/cpdf_type1font.cpp.orig   2022-05-20 
09:26:59.090862058 +0000
++++ pdfium/core/fpdfapi/font/cpdf_type1font.cpp        2022-05-20 
09:27:33.810932435 +0000
+@@ -260,7 +260,7 @@
+                                           static_cast<uint32_t>(charcode));
+       if (name) {
+         m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+       } else {
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(
+             m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
+@@ -291,7 +291,7 @@
+       continue;
+ 
+     m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+     if (m_GlyphIndex[charcode] != 0)
+       continue;
+ 
+--- pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp.orig        2022-05-20 
09:26:12.066767996 +0000
++++ pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp     2022-05-20 
09:26:46.690836923 +0000
+@@ -90,7 +90,7 @@
+               FT_ENCODING_APPLE_ROMAN,
+               m_Encoding.UnicodeFromCharCode(charcode));
+           if (!maccode) {
+-            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+           } else {
+             m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
+           }
+@@ -104,7 +104,7 @@
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
+         continue;
+       }
+-      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+       if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
+         continue;
+ 
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index 95367e7c6a91..92d3c4cd2421 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -45,6 +45,7 @@
 #include <map>
 #include <math.h>
 #include <memory>
+#include <new>
 #include <numeric>
 #include <ostream>
 #include <set>
@@ -72,6 +73,7 @@
 #include <constants/annotation_flags.h>
 #include <constants/appearance.h>
 #include <constants/ascii.h>
+#include <constants/font_encodings.h>
 #include <constants/form_fields.h>
 #include <constants/form_flags.h>
 #include <constants/page_object.h>
@@ -93,7 +95,6 @@
 #include <core/fpdfapi/font/cpdf_cid2unicodemap.h>
 #include <core/fpdfapi/font/cpdf_cidfont.h>
 #include <core/fpdfapi/font/cpdf_cmap.h>
-#include <core/fpdfapi/font/cpdf_cmapmanager.h>
 #include <core/fpdfapi/font/cpdf_cmapparser.h>
 #include <core/fpdfapi/font/cpdf_font.h>
 #include <core/fpdfapi/font/cpdf_fontencoding.h>
@@ -126,6 +127,7 @@
 #include <core/fpdfapi/page/cpdf_iccprofile.h>
 #include <core/fpdfapi/page/cpdf_image.h>
 #include <core/fpdfapi/page/cpdf_imageobject.h>
+#include <core/fpdfapi/page/cpdf_indexedcs.h>
 #include <core/fpdfapi/page/cpdf_meshstream.h>
 #include <core/fpdfapi/page/cpdf_occontext.h>
 #include <core/fpdfapi/page/cpdf_page.h>
@@ -270,6 +272,7 @@
 #include <core/fxcodec/jpx/cjpx_decoder.h>
 #include <core/fxcodec/jpx/jpx_decode_utils.h>
 #include <core/fxcodec/scanlinedecoder.h>
+#include <core/fxcrt/autonuller.h>
 #include <core/fxcrt/autorestorer.h>
 #include <core/fxcrt/bytestring.h>
 #include <core/fxcrt/cfx_binarybuf.h>
@@ -317,6 +320,7 @@
 #include <core/fxcrt/fx_safe_types.h>
 #include <core/fxcrt/fx_stream.h>
 #include <core/fxcrt/fx_string.h>
+#include <core/fxcrt/fx_string_wrappers.h>
 #include <core/fxcrt/fx_system.h>
 #include <core/fxcrt/fx_unicode.h>
 #include <core/fxcrt/maybe_owned.h>
@@ -338,6 +342,7 @@
 #include <core/fxcrt/xml/cfx_xmlparser.h>
 #include <core/fxcrt/xml/cfx_xmltext.h>
 #include <core/fxge/agg/fx_agg_driver.h>
+#include <core/fxge/calculate_pitch.h>
 #include <core/fxge/cfx_cliprgn.h>
 #include <core/fxge/cfx_color.h>
 #include <core/fxge/cfx_defaultrenderdevice.h>
@@ -373,22 +378,18 @@
 #include <core/fxge/dib/fx_dib.h>
 #include <core/fxge/dib/scanlinecomposer_iface.h>
 #include <core/fxge/fontdata/chromefontdata/chromefontdata.h>
+#include <core/fxge/freetype/fx_freetype.h>
 #include <core/fxge/fx_font.h>
-#include <core/fxge/fx_freetype.h>
-#include <core/fxge/render_defines.h>
 #include <core/fxge/renderdevicedriver_iface.h>
 #include <core/fxge/scoped_font_transform.h>
 #include <core/fxge/systemfontinfo_iface.h>
 #include <core/fxge/text_char_pos.h>
 #include <core/fxge/text_glyph_pos.h>
-#include <fpdfsdk/cpdfsdk_actionhandler.h>
 #include <fpdfsdk/cpdfsdk_annot.h>
-#include <fpdfsdk/cpdfsdk_annothandlermgr.h>
 #include <fpdfsdk/cpdfsdk_annotiteration.h>
 #include <fpdfsdk/cpdfsdk_annotiterator.h>
 #include <fpdfsdk/cpdfsdk_appstream.h>
 #include <fpdfsdk/cpdfsdk_baannot.h>
-#include <fpdfsdk/cpdfsdk_baannothandler.h>
 #include <fpdfsdk/cpdfsdk_customaccess.h>
 #include <fpdfsdk/cpdfsdk_filewriteadapter.h>
 #include <fpdfsdk/cpdfsdk_formfillenvironment.h>
@@ -398,7 +399,6 @@
 #include <fpdfsdk/cpdfsdk_pauseadapter.h>
 #include <fpdfsdk/cpdfsdk_renderpage.h>
 #include <fpdfsdk/cpdfsdk_widget.h>
-#include <fpdfsdk/cpdfsdk_widgethandler.h>
 #include <fpdfsdk/formfiller/cffl_button.h>
 #include <fpdfsdk/formfiller/cffl_checkbox.h>
 #include <fpdfsdk/formfiller/cffl_combobox.h>
@@ -411,7 +411,6 @@
 #include <fpdfsdk/formfiller/cffl_radiobutton.h>
 #include <fpdfsdk/formfiller/cffl_textfield.h>
 #include <fpdfsdk/formfiller/cffl_textobject.h>
-#include <fpdfsdk/ipdfsdk_annothandler.h>
 #include <fpdfsdk/pwl/cpwl_button.h>
 #include <fpdfsdk/pwl/cpwl_caret.h>
 #include <fpdfsdk/pwl/cpwl_cbbutton.h>
@@ -426,7 +425,6 @@
 #include <fpdfsdk/pwl/cpwl_special_button.h>
 #include <fpdfsdk/pwl/cpwl_wnd.h>
 #include <fpdfsdk/pwl/ipwl_fillernotify.h>
-#include <fpdfsdk/pwl/ipwl_systemhandler.h>
 #include <fxjs/cjs_event_context_stub.h>
 #include <fxjs/cjs_runtimestub.h>
 #include <fxjs/ijs_event_context.h>
commit c9bf4a312ef4ffd611617a677426f0255e5eb743
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Mar 17 09:02:29 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 4933
    
    Stop tracking build_config.h in our repo, it can be now part of the
    release tarball. It was a mistake in the past to think that this is
    generated code, it's just external code.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131695
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 71b952340726190d1f178ef0dadfa89677f2c1dd)
    
    Change-Id: Ife2fed362e28c53859399244e2f1247efb1efe86

diff --git a/download.lst b/download.lst
index 2537ad010fcc..d5c73ec81f0d 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
2652db0220ffd12b7f62a634e14d21a49116439148101c37cb24ba17b562a39f
-PDFIUM_TARBALL := pdfium-4818.tar.bz2
+PDFIUM_SHA256SUM := 
563842a02657daee3a162b769fb42ae436782c839a5ac5d22d04c4e5664970e1
+PDFIUM_TARBALL := pdfium-4933.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index 305d2931ef35..aef51bcc9350 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -291,6 +291,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfuncdib \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfunc \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_basedcs \
+    UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_indexedcs \
 ))
 
 # fpdfdoc
@@ -481,6 +482,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxge/dib/cfx_cmyk_to_srgb \
     UnpackedTarball/pdfium/core/fxge/text_char_pos \
     UnpackedTarball/pdfium/core/fxge/cfx_face \
+    UnpackedTarball/pdfium/core/fxge/calculate_pitch \
 ))
 
 # javascript, build with pdf_enable_v8 disabled.
diff --git a/external/pdfium/README b/external/pdfium/README
index fdcc91a0a45c..2be9e8f11b26 100644
--- a/external/pdfium/README
+++ b/external/pdfium/README
@@ -13,4 +13,5 @@ gclient sync
 git archive --prefix=pdfium/ --format=tar origin/chromium/${version} > 
pdfium-${version}.tar
 (cd ..; tar --append --file pdfium/pdfium-${version}.tar 
pdfium/third_party/freetype/src/include/ pdfium/third_party/freetype/src/src/)
 (cd ..; tar --append --file pdfium/pdfium-${version}.tar 
pdfium/third_party/abseil-cpp/absl/)
+(cd ..; tar --append --file pdfium/pdfium-${version}.tar 
pdfium/build/build_config.h pdfium/build/buildflag.h)
 bzip2 pdfium-${version}.tar
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index f2d0ba6dd1d6..6f02c007069d 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -27,10 +27,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,pdfium,\
     $(foreach patch,$(pdfium_patches),external/pdfium/$(patch)) \
 ))
 
-# Upstream build system generates this, but it's not really a generated file.
-# Stripped down version from 
<https://dxr.mozilla.org/mozilla-central/source/ipc/chromium/src/build/build_config.h>.
-$(eval $(call 
gb_UnpackedTarball_add_file,pdfium,build/build_config.h,external/pdfium/configs/build_config.h))
-
 $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
     mv third_party/bigint/BigInteger.cc third_party/bigint/BigInteger.cpp && \
     mv third_party/bigint/BigIntegerUtils.cc 
third_party/bigint/BigIntegerUtils.cpp && \
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 46ba8c96e913..0eeb18aa1e32 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -65,3 +65,33 @@ index d8875786c..bc019ebe1 100644
  }
  
  void sycc_to_rgb(int offset,
+diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
+index 8b3a72700..ea1db23f4 100644
+--- a/core/fxge/cfx_font.cpp
++++ b/core/fxge/cfx_font.cpp
+@@ -47,25 +47,9 @@ struct OUTLINE_PARAMS {
+ // TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be
+ // available to all users in the future, remove FreeMMVar() and use
+ // FT_Done_MM_Var() directly.
+-//
+-// Use weak symbols to check if FT_Done_MM_Var() is available at runtime.
+-#if !BUILDFLAG(IS_WIN)
+-extern "C" __attribute__((weak)) decltype(FT_Done_MM_Var) FT_Done_MM_Var;
+-#endif
+ 
+ void FreeMMVar(FXFT_FaceRec* rec, FXFT_MM_VarPtr variation_desc) {
+-#if BUILDFLAG(IS_WIN)
+-  // Assume `use_system_freetype` GN var is never set on Windows.
+-  constexpr bool has_ft_done_mm_var_func = true;
+-#else
+-  static const bool has_ft_done_mm_var_func = !!FT_Done_MM_Var;
+-#endif
+-  if (has_ft_done_mm_var_func) {
+-    FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
+-                   variation_desc);
+-  } else {
+     FXFT_Free(rec, variation_desc);
+-  }
+ }
+ 
+ FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) 
{
diff --git a/external/pdfium/c++20-comparison.patch 
b/external/pdfium/c++20-comparison.patch
index 025f9ba010db..638497f6aee4 100644
--- a/external/pdfium/c++20-comparison.patch
+++ b/external/pdfium/c++20-comparison.patch
@@ -1,13 +1,13 @@
 --- core/fxcrt/fx_memory_wrappers.h
 +++ core/fxcrt/fx_memory_wrappers.h
-@@ -70,8 +70,8 @@
+@@ -70,8 +70,8 @@ struct FxPartitionAllocAllocator {
    }
  
    // There's no state, so they are all the same,
--  bool operator==(const FxAllocAllocator& that) { return true; }
--  bool operator!=(const FxAllocAllocator& that) { return false; }
-+  bool operator==(const FxAllocAllocator& that) const { return true; }
-+  bool operator!=(const FxAllocAllocator& that) const { return false; }
+-  bool operator==(const FxPartitionAllocAllocator& that) { return true; }
+-  bool operator!=(const FxPartitionAllocAllocator& that) { return false; }
++  bool operator==(const FxPartitionAllocAllocator& that) const { return true; 
}
++  bool operator!=(const FxPartitionAllocAllocator& that) const { return 
false; }
  };
  
- #endif  // CORE_FXCRT_FX_MEMORY_WRAPPERS_H_
+ // Used to put backing store for std::vector<> and such
diff --git a/external/pdfium/configs/build_config.h 
b/external/pdfium/configs/build_config.h
deleted file mode 100644
index ec93c278767c..000000000000
--- a/external/pdfium/configs/build_config.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file adds defines about the platform we're currently building on.
-//  Operating System:
-//    OS_WIN / OS_APPLE / OS_LINUX / OS_POSIX (MACOSX or LINUX)
-//  Compiler:
-//    COMPILER_MSVC / COMPILER_GCC
-//  Processor:
-//    ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
-//    ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
-
-#ifndef BUILD_BUILD_CONFIG_H_
-#define BUILD_BUILD_CONFIG_H_
-
-// A set of macros to use for platform detection.
-#if defined(ANDROID)
-#define OS_ANDROID 1
-#define OS_LINUX 1
-#elif defined(__APPLE__)
-#define OS_APPLE 1
-#elif defined(__linux__)
-#define OS_LINUX 1
-#elif defined(__DragonFly__)
-#define OS_DRAGONFLY 1
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#define OS_FREEBSD 1
-#elif defined(__NetBSD__)
-#define OS_NETBSD 1
-#elif defined(__OpenBSD__)
-#define OS_OPENBSD 1
-#elif defined(__sun__)
-#define OS_SOLARIS 1
-#elif defined(_WIN32)
-#define OS_WIN 1
-#else
-#error Please add support for your platform in build/build_config.h
-#endif
-
-// For access to standard BSD features, use OS_BSD instead of a
-// more specific macro.
-#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) || defined(OS_NETBSD) || 
defined(OS_OPENBSD)
-#define OS_BSD 1
-#endif
-
-// For access to standard POSIX features, use OS_POSIX instead of a more
-// specific macro.
-#if defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_BSD) || 
defined(OS_SOLARIS)
-#define OS_POSIX 1
-#endif
-
-// Compiler detection.
-#if defined(__GNUC__)
-#define COMPILER_GCC 1
-#elif defined(_MSC_VER)
-#define COMPILER_MSVC 1
-#else
-#error Please add support for your compiler in build/build_config.h
-#endif
-
-// Processor architecture detection.  For more info on what's defined, see:
-//   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
-//   http://www.agner.org/optimize/calling_conventions.pdf
-//   or with gcc, run: "echo | gcc -E -dM -"
-#if defined(_M_X64) || defined(__x86_64__)
-#define ARCH_CPU_X86_FAMILY 1
-#define ARCH_CPU_X86_64 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(_M_IX86) || defined(__i386__)
-#define ARCH_CPU_X86_FAMILY 1
-#define ARCH_CPU_X86 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__ARMEL__)
-#define ARCH_CPU_ARM_FAMILY 1
-#define ARCH_CPU_ARMEL 1
-#define ARCH_CPU_32_BITS 1
-#define WCHAR_T_IS_UNSIGNED 1
-#elif defined(__powerpc64__)
-#define ARCH_CPU_PPC64 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__ppc__) || defined(__powerpc__)
-#define ARCH_CPU_PPC 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__sparc__) && defined(__arch64__)
-#define ARCH_CPU_SPARC 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__sparc__)
-#define ARCH_CPU_SPARC 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__mips64) && defined(__LP64__)
-#define ARCH_CPU_MIPS 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__mips__)
-#define ARCH_CPU_MIPS 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__hppa__)
-#define ARCH_CPU_HPPA 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__ia64__)
-#define ARCH_CPU_IA64 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__s390x__)
-#define ARCH_CPU_S390X 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__s390__)
-#define ARCH_CPU_S390 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__sh__)
-#define ARCH_CPU_SH 1
-#define ARCH_CPU_32_BITS 1
-#elif defined(__alpha__)
-#define ARCH_CPU_ALPHA 1
-#define ARCH_CPU_64_BITS 1
-#elif defined(__aarch64__)
-#define ARCH_CPU_ARM_FAMILY 1
-#define ARCH_CPU_ARM64 1
-#define ARCH_CPU_64_BITS 1
-#else
-#error Please add support for your architecture in build/build_config.h
-#endif
-
-// Type detection for wchar_t.
-#if defined(OS_WIN)
-#define WCHAR_T_IS_UTF16
-#else
-#define WCHAR_T_IS_UTF32
-#endif
-
-#endif // BUILD_BUILD_CONFIG_H_
diff --git a/external/pdfium/include.patch.1 b/external/pdfium/include.patch.1
index 403ccb685da9..2d123017e049 100644
--- a/external/pdfium/include.patch.1
+++ b/external/pdfium/include.patch.1
@@ -1,13 +1,3 @@
---- pdfium/core/fxcodec/fx_codec.h.orig        2023-06-01 18:01:21.463535717 
+0200
-+++ pdfium/core/fxcodec/fx_codec.h     2023-06-01 18:01:26.144536561 +0200
-@@ -8,6 +8,7 @@
- #define CORE_FXCODEC_FX_CODEC_H_
- 
- #include <map>
-+#include <cstdint>
- 
- #include "third_party/abseil-cpp/absl/types/optional.h"
- 
 --- pdfium/constants/annotation_flags.h.orig   2023-06-26 14:53:05.531326301 
+0200
 +++ pdfium/constants/annotation_flags.h        2023-06-26 14:53:10.921369624 
+0200
 @@ -5,6 +5,8 @@
commit a81fcdc292e2f4e5874f3768ad03e4c35bf81cf3
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Jan 12 20:07:02 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 4818
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128353
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit b24ef22fee1196a89750b92463cb0b7a541e83c9)
    
    Change-Id: I68751a7b6ca2c8c86a412a0fd401e0d0f172297b

diff --git a/download.lst b/download.lst
index 6eb590dc4198..2537ad010fcc 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
ee80fe0a3b20ef5c5babc494cd655d1b1a0bdec710acb04524789df500c563bf
-PDFIUM_TARBALL := pdfium-4699.tar.bz2
+PDFIUM_SHA256SUM := 
2652db0220ffd12b7f62a634e14d21a49116439148101c37cb24ba17b562a39f
+PDFIUM_TARBALL := pdfium-4818.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index e01a59b758cb..95367e7c6a91 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -66,7 +66,6 @@
 #if PCH_LEVEL >= 2
 #endif // PCH_LEVEL >= 2
 #if PCH_LEVEL >= 3
-#include <absl/types/bad_optional_access.h>
 #include <build/build_config.h>
 #include <constants/access_permissions.h>
 #include <constants/annotation_common.h>
commit 8127302d4bdc0bca92e86d496b24484b46327457
Author:     Michael Stahl <[email protected]>
AuthorDate: Mon Jun 26 19:13:35 2023 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    pdfium: remove MSVC version check
    
    Change-Id: Icbcaa159a317ad2701cfa3fb586d9d62c5a1690c

diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index fdb8201b2f25..f2d0ba6dd1d6 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -12,6 +12,7 @@ pdfium_patches += ubsan.patch
 # Fixes build on our baseline.
 pdfium_patches += build.patch.1
 pdfium_patches += include.patch.1
+pdfium_patches += msvc2017.patch.1
 # Avoids Windows 8 build dependency.
 pdfium_patches += windows7.patch.1
 pdfium_patches += c++20-comparison.patch
diff --git a/external/pdfium/msvc2017.patch.1 b/external/pdfium/msvc2017.patch.1
new file mode 100644
index 000000000000..d19279bd3ca7
--- /dev/null
+++ b/external/pdfium/msvc2017.patch.1
@@ -0,0 +1,15 @@
+--- pdfium/third_party/abseil-cpp/absl/base/policy_checks.h.orig       
2023-06-26 19:10:40.362247395 +0200
++++ pdfium/third_party/abseil-cpp/absl/base/policy_checks.h    2023-06-26 
19:10:55.204269825 +0200
+@@ -46,9 +46,9 @@
+ 
+ // We support Visual Studio 2019 (MSVC++ 16.0) and later.
+ // This minimum will go up.
+-#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
+-#error "This package requires Visual Studio 2019 (MSVC++ 16.0) or higher."
+-#endif
++//#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
++//#error "This package requires Visual Studio 2019 (MSVC++ 16.0) or higher."
++//#endif
+ 
+ // We support GCC 7 and later.
+ // This minimum will go up.
commit 20f24bf84d6c28b740dd3cddfd9e65405b338ad4
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Nov 11 20:26:18 2021 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    external: update pdfium to 4699
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125068
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit d4f0281f3127255b792a9ec492ba4a14d5ee64c2)
    
    Change-Id: I545adce0491e48fad2bfc4003695bd96cc911f22

diff --git a/download.lst b/download.lst
index dcb9e7925a51..6eb590dc4198 100644
--- a/download.lst
+++ b/download.lst
@@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
eb98a77eaaab9e9e8de541cfd18b9438dd3c538bd5ef163820353179727f5dc9
-PDFIUM_TARBALL := pdfium-4643.tar.bz2
+PDFIUM_SHA256SUM := 
ee80fe0a3b20ef5c5babc494cd655d1b1a0bdec710acb04524789df500c563bf
+PDFIUM_TARBALL := pdfium-4699.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index 07282fc3d157..305d2931ef35 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_Library_set_include,pdfium,\
     -I$(call gb_UnpackedTarball_get_dir,pdfium) \
     -I$(call gb_UnpackedTarball_get_dir,pdfium)/third_party \
     -I$(call gb_UnpackedTarball_get_dir,pdfium)/third_party/agg23 \
+    -I$(call gb_UnpackedTarball_get_dir,pdfium)/third_party/abseil-cpp \
     $$(INCLUDE) \
 ))
 
@@ -72,6 +73,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fpdfsdk/fpdf_save \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_text \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_view \
+    UnpackedTarball/pdfium/fpdfsdk/ipdfsdk_annothandler \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_pauseadapter \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_interactiveform \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_renderpage \
@@ -524,6 +526,11 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/third_party/agg23/agg_vcgen_stroke \
 ))
 
+# third_party/abseil-cpp
+$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
+    
UnpackedTarball/pdfium/third_party/abseil-cpp/absl/types/bad_optional_access \
+))
+
 # third_party/fx_libopenjpeg
 $(eval $(call gb_Library_add_generated_cobjects,pdfium,\
     UnpackedTarball/pdfium/third_party/libopenjpeg20/bio \
diff --git a/external/pdfium/README b/external/pdfium/README
index 0a146d2e74de..fdcc91a0a45c 100644
--- a/external/pdfium/README
+++ b/external/pdfium/README
@@ -12,4 +12,5 @@ git checkout --track origin/chromium/$version
 gclient sync
 git archive --prefix=pdfium/ --format=tar origin/chromium/${version} > 
pdfium-${version}.tar
 (cd ..; tar --append --file pdfium/pdfium-${version}.tar 
pdfium/third_party/freetype/src/include/ pdfium/third_party/freetype/src/src/)
+(cd ..; tar --append --file pdfium/pdfium-${version}.tar 
pdfium/third_party/abseil-cpp/absl/)
 bzip2 pdfium-${version}.tar
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 47c1c4749ea3..fdb8201b2f25 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -48,7 +48,8 @@ $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
     mv third_party/base/allocator/partition_allocator/random.cc 
third_party/base/allocator/partition_allocator/random.cpp && \
     mv third_party/base/memory/aligned_memory.cc 
third_party/base/memory/aligned_memory.cpp && \
     mv third_party/base/win/win_util.cc third_party/base/win/win_util.cpp && \
-    mv third_party/libopenjpeg20/opj_malloc.cc 
third_party/libopenjpeg20/opj_malloc.cpp \
+    mv third_party/libopenjpeg20/opj_malloc.cc 
third_party/libopenjpeg20/opj_malloc.cpp && \
+    mv third_party/abseil-cpp/absl/types/bad_optional_access.cc 
third_party/abseil-cpp/absl/types/bad_optional_access.cpp \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 60283ac63c74..46ba8c96e913 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -53,80 +53,15 @@ index 0fb627ba8..dda1fc8bc 100644
    uint8_t r;
    uint8_t g;
 diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp 
b/core/fxcodec/jpx/cjpx_decoder.cpp
-index c66985a7f..817f81dfa 100644
+index d8875786c..bc019ebe1 100644
 --- a/core/fxcodec/jpx/cjpx_decoder.cpp
 +++ b/core/fxcodec/jpx/cjpx_decoder.cpp
-@@ -71,7 +71,7 @@ Optional<OpjImageRgbData> alloc_rgb(size_t size) {
+@@ -73,7 +73,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
    if (!data.b)
-     return pdfium::nullopt;
+     return absl::nullopt;
  
 -  return data;
 +  return std::move(data);
  }
  
  void sycc_to_rgb(int offset,
-diff --git a/core/fdrm/fx_crypt_aes.cpp b/core/fdrm/fx_crypt_aes.cpp
-index f2170220b..ede18f581 100644
---- a/core/fdrm/fx_crypt_aes.cpp
-+++ b/core/fdrm/fx_crypt_aes.cpp
-@@ -437,7 +437,7 @@ const unsigned int D3[256] = {
-   (block[0] ^= *keysched++, block[1] ^= *keysched++, block[2] ^= *keysched++, 
\
-    block[3] ^= *keysched++)
- #define MOVEWORD(i) (block[i] = newstate[i])
--#define MAKEWORD(i)                                         \
-+#define FMAKEWORD(i)                                         \
-   (newstate[i] = (E0[(block[i] >> 24) & 0xFF] ^             \
-                   E1[(block[(i + C1) % Nb] >> 16) & 0xFF] ^ \
-                   E2[(block[(i + C2) % Nb] >> 8) & 0xFF] ^  \
-@@ -458,10 +458,10 @@ void aes_encrypt_nb_4(CRYPT_aes_context* ctx, unsigned 
int* block) {
-   unsigned int newstate[4];
-   for (i = 0; i < ctx->Nr - 1; i++) {
-     ADD_ROUND_KEY_4();
--    MAKEWORD(0);
--    MAKEWORD(1);
--    MAKEWORD(2);
--    MAKEWORD(3);
-+    FMAKEWORD(0);
-+    FMAKEWORD(1);
-+    FMAKEWORD(2);
-+    FMAKEWORD(3);
-     MOVEWORD(0);
-     MOVEWORD(1);
-     MOVEWORD(2);
-@@ -478,10 +478,10 @@ void aes_encrypt_nb_4(CRYPT_aes_context* ctx, unsigned 
int* block) {
-   MOVEWORD(3);
-   ADD_ROUND_KEY_4();
- }
--#undef MAKEWORD
-+#undef FMAKEWORD
- #undef LASTWORD
- 
--#define MAKEWORD(i)                                         \
-+#define FMAKEWORD(i)                                         \
-   (newstate[i] = (D0[(block[i] >> 24) & 0xFF] ^             \
-                   D1[(block[(i + C1) % Nb] >> 16) & 0xFF] ^ \
-                   D2[(block[(i + C2) % Nb] >> 8) & 0xFF] ^  \
-@@ -502,10 +502,10 @@ void aes_decrypt_nb_4(CRYPT_aes_context* ctx, unsigned 
int* block) {
-   unsigned int newstate[4];
-   for (i = 0; i < ctx->Nr - 1; i++) {
-     ADD_ROUND_KEY_4();
--    MAKEWORD(0);
--    MAKEWORD(1);
--    MAKEWORD(2);
--    MAKEWORD(3);
-+    FMAKEWORD(0);
-+    FMAKEWORD(1);
-+    FMAKEWORD(2);
-+    FMAKEWORD(3);
-     MOVEWORD(0);
-     MOVEWORD(1);
-     MOVEWORD(2);
-@@ -522,7 +522,7 @@ void aes_decrypt_nb_4(CRYPT_aes_context* ctx, unsigned 
int* block) {
-   MOVEWORD(3);
-   ADD_ROUND_KEY_4();
- }
--#undef MAKEWORD
-+#undef FMAKEWORD
- #undef LASTWORD
- 
- void aes_setup(CRYPT_aes_context* ctx, const unsigned char* key, int keylen) {
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index 357c37d6a81e..e01a59b758cb 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -66,6 +66,7 @@
 #if PCH_LEVEL >= 2
 #endif // PCH_LEVEL >= 2
 #if PCH_LEVEL >= 3
+#include <absl/types/bad_optional_access.h>
 #include <build/build_config.h>
 #include <constants/access_permissions.h>
 #include <constants/annotation_common.h>
@@ -450,6 +451,7 @@
 #include <public/fpdf_text.h>
 #include <public/fpdf_transformpage.h>
 #include <public/fpdfview.h>
+#include <third_party/abseil-cpp/absl/types/optional.h>
 #include <third_party/agg23/agg_clip_liang_barsky.h>
 #include <third_party/agg23/agg_conv_dash.h>
 #include <third_party/agg23/agg_conv_stroke.h>
@@ -487,7 +489,6 @@
 #include <third_party/base/notreached.h>
 #include <third_party/base/numerics/safe_conversions.h>
 #include <third_party/base/numerics/safe_math.h>
-#include <third_party/base/optional.h>
 #include <third_party/base/ptr_util.h>
 #include <third_party/base/span.h>
 #include <third_party/skia_shared/SkFloatToDecimal.h>
diff --git a/external/pdfium/include.patch.1 b/external/pdfium/include.patch.1
index 3fe9c5fa9983..403ccb685da9 100644
--- a/external/pdfium/include.patch.1
+++ b/external/pdfium/include.patch.1
@@ -6,7 +6,7 @@
  #include <map>
 +#include <cstdint>
  
- #include "third_party/base/optional.h"
+ #include "third_party/abseil-cpp/absl/types/optional.h"
  
 --- pdfium/constants/annotation_flags.h.orig   2023-06-26 14:53:05.531326301 
+0200
 +++ pdfium/constants/annotation_flags.h        2023-06-26 14:53:10.921369624 
+0200
commit 3fcab22236cf48cf948c6f8ba480c1797364781a
Author:     Michael Stahl <[email protected]>
AuthorDate: Mon Jun 26 17:15:20 2023 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    svx: replace FPDFTextObj_GetFontName
    
    Change-Id: Ib4e11f8aeee932160862d1b9a2b56068a90e9895

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index ba27b6d651cb..d9c478f9f31c 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -826,8 +826,8 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 
     const int nFontName = 80 + 1;
     std::unique_ptr<char[]> pFontName(new char[nFontName]); // + terminating 
null
-    char* pCharFontName = reinterpret_cast<char*>(pFontName.get());
-    int nFontNameChars = FPDFTextObj_GetFontName(pPageObject, pCharFontName, 
nFontName);
+    FPDF_FONT pFontObject = FPDFTextObj_GetFont(pPageObject);
+    int nFontNameChars = FPDFFont_GetFontName(pFontObject, pFontName.get(), 
nFontName);
     if (nFontName >= nFontNameChars)
     {
         OUString sFontName = OUString::createFromAscii(pFontName.get());
commit c2f346fbb44d99128fc4c75caf8e792b803a796a
Author:     Michael Stahl <[email protected]>
AuthorDate: Mon Jun 26 15:08:45 2023 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jun 26 20:19:36 2023 +0200

    pdfium: missing include
    
    Change-Id: I27091093dadc699317141a4dd3d5c80b51e56be6

diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index f4643376cee0..47c1c4749ea3 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -11,6 +11,7 @@ pdfium_patches :=
 pdfium_patches += ubsan.patch
 # Fixes build on our baseline.
 pdfium_patches += build.patch.1
+pdfium_patches += include.patch.1
 # Avoids Windows 8 build dependency.
 pdfium_patches += windows7.patch.1
 pdfium_patches += c++20-comparison.patch
diff --git a/external/pdfium/include.patch.1 b/external/pdfium/include.patch.1
new file mode 100644
index 000000000000..3fe9c5fa9983
--- /dev/null
+++ b/external/pdfium/include.patch.1
@@ -0,0 +1,21 @@
+--- pdfium/core/fxcodec/fx_codec.h.orig        2023-06-01 18:01:21.463535717 
+0200
++++ pdfium/core/fxcodec/fx_codec.h     2023-06-01 18:01:26.144536561 +0200
+@@ -8,6 +8,7 @@
+ #define CORE_FXCODEC_FX_CODEC_H_
+ 
+ #include <map>
++#include <cstdint>
+ 
+ #include "third_party/base/optional.h"
+ 
+--- pdfium/constants/annotation_flags.h.orig   2023-06-26 14:53:05.531326301 
+0200
++++ pdfium/constants/annotation_flags.h        2023-06-26 14:53:10.921369624 
+0200
+@@ -5,6 +5,8 @@
+ #ifndef CONSTANTS_ANNOTATION_FLAGS_H_
+ #define CONSTANTS_ANNOTATION_FLAGS_H_
+ 
++#include <stdint.h>
++
+ namespace pdfium {
+ namespace annotation_flags {
+ 

Reply via email to