[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-1' - 10 commits - comphelper/source configure.ac dbaccess/source download.lst external/firebird external/libxml2 external/libxslt external/poppler external/python3 external/twain_dsm include/comphelper include/oox include/sfx2 include/xmloff oox/source sc/qa scripting/source sc/source sdext/source sfx2/source svx/source sw/source xmloff/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 22 18:02:13 UTC 2019


 comphelper/source/misc/documentinfo.cxx                                            |   14 
 configure.ac                                                                       |   11 
 dbaccess/source/core/dataaccess/ModelImpl.cxx                                      |    7 
 dbaccess/source/core/dataaccess/databasedocument.cxx                               |   25 -
 dbaccess/source/core/inc/ModelImpl.hxx                                             |    2 
 download.lst                                                                       |   16 
 external/firebird/firebird-vs2017.patch.1                                          |    5 
 external/libxml2/libxml2-android.patch                                             |    2 
 external/libxml2/libxml2-config.patch.1                                            |   46 --
 external/libxslt/UnpackedTarball_libxslt.mk                                        |    2 
 external/libxslt/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1                  |  120 ------
 external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1                  |   69 +++
 external/libxslt/libxslt-config.patch.1                                            |   18 
 external/libxslt/libxslt-internal-symbols.patch.1                                  |    8 
 external/poppler/0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1        |   27 -
 external/poppler/0001-Revert-Make-the-mul-tables-be-calculated-at-compile-.patch.1 |  169 +++++++++
 external/poppler/StaticLibrary_poppler.mk                                          |    1 
 external/poppler/UnpackedTarball_poppler.mk                                        |    4 
 external/poppler/poppler-config.patch.1                                            |   19 -
 external/python3/ExternalProject_python3.mk                                        |    6 
 external/python3/UnpackedTarball_python3.mk                                        |    2 
 external/python3/python-3.3.5-pyexpat-symbols.patch.1                              |   28 -
 external/python3/python-3.5.7-c99.patch.1                                          |   62 ---
 external/twain_dsm/TWAIN_DSM_VS2015.vcxproj.patch                                  |    8 
 include/comphelper/documentinfo.hxx                                                |    5 
 include/oox/ole/axcontrol.hxx                                                      |    2 
 include/sfx2/docmacromode.hxx                                                      |    7 
 include/sfx2/objsh.hxx                                                             |    3 
 include/xmloff/xmlimp.hxx                                                          |    3 
 oox/source/ole/vbaproject.cxx                                                      |    4 
 sc/qa/unit/data/ods/keep-preview-missing-obj-link.ods                              |binary
 sc/qa/unit/helper/qahelper.cxx                                                     |   17 
 sc/qa/unit/helper/qahelper.hxx                                                     |    2 
 sc/qa/unit/subsequent_filters-test.cxx                                             |   19 +
 sc/source/filter/excel/xiescher.cxx                                                |   36 +
 sc/source/filter/inc/xiescher.hxx                                                  |   11 
 sc/source/ui/vba/vbasheetobject.cxx                                                |   13 
 sc/source/ui/vba/vbasheetobject.hxx                                                |    4 
 scripting/source/protocolhandler/scripthandler.cxx                                 |    6 
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx                              |   25 +
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx                              |   14 
 sfx2/source/doc/docmacromode.cxx                                                   |    2 
 sfx2/source/doc/objmisc.cxx                                                        |   13 
 sfx2/source/doc/objstor.cxx                                                        |   10 
 sfx2/source/doc/objxtor.cxx                                                        |    1 
 sfx2/source/doc/sfxbasemodel.cxx                                                   |    7 
 sfx2/source/inc/objshimp.hxx                                                       |    4 
 sfx2/source/notify/eventsupplier.cxx                                               |  187 +++++-----
 svx/source/svdraw/svdoole2.cxx                                                     |    8 
 sw/source/filter/html/htmlform.cxx                                                 |   16 
 sw/source/filter/html/htmlgrin.cxx                                                 |   19 +
 sw/source/filter/html/swhtml.cxx                                                   |    1 
 sw/source/filter/html/swhtml.hxx                                                   |    4 
 sw/source/filter/ww8/ww8par.cxx                                                    |   11 
 sw/source/filter/ww8/ww8par.hxx                                                    |    2 
 sw/source/filter/ww8/ww8par5.cxx                                                   |    2 
 sw/source/filter/ww8/ww8toolbar.cxx                                                |    6 
 xmloff/source/core/xmlimp.cxx                                                      |   14 
 xmloff/source/script/XMLEventImportHelper.cxx                                      |    3 
 59 files changed, 714 insertions(+), 438 deletions(-)

New commits:
commit d750cdb0ee54703760f5a6c0cd4181563e2f5b11
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Nov 22 14:05:59 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 16:27:42 2019 +0100

    configure: search harder for MSBbuild.exe
    
    If you install Visual Studio 2017 with the Visual Studio 2015 toolset,
    you don't get the 2015 MSBuild.exe so try to find the 2017 one.
    
    Also, DEVENV isn't used during the build so only warn if it's missing.
    
    FIXME: this doesn't actually work, msbuild.exe complains about wrong
    tools version 14.0.
    
    Change-Id: I656e37c4c524c0836430ba7d4a092f26817a5017

diff --git a/configure.ac b/configure.ac
index 9c4a7db50780..92ef5852cc86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3404,6 +3404,13 @@ if test "$_os" = "WINNT"; then
                 regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin/amd64"
             fi
             MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
+        elif test $vcnum = "140"; then
+            if test "$BITNESS_OVERRIDE" = ""; then
+                regvalue="$VC_PRODUCT_DIR/../MSBuild/15.0/Bin"
+            else
+                regvalue="$VC_PRODUCT_DIR/../MSBuild/15.0/Bin/amd64"
+            fi
+            MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
         else
             AC_MSG_ERROR([No msbuild found, Visual Studio installation broken?])
         fi
@@ -3414,7 +3421,7 @@ if test "$_os" = "WINNT"; then
     # MSVC 2017 devenv does not start properly from a DOS 8.3 path
     DEVENV=$(cygpath -lm "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe")
     if test ! -e "$DEVENV"; then
-        AC_MSG_ERROR([No devenv.exe found, Visual Studio installation broken?])
+        AC_MSG_WARN([No devenv.exe found, Visual Studio installation broken?])
     fi
 
     dnl ===========================================================
commit 0629491d47101df1646a50258a776c7e4549f957
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 15 14:00:56 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 16:26:43 2019 +0100

    Allow all _MSC_VER up to (excluding) 2000 (Firebird)
    
    (see https://blogs.msdn.microsoft.com/vcblog/2016/10/05/visual-c-compiler-version/)
    
    Change-Id: I69133a3742f72c20daa0ad94e093e4fffbd5d8c2
    Reviewed-on: https://gerrit.libreoffice.org/59097
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit b3b5abf3fdb0e088f6b902a22c3434e7176513c1)

diff --git a/external/firebird/firebird-vs2017.patch.1 b/external/firebird/firebird-vs2017.patch.1
index a4dad62e34a9..609f380a3e46 100644
--- a/external/firebird/firebird-vs2017.patch.1
+++ b/external/firebird/firebird-vs2017.patch.1
@@ -4,9 +4,8 @@ diff -ru firebird.orig/src/common/os/win32/mod_loader.cpp firebird/src/common/os
 @@ -103,6 +103,6 @@
  					"msvcr120.dll",
 -#elif _MSC_VER == 1900
--					"vcruntime140.dll",
-+#elif _MSC_VER >= 1900 && _MSC_VER <= 1914
-+					"vcruntime140.dll",
++#elif _MSC_VER >= 1900 && _MSC_VER < 2000
+ 					"vcruntime140.dll",
  #else
                      #error Specify CRT DLL name here !
  #endif
commit a814d164e0c5b1b2f55dd2a5fb75340dc24df0e1
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 15 13:47:31 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 16:26:35 2019 +0100

    Don't break on twain_dsm warnings
    
    Change-Id: I5e180ebef0a9d6809f0b5ca3014f60eaedd8ffe9
    Reviewed-on: https://gerrit.libreoffice.org/59070
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit c144dcbdb54cf657e21b0ba09ca8675246441519)

diff --git a/external/twain_dsm/TWAIN_DSM_VS2015.vcxproj.patch b/external/twain_dsm/TWAIN_DSM_VS2015.vcxproj.patch
index 86b87a4ff41b..40e131d2ad71 100644
--- a/external/twain_dsm/TWAIN_DSM_VS2015.vcxproj.patch
+++ b/external/twain_dsm/TWAIN_DSM_VS2015.vcxproj.patch
@@ -3,7 +3,7 @@ new file mode 100755
 index 000000000000..425c39966171
 --- /dev/null
 +++ b/visual_studio/TWAIN_DSM_VS2015.vcxproj
-@@ -0,0 +1,256 @@
+@@ -0,0 +1,258 @@
 +<?xml version="1.0" encoding="utf-8"?>
 +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 +  <ItemGroup Label="ProjectConfigurations">
@@ -122,7 +122,7 @@ index 000000000000..425c39966171
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <WarningLevel>Level4</WarningLevel>
-+      <TreatWarningAsError>true</TreatWarningAsError>
++      <TreatWarningAsError>false</TreatWarningAsError>
 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 +    </ClCompile>
 +    <Link>
@@ -158,7 +158,7 @@ index 000000000000..425c39966171
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <WarningLevel>Level4</WarningLevel>
-+      <TreatWarningAsError>true</TreatWarningAsError>
++      <TreatWarningAsError>false</TreatWarningAsError>
 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 +    </ClCompile>
 +    <ResourceCompile>
@@ -191,6 +191,7 @@ index 000000000000..425c39966171
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <WarningLevel>Level3</WarningLevel>
++      <TreatWarningAsError>false</TreatWarningAsError>
 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 +    </ClCompile>
 +    <Link>
@@ -223,6 +224,7 @@ index 000000000000..425c39966171
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <WarningLevel>Level3</WarningLevel>
++      <TreatWarningAsError>false</TreatWarningAsError>
 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
 +    </ClCompile>
 +    <ResourceCompile>
commit 7e9c5db6e01c0a8629f474cd0550cb470fdb4cb8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 20 14:54:16 2019 +0000
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 16:26:18 2019 +0100

    If a SdrOle2Obj object is missing/broken show the preview set for it
    
    if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
    graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback, otherwise
    the failing mxObjRef.is test in SdrOle2Obj::GetGraphic means it doesn't get used
    
    Reviewed-on: https://gerrit.libreoffice.org/83329
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 35300000346902db38f063b4427a07fdaf6240cd)
    
    Change-Id: I8f1aea6b25dc216e01a0f888a44d10876bb1bebd

diff --git a/sc/qa/unit/data/ods/keep-preview-missing-obj-link.ods b/sc/qa/unit/data/ods/keep-preview-missing-obj-link.ods
new file mode 100644
index 000000000000..e7b15fd7688a
Binary files /dev/null and b/sc/qa/unit/data/ods/keep-preview-missing-obj-link.ods differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 809fdbf4bbd0..481661e176a7 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -279,7 +279,7 @@ void testFormats(ScBootstrapFixture* pTest, ScDocument* pDoc, sal_Int32 nFormat)
     CPPUNIT_ASSERT_EQUAL(ScRangeList(ScRange(1,1,2,3,1,2)), rRange3);
 }
 
-const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage)
+const SdrOle2Obj* getSingleOleObject(ScDocument& rDoc, sal_uInt16 nPage)
 {
     // Retrieve the chart object instance from the 2nd page (for the 2nd sheet).
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
@@ -315,14 +315,23 @@ const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage)
         return nullptr;
     }
 
