0f4a587
From 9ffb1f6ac0f11fd446fd0e84b8dc69898691b4d3 Mon Sep 17 00:00:00 2001
0f4a587
From: Kohei Yoshida <kohei@libreoffice.org>
0f4a587
Date: Wed, 9 Sep 2020 21:23:48 -0400
0f4a587
Subject: [PATCH] Upgrade liborcus to 0.16.0.
0f4a587
0f4a587
Change-Id: Iae29fb26417dfc161698a81bee84e81545969065
0f4a587
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102502
0f4a587
Tested-by: Jenkins
0f4a587
Reviewed-by: Kohei Yoshida <kohei@libreoffice.org>
0f4a587
---
0f4a587
 RepositoryExternal.mk                         |   4 +-
0f4a587
 configure.ac                                  |   2 +-
0f4a587
 download.lst                                  |   4 +-
0f4a587
 ...k-all-untentionally-unused-variables.patch | 376 ++++++++++++++++++
0f4a587
 external/liborcus/ExternalPackage_liborcus.mk |   8 +-
0f4a587
 external/liborcus/ExternalProject_liborcus.mk |   4 +-
0f4a587
 external/liborcus/Library_orcus-parser.mk     |   1 +
0f4a587
 external/liborcus/Library_orcus.mk            |   4 +
0f4a587
 external/liborcus/UnpackedTarball_liborcus.mk |   1 +
0f4a587
 .../liborcus/windows-constants-hack.patch     |   2 +-
0f4a587
 sc/source/filter/inc/orcusinterface.hxx       |  21 +-
0f4a587
 sc/source/filter/orcus/interface.cxx          |  82 ++--
0f4a587
 sc/source/filter/orcus/xmlcontext.cxx         |   7 +-
0f4a587
 sc/source/ui/xmlsource/xmlsourcedlg.cxx       |   6 +-
0f4a587
 14 files changed, 475 insertions(+), 47 deletions(-)
0f4a587
 create mode 100644 external/liborcus/0001-Mark-all-untentionally-unused-variables.patch
0f4a587
0f4a587
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
0f4a587
index 7f623ac..df765fa 100644
0f4a587
--- a/RepositoryExternal.mk
0f4a587
+++ b/RepositoryExternal.mk
0f4a587
@@ -3281,7 +3281,7 @@ $(call gb_LinkTarget_set_include,$(1),\
0f4a587
 )
0f4a587
 
0f4a587
 $(call gb_LinkTarget_add_libs,$(1),\
0f4a587
-       -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.15 \
0f4a587
+       -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.16 \
0f4a587
 )
0f4a587
 
0f4a587
 $(if $(SYSTEM_BOOST), \
0f4a587
@@ -3300,7 +3300,7 @@ $(call gb_LinkTarget_set_include,$(1),\
0f4a587
 )
0f4a587
 
0f4a587
 $(call gb_LinkTarget_add_libs,$(1),\
0f4a587
-	-L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.15 \
0f4a587
+	-L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.16 \
0f4a587
 )
0f4a587
 
0f4a587
 endef
0f4a587
diff --git a/configure.ac b/configure.ac
0f4a587
index ce14b54..36342b1 100644
0f4a587
--- a/configure.ac
0f4a587
+++ b/configure.ac
0f4a587
@@ -9827,7 +9827,7 @@ AC_SUBST(ENABLE_FUZZERS)
0f4a587
 dnl ===================================================================
0f4a587
 dnl Orcus
0f4a587
 dnl ===================================================================
0f4a587
-libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.15 >= 0.15.0])
0f4a587
+libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.16 >= 0.16.0])
0f4a587
 if test "$with_system_orcus" != "yes"; then
0f4a587
     if test "$SYSTEM_BOOST" = "TRUE"; then
0f4a587
         # ===========================================================
0f4a587
diff --git a/download.lst b/download.lst
0f4a587
index 6398a09..1f3b4b1 100644
0f4a587
--- a/download.lst
0f4a587
+++ b/download.lst
0f4a587
@@ -204,8 +204,8 @@ export OPENLDAP_SHA256SUM := cdd6cffdebcd95161a73305ec13fc7a78e9707b46ca9f84fb89
0f4a587
 export OPENLDAP_TARBALL := openldap-2.4.45.tgz
0f4a587
 export OPENSSL_SHA256SUM := 14cb464efe7ac6b54799b34456bd69558a749a4931ecfd9cf9f71d7881cac7bc
0f4a587
 export OPENSSL_TARBALL := openssl-1.0.2t.tar.gz
0f4a587
-export ORCUS_SHA256SUM := cfb2aa60825f2a78589ed030c07f46a1ee16ef8a2d1bf2279192fbc1ae5a5f61
0f4a587
-export ORCUS_TARBALL := liborcus-0.15.4.tar.bz2
0f4a587
+export ORCUS_SHA256SUM := 854c6ec167ace59baa2984e175bac7b5b2af91bfde4bb10d2088b87a51ed76ec
0f4a587
+export ORCUS_TARBALL := liborcus-0.16.0.tar.bz2
0f4a587
 export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b6330f6a383dc4be34439aca5e9fb
