Submitted By:            Douglas R. Reno <renodr at linuxfromscratch dot org>
Additional Credits:      Joe Locash
                         Marty Jack
Date:                    2023-11-26
Initial Package Version: 7.6.3.2
Origin:                  Self + Credits
Upstream Status:         Submitted
Description:             Fixes building Libreoffice with libxml2-2.12. There
                         were several changes required to the source code of
                         the external tarballs as well as to Libreoffice itself.
                         These patchset is the combined work of Marty Jack and
                         Joe Locash. Please see #18907 for more information.

diff -Nuarp libreoffice-7.6.3.2.orig/external/libcmis/libcmis-libxml2-2.12.patch libreoffice-7.6.3.2/external/libcmis/libcmis-libxml2-2.12.patch
--- libreoffice-7.6.3.2.orig/external/libcmis/libcmis-libxml2-2.12.patch	1969-12-31 19:00:00.000000000 -0500
+++ libreoffice-7.6.3.2/external/libcmis/libcmis-libxml2-2.12.patch	2023-11-24 15:24:17.705634458 -0500
@@ -0,0 +1,55 @@
+--- src/libcmis/atom-object.cxx.orig	2023-11-13 04:46:38.000000000 -0500
++++ src/libcmis/atom-object.cxx	2023-11-24 07:55:47.041856695 -0500
+@@ -42,6 +42,8 @@
+ #include "atom-object-type.hxx"
+ #include "atom-session.hxx"
+ 
++#include <libxml/parser.h>
++
+ using namespace std;
+ using libcmis::PropertyPtrMap;
+ 
+--- src/libcmis/atom-folder.cxx.orig	2023-11-13 04:46:38.000000000 -0500
++++ src/libcmis/atom-folder.cxx	2023-11-24 07:56:04.848924004 -0500
+@@ -37,6 +37,8 @@
+ #include "atom-document.hxx"
+ #include "atom-session.hxx"
+ 
++#include <libxml/parser.h>
++
+ using namespace std;
+ using libcmis::PropertyPtrMap;
+ 
+--- src/libcmis/atom-object-type.cxx.orig	2023-11-13 04:46:38.000000000 -0500
++++ src/libcmis/atom-object-type.cxx	2023-11-24 07:56:23.854003191 -0500
+@@ -32,6 +32,8 @@
+ 
+ #include <libcmis/xml-utils.hxx>
+ 
++#include <libxml/parser.h>
++
+ using namespace std;
+ using namespace boost;
+ 
+--- src/libcmis/atom-document.cxx.orig	2023-11-13 04:46:38.000000000 -0500
++++ src/libcmis/atom-document.cxx	2023-11-24 07:56:40.045078638 -0500
+@@ -38,6 +38,8 @@
+ 
+ #include "atom-session.hxx"
+ 
++#include <libxml/parser.h>
++
+ using namespace std;
+ using namespace libcmis;
+ 
+--- src/libcmis/sharepoint-utils.cxx.orig	2023-11-13 04:46:38.000000000 -0500
++++ src/libcmis/sharepoint-utils.cxx	2023-11-24 08:08:23.647825863 -0500
+@@ -34,6 +34,8 @@
+ 
+ #include "json-utils.hxx"
+ 
++#include <libxml/parser.h>
++
+ using namespace std;
+ using libcmis::PropertyPtrMap;
+ 
diff -Nuarp libreoffice-7.6.3.2.orig/external/libcmis/UnpackedTarball_libcmis.mk libreoffice-7.6.3.2/external/libcmis/UnpackedTarball_libcmis.mk
--- libreoffice-7.6.3.2.orig/external/libcmis/UnpackedTarball_libcmis.mk	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/external/libcmis/UnpackedTarball_libcmis.mk	2023-11-24 15:18:41.212080370 -0500
@@ -11,9 +11,10 @@ $(eval $(call gb_UnpackedTarball_Unpacke
 
 $(eval $(call gb_UnpackedTarball_set_tarball,libcmis,$(LIBCMIS_TARBALL)))
 
-$(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1))
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,0))
 
 $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\