-    const SdrOle2Obj& rOleObj = static_cast<const SdrOle2Obj&>(*pObj);
-    if (!rOleObj.IsChart())
+    return static_cast<const SdrOle2Obj*>(pObj);
+}
+
+const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage)
+{
+    const SdrOle2Obj* pObj = getSingleOleObject(rDoc, nPage);
+
+    if (!pObj)
+        return pObj;
+
+    if (!pObj->IsChart())
     {
         cout << "This should be a chart object." << endl;
         return nullptr;
     }
 
-    return &rOleObj;
+    return pObj;
 }
 
 std::vector<OUString> getChartRangeRepresentations(const SdrOle2Obj& rChartObj)
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index c31569068a30..3cc5acc5161e 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -127,6 +127,8 @@ SCQAHELPER_DLLPUBLIC void testFile(const OUString& aFileName, ScDocument& rDoc,
 //need own handler because conditional formatting strings must be generated
 SCQAHELPER_DLLPUBLIC void testCondFile(const OUString& aFileName, ScDocument* pDoc, SCTAB nTab);
 
+SCQAHELPER_DLLPUBLIC const SdrOle2Obj* getSingleOleObject(ScDocument& rDoc, sal_uInt16 nPage);
+
 SCQAHELPER_DLLPUBLIC const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage);
 
 SCQAHELPER_DLLPUBLIC std::vector<OUString> getChartRangeRepresentations(const SdrOle2Obj& rChartObj);
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 326dc0608f29..6ac3e6dbd484 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -247,6 +247,7 @@ public:
     void testHiddenRowsColumnsXLSXML();
     void testColumnWidthRowHeightXLSXML();
     void testTdf62268();
+    void testPreviewMissingObjLink();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -380,6 +381,7 @@ public:
     CPPUNIT_TEST(testColumnWidthRowHeightXLSXML);
     CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
     CPPUNIT_TEST(testTdf62268);
+    CPPUNIT_TEST(testPreviewMissingObjLink);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -4096,6 +4098,23 @@ void ScFiltersTest::testTdf62268()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testPreviewMissingObjLink()
+{
+    ScDocShellRef xDocSh = loadDoc("keep-preview-missing-obj-link.", FORMAT_ODS);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load keep-preview-missing-obj-link.ods.", xDocSh.is());
+
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    // Retrieve the ole object
+    const SdrOle2Obj* pOleObj = getSingleOleObject(rDoc, 0);
+    CPPUNIT_ASSERT_MESSAGE("Failed to retrieve an ole object from the 2nd sheet.", pOleObj);
+
+    const Graphic* pGraphic = pOleObj->GetGraphic();
+    CPPUNIT_ASSERT_MESSAGE("the ole object links to a missing file, but we should retain its preview", pGraphic);
+
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "sc/qa/unit/data" )
 {
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index cddbd3285444..ca65521bed0b 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1864,11 +1864,19 @@ bool SdrOle2Obj::IsReal3DChart() const
 void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const OUString& aMediaType )
 {
     mpImpl->mxObjRef.SetGraphic( aGraphic, aMediaType );
+    // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
+    // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
+    if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic())
+        mpImpl->mxGraphic.reset(new Graphic(*pObjGraphic));
 }
 
 void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const OUString& aMediaType )
 {
     mpImpl->mxObjRef.SetGraphicStream( xGrStream, aMediaType );
+    // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
+    // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
+    if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic())
+        mpImpl->mxGraphic.reset(new Graphic(*pObjGraphic));
 }
 
 bool SdrOle2Obj::IsCalc() const
commit dafa0d92a5989c9daa4e6bb33a0c217e65d83c75
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Nov 20 13:11:59 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 16:20:15 2019 +0100

    poppler: upgrade to release 0.82.0
    
    fixes CVE-2019-9903 CVE-2019-9631 CVE-2019-9545 CVE-2019-9543
    CVE-2019-14494 CVE-2019-12293 CVE-2019-11026 CVE-2019-10873
    CVE-2019-10872 CVE-2019-10871 CVE-2019-10018
    
    remove obsolete 0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1
    
    Reviewed-on: https://gerrit.libreoffice.org/83308
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 28e52c49452320ac76489d0f93ca5692456e5331)
    Reviewed-on: https://gerrit.libreoffice.org/83336
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    (cherry picked from commit f3b2d61376c6d7ae262f58406d89ef0caa8b0aaf)
    
    Change-Id: I72b3bf89b294ed3e24157c7e75fd58d4f68d9f35

diff --git a/download.lst b/download.lst
index 274ce1b0b768..86a8548c40d3 100644
--- a/download.lst
+++ b/download.lst
@@ -206,8 +206,8 @@ export PIXMAN_SHA256SUM := 21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3
 export PIXMAN_TARBALL := e80ebae4da01e77f68744319f01d52a3-pixman-0.34.0.tar.gz
 export LIBPNG_SHA256SUM := 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca
 export LIBPNG_TARBALL := libpng-1.6.37.tar.xz