0f4a587
 export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz
0f4a587
 export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d
0f4a587
diff --git a/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch b/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch
0f4a587
new file mode 100644
0f4a587
index 0000000..b0f6a57
0f4a587
--- /dev/null
0f4a587
+++ b/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch
0f4a587
@@ -0,0 +1,376 @@
0f4a587
+From 6d34c41b661a9e8dddf6d08bf1f3c1fd4f5581da Mon Sep 17 00:00:00 2001
0f4a587
+From: Kohei Yoshida <kohei.yoshida@gmail.com>
0f4a587
+Date: Fri, 11 Sep 2020 21:39:09 -0400
0f4a587
+Subject: [PATCH] Mark all untentionally unused variables.
0f4a587
+
0f4a587
+---
0f4a587
+ include/orcus/css_parser.hpp       | 70 ++++++++++++++++++++++++------
0f4a587
+ include/orcus/csv_parser.hpp       |  5 ++-
0f4a587
+ include/orcus/json_parser.hpp      | 15 +++++--
0f4a587
+ include/orcus/sax_parser.hpp       | 35 ++++++++++++---
0f4a587
+ include/orcus/sax_token_parser.hpp | 20 +++++++--
0f4a587
+ include/orcus/yaml_parser.hpp      | 10 ++++-
0f4a587
+ 6 files changed, 124 insertions(+), 31 deletions(-)
0f4a587
+
0f4a587
+diff --git a/include/orcus/css_parser.hpp b/include/orcus/css_parser.hpp
0f4a587
+index cdfae5e0..3e96980b 100644
0f4a587
+--- a/include/orcus/css_parser.hpp
0f4a587
++++ b/include/orcus/css_parser.hpp
0f4a587
+@@ -31,23 +31,44 @@ namespace orcus {
0f4a587
+ class css_handler
0f4a587
+ {
0f4a587
+ public:
0f4a587
+-    void at_rule_name(const char* p, size_t n) {}
0f4a587
++    void at_rule_name(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+-    void simple_selector_type(const char* p, size_t n) {}
0f4a587
++    void simple_selector_type(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+-    void simple_selector_class(const char* p, size_t n) {}
0f4a587
++    void simple_selector_class(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+-    void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe) {}
0f4a587
++    void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe)
0f4a587
++    {
0f4a587
++        (void)pe;
0f4a587
++    }
0f4a587
+ 
0f4a587
+-    void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc) {}
0f4a587
++    void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc)
0f4a587
++    {
0f4a587
++        (void)pc;
0f4a587
++    }
0f4a587
+ 
0f4a587
+-    void simple_selector_id(const char* p, size_t n) {}
0f4a587
++    void simple_selector_id(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     void end_simple_selector() {}
0f4a587
+ 
0f4a587
+     void end_selector() {}
0f4a587
+ 
0f4a587
+-    void combinator(orcus::css::combinator_t combinator) {}
0f4a587
++    void combinator(orcus::css::combinator_t combinator)
0f4a587
++    {
0f4a587
++        (void)combinator;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each property name.
0f4a587
+@@ -55,7 +76,10 @@ public:
0f4a587
+      * @param p pointer to the char-array containing the property name string.
0f4a587
+      * @param n length of the property name string.
0f4a587
+      */
0f4a587
+-    void property_name(const char* p, size_t n) {}
0f4a587
++    void property_name(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each ordinary property value string.
0f4a587
+@@ -63,7 +87,10 @@ public:
0f4a587
+      * @param p pointer to the char-array containing the value string.
0f4a587
+      * @param n length of the value string.
0f4a587
+      */
0f4a587
+-    void value(const char* p, size_t n) {}
0f4a587
++    void value(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each RGB color value of a property.
0f4a587
+@@ -72,7 +99,10 @@ public:
0f4a587
+      * @param green value of green (0-255)
0f4a587
+      * @param blue value of blue (0-255)
0f4a587
+      */
0f4a587
+-    void rgb(uint8_t red, uint8_t green, uint8_t blue) {}
0f4a587
++    void rgb(uint8_t red, uint8_t green, uint8_t blue)
0f4a587
++    {
0f4a587
++        (void)red; (void)green; (void)blue;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each RGB color value of a property with alpha transparency
0f4a587
+@@ -83,7 +113,10 @@ public:
0f4a587
+      * @param blue value of blue (0-255)
0f4a587
+      * @param alpha alpha transparency value
0f4a587
+      */
0f4a587
+-    void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha) {}
0f4a587
++    void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha)
0f4a587
++    {
0f4a587
++        (void)red; (void)green; (void)blue; (void)alpha;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each HSL color value of a property.
0f4a587
+@@ -92,7 +125,10 @@ public:
0f4a587
+      * @param sat saturation
0f4a587
+      * @param light lightness
0f4a587
+      */
0f4a587
+-    void hsl(uint8_t hue, uint8_t sat, uint8_t light) {}
0f4a587
++    void hsl(uint8_t hue, uint8_t sat, uint8_t light)
0f4a587
++    {
0f4a587
++        (void)hue; (void)sat; (void)light;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each HSL color value of a property with alpha transparency
0f4a587
+@@ -103,7 +139,10 @@ public:
0f4a587
+      * @param light lightness
0f4a587
+      * @param alpha alpha value
0f4a587
+      */
0f4a587
+-    void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha) {}
0f4a587
++    void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha)
0f4a587
++    {
0f4a587
++        (void)hue; (void)sat; (void)light; (void)alpha;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at each URL value of a property.
0f4a587
+@@ -111,7 +150,10 @@ public:
0f4a587
+      * @param p pointer to the char-array containing the URL value string.
0f4a587
+      * @param n length of the URL value string.
0f4a587
+      */
0f4a587
+-    void url(const char* p, size_t n) {}
0f4a587
++    void url(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when the parsing begins.
0f4a587
+diff --git a/include/orcus/csv_parser.hpp b/include/orcus/csv_parser.hpp
0f4a587
+index a873b0f2..27b4f924 100644
0f4a587
+--- a/include/orcus/csv_parser.hpp
0f4a587
++++ b/include/orcus/csv_parser.hpp
0f4a587
+@@ -47,7 +47,10 @@ public:
0f4a587
+      *                  the text content is guaranteed to be valid so long as
0f4a587
+      *                  the original CSV stream content is valid.
0f4a587
+      */
0f4a587
+-    void cell(const char* p, size_t n, bool transient) {}
0f4a587
++    void cell(const char* p, size_t n, bool transient)
0f4a587
++    {
0f4a587
++        (void)p; (void)n; (void)transient;
0f4a587
++    }
0f4a587
+ };
0f4a587
+ 
0f4a587
+ template<typename _Handler>
0f4a587
+diff --git a/include/orcus/json_parser.hpp b/include/orcus/json_parser.hpp
0f4a587
+index 51a3d7cc..ef22b3a8 100644
0f4a587
+--- a/include/orcus/json_parser.hpp
0f4a587
++++ b/include/orcus/json_parser.hpp
0f4a587
+@@ -54,7 +54,10 @@ public:
0f4a587
+      *                  pointer points to somewhere in the JSON stream being
0f4a587
+      *                  parsed.
0f4a587
+      */
0f4a587
+-    void object_key(const char* p, size_t len, bool transient) {}
0f4a587
++    void object_key(const char* p, size_t len, bool transient)
0f4a587
++    {
0f4a587
++        (void)p; (void)len; (void)transient;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when the closing curly brace of an object is encountered.
0f4a587
+@@ -87,14 +90,20 @@ public:
0f4a587
+      *                  pointer points to somewhere in the JSON stream being
0f4a587
+      *                  parsed.
0f4a587
+      */
0f4a587
+-    void string(const char* p, size_t len, bool transient) {}
0f4a587
++    void string(const char* p, size_t len, bool transient)
0f4a587
++    {
0f4a587
++        (void)p; (void)len; (void)transient;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when a numeric value is encountered.
0f4a587
+      *
0f4a587
+      * @param val numeric value.
0f4a587
+      */
0f4a587
+-    void number(double val) {}
0f4a587
++    void number(double val)
0f4a587
++    {
0f4a587
++        (void)val;
0f4a587
++    }
0f4a587
+ };
0f4a587
+ 
0f4a587
+ /**
0f4a587
+diff --git a/include/orcus/sax_parser.hpp b/include/orcus/sax_parser.hpp
0f4a587
+index 73c17d06..3b21bfdf 100644
0f4a587
+--- a/include/orcus/sax_parser.hpp
0f4a587
++++ b/include/orcus/sax_parser.hpp
0f4a587
+@@ -30,7 +30,10 @@ public:
0f4a587
+      *
0f4a587
+      * @param param struct containing doctype declaration data.
0f4a587
+      */
0f4a587
+-    void doctype(const orcus::sax::doctype_declaration& param) {}
0f4a587
++    void doctype(const orcus::sax::doctype_declaration& param)
0f4a587
++    {
0f4a587
++        (void)param;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when <?... is encountered, where the '...' may be an
0f4a587
+@@ -39,28 +42,40 @@ public:
0f4a587
+      *
0f4a587
+      * @param decl name of the identifier.
0f4a587
+      */
0f4a587
+-    void start_declaration(const orcus::pstring& decl) {}
0f4a587
++    void start_declaration(const orcus::pstring& decl)
0f4a587
++    {
0f4a587
++        (void)decl;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when the closing tag (>) of a <?... ?> is encountered.
0f4a587
+      *
0f4a587
+      * @param decl name of the identifier.
0f4a587
+      */
0f4a587
+-    void end_declaration(const orcus::pstring& decl) {}
0f4a587
++    void end_declaration(const orcus::pstring& decl)
0f4a587
++    {
0f4a587
++        (void)decl;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at the start of each element.
0f4a587
+      *
0f4a587
+      * @param elem information of the element being parsed.
0f4a587
+      */
0f4a587
+-    void start_element(const orcus::sax::parser_element& elem) {}
0f4a587
++    void start_element(const orcus::sax::parser_element& elem)
0f4a587
++    {
0f4a587
++        (void)elem;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at the end of each element.
0f4a587
+      *
0f4a587
+      * @param elem information of the element being parsed.
0f4a587
+      */
0f4a587
+-    void end_element(const orcus::sax::parser_element& elem) {}
0f4a587
++    void end_element(const orcus::sax::parser_element& elem)
0f4a587
++    {
0f4a587
++        (void)elem;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when a segment of a text content is parsed.  Each text content
0f4a587
+@@ -76,7 +91,10 @@ public:
0f4a587
+      *                  a non-text value or be interned within the scope of
0f4a587
+      *                  the callback.
0f4a587
+      */
0f4a587
+-    void characters(const orcus::pstring& val, bool transient) {}
0f4a587
++    void characters(const orcus::pstring& val, bool transient)
0f4a587
++    {
0f4a587
++        (void)val; (void)transient;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called upon parsing of an attribute of an element.  Note that when
0f4a587
+@@ -86,7 +104,10 @@ public:
0f4a587
+      *
0f4a587
+      * @param attr struct containing attribute information.
0f4a587
+      */
0f4a587
+-    void attribute(const orcus::sax::parser_attribute& attr) {}
0f4a587
++    void attribute(const orcus::sax::parser_attribute& attr)
0f4a587
++    {
0f4a587
++        (void)attr;
0f4a587
++    }
0f4a587
+ };
0f4a587
+ 
0f4a587
+ /**
0f4a587
+diff --git a/include/orcus/sax_token_parser.hpp b/include/orcus/sax_token_parser.hpp
0f4a587
+index 1452bc27..6b1b1de4 100644
0f4a587
+--- a/include/orcus/sax_token_parser.hpp
0f4a587
++++ b/include/orcus/sax_token_parser.hpp
0f4a587
+@@ -71,7 +71,10 @@ public:
0f4a587
+      *
0f4a587
+      * @param decl struct containing the attributes of the XML declaration.
0f4a587
+      */
0f4a587
+-    void declaration(const orcus::xml_declaration_t& decl) {}
0f4a587
++    void declaration(const orcus::xml_declaration_t& decl)
0f4a587
++    {
0f4a587
++        (void)decl;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at the start of each element.
0f4a587
+@@ -79,7 +82,10 @@ public:
0f4a587
+      * @param elem struct containing the element's information as well as all
0f4a587
+      *             the attributes that belong to the element.
0f4a587
+      */
0f4a587
+-    void start_element(const orcus::xml_token_element_t& elem) {}
0f4a587
++    void start_element(const orcus::xml_token_element_t& elem)
0f4a587
++    {
0f4a587
++        (void)elem;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called at the end of each element.
0f4a587
+@@ -87,7 +93,10 @@ public:
0f4a587
+      * @param elem struct containing the element's information as well as all
0f4a587
+      *             the attributes that belong to the element.
0f4a587
+      */
0f4a587
+-    void end_element(const orcus::xml_token_element_t& elem) {}
0f4a587
++    void end_element(const orcus::xml_token_element_t& elem)
0f4a587
++    {
0f4a587
++        (void)elem;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when a segment of a text content is parsed.  Each text content
0f4a587
+@@ -103,7 +112,10 @@ public:
0f4a587
+      *                  a non-text value or be interned within the scope of
0f4a587
+      *                  the callback.
0f4a587
+      */
0f4a587
+-    void characters(const orcus::pstring& val, bool transient) {}
0f4a587
++    void characters(const orcus::pstring& val, bool transient)
0f4a587
++    {
0f4a587
++        (void)val; (void)transient;
0f4a587
++    }
0f4a587
+ };
0f4a587
+ 
0f4a587
+ /**
0f4a587
+diff --git a/include/orcus/yaml_parser.hpp b/include/orcus/yaml_parser.hpp
0f4a587
+index 797ebbec..8d16fbc7 100644
0f4a587
+--- a/include/orcus/yaml_parser.hpp
0f4a587
++++ b/include/orcus/yaml_parser.hpp
0f4a587
+@@ -72,14 +72,20 @@ public:
0f4a587
+      * @param p pointer to the first character of the string value.
0f4a587
+      * @param len length of the string value.
0f4a587
+      */
0f4a587
+-    void string(const char* p, size_t n) {}
0f4a587
++    void string(const char* p, size_t n)
0f4a587
++    {
0f4a587
++        (void)p; (void)n;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when a numeric value is encountered.
0f4a587
+      *
0f4a587
+      * @param val numeric value.
0f4a587
+      */
0f4a587
+-    void number(double val) {}
0f4a587
++    void number(double val)
0f4a587
++    {
0f4a587
++        (void)val;
0f4a587
++    }
0f4a587
+ 
0f4a587
+     /**
0f4a587
+      * Called when a boolean 'true' keyword is encountered.
0f4a587
+-- 
0f4a587
+2.25.1
0f4a587
+
0f4a587
diff --git a/external/liborcus/ExternalPackage_liborcus.mk b/external/liborcus/ExternalPackage_liborcus.mk
0f4a587
index 21dd1bf..7476918 100644
0f4a587
--- a/external/liborcus/ExternalPackage_liborcus.mk
0f4a587
+++ b/external/liborcus/ExternalPackage_liborcus.mk
0f4a587
@@ -12,11 +12,11 @@ $(eval $(call gb_ExternalPackage_ExternalPackage,liborcus,liborcus))
0f4a587
 $(eval $(call gb_ExternalPackage_use_external_project,liborcus,liborcus))
0f4a587
 
0f4a587
 ifeq ($(OS),MACOSX)
0f4a587
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.15.0.dylib,src/liborcus/.libs/liborcus-0.15.0.dylib))
0f4a587
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.15.0.dylib,src/parser/.libs/liborcus-parser-0.15.0.dylib))
0f4a587
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.16.0.dylib,src/liborcus/.libs/liborcus-0.16.0.dylib))
0f4a587
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.16.0.dylib,src/parser/.libs/liborcus-parser-0.16.0.dylib))
0f4a587
 else ifeq ($(DISABLE_DYNLOADING),)
0f4a587
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.15.so.0,src/liborcus/.libs/liborcus-0.15.so.0.0.0))
0f4a587
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.15.so.0,src/parser/.libs/liborcus-parser-0.15.so.0.0.0))
0f4a587
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.16.so.0,src/liborcus/.libs/liborcus-0.16.so.0.0.0))
0f4a587
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.16.so.0,src/parser/.libs/liborcus-parser-0.16.so.0.0.0))
0f4a587
 endif
0f4a587
 
0f4a587
 # vim: set noet sw=4 ts=4:
0f4a587
diff --git a/external/liborcus/ExternalProject_liborcus.mk b/external/liborcus/ExternalProject_liborcus.mk
0f4a587
index 38658cc..3671294 100644
0f4a587
--- a/external/liborcus/ExternalProject_liborcus.mk
0f4a587
+++ b/external/liborcus/ExternalProject_liborcus.mk
0f4a587
@@ -123,8 +123,8 @@ $(call gb_ExternalProject_get_state_target,liborcus,build) :
0f4a587
 		   $(MAKE) \
0f4a587
 		$(if $(filter MACOSX,$(OS)),\
0f4a587
 			&& $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \
0f4a587
-				$(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.15.0.dylib \
0f4a587
-				$(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.15.0.dylib \
0f4a587
+				$(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.16.0.dylib \
0f4a587
+				$(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.16.0.dylib \
0f4a587
 		) \
0f4a587
 	)
0f4a587
 	$(call gb_Trace_EndRange,liborcus,EXTERNAL)
0f4a587
diff --git a/external/liborcus/Library_orcus-parser.mk b/external/liborcus/Library_orcus-parser.mk
0f4a587
index d3cbddb..4e46591 100644
0f4a587
--- a/external/liborcus/Library_orcus-parser.mk
0f4a587
+++ b/external/liborcus/Library_orcus-parser.mk
0f4a587
@@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus-parser,\
0f4a587
 	UnpackedTarball/liborcus/src/parser/tokens \
0f4a587
 	UnpackedTarball/liborcus/src/parser/types \
0f4a587
 	UnpackedTarball/liborcus/src/parser/xml_namespace \
0f4a587
+	UnpackedTarball/liborcus/src/parser/xml_writer \
0f4a587
 	UnpackedTarball/liborcus/src/parser/yaml_parser_base \
0f4a587
 	UnpackedTarball/liborcus/src/parser/zip_archive \
0f4a587
 	UnpackedTarball/liborcus/src/parser/zip_archive_stream \
0f4a587
diff --git a/external/liborcus/Library_orcus.mk b/external/liborcus/Library_orcus.mk
0f4a587
index ea99e75..0a0ca58 100644
0f4a587
--- a/external/liborcus/Library_orcus.mk
0f4a587
+++ b/external/liborcus/Library_orcus.mk
0f4a587
@@ -85,6 +85,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/odf_tokens \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/ods_content_xml_context \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/ods_content_xml_handler \
0f4a587
+	UnpackedTarball/liborcus/src/liborcus/ods_dde_links_context \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/ods_session_data \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/ooxml_content_types \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/ooxml_global \
0f4a587
@@ -103,6 +104,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/orcus_xls_xml \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/orcus_xlsx \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/orcus_xml \
0f4a587
+	UnpackedTarball/liborcus/src/liborcus/orcus_xml_impl \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/orcus_xml_map_def \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/session_context \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/spreadsheet_iface_util \
0f4a587
@@ -134,7 +136,9 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/xml_simple_stream_handler \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/xml_stream_handler \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/xml_stream_parser \
0f4a587
+	UnpackedTarball/liborcus/src/liborcus/xml_structure_mapper \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/xml_structure_tree \
0f4a587
+	UnpackedTarball/liborcus/src/liborcus/xpath_parser \
0f4a587
 	UnpackedTarball/liborcus/src/liborcus/yaml_document_tree \
0f4a587
 ))
0f4a587
 
0f4a587
diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk
0f4a587
index e5e33b0..4736dbc 100644
0f4a587
--- a/external/liborcus/UnpackedTarball_liborcus.mk
0f4a587
+++ b/external/liborcus/UnpackedTarball_liborcus.mk
0f4a587
@@ -20,6 +20,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
0f4a587
 	external/liborcus/gcc9.patch.0 \
0f4a587
 	external/liborcus/libtool.patch.0 \
0f4a587
 	external/liborcus/fix-pch.patch.0 \
0f4a587
+	external/liborcus/0001-Mark-all-untentionally-unused-variables.patch \
0f4a587
 ))
0f4a587
 
0f4a587
 ifeq ($(OS),WNT)
0f4a587
diff --git a/external/liborcus/windows-constants-hack.patch b/external/liborcus/windows-constants-hack.patch
0f4a587
index 876bc16..51aabfa 100644
0f4a587
--- a/external/liborcus/windows-constants-hack.patch
0f4a587
+++ b/external/liborcus/windows-constants-hack.patch
0f4a587
@@ -8,7 +8,7 @@ index ae571f5..539ce18 100644
0f4a587
  
0f4a587
 -#include "constants.inl"
0f4a587
 +#define ORCUS_MAJOR_VERSION 0
0f4a587
-+#define ORCUS_MINOR_VERSION 11
0f4a587
++#define ORCUS_MINOR_VERSION 16
0f4a587
 +#define ORCUS_MICRO_VERSION 0
0f4a587
  
0f4a587
  namespace orcus {
0f4a587
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
0f4a587
index b298c71..00aea67 100644
0f4a587
--- a/sc/source/filter/inc/orcusinterface.hxx
0f4a587
+++ b/sc/source/filter/inc/orcusinterface.hxx
0f4a587
@@ -62,6 +62,11 @@ public:
0f4a587
     {
0f4a587
         return mnTextEncoding;
0f4a587
     }
0f4a587
+
0f4a587
+    ScDocumentImport& getDoc() const
0f4a587
+    {
0f4a587
+        return mrDoc;
0f4a587
+    }
0f4a587
 };
0f4a587
 
0f4a587
 class ScOrcusRefResolver : public orcus::spreadsheet::iface::import_reference_resolver
0f4a587
@@ -71,20 +76,28 @@ class ScOrcusRefResolver : public orcus::spreadsheet::iface::import_reference_re
0f4a587
 public:
0f4a587
     ScOrcusRefResolver( const ScOrcusGlobalSettings& rGS );
0f4a587
 
0f4a587
-    orcus::spreadsheet::address_t resolve_address(const char* p, size_t n) override;
0f4a587
-    orcus::spreadsheet::range_t resolve_range(const char* p, size_t n) override;
0f4a587
+    orcus::spreadsheet::src_address_t resolve_address(const char* p, size_t n) override;
0f4a587
+    orcus::spreadsheet::src_range_t resolve_range(const char* p, size_t n) override;
0f4a587
 };
0f4a587
 
0f4a587
 class ScOrcusNamedExpression : public orcus::spreadsheet::iface::import_named_expression
0f4a587
 {
0f4a587
     ScDocumentImport& mrDoc;
0f4a587
     const ScOrcusGlobalSettings& mrGlobalSettings;
0f4a587
-    SCTAB mnTab; //< negative if global, else >= 0 for sheet-local named expressions.
0f4a587
+    ScAddress maBasePos;
0f4a587
+    OUString maName;
0f4a587
+    OUString maExpr;
0f4a587
+    const SCTAB mnTab; //< negative if global, else >= 0 for sheet-local named expressions.
0f4a587
 
0f4a587
 public:
0f4a587
     ScOrcusNamedExpression( ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS, SCTAB nTab = -1 );
0f4a587
 
0f4a587
-    virtual void define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) override;
0f4a587
+    void reset();
0f4a587
+
0f4a587
+    virtual void set_base_position(const orcus::spreadsheet::src_address_t& pos) override;
0f4a587
+    virtual void set_named_expression(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) override;
0f4a587
+    virtual void set_named_range(const char* p_name, size_t n_name, const char* p_range, size_t n_range) override;
0f4a587
+    virtual void commit() override;
0f4a587
 };
0f4a587
 
0f4a587
 class ScOrcusSharedStrings : public orcus::spreadsheet::iface::import_shared_strings
0f4a587
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
0f4a587
index 220f7ce..aa96eb2 100644
0f4a587
--- a/sc/source/filter/orcus/interface.cxx
0f4a587
+++ b/sc/source/filter/orcus/interface.cxx
0f4a587
@@ -46,6 +46,7 @@
0f4a587
 #include <sal/log.hxx>
0f4a587
 
0f4a587
 #include <stylesbuffer.hxx>
0f4a587
+#include <orcus/exception.hpp>
0f4a587
 
0f4a587
 using namespace com::sun::star;
0f4a587
 
0f4a587
@@ -158,51 +159,54 @@ orcus::spreadsheet::formula_grammar_t ScOrcusGlobalSettings::get_default_formula
0f4a587
 ScOrcusRefResolver::ScOrcusRefResolver( const ScOrcusGlobalSettings& rGS ) :
0f4a587
     mrGlobalSettings(rGS) {}
0f4a587
 
0f4a587
-os::address_t ScOrcusRefResolver::resolve_address(const char* p, size_t n)
0f4a587
+os::src_address_t ScOrcusRefResolver::resolve_address(const char* p, size_t n)
0f4a587
 {
0f4a587
     OUString aStr(p, n, mrGlobalSettings.getTextEncoding());
0f4a587
 
0f4a587
     ScAddress aAddr;
0f4a587
-    aAddr.Parse(aStr, nullptr,
0f4a587
+    aAddr.Parse(aStr, &mrGlobalSettings.getDoc().getDoc(),
0f4a587
         formula::FormulaGrammar::extractRefConvention(
0f4a587
             mrGlobalSettings.getCalcGrammar()));
0f4a587
 
0f4a587
-    os::address_t ret;
0f4a587
-    ret.column = 0;
0f4a587
-    ret.row = 0;
0f4a587
-
0f4a587
-    if (aAddr.IsValid())
0f4a587
+    if (!aAddr.IsValid())
0f4a587
     {
0f4a587
-        ret.column = aAddr.Col();
0f4a587
-        ret.row = aAddr.Row();
0f4a587
+        std::ostringstream os;
0f4a587
+        os << "'" << std::string(p, n) << "' is not a valid address expression.";
0f4a587
+        throw orcus::invalid_arg_error(os.str());
0f4a587
     }
0f4a587
 
0f4a587
+    os::src_address_t ret;
0f4a587
+    ret.sheet = aAddr.Tab();
0f4a587
+    ret.column = aAddr.Col();
0f4a587
+    ret.row = aAddr.Row();
0f4a587
+
0f4a587
     return ret;
0f4a587
 }
0f4a587
 
0f4a587
-os::range_t ScOrcusRefResolver::resolve_range(const char* p, size_t n)
0f4a587
+os::src_range_t ScOrcusRefResolver::resolve_range(const char* p, size_t n)
0f4a587
 {
0f4a587
     OUString aStr(p, n, mrGlobalSettings.getTextEncoding());
0f4a587
 
0f4a587
     ScRange aRange;
0f4a587
-    aRange.Parse(aStr, nullptr,
0f4a587
+    aRange.Parse(aStr, &mrGlobalSettings.getDoc().getDoc(),
0f4a587
         formula::FormulaGrammar::extractRefConvention(
0f4a587
             mrGlobalSettings.getCalcGrammar()));
0f4a587
 
0f4a587
-    os::range_t ret;
0f4a587
-    ret.first.column = 0;
0f4a587
-    ret.first.row = 0;
0f4a587
-    ret.last.column = 0;
0f4a587
-    ret.last.row = 0;
0f4a587
-
0f4a587
-    if (aRange.IsValid())
0f4a587
+    if (!aRange.IsValid())
0f4a587
     {
0f4a587
-        ret.first.column = aRange.aStart.Col();
0f4a587
-        ret.first.row    = aRange.aStart.Row();
0f4a587
-        ret.last.column  = aRange.aEnd.Col();
0f4a587
-        ret.last.row     = aRange.aEnd.Row();
0f4a587
+        std::ostringstream os;
0f4a587
+        os << "'" << std::string(p, n) << "' is not a valid range expression.";
0f4a587
+        throw orcus::invalid_arg_error(os.str());
0f4a587
     }
0f4a587
 
0f4a587
+    os::src_range_t ret;
0f4a587
+    ret.first.sheet  = aRange.aStart.Tab();
0f4a587
+    ret.first.column = aRange.aStart.Col();
0f4a587
+    ret.first.row    = aRange.aStart.Row();
0f4a587
+    ret.last.sheet   = aRange.aEnd.Tab();
0f4a587
+    ret.last.column  = aRange.aEnd.Col();
0f4a587
+    ret.last.row     = aRange.aEnd.Row();
0f4a587
+
0f4a587
     return ret;
0f4a587
 }
0f4a587
 
0f4a587
@@ -210,20 +214,46 @@ ScOrcusNamedExpression::ScOrcusNamedExpression(
0f4a587
     ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS, SCTAB nTab ) :
0f4a587
     mrDoc(rDoc), mrGlobalSettings(rGS), mnTab(nTab) {}
0f4a587
 
0f4a587
-void ScOrcusNamedExpression::define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp)
0f4a587
+void ScOrcusNamedExpression::reset()
0f4a587
+{
0f4a587
+    maBasePos.SetTab(0);
0f4a587
+    maBasePos.SetCol(0);
0f4a587
+    maBasePos.SetRow(0);
0f4a587
+    maName.clear();
0f4a587
+    maExpr.clear();
0f4a587
+}
0f4a587
+
0f4a587
+void ScOrcusNamedExpression::set_base_position(const orcus::spreadsheet::src_address_t& pos)
0f4a587
+{
0f4a587
+    maBasePos.SetTab(pos.sheet);
0f4a587
+    maBasePos.SetCol(pos.column);
0f4a587
+    maBasePos.SetRow(pos.row);
0f4a587
+}
0f4a587
+
0f4a587
+void ScOrcusNamedExpression::set_named_expression(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp)
0f4a587
+{
0f4a587
+    maName = OUString(p_name, n_name, mrGlobalSettings.getTextEncoding());
0f4a587
+    maExpr = OUString(p_exp, n_exp, mrGlobalSettings.getTextEncoding());
0f4a587
+}
0f4a587
+
0f4a587
+void ScOrcusNamedExpression::set_named_range(const char* /*p_name*/, size_t /*n_name*/, const char* /*p_range*/, size_t /*n_range*/)
0f4a587
 {
0f4a587
-    OUString aName(p_name, n_name, mrGlobalSettings.getTextEncoding());
0f4a587
-    OUString aExpr(p_exp, n_exp, mrGlobalSettings.getTextEncoding());
0f4a587
+    throw std::runtime_error("ScOrcusNamedExpression::set_named_range not implemented yet.");
0f4a587
+}
0f4a587
 
0f4a587
+void ScOrcusNamedExpression::commit()
0f4a587
+{
0f4a587
     ScRangeName* pNames = mnTab >= 0 ? mrDoc.getDoc().GetRangeName(mnTab) : mrDoc.getDoc().GetRangeName();
0f4a587
     if (!pNames)
0f4a587
         return;
0f4a587
 
0f4a587
     ScRangeData* pRange = new ScRangeData(
0f4a587
-        &mrDoc.getDoc(), aName, aExpr, ScAddress(), ScRangeData::Type::Name,
0f4a587
+        &mrDoc.getDoc(), maName, maExpr, maBasePos, ScRangeData::Type::Name,
0f4a587
         mrGlobalSettings.getCalcGrammar());
0f4a587
 
0f4a587
     pNames->insert(pRange, false);
0f4a587
+
0f4a587
+    reset(); // make sure to reset the state for the next run.
0f4a587
 }
0f4a587
 
0f4a587
 ScOrcusFactory::CellStoreToken::CellStoreToken(const ScAddress& rPos, Type eType)
0f4a587
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
0f4a587
index ab16ae6..09f3ba9 100644
0f4a587
--- a/sc/source/filter/orcus/xmlcontext.cxx
0f4a587
+++ b/sc/source/filter/orcus/xmlcontext.cxx
0f4a587
@@ -89,10 +89,9 @@ void populateTree(
0f4a587
        rTreeCtrl.set_image(*xEntry, rParam.maImgElementRepeat, -1);
0f4a587
     }
0f4a587
 
0f4a587
-    orcus::xml_structure_tree::entity_names_type aNames;
0f4a587
+    orcus::xml_structure_tree::entity_names_type aNames = rWalker.get_attributes();
0f4a587
 
0f4a587
     // Insert attributes.
0f4a587
-    rWalker.get_attributes(aNames);
0f4a587
     for (const orcus::xml_structure_tree::entity_name& rAttrName : aNames)
0f4a587
     {
0f4a587
         OUString sAttr(toString(rAttrName, rWalker));
0f4a587
@@ -106,7 +105,7 @@ void populateTree(
0f4a587
         rTreeCtrl.set_image(*xAttr, rParam.maImgAttribute, -1);
0f4a587
     }
0f4a587
 
0f4a587
-    rWalker.get_children(aNames);
0f4a587
+    aNames = rWalker.get_children();
0f4a587
 
0f4a587
     // Non-leaf if it has child elements, leaf otherwise.
0f4a587
     rEntryData.mbLeafNode = aNames.empty();
0f4a587
@@ -266,7 +265,7 @@ void ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
0f4a587
             std::for_each(rLink.maFieldPaths.begin(), rLink.maFieldPaths.end(),
0f4a587
                 [&filter](const OString& rFieldPath)
0f4a587
                 {
0f4a587
-                    filter.append_field_link(rFieldPath.getStr());
0f4a587
+                    filter.append_field_link(rFieldPath.getStr(), orcus::pstring());
0f4a587
                 }
0f4a587
             );
0f4a587
 
0f4a587
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
0f4a587
index 1eb2e4b..167ecae 100644
0f4a587
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
0f4a587
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
0f4a587
@@ -49,8 +49,12 @@ OUString getXPath(
0f4a587
         if (pData)
0f4a587
             rNamespaces.push_back(pData->mnNamespaceID);
0f4a587
 
0f4a587
+        // element separator is '/' whereas attribute separator is '/@' in xpath.
0f4a587
         aBuf.insert(0, rTree.get_text(*xEntry, 0));
0f4a587
-        aBuf.insert(0, isAttribute(rTree, *xEntry) ? '@' : '/');
0f4a587
+        if (isAttribute(rTree, *xEntry))
0f4a587
+            aBuf.insert(0, "/@");
0f4a587
+        else
0f4a587
+            aBuf.insert(0, '/');
0f4a587
     }
0f4a587
     while (rTree.iter_parent(*xEntry));
0f4a587
 
0f4a587
-- 
0f4a587
2.26.2
0f4a587