+        external/libcmis/libcmis-libxml2-2.12.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff -Nuarp libreoffice-7.6.3.2.orig/external/liblangtag/liblangtag-libxml2.patch libreoffice-7.6.3.2/external/liblangtag/liblangtag-libxml2.patch
--- libreoffice-7.6.3.2.orig/external/liblangtag/liblangtag-libxml2.patch	1969-12-31 19:00:00.000000000 -0500
+++ libreoffice-7.6.3.2/external/liblangtag/liblangtag-libxml2.patch	2023-11-24 14:02:32.526647691 -0500
@@ -0,0 +1,20 @@
+--- liblangtag/lt-tag.c.orig	2017-10-21 04:25:25.000000000 -0400
++++ liblangtag/lt-tag.c	2023-11-23 11:14:36.264330458 -0500
+@@ -16,6 +16,7 @@
+ 
+ #include "lt-stdint.h"
+ 
++#include <stdlib.h>
+ #include <ctype.h>
+ #include <locale.h>
+ #include <string.h>
+--- extensions/lt-ext-ldml-u.c.orig	2015-11-25 04:44:04.000000000 -0500
++++ extensions/lt-ext-ldml-u.c	2023-11-23 11:43:06.530712707 -0500
+@@ -16,6 +16,7 @@
+ 
+ #include "lt-stdint.h"
+ 
++#include <stdlib.h>
+ #include <string.h>
+ #include <libxml/xpath.h>
+ #include "lt-error.h"
diff -Nuarp libreoffice-7.6.3.2.orig/external/liblangtag/UnpackedTarball_liblangtag.mk libreoffice-7.6.3.2/external/liblangtag/UnpackedTarball_liblangtag.mk
--- libreoffice-7.6.3.2.orig/external/liblangtag/UnpackedTarball_liblangtag.mk	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/external/liblangtag/UnpackedTarball_liblangtag.mk	2023-11-24 14:06:28.720720988 -0500
@@ -32,4 +32,8 @@ $(eval $(call gb_UnpackedTarball_add_pat
     external/liblangtag/clang-cl.patch.0 \
 ))
 
+$(eval $(call gb_UnpackedTarball_add_patches,liblangtag,\
+	external/liblangtag/liblangtag-libxml2.patch \
+))
+
 # vim: set noet sw=4 ts=4:
diff -Nuarp libreoffice-7.6.3.2.orig/external/xmlsec/UnpackedTarball_xmlsec.mk libreoffice-7.6.3.2/external/xmlsec/UnpackedTarball_xmlsec.mk
--- libreoffice-7.6.3.2.orig/external/xmlsec/UnpackedTarball_xmlsec.mk	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/external/xmlsec/UnpackedTarball_xmlsec.mk	2023-11-24 14:00:44.109154481 -0500
@@ -8,6 +8,7 @@
 #
 
 xmlsec_patches :=
+xmlsec_patches += xmlsec-libxml2.patch
 
 $(eval $(call gb_UnpackedTarball_UnpackedTarball,xmlsec))
 