-export POPPLER_SHA256SUM := 92e09fd3302567fd36146b36bb707db43ce436e8841219025a82ea9fb0076b2f
-export POPPLER_TARBALL := poppler-0.74.0.tar.xz
+export POPPLER_SHA256SUM := 234f8e573ea57fb6a008e7c1e56bfae1af5d1adf0e65f47555e1ae103874e4df
+export POPPLER_TARBALL := poppler-0.82.0.tar.xz
 export POSTGRESQL_SHA256SUM := db61d498105a7d5fe46185e67ac830c878cdd7dc1f82a87f06b842217924c461
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 export PYTHON_SHA256SUM := c24a37c63a67f53bdd09c5f287b5cff8e8b98f857bf348c577d454d3f74db049
diff --git a/external/poppler/0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1 b/external/poppler/0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1
deleted file mode 100644
index b459a0a0bef7..000000000000
--- a/external/poppler/0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1
+++ /dev/null
@@ -1,27 +0,0 @@
-From f4136a6353162db249f63ddb0f20611622ab61b4 Mon Sep 17 00:00:00 2001
-From: Albert Astals Cid <aacid at kde.org>
-Date: Wed, 27 Feb 2019 19:43:22 +0100
-Subject: [PATCH] ImageStream::getLine: fix crash on broken files
-
-Fixes #728
----
- poppler/Stream.cc | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/poppler/Stream.cc b/poppler/Stream.cc
-index 33537b0e..a41435ab 100644
---- a/poppler/Stream.cc
-+++ b/poppler/Stream.cc
-@@ -496,6 +496,9 @@ unsigned char *ImageStream::getLine() {
-   }
-  
-   int readChars = str->doGetChars(inputLineSize, inputLine);
-+  if (unlikely(readChars == -1)) {
-+      readChars = 0;
-+  }
-   for ( ; readChars < inputLineSize; readChars++) inputLine[readChars] = EOF;
-   if (nBits == 1) {
-     unsigned char *p = inputLine;
--- 
-2.20.1
-
diff --git a/external/poppler/0001-Revert-Make-the-mul-tables-be-calculated-at-compile-.patch.1 b/external/poppler/0001-Revert-Make-the-mul-tables-be-calculated-at-compile-.patch.1
new file mode 100644
index 000000000000..26fdc10dec50
--- /dev/null
+++ b/external/poppler/0001-Revert-Make-the-mul-tables-be-calculated-at-compile-.patch.1
@@ -0,0 +1,169 @@
+Revert "Make the mul tables be calculated at compile time with constexpr"
+
+This reverts commit e0ef346c0f669140076c4cf443f07ea0770996da.
+---
+ poppler/Decrypt.cc | 134 ++++++++++++---------------------------------
+ 1 file changed, 35 insertions(+), 99 deletions(-)
+
+diff --git a/poppler/Decrypt.cc b/poppler/Decrypt.cc
+index 57945778..f5062929 100644
+--- a/poppler/Decrypt.cc
++++ b/poppler/Decrypt.cc
+@@ -763,119 +763,55 @@ static inline void invShiftRows(unsigned char *state) {
+ }
+ 
+ // {02} \cdot s
+-struct Mul02Table
+-{
+-  constexpr Mul02Table() : values()
+-  {
+-    for(int s = 0; s < 256; s++) {
+-      values[s] = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-    }
+-  }
+-
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
+-
+-  unsigned char values[256];
+-};
+-
+-static constexpr Mul02Table mul02;
++static inline unsigned char mul02(unsigned char s) {
++  return (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++}
+ 
+ // {03} \cdot s
+-struct Mul03Table
+-{
+-  constexpr Mul03Table() : values()
+-  {
+-    for(int s=0; s<256; s++) {
+-      const unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-      values[s] = s ^ s2;
+-    }
+-  }
+-
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
+-
+-  unsigned char values[256];
+-};
+-
+-static constexpr Mul03Table mul03;
++static inline unsigned char mul03(unsigned char s) {
++  unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++  return s ^ s2;
++}
+ 
+ // {09} \cdot s
+-struct Mul09Table
+-{
+-  constexpr Mul09Table() : values()
+-  {
+-    for(int s=0; s<256; s++) {
+-      const unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-      const unsigned char s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
+-      const unsigned char s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
+-      values[s] = s ^ s8;
+-    }
+-  }
+-
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
+-
+-  unsigned char values[256];
+-};
++static inline unsigned char mul09(unsigned char s) {
++  unsigned char s2, s4, s8;
+ 
+-static constexpr Mul09Table mul09;
++  s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++  s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
++  s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
++  return s ^ s8;
++}
+ 
+ // {0b} \cdot s
+-struct Mul0bTable
+-{
+-  constexpr Mul0bTable() : values()
+-  {
+-    for(int s=0; s<256; s++) {
+-      const unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-      const unsigned char s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
+-      const unsigned char s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
+-      values[s] = s ^ s2 ^ s8;
+-    }
+-  }
+-
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
++static inline unsigned char mul0b(unsigned char s) {
++  unsigned char s2, s4, s8;
+ 
+-  unsigned char values[256];
+-};
+-
+-static constexpr Mul0bTable mul0b;
++  s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++  s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
++  s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
++  return s ^ s2 ^ s8;
++}
+ 
+ // {0d} \cdot s
+-struct Mul0dTable
+-{
+-  constexpr Mul0dTable() : values()
+-  {
+-    for(int s=0; s<256; s++) {
+-      const unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-      const unsigned char s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
+-      const unsigned char s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
+-      values[s] = s ^ s4 ^ s8;
+-    }
+-  }
++static inline unsigned char mul0d(unsigned char s) {
++  unsigned char s2, s4, s8;
+ 
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
+-
+-  unsigned char values[256];
+-};
+-
+-static constexpr Mul0dTable mul0d;
++  s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++  s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
++  s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
++  return s ^ s4 ^ s8;
++}
+ 
+ // {0e} \cdot s
+-struct Mul0eTable
+-{
+-  constexpr Mul0eTable() : values()
+-  {
+-    for(int s=0; s<256; s++) {
+-      const unsigned char s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
+-      const unsigned char s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
+-      const unsigned char s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
+-      values[s] = s2 ^ s4 ^ s8;
+-    }
+-  }
+-
+-  constexpr unsigned char operator()(uint8_t i) const { return values[i]; }
++static inline unsigned char mul0e(unsigned char s) {
++  unsigned char s2, s4, s8;
+ 
+-  unsigned char values[256];
+-};
+-
+-static constexpr Mul0eTable mul0e;
++  s2 = (s & 0x80) ? ((s << 1) ^ 0x1b) : (s << 1);
++  s4 = (s2 & 0x80) ? ((s2 << 1) ^ 0x1b) : (s2 << 1);
++  s8 = (s4 & 0x80) ? ((s4 << 1) ^ 0x1b) : (s4 << 1);
++  return s2 ^ s4 ^ s8;
++}
+ 
+ static inline void mixColumns(unsigned char *state) {
+   int c;
+-- 
+2.21.0
+
diff --git a/external/poppler/StaticLibrary_poppler.mk b/external/poppler/StaticLibrary_poppler.mk
index aa5ed693eb22..ae03836f2ba6 100644
--- a/external/poppler/StaticLibrary_poppler.mk
+++ b/external/poppler/StaticLibrary_poppler.mk
@@ -55,7 +55,6 @@ $(eval $(call gb_StaticLibrary_add_generated_exception_objects,poppler,\
 	UnpackedTarball/poppler/goo/gfile \
 	UnpackedTarball/poppler/goo/GooTimer \
 	UnpackedTarball/poppler/goo/GooString \
-	UnpackedTarball/poppler/goo/FixedPoint \
 	UnpackedTarball/poppler/goo/NetPBMWriter \
 	UnpackedTarball/poppler/goo/PNGWriter \
 	UnpackedTarball/poppler/goo/TiffWriter \
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index 151fa5d0444f..76fd33236e5d 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,poppler,$(POPPLER_TARBALL),,poppler
 $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
 	external/poppler/poppler-config.patch.1 \
 	external/poppler/poppler-c++11.patch.1 \
-	external/poppler/0001-ImageStream-getLine-fix-crash-on-broken-files.patch.1 \
+	external/poppler/0001-Revert-Make-the-mul-tables-be-calculated-at-compile-.patch.1 \
 ))
 
 # std::make_unique is only available in C++14
@@ -23,7 +23,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
 # be happy with std::make_unique so just skip it
 ifneq ($(OS_FOR_BUILD),MACOSX)
 $(eval $(call gb_UnpackedTarball_set_post_action,poppler,\
-	env -i PATH="$(PATH)" $(FIND) . -name '*.cc' -exec sed -i -e 's/std::make_unique/o3tl::make_unique/' {} \\; \
+	env -i PATH="$(if $(filter WNT,$(OS)),/usr/bin,$(PATH))" $(FIND) . -name '*.cc' -exec sed -i -e 's/std::make_unique/o3tl::make_unique/' {} \\; \
 ))
 endif
 
diff --git a/external/poppler/poppler-config.patch.1 b/external/poppler/poppler-config.patch.1
index 1c68806276f7..cb74cd66fb5e 100644
--- a/external/poppler/poppler-config.patch.1
+++ b/external/poppler/poppler-config.patch.1
@@ -195,7 +195,7 @@ index 0fbd336a..451213f8 100644
 +#define PACKAGE_NAME "poppler"
 +
 +/* Define to the full name and version of this package. */
-+#define PACKAGE_STRING "poppler 0.74.0"
++#define PACKAGE_STRING "poppler 0.82.0"
 +
 +/* Define to the one symbol short name of this package. */
 +#define PACKAGE_TARNAME "poppler"
@@ -204,7 +204,7 @@ index 0fbd336a..451213f8 100644
 +#define PACKAGE_URL ""
 +
 +/* Define to the version of this package. */
-+#define PACKAGE_VERSION "0.74.0"
++#define PACKAGE_VERSION "0.82.0"
 +
 +/* Poppler data dir */
 +#define POPPLER_DATADIR "/usr/local/share/poppler"
@@ -228,7 +228,7 @@ index 0fbd336a..451213f8 100644
 +/* #undef USE_FLOAT */
 +
 +/* Version number of package */
-+#define VERSION "0.74.0"
++#define VERSION "0.82.0"
 +
 +#if defined(__APPLE__)
 +#elif defined (_WIN32)
@@ -268,7 +268,7 @@ new file mode 100644
 index 0fbd336a..451213f8 100644
 --- /dev/null
 +++ b/poppler/poppler-config.h
-@@ -0,0 +1,168 @@
+@@ -0,0 +1,173 @@
 +//================================================= -*- mode: c++ -*- ====
 +//
 +// poppler-config.h
@@ -304,7 +304,7 @@ index 0fbd336a..451213f8 100644
 +
 +/* Defines the poppler version. */
 +#ifndef POPPLER_VERSION
-+#define POPPLER_VERSION "0.74.0"
++#define POPPLER_VERSION "0.82.0"
 +#endif
 +
 +/* Enable multithreading support. */
@@ -396,6 +396,11 @@ index 0fbd336a..451213f8 100644
 +/* #undef USE_CMS */
 +#endif
 +
++/* Use header-only classes from Boost in the Splash backend */
++#ifndef USE_BOOST_HEADERS
++/* #undef USE_BOOST_HEADERS */
++#endif
++
 +// Also, there are preprocessor symbols in the header files
 +// that are used but never defined when building poppler using configure
 +// or cmake: DISABLE_OUTLINE, DEBUG_MEM,
@@ -466,9 +471,9 @@ index 0fbd336a..451213f8 100644
 +
 +#include "poppler-global.h"
 +
-+#define POPPLER_VERSION "0.74.0"
++#define POPPLER_VERSION "0.82.0"
 +#define POPPLER_VERSION_MAJOR 0
-+#define POPPLER_VERSION_MINOR 74
++#define POPPLER_VERSION_MINOR 82
 +#define POPPLER_VERSION_MICRO 0
 +
 +namespace poppler
commit d93da9a69e385a7732d07fbaa963c12a7df2a286
Author:     Rasmus Thomsen <oss at cogitri.dev>
AuthorDate: Sat Oct 26 14:11:35 2019 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Nov 22 14:45:32 2019 +0100

    Fix build with poppler-0.82
    
    Reviewed-on: https://gerrit.libreoffice.org/81545
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 2eadd46ab81058087af95bdfc1fea28fcdb65998)
    Reviewed-on: https://gerrit.libreoffice.org/83363
    Reviewed-by: Rasmus Thomsen <oss at cogitri.dev>
    (cherry picked from commit 928a372775a0758aa76eb10e568d5c106a8586eb)
    
    Change-Id: I3b6b3faea7986f3e5a6ae4790580d03bc9c955fc

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 9432755c9a7b..a5d8109589be 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -863,11 +863,20 @@ void PDFOutDev::eoClip(GfxState *state)
     local offset of character (zero for horizontal writing mode). not
     taken into account for output pos updates. Used for vertical writing.
  */
+
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+void PDFOutDev::drawChar(GfxState *state, double x, double y,
+                         double dx, double dy,
+                         double originX, double originY,
+                         CharCode, int /*nBytes*/, const Unicode *u, int uLen)
+{
+#else
 void PDFOutDev::drawChar(GfxState *state, double x, double y,
                          double dx, double dy,
                          double originX, double originY,
                          CharCode, int /*nBytes*/, Unicode *u, int uLen)
 {
+#endif
     assert(state);
 
     if( u == nullptr )
@@ -981,6 +990,13 @@ void PDFOutDev::drawImageMask(GfxState* pState, Object*, Stream* str,
     writeBinaryBuffer(aBuf);
 }
 
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
+                          int width, int height, GfxImageColorMap* colorMap,
+                          poppler_bool /*interpolate*/,
+                          const int* maskColors, poppler_bool /*inlineImg*/ )
+{
+#else
 void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
                           int width, int height, GfxImageColorMap* colorMap,
 #if POPPLER_CHECK_VERSION(0, 12, 0)
@@ -988,6 +1004,7 @@ void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
 #endif
                           int* maskColors, poppler_bool /*inlineImg*/ )
 {
+#endif
     if (m_bSkipImages)
         return;
     OutputBuffer aBuf; initBuf(aBuf);
@@ -1008,12 +1025,20 @@ void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
         {
             GfxRGB aMinRGB;
             colorMap->getColorSpace()->getRGB(
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+                reinterpret_cast<const GfxColor*>(maskColors),
+#else
                 reinterpret_cast<GfxColor*>(maskColors),
+#endif
                 &aMinRGB );
 
             GfxRGB aMaxRGB;
             colorMap->getColorSpace()->getRGB(
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+                reinterpret_cast<const GfxColor*>(maskColors)+gfxColorMaxComps,
+#else
                 reinterpret_cast<GfxColor*>(maskColors)+gfxColorMaxComps,
+#endif
                 &aMaxRGB );
 
             aMaskBuf.push_back( colToByte(aMinRGB.r) );
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
index ced1a653a494..ccf5b8fa9535 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
@@ -232,10 +232,17 @@ namespace pdfi
         virtual void eoClip(GfxState *state) override;
 
         //----- text drawing
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+        virtual void drawChar(GfxState *state, double x, double y,
+                              double dx, double dy,
+                              double originX, double originY,
+                              CharCode code, int nBytes, const Unicode *u, int uLen) override;
+#else
         virtual void drawChar(GfxState *state, double x, double y,
                               double dx, double dy,
                               double originX, double originY,
                               CharCode code, int nBytes, Unicode *u, int uLen) override;
+#endif
 #if POPPLER_CHECK_VERSION(0, 64, 0)
         virtual void drawString(GfxState *state, const GooString *s) override;
 #else
@@ -250,12 +257,19 @@ namespace pdfi
                                    poppler_bool interpolate,
 #endif
                                    poppler_bool inlineImg) override;
+#if POPPLER_CHECK_VERSION(0, 82, 0)
+        virtual void drawImage(GfxState *state, Object *ref, Stream *str,
+                               int width, int height, GfxImageColorMap *colorMap,
+                               poppler_bool interpolate,
+                               const int* maskColors, poppler_bool inlineImg) override;
+#else
         virtual void drawImage(GfxState *state, Object *ref, Stream *str,
                                int width, int height, GfxImageColorMap *colorMap,
 #if POPPLER_CHECK_VERSION(0, 12, 0)
                                poppler_bool interpolate,
 #endif
                                int *maskColors, poppler_bool inlineImg) override;
+#endif
         virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
                                      int width, int height,
                                      GfxImageColorMap *colorMap,
commit 47efb3a29c6ed30710e6963ec9f795e9d1387c7a
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Nov 20 15:08:24 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Nov 21 18:46:46 2019 +0100

    libxslt: upgrade to release 1.1.34
    
    Fixes CVE-2019-18197.
    
    Remove obsolete e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1.
    
    Change-Id: I95cf498e245083528f98bfef8cdd240bbe2211b9
    Reviewed-on: https://gerrit.libreoffice.org/83312
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit e9ea24cc004a8b9a5856f2f268bd40433c504db1)
    Reviewed-on: https://gerrit.libreoffice.org/83377
    (cherry picked from commit d19b32c779bfeb51ef9570c3de8ed1925ec44473)

diff --git a/download.lst b/download.lst
index f0a3164fbd0f..274ce1b0b768 100644
--- a/download.lst
+++ b/download.lst
@@ -157,8 +157,8 @@ export XMLSEC_TARBALL := xmlsec1-1.2.25.tar.gz
 export LIBXML_SHA256SUM := aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f
 export LIBXML_VERSION_MICRO := 10
 export LIBXML_TARBALL := libxml2-2.9.$(LIBXML_VERSION_MICRO).tar.gz
-export LIBXSLT_SHA256SUM := 8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8
-export LIBXSLT_VERSION_MICRO := 33
+export LIBXSLT_SHA256SUM := 98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f
+export LIBXSLT_VERSION_MICRO := 34
 export LIBXSLT_TARBALL := libxslt-1.1.$(LIBXSLT_VERSION_MICRO).tar.gz
 export LPSOLVE_SHA256SUM := 171816288f14215c69e730f7a4f1c325739873e21f946ff83884b350574e6695
 export LPSOLVE_TARBALL := 26b3e95ddf3d9c077c480ea45874b3b8-lp_solve_5.5.tar.gz
diff --git a/external/libxslt/UnpackedTarball_libxslt.mk b/external/libxslt/UnpackedTarball_libxslt.mk
index beb591b8b2a8..b035e99f0a79 100644
--- a/external/libxslt/UnpackedTarball_libxslt.mk
+++ b/external/libxslt/UnpackedTarball_libxslt.mk
@@ -19,7 +19,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libxslt,\
 	external/libxslt/libxslt-msvc.patch.2 \
 	external/libxslt/libxslt-1.1.26-memdump.patch \
 	external/libxslt/rpath.patch.0 \
-	external/libxslt/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1 \
+	external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libxslt/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1 b/external/libxslt/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1
deleted file mode 100644
index 260f35d1a35e..000000000000
--- a/external/libxslt/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch.1
+++ /dev/null
@@ -1,120 +0,0 @@
-From e03553605b45c88f0b4b2980adfbbb8f6fca2fd6 Mon Sep 17 00:00:00 2001
-From: Nick Wellnhofer <wellnhofer at aevum.de>
-Date: Sun, 24 Mar 2019 09:51:39 +0100
-Subject: [PATCH] Fix security framework bypass
-
-xsltCheckRead and xsltCheckWrite return -1 in case of error but callers
-don't check for this condition and allow access. With a specially
-crafted URL, xsltCheckRead could be tricked into returning an error
-because of a supposedly invalid URL that would still be loaded
-succesfully later on.
-
-Fixes #12.
-
-Thanks to Felix Wilhelm for the report.
----
- libxslt/documents.c | 18 ++++++++++--------
- libxslt/imports.c   |  9 +++++----
- libxslt/transform.c |  9 +++++----
- libxslt/xslt.c      |  9 +++++----
- 4 files changed, 25 insertions(+), 20 deletions(-)
-
-diff --git a/libxslt/documents.c b/libxslt/documents.c
-index 3f3a7312..4aad11bb 100644
---- a/libxslt/documents.c
-+++ b/libxslt/documents.c
-@@ -296,10 +296,11 @@ xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
- 	int res;
- 
- 	res = xsltCheckRead(ctxt->sec, ctxt, URI);
--	if (res == 0) {
--	    xsltTransformError(ctxt, NULL, NULL,
--		 "xsltLoadDocument: read rights for %s denied\n",
--			     URI);
-+	if (res <= 0) {
-+            if (res == 0)
-+                xsltTransformError(ctxt, NULL, NULL,
-+                     "xsltLoadDocument: read rights for %s denied\n",
-+                                 URI);
- 	    return(NULL);
- 	}
-     }
-@@ -372,10 +373,11 @@ xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
- 	int res;
- 
- 	res = xsltCheckRead(sec, NULL, URI);
--	if (res == 0) {
--	    xsltTransformError(NULL, NULL, NULL,
--		 "xsltLoadStyleDocument: read rights for %s denied\n",
--			     URI);
-+	if (res <= 0) {
-+            if (res == 0)
-+                xsltTransformError(NULL, NULL, NULL,
-+                     "xsltLoadStyleDocument: read rights for %s denied\n",
-+                                 URI);
- 	    return(NULL);
- 	}
-     }
-diff --git a/libxslt/imports.c b/libxslt/imports.c
-index 874870cc..3783b247 100644
---- a/libxslt/imports.c
-+++ b/libxslt/imports.c
-@@ -130,10 +130,11 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
- 	int secres;
- 
- 	secres = xsltCheckRead(sec, NULL, URI);
--	if (secres == 0) {
--	    xsltTransformError(NULL, NULL, NULL,
--		 "xsl:import: read rights for %s denied\n",
--			     URI);
-+	if (secres <= 0) {
-+            if (secres == 0)
-+                xsltTransformError(NULL, NULL, NULL,
-+                     "xsl:import: read rights for %s denied\n",
-+                                 URI);
- 	    goto error;
- 	}
-     }
-diff --git a/libxslt/transform.c b/libxslt/transform.c
-index 13793914..0636dbd0 100644
---- a/libxslt/transform.c
-+++ b/libxslt/transform.c
-@@ -3493,10 +3493,11 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
-      */
-     if (ctxt->sec != NULL) {
- 	ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
--	if (ret == 0) {
--	    xsltTransformError(ctxt, NULL, inst,
--		 "xsltDocumentElem: write rights for %s denied\n",
--			     filename);
-+	if (ret <= 0) {
-+            if (ret == 0)
-+                xsltTransformError(ctxt, NULL, inst,
-+                     "xsltDocumentElem: write rights for %s denied\n",
-+                                 filename);
- 	    xmlFree(URL);
- 	    xmlFree(filename);
- 	    return;
-diff --git a/libxslt/xslt.c b/libxslt/xslt.c
-index 780a5ad7..a234eb79 100644
---- a/libxslt/xslt.c
-+++ b/libxslt/xslt.c
-@@ -6763,10 +6763,11 @@ xsltParseStylesheetFile(const xmlChar* filename) {
- 	int res;
- 
- 	res = xsltCheckRead(sec, NULL, filename);
--	if (res == 0) {
--	    xsltTransformError(NULL, NULL, NULL,
--		 "xsltParseStylesheetFile: read rights for %s denied\n",
--			     filename);
-+	if (res <= 0) {
-+            if (res == 0)
-+                xsltTransformError(NULL, NULL, NULL,
-+                     "xsltParseStylesheetFile: read rights for %s denied\n",
-+                                 filename);
- 	    return(NULL);
- 	}
-     }
--- 
-2.18.1
-
diff --git a/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 b/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1
new file mode 100644
index 000000000000..f82c2e4f77ee
--- /dev/null
+++ b/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1
@@ -0,0 +1,69 @@
+From e2584eed1c84c18f16e42188c30d2c3d8e3e8853 Mon Sep 17 00:00:00 2001
+From: Chun-wei Fan <fanchunwei at src.gnome.org>
+Date: Tue, 12 Nov 2019 17:37:05 +0800
+Subject: [PATCH] win32: Add configuration for profiler
+
+Without this the generated xsltconfig.h will not be complete as there
+will be a configuration variable that is left in the header, breaking
+builds.
+
+This will allow one to enable or disable profiler support in Windows
+builds, and the default is to enable this.
+---
+ win32/configure.js | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/win32/configure.js b/win32/configure.js
+index 56694cce..12c99f30 100644
+--- a/win32/configure.js
++++ b/win32/configure.js
+@@ -47,6 +47,7 @@ var withIconv = true;
+ var withZlib = false;
+ var withCrypto = true;
+ var withModules = false;
++var withProfiler = true;
+ /* Win32 build options. */
+ var dirSep = "\\";
+ var compiler = "msvc";
+@@ -106,6 +107,7 @@ function usage()
+ 	txt += "  zlib:       Use zlib library (" + (withZlib? "yes" : "no") + ")\n";
+ 	txt += "  crypto:     Enable Crypto support (" + (withCrypto? "yes" : "no") + ")\n";
+ 	txt += "  modules:    Enable Module support (" + (withModules? "yes" : "no") + ")\n";
++	txt += "  profiler:   Enable Profiler support (" + (withProfiler? "yes" : "no") + ")\n";
+ 	txt += "\nWin32 build options, default value given in parentheses:\n\n";
+ 	txt += "  compiler:   Compiler to be used [msvc|mingw] (" + compiler + ")\n";
+ 	txt += "  cruntime:   C-runtime compiler option (only msvc) (" + cruntime + ")\n";
+@@ -192,6 +194,7 @@ function discoverVersion()
+ 	vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
+ 	vf.WriteLine("WITH_CRYPTO=" + (withCrypto? "1" : "0"));
+ 	vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0"));
++	vf.WriteLine("WITH_PROFILER=" + (withProfiler? "1" : "0"));
+ 	vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
+ 	vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
+ 	vf.WriteLine("PREFIX=" + buildPrefix);
+@@ -240,6 +243,8 @@ function configureXslt()
+ 			of.WriteLine(s.replace(/\@WITH_DEBUGGER\@/, withDebugger? "1" : "0"));
+ 		} else if (s.search(/\@WITH_MODULES\@/) != -1) {
+ 			of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
++		} else if (s.search(/\@WITH_PROFILER\@/) != -1) {
++			of.WriteLine(s.replace(/\@WITH_PROFILER\@/, withProfiler? "1" : "0"));
+ 		} else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) {
+ 			of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL"));
+ 		} else
+@@ -343,6 +348,8 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
+ 			withCrypto = strToBool(arg.substring(opt.length + 1, arg.length));
+ 		else if (opt == "modules")
+ 			withModules = strToBool(arg.substring(opt.length + 1, arg.length));
++		else if (opt == "profiler")
++			withProfiler = strToBool(arg.substring(opt.length + 1, arg.length));
+ 		else if (opt == "compiler")
+ 			compiler = arg.substring(opt.length + 1, arg.length);
+  		else if (opt == "cruntime")
+@@ -477,6 +484,7 @@ txtOut += "         Use iconv: " + boolToStr(withIconv) + "\n";
+ txtOut += "         With zlib: " + boolToStr(withZlib) + "\n";
+ txtOut += "            Crypto: " + boolToStr(withCrypto) + "\n";
+ txtOut += "           Modules: " + boolToStr(withModules) + "\n";
++txtOut += "          Profiler: " + boolToStr(withProfiler) + "\n";
+ txtOut += "\n";
+ txtOut += "Win32 build configuration\n";
+ txtOut += "-------------------------\n";
diff --git a/external/libxslt/libxslt-config.patch.1 b/external/libxslt/libxslt-config.patch.1
index 5f9d107bd1e7..e4ce5d9e27cf 100644
--- a/external/libxslt/libxslt-config.patch.1
+++ b/external/libxslt/libxslt-config.patch.1
@@ -23,13 +23,13 @@ Hack the xslt-config to return paths into WORKDIR.
  
  usage()
  {
-@@ -89,7 +95,8 @@
-     shift
- done
+@@ -92,7 +98,8 @@
+             libs="@XSLT_LIBDIR@ $libs"
+         fi
  
--the_libs="@XSLT_LIBDIR@ @XSLT_LIBS@ @EXTRA_LIBS@"
-+#the_libs="@XSLT_LIBDIR@ @XSLT_LIBS@ @EXTRA_LIBS@"
-+the_libs="-L${libdir}/libxslt/.libs -L${libdir}/libexslt/.libs -lxslt -lm"
- if test "$includedir" != "/usr/include"; then
-     the_flags="$the_flags -I$includedir `@XML_CONFIG@ --cflags`"
- else
+-        libs="$libs @EXTRA_LIBS@"
++        #libs="$libs @EXTRA_LIBS@"
++        libs="-L${libdir}/libxslt/.libs -L${libdir}/libexslt/.libs -lxslt -lm"
+        	;;
+ 
+     *)
diff --git a/external/libxslt/libxslt-internal-symbols.patch.1 b/external/libxslt/libxslt-internal-symbols.patch.1
index 7b13e1007c00..84a15154d729 100644
--- a/external/libxslt/libxslt-internal-symbols.patch.1
+++ b/external/libxslt/libxslt-internal-symbols.patch.1
@@ -1,13 +1,13 @@
 --- xslt/libxslt/libxslt.syms.orig	2017-09-05 16:25:50.504966267 +0200
 +++ xslt/libxslt/libxslt.syms	2017-09-05 16:41:00.256895709 +0200
 @@ -497,5 +497,10 @@
- # xsltInternals
-   xsltFlagRVTs;
-   xsltDecimalFormatGetByQName;
+ 
+ # pattern
+   xsltCompMatchClearCache;
 +
 +# Solaris ld needs explicit auto-reduction (or, alternatively, "-B local")
 +    local:
 +  *;
 +
- } LIBXML2_1.1.27;
+ } LIBXML2_1.1.30;
  
commit 07abff7f62c5f2d9afdb68c55a84df896f428884
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Nov 20 15:05:02 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Nov 21 18:42:48 2019 +0100

    libxml2: upgrade to release 2.9.10
    
    ... which is, surprisingly enough, required to build the latest libxslt.
    
    Reviewed-on: https://gerrit.libreoffice.org/83311
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit d1bf39a78ed239d4493f0470ca937852265e79d6)
    Reviewed-on: https://gerrit.libreoffice.org/83347
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit e9dc4662d4ba3bde91407911f1bc1a7aa25fa0ce)
    
    Change-Id: Ifbb36ed61b8f68185f9c788f63a8edeb58899f94

diff --git a/download.lst b/download.lst
index b3cd2e7cdbe4..f0a3164fbd0f 100644
--- a/download.lst
+++ b/download.lst
@@ -154,8 +154,8 @@ export LIBTOMMATH_SHA256SUM := 083daa92d8ee6f4af96a6143b12d7fc8fe1a547e14f862304
 export LIBTOMMATH_TARBALL := ltm-1.0.zip
 export XMLSEC_SHA256SUM := 967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2
 export XMLSEC_TARBALL := xmlsec1-1.2.25.tar.gz
-export LIBXML_SHA256SUM := 94fb70890143e3c6549f265cee93ec064c80a84c42ad0f23e85ee1fd6540a871
-export LIBXML_VERSION_MICRO := 9
+export LIBXML_SHA256SUM := aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f
+export LIBXML_VERSION_MICRO := 10
 export LIBXML_TARBALL := libxml2-2.9.$(LIBXML_VERSION_MICRO).tar.gz
 export LIBXSLT_SHA256SUM := 8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8
 export LIBXSLT_VERSION_MICRO := 33
diff --git a/external/libxml2/libxml2-android.patch b/external/libxml2/libxml2-android.patch
index 714de61068fb..42af83274026 100644
--- a/external/libxml2/libxml2-android.patch
+++ b/external/libxml2/libxml2-android.patch
@@ -4,7 +4,7 @@
  	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
  check: $(BUILT_SOURCES)
  	$(MAKE) $(AM_MAKEFLAGS) check-recursive
--all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) \
+-all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) \
 +all-am: Makefile $(LTLIBRARIES) \
  		config.h
  install-binPROGRAMS: install-libLTLIBRARIES
diff --git a/external/libxml2/libxml2-config.patch.1 b/external/libxml2/libxml2-config.patch.1
index 7d96fb530e57..8c28fb6a7806 100644
--- a/external/libxml2/libxml2-config.patch.1
+++ b/external/libxml2/libxml2-config.patch.1
@@ -25,45 +25,19 @@ Hack the xml2-config to return paths into WORKDIR.
  	;;
  
      --cflags)
--       	echo @XML_INCLUDEDIR@ @XML_CFLAGS@
-+        echo -I${includedir}
-+#       	echo @XML_INCLUDEDIR@ @XML_CFLAGS@
+-        cflags="@XML_INCLUDEDIR@ @XML_CFLAGS@"
++        #cflags="@XML_INCLUDEDIR@ @XML_CFLAGS@"
++        cflags="-I${includedir}"
         	;;
  
      --libtool-libs)
-@@ -82,19 +88,24 @@
-        	;;
+@@ -91,7 +96,8 @@
+             libs="@XML_LIBDIR@ $libs"
+         fi
  
-     --libs)
--        if [ "`uname`" = "Linux" ]
--	then
--	    if [ "@XML_LIBDIR@" = "-L/usr/lib" -o "@XML_LIBDIR@" = "-L/usr/lib64" ]
--	    then
--		echo @XML_LIBS@ @MODULE_PLATFORM_LIBS@
--	    else
--		echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@
--	    fi
--	else
--	    echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@ @WIN32_EXTRA_LIBADD@
--	fi
-+        echo -L${libdir} -lxml2 -lm
-+#        if [ "`uname`" = "Linux" ]
-+#	then
-+#	    if [ "@XML_LIBDIR@" = "-L/usr/lib" -o "@XML_LIBDIR@" = "-L/usr/lib64" ]
-+#	    then
-+#		echo @XML_LIBS@ @MODULE_PLATFORM_LIBS@
-+#	    else
-+#		echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@
-+#	    fi
-+#	else
-+#	    echo @XML_LIBDIR@ @XML_LIBS@ @MODULE_PLATFORM_LIBS@ @WIN32_EXTRA_LIBADD@
-+#	fi
-        	;;
+-        libs="$libs @WIN32_EXTRA_LIBADD@"
++        #libs="$libs @WIN32_EXTRA_LIBADD@"
++        libs="-L${libdir} -lxml2 -lm"
+         ;;
  