@@ -15,6 +16,8 @@ $(eval $(call gb_UnpackedTarball_set_tar
 
 $(eval $(call gb_UnpackedTarball_update_autoconf_configs,xmlsec))
 
+$(eval $(call gb_UnpackedTarball_set_patchlevel,xmlsec,0))
+
 $(eval $(call gb_UnpackedTarball_add_patches,xmlsec,\
 	$(foreach patch,$(xmlsec_patches),external/xmlsec/$(patch)) \
 ))
diff -Nuarp libreoffice-7.6.3.2.orig/external/xmlsec/xmlsec-libxml2.patch libreoffice-7.6.3.2/external/xmlsec/xmlsec-libxml2.patch
--- libreoffice-7.6.3.2.orig/external/xmlsec/xmlsec-libxml2.patch	1969-12-31 19:00:00.000000000 -0500
+++ libreoffice-7.6.3.2/external/xmlsec/xmlsec-libxml2.patch	2023-11-24 14:01:11.008276880 -0500
@@ -0,0 +1,41 @@
+--- src/buffer.c.orig	2022-11-28 16:40:24.000000000 -0500
++++ src/buffer.c	2023-11-23 10:40:26.016942635 -0500
+@@ -21,6 +21,7 @@
+ #include <ctype.h>
+ 
+ #include <libxml/tree.h>
++#include <libxml/xmlIO.h>
+ 
+ #include <xmlsec/xmlsec.h>
+ #include <xmlsec/xmltree.h>
+--- src/relationship.c.orig	2022-11-28 16:40:24.000000000 -0500
++++ src/relationship.c	2023-11-23 10:53:09.710259702 -0500
+@@ -81,6 +81,7 @@
+ #include <libxml/tree.h>
+ #include <libxml/xpointer.h>
+ #include <libxml/c14n.h>
++#include <libxml/list.h>
+ 
+ #include <xmlsec/xmlsec.h>
+ #include <xmlsec/xmltree.h>
+--- src/xmlsec.c.orig	2022-11-28 16:40:24.000000000 -0500
++++ src/xmlsec.c	2023-11-23 11:41:19.506287708 -0500
+@@ -21,6 +21,7 @@
+ #include <string.h>
+ 
+ #include <libxml/tree.h>
++#include <libxml/parser.h>
+ 
+ #include <xmlsec/xmlsec.h>
+ #include <xmlsec/xmltree.h>
+diff -Naur xmlsec1-1.2.37.orig/include/xmlsec/xmlsec.h xmlsec1-1.2.37/include/xmlsec/xmlsec.h
+--- include/xmlsec/xmlsec.h 2022-11-28 16:40:24.000000000 -0500
++++ include/xmlsec/xmlsec.h      2023-11-25 14:08:07.304669450 -0500
+@@ -11,6 +11,7 @@
+ #ifndef __XMLSEC_H__
+ #define __XMLSEC_H__
+ 
++#include <libxml/parser.h>
+ #include <libxml/tree.h>
+ 
+ #include <xmlsec/version.h>
diff -Naur libreoffice-7.6.3.2.orig/drawinglayer/source/tools/primitive2dxmldump.cxx libreoffice-7.6.3.2/drawinglayer/source/tools/primitive2dxmldump.cxx
--- libreoffice-7.6.3.2.orig/drawinglayer/source/tools/primitive2dxmldump.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/drawinglayer/source/tools/primitive2dxmldump.cxx	2023-11-25 13:59:08.721548846 -0500
@@ -12,6 +12,7 @@
 #include <rtl/string.hxx>
 #include <tools/stream.hxx>
 #include <tools/XmlWriter.hxx>
+#include <libxml/parser.h>
 
 #include <math.h>
 #include <memory>
diff -Naur libreoffice-7.6.3.2.orig/filter/source/xsltfilter/LibXSLTTransformer.cxx libreoffice-7.6.3.2/filter/source/xsltfilter/LibXSLTTransformer.cxx
--- libreoffice-7.6.3.2.orig/filter/source/xsltfilter/LibXSLTTransformer.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/filter/source/xsltfilter/LibXSLTTransformer.cxx	2023-11-25 13:59:20.271505939 -0500
@@ -333,7 +333,7 @@
         }
         else
         {
-            xmlErrorPtr lastErr = xmlGetLastError();
+            const _xmlError * lastErr = xmlGetLastError();
             OUString msg;
             if (lastErr)
                 msg = OStringToOUString(lastErr->message, RTL_TEXTENCODING_UTF8);
diff -Naur libreoffice-7.6.3.2.orig/helpcompiler/source/HelpLinker.cxx libreoffice-7.6.3.2/helpcompiler/source/HelpLinker.cxx
--- libreoffice-7.6.3.2.orig/helpcompiler/source/HelpLinker.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/helpcompiler/source/HelpLinker.cxx	2023-11-25 13:59:38.464771608 -0500
@@ -815,7 +815,7 @@
 
 extern "C" {
 
-static void StructuredXMLErrorFunction(SAL_UNUSED_PARAMETER void *, xmlErrorPtr error)
+static void StructuredXMLErrorFunction(SAL_UNUSED_PARAMETER void *, const _xmlError * error)
 {
     std::string aErrorMsg = error->message;
     std::string aXMLParsingFile;
diff -Naur libreoffice-7.6.3.2.orig/include/xmloff/xmltoken.hxx libreoffice-7.6.3.2/include/xmloff/xmltoken.hxx
--- libreoffice-7.6.3.2.orig/include/xmloff/xmltoken.hxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/include/xmloff/xmltoken.hxx	2023-11-25 13:58:42.514979361 -0500
@@ -24,6 +24,7 @@
 #include <xmloff/dllapi.h>
 #include <rtl/ustring.hxx>
 #include <sax/fastattribs.hxx>
+#undef XML_EMPTY	/* Collision with xmlversion.h */
 
 /**
  * Handling of tokens in XML:
diff -Naur libreoffice-7.6.3.2.orig/sax/source/fastparser/fastparser.cxx libreoffice-7.6.3.2/sax/source/fastparser/fastparser.cxx
--- libreoffice-7.6.3.2.orig/sax/source/fastparser/fastparser.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/sax/source/fastparser/fastparser.cxx	2023-11-25 13:59:32.121461868 -0500
@@ -579,7 +579,7 @@
 OUString lclGetErrorMessage( xmlParserCtxtPtr ctxt, std::u16string_view sSystemId, sal_Int32 nLine )
 {
     const char* pMessage;
-    xmlErrorPtr error = xmlCtxtGetLastError( ctxt );
+    const _xmlError * error = xmlCtxtGetLastError( ctxt );
     if( error && error->message )
         pMessage = error->message;
     else
diff -Naur libreoffice-7.6.3.2.orig/sc/source/core/tool/interpr7.cxx libreoffice-7.6.3.2/sc/source/core/tool/interpr7.cxx
--- libreoffice-7.6.3.2.orig/sc/source/core/tool/interpr7.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/sc/source/core/tool/interpr7.cxx	2023-11-25 13:58:48.064958800 -0500
@@ -19,6 +19,7 @@
 #include <tools/urlobj.hxx>
 
 #include <officecfg/Office/Common.hxx>
+#include <libxml/parser.h>
 #include <libxml/xpath.h>
 #include <datastreamgettime.hxx>
 #include <dpobject.hxx>
diff -Naur libreoffice-7.6.3.2.orig/unoxml/source/dom/attr.cxx libreoffice-7.6.3.2/unoxml/source/dom/attr.cxx
--- libreoffice-7.6.3.2.orig/unoxml/source/dom/attr.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/unoxml/source/dom/attr.cxx	2023-11-25 13:58:27.921700042 -0500
@@ -29,6 +29,7 @@
 #include <com/sun/star/xml/dom/events/XMutationEvent.hpp>
 
 #include "document.hxx"
+#include <libxml/entities.h>
 
 using namespace css::uno;
 using namespace css::xml::dom;
diff -Naur libreoffice-7.6.3.2.orig/unoxml/source/dom/documentbuilder.cxx libreoffice-7.6.3.2/unoxml/source/dom/documentbuilder.cxx
--- libreoffice-7.6.3.2.orig/unoxml/source/dom/documentbuilder.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/unoxml/source/dom/documentbuilder.cxx	2023-11-25 13:58:22.695052708 -0500
@@ -21,6 +21,7 @@
 
 #include <string.h>
 
+#include <libxml/parser.h>
 #include <libxml/xmlerror.h>
 
 #include <memory>
diff -Naur libreoffice-7.6.3.2.orig/unoxml/source/dom/document.cxx libreoffice-7.6.3.2/unoxml/source/dom/document.cxx
--- libreoffice-7.6.3.2.orig/unoxml/source/dom/document.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/unoxml/source/dom/document.cxx	2023-11-25 13:58:34.345009614 -0500
@@ -33,6 +33,7 @@
 #include "domimplementation.hxx"
 #include "entity.hxx"
 #include "notation.hxx"
+#include <libxml/xmlIO.h>
 
 #include <event.hxx>
 #include <mutationevent.hxx>
diff -Naur libreoffice-7.6.3.2.orig/unoxml/source/dom/entity.hxx libreoffice-7.6.3.2/unoxml/source/dom/entity.hxx
--- libreoffice-7.6.3.2.orig/unoxml/source/dom/entity.hxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/unoxml/source/dom/entity.hxx	2023-11-25 13:58:10.751763491 -0500
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <libxml/entities.h>
 #include <libxml/tree.h>
 
 #include <sal/types.h>
diff -Naur libreoffice-7.6.3.2.orig/unoxml/source/xpath/xpathapi.cxx libreoffice-7.6.3.2/unoxml/source/xpath/xpathapi.cxx
--- libreoffice-7.6.3.2.orig/unoxml/source/xpath/xpathapi.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/unoxml/source/xpath/xpathapi.cxx	2023-11-25 13:58:04.681785892 -0500
@@ -217,7 +217,7 @@
         return selectSingleNode(contextNode, expr);
     }
 
-    static OUString make_error_message(xmlErrorPtr pError)
+    static OUString make_error_message(const _xmlError * pError)
     {
         OUStringBuffer buf;
         if (pError) {
@@ -259,7 +259,7 @@
             SAL_WARN("unoxml", "libxml2 error: " << str);
         }
 
-        static void structured_error_func(void *, xmlErrorPtr error)
+        static void structured_error_func(void *, const _xmlError * error)
         {
             SAL_WARN("unoxml", "libxml2 error: " << make_error_message(error));
         }
diff -Naur libreoffice-7.6.3.2.orig/xmlsecurity/inc/xmlsec/saxhelper.hxx libreoffice-7.6.3.2/xmlsecurity/inc/xmlsec/saxhelper.hxx
--- libreoffice-7.6.3.2.orig/xmlsecurity/inc/xmlsec/saxhelper.hxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/xmlsecurity/inc/xmlsec/saxhelper.hxx	2023-11-25 13:58:54.871600243 -0500
@@ -23,6 +23,7 @@
 
 #include <string_view>
 
+#include <libxml/parser.h>
 #include <libxml/tree.h>
 
 #include <rtl/ustring.hxx>
diff -Naur libreoffice-7.6.3.2.orig/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx libreoffice-7.6.3.2/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
--- libreoffice-7.6.3.2.orig/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx	2023-11-16 18:06:03.000000000 -0500
+++ libreoffice-7.6.3.2/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx	2023-11-25 13:59:02.488238642 -0500
@@ -27,6 +27,7 @@
 #include "xmlelementwrapper_xmlsecimpl.hxx"
 #include <comphelper/attributelist.hxx>
 #include <rtl/ref.hxx>
+#include <libxml/valid.h>
 
 #ifdef UNX
 #define stricmp strcasecmp