-+    print) # ugly configure hack
-+        exit 0
-+        ;;
-+ 
      *)
- 	usage
- 	exit 1
commit fd9efb9d204008e859cc804fc4c4ffeb3d58a745
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Nov 18 18:45:46 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Nov 21 18:38:34 2019 +0100

    python3: upgrade to release 3.5.9
    
    Fixes CVE-2019-9948 CVE-2019-9740 CVE-2019-10160 CVE-2019-16056
    and expat CVE-2019-15903.
    
    python-3.3.5-pyexpat-symbols.patch.1 fails to apply, and it's a
    mystery why --with-system-expat is used everywhere but on MacOSX,
    where 292af048ace2d4b455b2da3a22c784cb05db1d09 disabled it for no
    obvious reason, so try to remove the special case and get rid of the
    patch.
    
    Reviewed-on: https://gerrit.libreoffice.org/83117
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit b0930d56130fdddfe65e92b081a8afad77974076)
    Reviewed-on: https://gerrit.libreoffice.org/83189
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit 0d4b1f624349361e5bf11b58ccc9e0e295c0e4aa)
    
    Remove external/python3/python-3.5.7-c99.patch.1 - was apparently
    reverted upstream.
    
    Change-Id: I5ba4532eb6e7c2fb90daba95d132dcc7c9013d96

diff --git a/configure.ac b/configure.ac
index f079b082327e..9c4a7db50780 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8290,7 +8290,7 @@ internal)
     SYSTEM_PYTHON=
     PYTHON_VERSION_MAJOR=3
     PYTHON_VERSION_MINOR=5
-    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.7
+    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.9
     if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
         AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
     fi
diff --git a/download.lst b/download.lst
index f271916cf397..b3cd2e7cdbe4 100644
--- a/download.lst
+++ b/download.lst
@@ -210,8 +210,8 @@ export POPPLER_SHA256SUM := 92e09fd3302567fd36146b36bb707db43ce436e8841219025a82
 export POPPLER_TARBALL := poppler-0.74.0.tar.xz
 export POSTGRESQL_SHA256SUM := db61d498105a7d5fe46185e67ac830c878cdd7dc1f82a87f06b842217924c461
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
-export PYTHON_SHA256SUM := 285892899bf4d5737fd08482aa6171c6b2564a45b9102dfacfb72826aebdc7dc
-export PYTHON_TARBALL := Python-3.5.7.tar.xz
+export PYTHON_SHA256SUM := c24a37c63a67f53bdd09c5f287b5cff8e8b98f857bf348c577d454d3f74db049
+export PYTHON_TARBALL := Python-3.5.9.tar.xz
 export QXP_SHA256SUM := 8c257f6184ff94aefa7c9fa1cfae82083d55a49247266905c71c53e013f95c73
 export QXP_TARBALL := libqxp-0.0.1.tar.xz
 export RAPTOR_SHA256SUM := ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed
diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk
index 09edc2a099f2..99547f384844 100644
--- a/external/python3/ExternalProject_python3.mk
+++ b/external/python3/ExternalProject_python3.mk
@@ -42,9 +42,7 @@ $(call gb_ExternalProject_get_state_target,python3,build) :
 
 else
 
-# this was added in 2004, hopefully is obsolete now (and why only intel anyway)? $(if $(filter SOLARIS-INTEL,$(OS)$(CPUNAME)),--disable-ipv6)
-
-# --with-system-expat: this should find the one in the solver (or system)
+# --with-system-expat: this should find the one in the workdir (or system)
 
 # create a symlink "LO_lib" because the .so are in a directory with platform
 # specific name like build/lib.linux-x86_64-3.3
@@ -66,7 +64,7 @@ $(call gb_ExternalProject_get_state_target,python3,build) :
 		$(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
 		$(if $(ENABLE_VALGRIND),--with-valgrind) \
 		--prefix=/python-inst \
-		$(if $(filter MACOSX,$(OS)),,--with-system-expat) \
+		--with-system-expat \
 		$(if $(filter AIX,$(OS)), \
 			--disable-ipv6 --with-threads OPT="-g0 -fwrapv -O3 -Wall", \
 			$(if $(gb_Module_CURRENTMODULE_DEBUG_ENABLED), \
diff --git a/external/python3/UnpackedTarball_python3.mk b/external/python3/UnpackedTarball_python3.mk
index 66a82955e440..ee99de1f5e0c 100644
--- a/external/python3/UnpackedTarball_python3.mk
+++ b/external/python3/UnpackedTarball_python3.mk
@@ -23,11 +23,9 @@ $(eval $(call gb_UnpackedTarball_add_patches,python3,\
 	external/python3/python-3.5.4-msvc-disable.patch.1 \
 	external/python3/python-3.3.0-pythreadstate.patch.1 \
 	external/python3/python-3.3.0-clang.patch.1 \
-	external/python3/python-3.3.5-pyexpat-symbols.patch.1 \
 	external/python3/ubsan.patch.0 \
 	external/python3/python-3.5.tweak.strip.soabi.patch \
 	external/python3/0001-3.6-bpo-17239-Disable-external-entities-in-SAX-parse.patch.1 \
-	external/python3/python-3.5.7-c99.patch.1 \
 ))
 
 ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD SOLARIS,$(OS)),)
diff --git a/external/python3/python-3.3.5-pyexpat-symbols.patch.1 b/external/python3/python-3.3.5-pyexpat-symbols.patch.1
deleted file mode 100644
index c04c78cf36e7..000000000000
--- a/external/python3/python-3.3.5-pyexpat-symbols.patch.1
+++ /dev/null
@@ -1,28 +0,0 @@
-HACK: Fix build breakage on MacOS:
-
-*** WARNING: renaming "pyexpat" since importing it failed: dlopen(build/lib.macosx-10.6-i386-3.3/pyexpat.so, 2): Symbol not found: _XML_ErrorString
-
-This reverts c242a8f30806 from the python hg repo:
-
-restore namespacing of pyexpat symbols (closes #19186)
-
-
-See http://bugs.python.org/issue19186#msg214069
-
-The recommendation to include Modules/inc at first broke the Linux build...
-
-So do it this way, as it was before. Needs some realignment later.
-
---- python3/Modules/expat/expat_external.h
-+++ python3/Modules/expat/expat_external.h
-@@ -7,10 +7,6 @@
-
- /* External API definitions */
-
--/* Namespace external symbols to allow multiple libexpat version to
--   co-exist. */
--#include "pyexpatns.h"
--
- #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
- #define XML_USE_MSC_EXTENSIONS 1
- #endif
diff --git a/external/python3/python-3.5.7-c99.patch.1 b/external/python3/python-3.5.7-c99.patch.1
deleted file mode 100644
index 558166d9953f..000000000000
--- a/external/python3/python-3.5.7-c99.patch.1
+++ /dev/null
@@ -1,62 +0,0 @@
-remove C99 which isn't suppored by all compilers yet
-
---- python3/Modules/_pickle.c.orig	2019-04-03 16:34:01.380124314 +0200
-+++ python3/Modules/_pickle.c	2019-04-03 16:35:18.579005171 +0200
-@@ -674,9 +674,12 @@
-         PyErr_NoMemory();
-         return NULL;
-     }
--    for (size_t i = 0; i < self->mt_allocated; i++) {
-+    {
-+    size_t i;
-+    for (i = 0; i < self->mt_allocated; i++) {
-         Py_XINCREF(self->mt_table[i].me_key);
-     }
-+    }
-     memcpy(new->mt_table, self->mt_table,
-            sizeof(PyMemoEntry) * self->mt_allocated);
- 
-@@ -4204,7 +4207,9 @@
-         return NULL;
- 
-     memo = self->pickler->memo;
--    for (size_t i = 0; i < memo->mt_allocated; ++i) {
-+    {
-+    size_t i;
-+    for (i = 0; i < memo->mt_allocated; ++i) {
-         PyMemoEntry entry = memo->mt_table[i];
-         if (entry.me_key != NULL) {
-             int status;
-@@ -4225,6 +4230,7 @@
-                 goto error;
-         }
-     }
-+    }
-     return new_memo;
- 
-   error:
-@@ -6791,10 +6797,13 @@
-         if (new_memo == NULL)
-             return -1;
- 
--        for (size_t i = 0; i < new_memo_size; i++) {
-+        {
-+        size_t i;
-+        for (i = 0; i < new_memo_size; i++) {
-             Py_XINCREF(unpickler->memo[i]);
-             new_memo[i] = unpickler->memo[i];
-         }
-+        }
-     }
-     else if (PyDict_Check(obj)) {
-         Py_ssize_t i = 0;
-@@ -6839,7 +6848,8 @@
- 
-   error:
-     if (new_memo_size) {
--        for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
-+        size_t i;
-+        for (i = new_memo_size - 1; i != SIZE_MAX; i--) {
-             Py_XDECREF(new_memo[i]);
-         }
-         PyMem_FREE(new_memo);
commit 37381d11906b19e120862d09ca959e23fc6283d7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 7 17:37:11 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Nov 20 15:59:53 2019 +0100

    warn on load when a document binds an event to a macro
    
    a) treat shared/Scripts equivalently to document scripts
    
    This doesn't automatically warn/block running those scripts when used in a
    freshly loaded document on its own however
    
    because DocumentMacroMode::checkMacrosOnLoading will see at...
    
    if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() )
    
    that the document contains no macros and flip the allow macros flag to true so
    that potentially new uses of macros added by the user during the edit are
    allowed to run
    
    b) so, add an additional flag to indicate existence of use of macros in a document
    
    c) for odf import, set it when a script:event-listener tag is encountered
    d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called
    e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure
    f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called
    g) for oox import when VbaProject::attachMacros is called
    
    Reviewed-on: https://gerrit.libreoffice.org/77387
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    (cherry picked from commit 35fe064a67b54b0680b4845477c9b8751edda160)
    
    Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b

diff --git a/comphelper/source/misc/documentinfo.cxx b/comphelper/source/misc/documentinfo.cxx
index b63450590554..f0d2840d922a 100644
--- a/comphelper/source/misc/documentinfo.cxx
+++ b/comphelper/source/misc/documentinfo.cxx
@@ -157,6 +157,20 @@ namespace comphelper {
         return sTitle;
     }
 
+    void DocumentInfo::notifyMacroEventRead(const css::uno::Reference<css::frame::XModel>& rModel)
+    {
+        if (!rModel.is())
+            return;
+
+        // like BreakMacroSignature of XMLScriptContext use XModel::attachResource
+        // to propagate this notification
+        css::uno::Sequence<css::beans::PropertyValue> aMedDescr = rModel->getArgs();
+        sal_Int32 nNewLen = aMedDescr.getLength() + 1;
+        aMedDescr.realloc(nNewLen);
+        aMedDescr[nNewLen-1].Name = "MacroEventRead";
+        aMedDescr[nNewLen-1].Value <<= true;
+        rModel->attachResource(rModel->getURL(), aMedDescr);
+    }
 
 } // namespace comphelper
 
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index af71c72510c4..3281d0dd2b7e 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -376,6 +376,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r
             ,m_bSuppressVersionColumns(true)
             ,m_bModified(false)
             ,m_bDocumentReadOnly(false)
+            ,m_bMacroCallsSeenWhileLoading(false)
             ,m_pSharedConnectionManager(nullptr)
             ,m_nControllerLockCount(0)
 {
@@ -409,6 +410,7 @@ ODatabaseModelImpl::ODatabaseModelImpl(
             ,m_bSuppressVersionColumns(true)
             ,m_bModified(false)
             ,m_bDocumentReadOnly(false)
+            ,m_bMacroCallsSeenWhileLoading(false)
             ,m_pSharedConnectionManager(nullptr)
             ,m_nControllerLockCount(0)
 {
@@ -1274,6 +1276,11 @@ bool ODatabaseModelImpl::documentStorageHasMacros() const
     return ( *m_aEmbeddedMacros != eNoMacros );
 }
 
+bool ODatabaseModelImpl::macroCallsSeenWhileLoading() const
+{
+    return m_bMacroCallsSeenWhileLoading;
+}
+
 Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const
 {
     return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index eee5e8465031..eb20c56ed849 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -744,15 +744,24 @@ sal_Bool SAL_CALL ODatabaseDocument::attachResource( const OUString& _rURL, cons
 bool ODatabaseDocument::impl_attachResource( const OUString& i_rLogicalDocumentURL,
             const Sequence< PropertyValue >& i_rMediaDescriptor, DocumentGuard& _rDocGuard )
 {
-    if  (   ( i_rLogicalDocumentURL == getURL() )
-        &&  ( i_rMediaDescriptor.getLength() == 1 )
-        &&  ( i_rMediaDescriptor[0].Name == "BreakMacroSignature" )
-        )
+    if  (i_rLogicalDocumentURL == getURL())
     {
-        // this is a BAD hack of the Basic importer code ... there should be a dedicated API for this,
-        // not this bad mis-using of existing interfaces
-        return false;
-            // (we do not support macro signatures, so we can ignore this call)
+        ::comphelper::NamedValueCollection aArgs(i_rMediaDescriptor);
+
+        // this misuse of attachresource is a hack of the Basic importer code
+        // repurposing existing interfaces for uses it probably wasn't intended
+        // for
+
+        // we do not support macro signatures, so we can ignore that request
+        aArgs.remove("BreakMacroSignature");
+
+        bool bMacroEventRead = false;
+        if ((aArgs.get( "MacroEventRead" ) >>= bMacroEventRead) && bMacroEventRead)
+            m_pImpl->m_bMacroCallsSeenWhileLoading = true;
+        aArgs.remove( "MacroEventRead" );
+
+        if (aArgs.empty())
+            return false;
     }
 
     // if no URL has been provided, the caller was lazy enough to not call our getURL - which is not allowed anymore,
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx
index 4a763c577912..d7a642a02397 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -208,6 +208,7 @@ public:
     bool                                            m_bSuppressVersionColumns : 1;
     bool                                            m_bModified : 1;
     bool                                            m_bDocumentReadOnly : 1;
+    bool                                            m_bMacroCallsSeenWhileLoading : 1;
     css::uno::Reference< css::beans::XPropertyBag >
                                                         m_xSettings;
     css::uno::Sequence< OUString >                      m_aTableFilter;
@@ -436,6 +437,7 @@ public:
     virtual void setCurrentMacroExecMode( sal_uInt16 ) override;
     virtual OUString getDocumentLocation() const override;
     virtual bool documentStorageHasMacros() const override;
+    virtual bool macroCallsSeenWhileLoading() const override;
     virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override;
     virtual SignatureState getScriptingSignatureState() override;
     virtual bool hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) override;
diff --git a/include/comphelper/documentinfo.hxx b/include/comphelper/documentinfo.hxx
index c30d79b40c95..e9c2b153885a 100644
--- a/include/comphelper/documentinfo.hxx
+++ b/include/comphelper/documentinfo.hxx
@@ -35,8 +35,11 @@ namespace comphelper {
         /** retrieves the UI title of the given document
         */
         COMPHELPER_DLLPUBLIC OUString  getDocumentTitle( const css::uno::Reference< css::frame::XModel >& _rxDocument );
-    }
 
+        /** notify that this document contains a macro event handler
+        */
+        COMPHELPER_DLLPUBLIC void notifyMacroEventRead( const css::uno::Reference< css::frame::XModel >& _rxDocument );
+    }
 
 }   // namespace comphelper
 
diff --git a/include/oox/ole/axcontrol.hxx b/include/oox/ole/axcontrol.hxx
index a932a7bcfcd2..434c0c43c49b 100644
--- a/include/oox/ole/axcontrol.hxx
+++ b/include/oox/ole/axcontrol.hxx
@@ -334,6 +334,8 @@ public:
                             PropertySet const & rPropSet,
                             sal_Int32& nOrientation );
 
+    const css::uno::Reference<css::frame::XModel> GetDocModel() const { return mxDocModel; }
+
 private:
     css::uno::Reference< css::frame::XModel > mxDocModel;
     const GraphicHelper& mrGraphicHelper;
diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx
index f043e36a26d3..7e1511625086 100644
--- a/include/sfx2/docmacromode.hxx
+++ b/include/sfx2/docmacromode.hxx
@@ -111,6 +111,12 @@ namespace sfx2
         virtual bool
                     documentStorageHasMacros() const = 0;
 
+        /** checks whether the document's contained calls to macros or scripts after loading
+
+        */
+        virtual bool
+                    macroCallsSeenWhileLoading() const = 0;
+
         /** provides access to the XEmbeddedScripts interface of the document
 
             Implementations are allowed to return <NULL/> here if and only if they
@@ -272,6 +278,7 @@ namespace sfx2
 
             @see isMacroExecutionDisallowed
             @see IMacroDocumentAccess::documentStorageHasMacros
+            @see IMacroDocumentAccess::macroCallsSeenWhileLoading
             @see hasMacroLibrary
             @see IMacroDocumentAccess::checkForBrokenScriptingSignatures
         */
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index ed09fc6e2acb..83033e57ed70 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -426,6 +426,9 @@ public:
     sal_uInt32                  GetModifyPasswordHash() const;
     bool                        SetModifyPasswordHash( sal_uInt32 nHash );
 
+    void                        SetMacroCallsSeenWhileLoading();
+    bool                        GetMacroCallsSeenWhileLoading() const;
+
     const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
     bool                        SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
 
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index f213f21cd2fa..cfdd00bb0455 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -241,6 +241,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
 protected:
     bool                        mbIsFormsSupported;
     bool                        mbIsTableShapeSupported;
+    bool                        mbNotifyMacroEventRead;
 
     // Create top-level element context.
     // This method is called after the namespace map has been updated, but
@@ -577,6 +578,8 @@ public:
     bool embeddedFontAlreadyProcessed( const OUString& url );
 
     virtual void NotifyEmbeddedFontRead() {};
+    // something referencing a macro/script was imported
+    void NotifyMacroEventRead();
 
     bool needFixPositionAfterZ() const;
 };
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index 5a779944e0e6..f7ae54fa2a41 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <comphelper/configurationhelper.hxx>
 #include <comphelper/string.hxx>
+#include <comphelper/documentinfo.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <osl/diagnose.h>
 #include <rtl/tencinfo.h>
@@ -515,6 +516,8 @@ void VbaProject::attachMacros()
 {
     if( !maMacroAttachers.empty() && mxContext.is() ) try
     {
+        comphelper::DocumentInfo::notifyMacroEventRead(mxDocModel);
+
         Reference< XMultiComponentFactory > xFactory( mxContext->getServiceManager(), UNO_SET_THROW );
         Sequence< Any > aArgs( 2 );
         aArgs[ 0 ] <<= mxDocModel;
@@ -522,6 +525,7 @@ void VbaProject::attachMacros()
         Reference< XVBAMacroResolver > xResolver( xFactory->createInstanceWithArgumentsAndContext(
             "com.sun.star.script.vba.VBAMacroResolver", aArgs, mxContext ), UNO_QUERY_THROW );
         maMacroAttachers.forEachMem( &VbaMacroAttacherBase::resolveAndAttachMacro, ::std::cref( xResolver ) );
+
     }
     catch(const Exception& )
     {
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index c41afaa1c08c..a58d8ece6201 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -48,6 +48,7 @@
 #include <vcl/wmf.hxx>
 #include <comphelper/types.hxx>
 #include <comphelper/classids.hxx>
+#include <comphelper/documentinfo.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <basegfx/point/b2dpoint.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
@@ -161,7 +162,8 @@ XclImpDrawObjBase::XclImpDrawObjBase( const XclImpRoot& rRoot ) :
     mbSimpleMacro( true ),
     mbProcessSdr( true ),
     mbInsertSdr( true ),
-    mbCustomDff( false )
+    mbCustomDff( false ),
+    mbNotifyMacroEventRead( false )
 {
 }
 
@@ -497,7 +499,18 @@ SdrObjectPtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, c
     return xSdrObj;
 }
 
-void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
+void XclImpDrawObjBase::NotifyMacroEventRead()
+{
+    if (mbNotifyMacroEventRead)
+        return;
+    SfxObjectShell* pDocShell = GetDocShell();
+    if (!pDocShell)
+        return;
+    comphelper::DocumentInfo::notifyMacroEventRead(pDocShell->GetModel());
+    mbNotifyMacroEventRead = true;
+}
+
+void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj )
 {
     // default: front layer, derived classes may have to set other layer in DoPreProcessSdrObj()
     rSdrObj.NbcSetLayer( SC_LAYER_FRONT );
@@ -524,7 +537,10 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
     {
         if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, true ) )
         {
-            pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) );
+            OUString sMacro = XclTools::GetSbMacroUrl(maMacroName, GetDocShell());
+            if (!sMacro.isEmpty())
+                NotifyMacroEventRead();
+            pInfo->SetMacro(sMacro);
             pInfo->SetHlink( maHyperlink );
         }
     }
@@ -3271,7 +3287,8 @@ XclImpDffConverter::XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffS
     XclImpSimpleDffConverter( rRoot, rDffStrm ),
     oox::ole::MSConvertOCXControls( rRoot.GetDocShell()->GetModel() ),
     maStdFormName( "Standard" ),
-    mnOleImpFlags( 0 )
+    mnOleImpFlags( 0 ),
+    mbNotifyMacroEventRead(false)
 {
     const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
     if( rFilterOpt.IsMathType2Math() )
@@ -3328,7 +3345,7 @@ void XclImpDffConverter::InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& r
     SetModel( &xConvData->mrSdrModel, 1440 );
 }
 
-void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj )
+void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, XclImpDrawObjBase& rDrawObj )
 {
     if( rDrawObj.IsProcessSdrObj() )
     {
@@ -3378,6 +3395,14 @@ void XclImpDffConverter::FinalizeDrawing()
         SetModel( &maDataStack.back()->mrSdrModel, 1440 );
 }
 
+void XclImpDffConverter::NotifyMacroEventRead()
+{
+    if (mbNotifyMacroEventRead)
+        return;
+    comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+    mbNotifyMacroEventRead = true;
+}
+
 SdrObjectPtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect )
 {
     SdrObjectPtr xSdrObj;
@@ -3400,6 +3425,7 @@ SdrObjectPtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxOb
             ScriptEventDescriptor aDescriptor;
             if( (rConvData.mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) )
             {
+                NotifyMacroEventRead();
                 Reference< XEventAttacherManager > xEventMgr( rConvData.mxCtrlForm, UNO_QUERY_THROW );
                 xEventMgr->registerScriptEvent( rConvData.mnLastCtrlIndex, aDescriptor );
             }
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index 015b7c745242..2d42ff6437ff 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -126,7 +126,7 @@ public:
     SdrObjectPtr        CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const;
     /** Additional processing for the passed SdrObject before insertion into
         the drawing page (calls virtual DoPreProcessSdrObj() function). */
-    void                PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+    void                PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj );
     /** Additional processing for the passed SdrObject after insertion into the
         drawing page (calls virtual DoPostProcessSdrObj() function). */
     void                PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
@@ -173,6 +173,9 @@ protected:
     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
     virtual void        DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+
+    /** Notify that the document contains a macro event handler */
+    void NotifyMacroEventRead();
 private:
     /** Reads the contents of a BIFF3 OBJ record. */
     void                ImplReadObj3( XclImpStream& rStrm );
@@ -203,6 +206,7 @@ private:
     bool                mbProcessSdr;   /// true = Object is valid, do processing and insertion.
     bool                mbInsertSdr;    /// true = Insert the SdrObject into draw page.
     bool                mbCustomDff;    /// true = Recreate SdrObject in DFF import.
+    bool                mbNotifyMacroEventRead; /// true == If we have already seen a macro event
 };
 
 class XclImpDrawObjVector
@@ -929,7 +933,7 @@ public:
     /** Initially called before the objects of the passed drawing manager are converted. */
     void                InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
     /** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
-    void                ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
+    void                ProcessObject( SdrObjList& rObjList, XclImpDrawObjBase& rDrawObj );
     /** Processes all objects in the passed list. */
     void                ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
     /** Processes a drawing container in the passed DFF stream, converts all objects. */
@@ -1018,6 +1022,8 @@ private:
     void                InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
     /** Initializes the mxCtrlForm referring to the standard controls form. */
     void                InitControlForm();
+    /** Notify that this document contains a macro event handler */
+    void                NotifyMacroEventRead();
 
 private:
     typedef std::shared_ptr< ScfProgressBar >     ScfProgressBarRef;
@@ -1030,6 +1036,7 @@ private:
     XclImpDffConvDataStack maDataStack;     /// Stack for registered drawing managers.
     sal_uInt32          mnOleImpFlags;      /// Application OLE import settings.
     sal_Int32           mnDefTextMargin;    /// Default margin in text boxes.
+    bool mbNotifyMacroEventRead;            /// If we have already seen a macro event
 };
 
 // Drawing manager ============================================================
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx
index ac58ce940325..6680952bce1b 100644
--- a/sc/source/ui/vba/vbasheetobject.cxx
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
 #include <com/sun/star/script/XEventAttacherManager.hpp>
 #include <com/sun/star/style/VerticalAlignment.hpp>
+#include <comphelper/documentinfo.hxx>
 #include <ooo/vba/excel/Constants.hpp>
 #include <ooo/vba/excel/XlOrientation.hpp>
 #include <ooo/vba/excel/XlPlacement.hpp>
@@ -296,7 +297,8 @@ ScVbaControlObjectBase::ScVbaControlObjectBase(
         ListenerType eListenerType ) :
     ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ),
     mxFormIC( rxFormIC, uno::UNO_SET_THROW ),
-    mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW )
+    mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW ),
+    mbNotifyMacroEventRead(false)
 {
     // set listener and event name to be used for OnAction attribute
     switch( eListenerType )
@@ -354,6 +356,14 @@ OUString SAL_CALL ScVbaControlObjectBase::getOnAction()
     return OUString();
 }
 
+void ScVbaControlObjectBase::NotifyMacroEventRead()
+{
+    if (mbNotifyMacroEventRead)
+        return;
+    comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+    mbNotifyMacroEventRead = true;
+}
+
 void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
 {
     uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
@@ -373,6 +383,7 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
         aDescriptor.EventMethod = maEventMethod;
         aDescriptor.ScriptType = "Script";
         aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro );
+        NotifyMacroEventRead();
         xEventMgr->registerScriptEvent( nIndex, aDescriptor );
     }
 }
diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx
index 721bcf99a243..9bc18954c0db 100644
--- a/sc/source/ui/vba/vbasheetobject.hxx
+++ b/sc/source/ui/vba/vbasheetobject.hxx
@@ -164,6 +164,9 @@ public:
     virtual sal_Bool SAL_CALL getAutoSize() override;
     virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
 
+    /// Notify that the document contains a macro event handler
+    void NotifyMacroEventRead();
+
 protected:
     /// @throws css::uno::RuntimeException
     sal_Int32 getModelIndexInForm() const;
@@ -173,6 +176,7 @@ protected:
     css::uno::Reference< css::beans::XPropertySet > mxControlProps;
     OUString maListenerType;
     OUString maEventMethod;
+    bool mbNotifyMacroEventRead;
 };
 
 typedef ::cppu::ImplInheritanceHelper< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index e7cd12a21f0e..85b9f3eccb33 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -124,7 +124,6 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
     const URL& aURL, const Sequence < PropertyValue >& lArgs,
     const Reference< XDispatchResultListener >& xListener )
 {
-
     bool bSuccess = false;
     Any invokeResult;
     bool bCaughtException = false;
@@ -161,12 +160,11 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
                         {
                             xListener->dispatchFinished( aEvent ) ;
                         }
-                        catch(RuntimeException & e)
+                        catch(const RuntimeException &e)
                         {
                             SAL_WARN("scripting",
                                 "ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException"
-                                "while dispatchFinished with failure of the execution "
-                                << e );
+                                "while dispatchFinished with failure of the execution" << e);
                         }
                     }
                     return;
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx
index c62a5ab87d9a..6e01b925d514 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -397,7 +397,7 @@ namespace sfx2
         }
         else
         {
-            if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() )
+            if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading())
             {
                 bAllow = adjustMacroMode( rxInteraction );
             }
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 0c9d1a8f7e42..248cabf92f69 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1390,13 +1390,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon
     Any aException;
     try
     {
-        css::uno::Reference<css::uri::XUriReferenceFactory> urifac(
-            css::uri::UriReferenceFactory::create(comphelper::getProcessComponentContext()));
-        css::uno::Reference<css::uri::XVndSunStarScriptUrlReference> uri(
-            urifac->parse(_rScriptURL), css::uno::UNO_QUERY_THROW);
-        auto const loc = uri->getParameter("location");
-        bool bIsDocumentScript = loc == "document";
-        if ( bIsDocumentScript && !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) )
+        if ( !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) )
             return ERRCODE_IO_ACCESSDENIED;
 
         if ( UnTrustedScript(_rScriptURL) )
@@ -1773,6 +1767,11 @@ bool SfxObjectShell_Impl::documentStorageHasMacros() const
     return ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocStorage );
 }
 
+bool SfxObjectShell_Impl::macroCallsSeenWhileLoading() const
+{
+    return rDocShell.GetMacroCallsSeenWhileLoading();
+}
+
 Reference< XEmbeddedScripts > SfxObjectShell_Impl::getEmbeddedDocumentScripts() const
 {
     return Reference< XEmbeddedScripts >( rDocShell.GetModel(), UNO_QUERY );
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d65a7e8666bb..9dda3e0c3f72 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -3584,6 +3584,16 @@ void SfxObjectShell::SetConfigOptionsChecked( bool bChecked )
     pImpl->m_bConfigOptionsChecked = bChecked;
 }
 
+void SfxObjectShell::SetMacroCallsSeenWhileLoading()
+{
+    pImpl->m_bMacroCallsSeenWhileLoading = true;
+}
+
+bool SfxObjectShell::GetMacroCallsSeenWhileLoading() const
+{
+    return pImpl->m_bMacroCallsSeenWhileLoading;
+}
+
 bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
 {
 #if !HAVE_FEATURE_SCRIPTING
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 88270d13f4a2..b3309bae2d8f 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -230,6 +230,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
     ,m_bSharedXMLFlag( false )
     ,m_bAllowShareControlFileClean( true )
     ,m_bConfigOptionsChecked( false )
+    ,m_bMacroCallsSeenWhileLoading( false )
     ,lErr(ERRCODE_NONE)
     ,nEventId ( SfxEventHintId::NONE )
     ,pReloadTimer ( nullptr)
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 72066d250740..33586d12763f 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -876,8 +876,15 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const   OUString&
             pObjectShell->BreakMacroSign_Impl( bBreakMacroSign );
         }
 
+        bool bMacroEventRead = false;
+        if ((aArgs.get("MacroEventRead") >>= bMacroEventRead) && bMacroEventRead)
+        {
+            pObjectShell->SetMacroCallsSeenWhileLoading();
+        }
+
         aArgs.remove( "WinExtent" );
         aArgs.remove( "BreakMacroSignature" );
+        aArgs.remove( "MacroEventRead" );
         aArgs.remove( "Stream" );
         aArgs.remove( "InputStream" );
         aArgs.remove( "URL" );
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 67628d5dbdb0..0b403e071d5c 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -90,7 +90,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
                         bSaveVersionOnClose:1,
                         m_bSharedXMLFlag:1, // whether the document should be edited in shared mode
                         m_bAllowShareControlFileClean:1, // whether the flag should be stored in xml file
-                        m_bConfigOptionsChecked:1; // whether or not the user options are checked after the Options dialog is closed.
+                        m_bConfigOptionsChecked:1, // whether or not the user options are checked after the Options dialog is closed.
+                        m_bMacroCallsSeenWhileLoading:1; // whether or not the user options are checked after the Options dialog is closed.
 
     IndexBitSet         aBitSet;
     ErrCode             lErr;
@@ -139,6 +140,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
     virtual void setCurrentMacroExecMode( sal_uInt16 nMacroMode ) override;
     virtual OUString getDocumentLocation() const override;
     virtual bool documentStorageHasMacros() const override;
+    virtual bool macroCallsSeenWhileLoading() const override;
     virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override;
     virtual SignatureState getScriptingSignatureState() override;
 
diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx
index 2656e9c213ec..3861149da731 100644
--- a/sfx2/source/notify/eventsupplier.cxx
+++ b/sfx2/source/notify/eventsupplier.cxx
@@ -19,11 +19,13 @@
 
 #include <com/sun/star/beans/PropertyValue.hpp>
 
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
 #include <com/sun/star/util/URL.hpp>
-
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/util/URLTransformer.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
 #include <tools/urlobj.hxx>
 #include <tools/diagnose_ex.h>
 #include <svl/macitem.hxx>
@@ -46,6 +48,8 @@
 #include <macroloader.hxx>
 
 using namespace css;
+using namespace ::com::sun::star;
+
 
 
     //  --- XNameReplace ---
@@ -167,102 +171,129 @@ sal_Bool SAL_CALL SfxEvents_Impl::hasElements()
         return false;
 }
 
+namespace
+{
+    bool lcl_isScriptAccessAllowed_nothrow(const uno::Reference<uno::XInterface>& rxScriptContext)
+    {
+        try
+        {
+            uno::Reference<document::XEmbeddedScripts> xScripts(rxScriptContext, uno::UNO_QUERY);
+            if (!xScripts.is())
+            {
+                uno::Reference<document::XScriptInvocationContext> xContext(rxScriptContext, uno::UNO_QUERY_THROW);
+                xScripts.set(xContext->getScriptContainer(), uno::UNO_SET_THROW);
+            }
+
+            return xScripts->getAllowMacroExecution();
+        }
+        catch( const uno::Exception& )
+        {
+            DBG_UNHANDLED_EXCEPTION("sfx.doc");
+        }
+        return false;
+    }
+}
+
 void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::DocumentEvent& aTrigger, SfxObjectShell* pDoc )
 {
     uno::Sequence < beans::PropertyValue > aProperties;
-    if ( aEventData >>= aProperties )
-    {
-        OUString aType;
-        OUString aScript;
-        OUString aLibrary;
-        OUString aMacroName;
+    if ( !(aEventData >>= aProperties) )
+        return;
 
-        sal_Int32 nCount = aProperties.getLength();
+    OUString aType;
+    OUString aScript;
+    OUString aLibrary;
+    OUString aMacroName;
 
-        if ( !nCount )
-            return;
+    sal_Int32 nCount = aProperties.getLength();
 
-        sal_Int32 nIndex = 0;
-        while ( nIndex < nCount )
-        {
-            if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE )
-                aProperties[ nIndex ].Value >>= aType;
-            else if ( aProperties[ nIndex ].Name == PROP_SCRIPT )
-                aProperties[ nIndex ].Value >>= aScript;
-            else if ( aProperties[ nIndex ].Name == PROP_LIBRARY )
-                aProperties[ nIndex ].Value >>= aLibrary;
-            else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME )
-                aProperties[ nIndex ].Value >>= aMacroName;
-            else {
-                OSL_FAIL("Unknown property value!");
-            }
-            nIndex += 1;
-        }
+    if ( !nCount )
+        return;
 
-        if (aType == STAR_BASIC && !aScript.isEmpty())
-        {
-            uno::Any aAny;
-            SfxMacroLoader::loadMacro( aScript, aAny, pDoc );
+    sal_Int32 nIndex = 0;
+    while ( nIndex < nCount )
+    {
+        if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE )
+            aProperties[ nIndex ].Value >>= aType;
+        else if ( aProperties[ nIndex ].Name == PROP_SCRIPT )
+            aProperties[ nIndex ].Value >>= aScript;
+        else if ( aProperties[ nIndex ].Name == PROP_LIBRARY )
+            aProperties[ nIndex ].Value >>= aLibrary;
+        else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME )
+            aProperties[ nIndex ].Value >>= aMacroName;
+        else {
+            OSL_FAIL("Unknown property value!");
         }
-        else if (aType == "Service" ||
-                  aType == "Script")
-        {
-            bool bAllowed = false;
-            util::URL aURL;
-            if (!aScript.isEmpty())
-            {
-                uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
+        nIndex += 1;
+    }
 
-                aURL.Complete = aScript;
-                xTrans->parseStrict( aURL );
+    if (aType.isEmpty())
+    {
+        // Empty type means no active binding for the event. Just ignore do nothing.
+        return;
+    }
 
-                bAllowed = !SfxObjectShell::UnTrustedScript(aURL.Complete);
-            }
+    if (aScript.isEmpty())
+        return;
 
-            if (bAllowed)
-            {
-                SfxViewFrame* pView = pDoc ?
-                    SfxViewFrame::GetFirst( pDoc ) :
-                    SfxViewFrame::Current();
+    if (!pDoc)
+        pDoc = SfxObjectShell::Current();
 
-                uno::Reference
-                    < frame::XDispatchProvider > xProv;
+    if (pDoc && !lcl_isScriptAccessAllowed_nothrow(pDoc->GetModel()))
+        return;
 
-                if ( pView != nullptr )
-                {
-                    xProv = uno::Reference
-                        < frame::XDispatchProvider > (
-                            pView->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
-                }
-                else
-                {
-                    xProv.set( frame::Desktop::create( ::comphelper::getProcessComponentContext() ),
-                               uno::UNO_QUERY );
-                }
+    if (aType == STAR_BASIC)
+    {
+        uno::Any aAny;
+        SfxMacroLoader::loadMacro( aScript, aAny, pDoc );
+    }
+    else if (aType == "Service" || aType == "Script")
+    {
+        util::URL aURL;
+        uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
 
-                uno::Reference < frame::XDispatch > xDisp;
-                if ( xProv.is() )
-                    xDisp = xProv->queryDispatch( aURL, OUString(), 0 );
+        aURL.Complete = aScript;
+        xTrans->parseStrict( aURL );
 
-                if ( xDisp.is() )
-                {
+        bool bAllowed = !SfxObjectShell::UnTrustedScript(aURL.Complete);
 
-                    beans::PropertyValue aEventParam;
-                    aEventParam.Value <<= aTrigger;
-                    uno::Sequence< beans::PropertyValue > aDispatchArgs( &aEventParam, 1 );
-                    xDisp->dispatch( aURL, aDispatchArgs );
-                }
-            }
-        }
-        else if ( aType.isEmpty() )
-        {
-            // Empty type means no active binding for the event. Just ignore do nothing.
-        }
-        else
+        if (bAllowed)
         {
-            SAL_WARN( "sfx.notify", "notifyEvent(): Unsupported event type" );
+            SfxViewFrame* pView = SfxViewFrame::GetFirst(pDoc);
+
+            uno::Reference
+                < frame::XDispatchProvider > xProv;
+
+            if ( pView != nullptr )
+            {
+                xProv = uno::Reference
+                    < frame::XDispatchProvider > (
+                        pView->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+            }
+            else
+            {
+                xProv.set( frame::Desktop::create( ::comphelper::getProcessComponentContext() ),
+                           uno::UNO_QUERY );
+            }
+
+            uno::Reference < frame::XDispatch > xDisp;
+            if ( xProv.is() )
+                xDisp = xProv->queryDispatch( aURL, OUString(), 0 );
+
+            if ( xDisp.is() )
+            {
+
+                beans::PropertyValue aEventParam;
+                aEventParam.Value <<= aTrigger;
+                uno::Sequence< beans::PropertyValue > aDispatchArgs( &aEventParam, 1 );
+                xDisp->dispatch( aURL, aDispatchArgs );
+            }
         }
     }
+    else
+    {
+        SAL_WARN( "sfx.notify", "notifyEvent(): Unsupported event type" );
+    }
 }
 
 
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index 358cac7388af..e6d06317809b 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <hintids.hxx>
+#include <comphelper/documentinfo.hxx>
 #include <comphelper/string.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/wrkwin.hxx>
@@ -735,7 +736,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha
     rShape->setSize( aSz );
 }
 
-static void lcl_html_setEvents(
+static bool lcl_html_setEvents(
         const uno::Reference< script::XEventAttacherManager > & rEvtMn,
         sal_uInt32 nPos, const SvxMacroTableDtor& rMacroTable,
         const std::vector<OUString>& rUnoMacroTable,
@@ -764,7 +765,7 @@ static void lcl_html_setEvents(
     }
 
     if( 0==nEvents )
-        return;
+        return false;
 
     Sequence<script::ScriptEventDescriptor> aDescs( nEvents );
     script::ScriptEventDescriptor* pDescs = aDescs.getArray();
@@ -822,6 +823,7 @@ static void lcl_html_setEvents(
         }
     }
     rEvtMn->registerScriptEvents( nPos, aDescs );
+    return true;
 }
 
 static void lcl_html_getEvents( const OUString& rOption, const OUString& rValue,
@@ -1190,10 +1192,12 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
     // To prevent previous JavaScript-Events from being called, these events will only be set retroactively
     if( !rMacroTable.empty() || !rUnoMacroTable.empty() )
     {
-        lcl_html_setEvents( m_pFormImpl->GetControlEventManager(),
+        bool bHasEvents = lcl_html_setEvents( m_pFormImpl->GetControlEventManager(),
                             rFormComps->getCount() - 1,
                             rMacroTable, rUnoMacroTable, rUnoMacroParamTable,
                             GetScriptTypeString(m_pFormImpl->GetHeaderAttrs()) );
+        if (bHasEvents)
+            NotifyMacroEventRead();
     }
 
     if( bSetFCompPropSet )
@@ -1355,10 +1359,14 @@ void SwHTMLParser::NewForm( bool bAppend )
     Any aAny( &xForm, cppu::UnoType<XForm>::get());
     rForms->insertByIndex( rForms->getCount(), aAny );
     if( !aMacroTable.empty() )
-        lcl_html_setEvents( m_pFormImpl->GetFormEventManager(),
+    {
+        bool bHasEvents = lcl_html_setEvents( m_pFormImpl->GetFormEventManager(),
                             rForms->getCount() - 1,
                             aMacroTable, aUnoMacroTable, aUnoMacroParamTable,
                             rDfltScriptType );
+        if (bHasEvents)
+            NotifyMacroEventRead();
+    }
 }
 
 void SwHTMLParser::EndForm( bool bAppend )
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 8e61296d5389..9f6f93218b2e 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -20,6 +20,7 @@
 #include <memory>
 #include <hintids.hxx>
 #include <comphelper/string.hxx>
+#include <comphelper/documentinfo.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/wrkwin.hxx>
 #include <svx/svxids.hrc>
@@ -866,7 +867,10 @@ IMAGE_SETEVENT:
     }
 
     if( !aMacroItem.GetMacroTable().empty() )
+    {
+        NotifyMacroEventRead();
         pFlyFormat->SetFormatAttr( aMacroItem );
+    }
 
     // tdf#87083 If the graphic has not been loaded yet, then load it now.
     // Otherwise it may be loaded during the first paint of the object and it
@@ -1297,7 +1301,10 @@ ANCHOR_SETEVENT:
         aINetFormat.SetName( aName );
 
         if( !aMacroTable.empty() )
+        {
+            NotifyMacroEventRead();
             aINetFormat.SetMacroTable( &aMacroTable );
+        }
 
         // set the default attribute
         InsertAttr(&m_xAttrTab->pINetFormat, aINetFormat, xCntxt.get());
@@ -1509,4 +1516,16 @@ void SwHTMLParser::StripTrailingPara()
     }
 }
 
+void SwHTMLParser::NotifyMacroEventRead()
+{
+    if (m_bNotifyMacroEventRead)
+        return;
+    SwDocShell *pDocSh = m_xDoc->GetDocShell();
+    if (!pDocSh)
+        return;
+    uno::Reference<frame::XModel> const xModel(pDocSh->GetBaseModel());
+    comphelper::DocumentInfo::notifyMacroEventRead(xModel);
+    m_bNotifyMacroEventRead = true;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 508bbc1a4671..85aa9eb5435e 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -309,6 +309,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
     m_bRemoveHidden( false ),
     m_bBodySeen( false ),
     m_bReadingHeaderOrFooter( false ),
+    m_bNotifyMacroEventRead( false ),
     m_isInTableStructure(false),
     m_nTableDepth( 0 ),
     m_pTempViewFrame(nullptr)
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index d649f4a123e2..34a7260f85ef 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -496,6 +496,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
 
     bool m_bBodySeen : 1;
     bool m_bReadingHeaderOrFooter : 1;
+    bool m_bNotifyMacroEventRead : 1;
     bool m_isInTableStructure;
 
     sal_Int32 m_nTableDepth;
@@ -963,6 +964,9 @@ public:
     }
 
     void DeregisterHTMLTable(HTMLTable* pOld);
+
+    void NotifyMacroEventRead();
+
 };
 
 struct SwPendingStackData
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 5df28f764002..9a38f548d05c 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -39,6 +39,7 @@
 #include <unotools/tempfile.hxx>
 
 #include <comphelper/docpasswordrequest.hxx>
+#include <comphelper/documentinfo.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/string.hxx>
 
@@ -4293,6 +4294,7 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
     , m_aTOXEndCps()
     , m_aCurrAttrCP(-1)
     , m_bOnLoadingMain(false)
+    , m_bNotifyMacroEventRead(false)
 {
     m_pStrm->SetEndian( SvStreamEndian::LITTLE );
     m_aApos.push_back(false);
@@ -6564,4 +6566,13 @@ std::unique_ptr<SfxItemSet> SwWW8ImplReader::SetCurrentItemSet(SfxItemSet* pItem
     return xRet;
 }
 
+void SwWW8ImplReader::NotifyMacroEventRead()
+{
+    if (m_bNotifyMacroEventRead)
+        return;
+    uno::Reference<frame::XModel> const xModel(m_rDoc.GetDocShell()->GetBaseModel());
+    comphelper::DocumentInfo::notifyMacroEventRead(xModel);
+    m_bNotifyMacroEventRead = true;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index b4fbecfef440..1a1f988e32ed 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1367,6 +1367,7 @@ private:
     cp_vector m_aEndParaPos;
     WW8_CP m_aCurrAttrCP;
     bool m_bOnLoadingMain:1;
+    bool m_bNotifyMacroEventRead:1;
 
     const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
 
@@ -1897,6 +1898,7 @@ public:     // really private, but can only be done public
 
     void PostProcessAttrs();
     void ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocShell, struct HyperLinksTable& hlStr);
+    void NotifyMacroEventRead();
 };
 
 bool CanUseRemoteLink(const OUString &rGrfName);
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 4d1f84a9ad76..e592073b3999 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2274,6 +2274,8 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
     if( aName.isEmpty() )
         return eF_ResT::TAGIGN;  // makes no sense without Macro-Name
 
+    NotifyMacroEventRead();
+
     //try converting macro symbol according to macro name
     bool bApplyWingdings = ConvertMacroSymbol( aName, aVText );
     aName = "StarOffice.Standard.Modul1." + aName;
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index b7dc69dc92bf..2a4242cdef58 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -18,8 +18,10 @@
 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
 #include <fstream>

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list