Hi again, On Mon, Feb 12, 2018 at 02:03:20PM +0100, Rene Engelhard wrote: > On Mon, Feb 12, 2018 at 01:56:42PM +0100, Rene Engelhard wrote: > > > > Probably needs (<< 1:5.2.7-1+deb9u3~) instead. > > > > > > Good catch. Wasn't updated after the security updates. Will change that to > > > (<< 1:5.2.7-1+deb9u3) > > ^ ~ > > > > with the ~ for eventual jessie-backports of course. > > > https://salsa.debian.org/libreoffice-team/libreoffice/libreoffice/commit/3fb213221e46b804f8878d08a63b19e5c43d10f1
Upstream came up with another fix to allow WEBSERVICE() usage in cases where the original patch didn't allow it. I think we should add it... So here's the new debdiffs (compared to deb9u2, so with the noise in the diff, and a clean stable->deb9u3). Didn't yet testbuild but can do. Regards, Rene
diff -Nru libreoffice-5.2.7/debian/changelog libreoffice-5.2.7/debian/changelog --- libreoffice-5.2.7/debian/changelog 2018-02-09 07:22:22.000000000 +0100 +++ libreoffice-5.2.7/debian/changelog 2018-02-22 11:14:18.000000000 +0100 @@ -1,3 +1,19 @@ +libreoffice (1:5.2.7-1+deb9u3) stretch; urgency=medium + + * debian/patches/WEBSERVICE-DDE.diff: + - improve to not throw more errors than neccessary (use the right error + code) on WEBSERVICE() failures, thanks Jan-Marek Glogowski; do another + s/FormulaError::NoValue/formula::errNoValue/ for clarity + - backport 4a412bdf0387cc2cb59d656d0738a63a286ec497 from 5.4 branch + to let FunctionAccess execute WEBSERVICE + + * debian/rules: + - do not run the tests except on i386 (notfatal) and amd64 + - move dk.mk from -dev-common to -dev as it's not arch-indep, thanks + Rico Tzschichholz + + -- Rene Engelhard <r...@debian.org> Thu, 22 Feb 2018 11:14:18 +0100 + libreoffice (1:5.2.7-1+deb9u2) stretch-security; urgency=high * fix control diff -Nru libreoffice-5.2.7/debian/control libreoffice-5.2.7/debian/control --- libreoffice-5.2.7/debian/control 2018-02-09 07:21:38.000000000 +0100 +++ libreoffice-5.2.7/debian/control 2018-02-22 11:14:18.000000000 +0100 @@ -4376,9 +4376,9 @@ Suggests: libmythes-dev, libreoffice-dev-doc, libreofficekit-dev Replaces: libreoffice-common (<< 1:4.1.0~beta1), libreoffice-core (<< 1:4.1.0~beta1), - libreoffice-dev-common (<< 1:5.2.6-2) + libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Conflicts: libreoffice (<< 1:5.2.5-2~), libreoffice-dev-doc (<< 1:5.2.5-2~) -Breaks: libreoffice-dev-common (<< 1:5.2.6-2) +Breaks: libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Description: office productivity suite -- SDK -- architecture-dependent parts LibreOffice is a full-featured office productivity suite that provides a near drop-in replacement for Microsoft(R) Office. diff -Nru libreoffice-5.2.7/debian/control.sdk.in libreoffice-5.2.7/debian/control.sdk.in --- libreoffice-5.2.7/debian/control.sdk.in 2018-02-07 20:08:04.000000000 +0100 +++ libreoffice-5.2.7/debian/control.sdk.in 2018-02-12 19:04:03.000000000 +0100 @@ -9,9 +9,9 @@ ${shlibs:Depends} Recommends: g++, ${java-common-depends}, ${java-runtime-depends} Suggests: libmythes-dev, libreofficekit-dev, libreoffice-dev-doc -Replaces: libreoffice-core (<< 1:4.1.0~beta1), libreoffice-common (<< 1:4.1.0~beta1), libreoffice-dev-common (<< 1:5.2.6-2) +Replaces: libreoffice-core (<< 1:4.1.0~beta1), libreoffice-common (<< 1:4.1.0~beta1), libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Conflicts: libreoffice-dev-doc (<< 1:5.2.5-2~), libreoffice (<< 1:5.2.5-2~) -Breaks: libreoffice-dev-common (<< 1:5.2.6-2) +Breaks: libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Description: office productivity suite -- SDK -- architecture-dependent parts LibreOffice is a full-featured office productivity suite that provides a near drop-in replacement for Microsoft(R) Office. diff -Nru libreoffice-5.2.7/debian/libreoffice-dbg.postinst.debhelper libreoffice-5.2.7/debian/libreoffice-dbg.postinst.debhelper --- libreoffice-5.2.7/debian/libreoffice-dbg.postinst.debhelper 2017-06-01 19:10:02.000000000 +0200 +++ libreoffice-5.2.7/debian/libreoffice-dbg.postinst.debhelper 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -# Automatically added by dh_installdeb -dpkg-maintscript-helper dir_to_symlink /usr/share/doc/libreoffice-dbg /usr/share/doc/libreoffice-core 1:5.0.3~rc1-2 $DPKG_MAINTSCRIPT_PACKAGE -- "$@" -# End automatically added section diff -Nru libreoffice-5.2.7/debian/libreoffice-dbg.postrm.debhelper libreoffice-5.2.7/debian/libreoffice-dbg.postrm.debhelper --- libreoffice-5.2.7/debian/libreoffice-dbg.postrm.debhelper 2017-06-01 19:10:02.000000000 +0200 +++ libreoffice-5.2.7/debian/libreoffice-dbg.postrm.debhelper 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -# Automatically added by dh_installdeb -dpkg-maintscript-helper dir_to_symlink /usr/share/doc/libreoffice-dbg /usr/share/doc/libreoffice-core 1:5.0.3~rc1-2 $DPKG_MAINTSCRIPT_PACKAGE -- "$@" -# End automatically added section diff -Nru libreoffice-5.2.7/debian/libreoffice-dbg.preinst.debhelper libreoffice-5.2.7/debian/libreoffice-dbg.preinst.debhelper --- libreoffice-5.2.7/debian/libreoffice-dbg.preinst.debhelper 2017-06-01 19:10:02.000000000 +0200 +++ libreoffice-5.2.7/debian/libreoffice-dbg.preinst.debhelper 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -# Automatically added by dh_installdeb -dpkg-maintscript-helper dir_to_symlink /usr/share/doc/libreoffice-dbg /usr/share/doc/libreoffice-core 1:5.0.3~rc1-2 $DPKG_MAINTSCRIPT_PACKAGE -- "$@" -# End automatically added section diff -Nru libreoffice-5.2.7/debian/libreoffice-dbg.prerm.debhelper libreoffice-5.2.7/debian/libreoffice-dbg.prerm.debhelper --- libreoffice-5.2.7/debian/libreoffice-dbg.prerm.debhelper 2017-06-01 19:10:02.000000000 +0200 +++ libreoffice-5.2.7/debian/libreoffice-dbg.prerm.debhelper 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -# Automatically added by dh_installdeb -dpkg-maintscript-helper dir_to_symlink /usr/share/doc/libreoffice-dbg /usr/share/doc/libreoffice-core 1:5.0.3~rc1-2 $DPKG_MAINTSCRIPT_PACKAGE -- "$@" -# End automatically added section diff -Nru libreoffice-5.2.7/debian/libreoffice-dbg.substvars libreoffice-5.2.7/debian/libreoffice-dbg.substvars --- libreoffice-5.2.7/debian/libreoffice-dbg.substvars 2017-06-01 19:12:02.000000000 +0200 +++ libreoffice-5.2.7/debian/libreoffice-dbg.substvars 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -misc:Depends=libreoffice-core (= 1:5.2.7-1~bpo8+1) -misc:Pre-Depends=dpkg (>= 1.17.13) -java:Depends= -java:Recommends= diff -Nru libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff --- libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff 2018-02-08 18:57:40.000000000 +0100 +++ libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff 2018-02-22 11:14:18.000000000 +0100 @@ -40,7 +40,7 @@ + INetProtocol eProtocol = aObj.GetProtocol(); + if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) + { -+ PushError( FormulaError::NoValue ); ++ PushError( formula::errNoValue ); + return; + } + @@ -401,7 +401,7 @@ INetProtocol eProtocol = aObj.GetProtocol(); if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) { -- PushError( FormulaError::NoValue ); +- PushError( formula::errNoValue ); - return; - } - @@ -445,7 +445,7 @@ - sal_Int32 nRead = 0; - while ( ( nRead = xStream->readBytes( buffer, BUF_LEN ) ) == BUF_LEN ) -+ bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNoCode); ++ bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNONE); + + if (!pLink) { @@ -484,8 +484,8 @@ - xStream->closeInput(); + // If an new Error from Reschedule appears when the link is executed then reset the errorflag -+ if (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNoCode && !bWasError) -+ pMyFormulaCell->SetErrCode(formula::errNoCode); ++ if (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNONE && !bWasError) ++ pMyFormulaCell->SetErrCode(formula::errNONE); + + // check the value + if (pLink->HasResult()) @@ -1104,3 +1104,159 @@ -- 1.9.1 +diff --git a/include/formula/errorcodes.hxx b/include/formula/errorcodes.hxx +index 173c744..5a5a8fd 100644 +--- a/include/formula/errorcodes.hxx ++++ b/include/formula/errorcodes.hxx +@@ -24,6 +24,7 @@ + + namespace formula { + ++const sal_uInt16 errNONE = 0; + const sal_uInt16 errIllegalChar = 501; + const sal_uInt16 errIllegalArgument = 502; + const sal_uInt16 errIllegalFPOperation = 503; // #NUM! + +From 4a412bdf0387cc2cb59d656d0738a63a286ec497 Mon Sep 17 00:00:00 2001 +From: Eike Rathke <er...@redhat.com> +Date: Mon, 19 Feb 2018 23:43:51 +0100 +Subject: Resolves: tdf#115710 let css::sheet::FunctionAccess execute + WEBSERVICE +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +... independent of a LinkManager that is not present in the +interim FunctionAccess document. FunctionAccess is executed by +extensions, Add-Ons and macros that the user gave permission +already. + +Change-Id: I9349a59ee24089c3657de7786b49e5e81946f175 +(cherry picked from commit 121fda77b0cc16d54607a1f5f7b26c0f1050284f) +Reviewed-on: https://gerrit.libreoffice.org/50020 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +--- + sc/inc/document.hxx | 5 ++++- + sc/source/core/data/documen2.cxx | 7 +++++-- + sc/source/core/tool/interpr7.cxx | 28 +++++++++++++++++++++++++++- + sc/source/ui/unoobj/funcuno.cxx | 2 +- + 4 files changed, 37 insertions(+), 5 deletions(-) + +diff -urN sc-old/inc/document.hxx sc/inc/document.hxx +--- a/sc/inc/document.hxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/inc/document.hxx 2018-02-22 11:06:40.329105073 +0100 +@@ -233,7 +233,8 @@ + { + SCDOCMODE_DOCUMENT, + SCDOCMODE_CLIP, +- SCDOCMODE_UNDO ++ SCDOCMODE_UNDO, ++ SCDOCMODE_FUNCTIONACCESS + }; + + struct ScDocStat +@@ -420,6 +421,7 @@ + bool bCalculatingFormulaTree; + bool bIsClip; + bool bIsUndo; ++ bool bIsFunctionAccess; + bool bIsVisible; // set from view ctor + + bool bIsEmbedded; // display/adjust Embedded area? +@@ -1351,6 +1353,7 @@ + bool IsClipboard() const { return bIsClip; } + bool IsUndoEnabled() const { return mbUndoEnabled; } + SC_DLLPUBLIC void EnableUndo( bool bVal ); ++ bool IsFunctionAccess() const { return bIsFunctionAccess; } + + bool IsAdjustHeightEnabled() const { return mbAdjustHeightEnabled; } + void EnableAdjustHeight( bool bVal ) { mbAdjustHeightEnabled = bVal; } +diff -urN sc-old/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx +--- a/sc/source/core/data/documen2.cxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/source/core/data/documen2.cxx 2018-02-22 11:04:01.777343579 +0100 +@@ -180,12 +180,13 @@ + eHardRecalcState(HARDRECALCSTATE_OFF), + nVisibleTab( 0 ), + eLinkMode(LM_UNKNOWN), +- bAutoCalc( eMode == SCDOCMODE_DOCUMENT ), ++ bAutoCalc( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS ), + bAutoCalcShellDisabled( false ), + bForcedFormulaPending( false ), + bCalculatingFormulaTree( false ), + bIsClip( eMode == SCDOCMODE_CLIP ), + bIsUndo( eMode == SCDOCMODE_UNDO ), ++ bIsFunctionAccess( eMode == SCDOCMODE_FUNCTIONACCESS ), + bIsVisible( false ), + bIsEmbedded( false ), + bInsertingFromOtherDoc( false ), +@@ -222,7 +223,9 @@ + + eSrcSet = osl_getThreadTextEncoding(); + +- if ( eMode == SCDOCMODE_DOCUMENT ) ++ /* TODO: for SCDOCMODE_FUNCTIONACCESS it might not even be necessary to ++ * have all of these available. */ ++ if ( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS ) + { + xPoolHelper = new ScPoolHelper( this ); + +diff -urN sc-old/source/core/tool/interpr7.cxx sc/source/core/tool/interpr7.cxx +--- a/sc/source/core/tool/interpr7.cxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/source/core/tool/interpr7.cxx 2018-02-22 11:08:38.336920129 +0100 +@@ -250,6 +250,21 @@ + return nullptr; + } + ++static bool lcl_FunctionAccessLoadWebServiceLink( OUString& rResult, ScDocument* pDoc, const OUString& rURI ) ++{ ++ // For FunctionAccess service always force a changed data update. ++ ScWebServiceLink aLink( pDoc, rURI); ++ if (aLink.DataChanged( OUString(), css::uno::Any()) != sfx2::SvBaseLink::UpdateResult::SUCCESS) ++ return false; ++ ++ if (!aLink.HasResult()) ++ return false; ++ ++ rResult = aLink.GetResult(); ++ ++ return true; ++} ++ + void ScInterpreter::ScWebservice() + { + sal_uInt8 nParamCount = GetByte(); +@@ -273,7 +288,19 @@ + + if (!mpLinkManager) + { +- PushError( formula::errNoValue ); ++ if (!pDok->IsFunctionAccess() || pDok->HasLinkFormulaNeedingCheck()) ++ { ++ PushError( formula::errNoValue); ++ } ++ else ++ { ++ OUString aResult; ++ if (lcl_FunctionAccessLoadWebServiceLink( aResult, pDok, aURI)) ++ PushString( aResult); ++ else ++ PushError( formula::errNoValue); ++ } ++ + return; + } + +diff -urN sc-old/source/ui/unoobj/funcuno.cxx sc/source/ui/unoobj/funcuno.cxx +--- a/sc/source/ui/unoobj/funcuno.cxx 2018-02-22 11:01:38.905545605 +0100 ++++ b/sc/source/ui/unoobj/funcuno.cxx 2018-02-22 11:04:01.781343573 +0100 +@@ -74,7 +74,7 @@ + + ScDocument* ScTempDocSource::CreateDocument() + { +- ScDocument* pDoc = new ScDocument; // SCDOCMODE_DOCUMENT ++ ScDocument* pDoc = new ScDocument( SCDOCMODE_FUNCTIONACCESS ); + pDoc->MakeTable( 0 ); + return pDoc; + } diff -Nru libreoffice-5.2.7/debian/rules libreoffice-5.2.7/debian/rules --- libreoffice-5.2.7/debian/rules 2018-02-07 20:08:04.000000000 +0100 +++ libreoffice-5.2.7/debian/rules 2018-02-11 19:00:23.000000000 +0100 @@ -272,11 +272,12 @@ ifeq "$(ENABLE_JAVA)" "y" ifeq "$(JDK)" "default" ifeq "$(shell LANG=C /usr/lib/jvm/default-java/bin/java -version 2>&1 | tail -n 1 | awk '{ print $$1 }')" "OpenJDK" - RUN_MAKE_CHECK=y ifeq "$(DEB_HOST_ARCH)" "i386" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif ifeq "$(DEB_HOST_ARCH)" "amd64" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif RUN_PYTESTS=y @@ -285,9 +286,11 @@ ifeq "$(JDK)" "openjdk" RUN_MAKE_CHECK=y ifeq "$(DEB_HOST_ARCH)" "i386" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif ifeq "$(DEB_HOST_ARCH)" "amd64" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif RUN_PYTESTS=y @@ -576,6 +579,7 @@ IGNORE_MAKE_CHECK_FAILURES=- ifneq "$(JDK)" "gcj-jdk" +# disabled due to the Linux/Java Stack Clash fix regression... # ifeq (i386,$(DEB_HOST_ARCH)) #IGNORE_MAKE_CHECK_FAILURES:= # endif @@ -2329,6 +2333,10 @@ $(PKGDIR)-dev-common/$(OOSDKDIR) mv $(PKGDIR)-dev/$(OOSDKDIR)/set* \ $(PKGDIR)-dev-common/$(OOSDKDIR) + # settings/dk.mk is not arch-indep + mkdir -p $(PKGDIR)-dev/$(OOSDKDIR)/settings + mv $(PKGDIR)-dev-common/$(OOSDKDIR)/settings/dk.mk \ + $(PKGDIR)-dev/$(OOSDKDIR)/settings mv $(PKGDIR)-dev/$(OOSDKDIR)/config* \ $(PKGDIR)-dev-common/$(OOSDKDIR) mv $(PKGDIR)-dev/$(OOSDKDIR)/index.html* \ diff -Nru libreoffice-5.2.7/debian/uno-libs3-dbg.substvars libreoffice-5.2.7/debian/uno-libs3-dbg.substvars --- libreoffice-5.2.7/debian/uno-libs3-dbg.substvars 2017-06-01 19:12:09.000000000 +0200 +++ libreoffice-5.2.7/debian/uno-libs3-dbg.substvars 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -java:Depends= -java:Recommends= -misc:Depends= diff -Nru libreoffice-5.2.7/debian/ure-dbg.substvars libreoffice-5.2.7/debian/ure-dbg.substvars --- libreoffice-5.2.7/debian/ure-dbg.substvars 2017-06-01 19:12:09.000000000 +0200 +++ libreoffice-5.2.7/debian/ure-dbg.substvars 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -java:Depends= -java:Recommends= -misc:Depends=
diff -Nru libreoffice-5.2.7/debian/changelog libreoffice-5.2.7/debian/changelog --- libreoffice-5.2.7/debian/changelog 2017-05-04 20:18:44.000000000 +0200 +++ libreoffice-5.2.7/debian/changelog 2018-02-22 11:14:18.000000000 +0100 @@ -1,3 +1,39 @@ +libreoffice (1:5.2.7-1+deb9u3) stretch; urgency=medium + + * debian/patches/WEBSERVICE-DDE.diff: + - improve to not throw more errors than neccessary (use the right error + code) on WEBSERVICE() failures, thanks Jan-Marek Glogowski; do another + s/FormulaError::NoValue/formula::errNoValue/ for clarity + - backport 4a412bdf0387cc2cb59d656d0738a63a286ec497 from 5.4 branch + to let FunctionAccess execute WEBSERVICE + + * debian/rules: + - do not run the tests except on i386 (notfatal) and amd64 + - move dk.mk from -dev-common to -dev as it's not arch-indep, thanks + Rico Tzschichholz + + -- Rene Engelhard <r...@debian.org> Thu, 22 Feb 2018 11:14:18 +0100 + +libreoffice (1:5.2.7-1+deb9u2) stretch-security; urgency=high + + * fix control + + -- Rene Engelhard <r...@debian.org> Fri, 09 Feb 2018 07:22:22 +0100 + +libreoffice (1:5.2.7-1+deb9u1) stretch-security; urgency=high + + * debian/patches/WEBSERVICE-DDE.diff: backport fix for "Remote arbitrary + file disclosure vulnerability via WEBSERVICE formula" (CVE-2018-1055) from + 5.4 + * debian/patches/layout-footnote-use-after-free.diff: add; as name says. + possible patch for iDefense V-mct3ei5wml + + * debian/rules: + - make i386 make check notfatal for now given the i386 Java Stack Clash + regression + + -- Rene Engelhard <r...@debian.org> Thu, 08 Feb 2018 19:02:13 +0100 + libreoffice (1:5.2.7-1) unstable; urgency=medium * New upstream release diff -Nru libreoffice-5.2.7/debian/control libreoffice-5.2.7/debian/control --- libreoffice-5.2.7/debian/control 2017-04-30 11:28:19.000000000 +0200 +++ libreoffice-5.2.7/debian/control 2018-02-22 11:14:18.000000000 +0100 @@ -4376,9 +4376,9 @@ Suggests: libmythes-dev, libreoffice-dev-doc, libreofficekit-dev Replaces: libreoffice-common (<< 1:4.1.0~beta1), libreoffice-core (<< 1:4.1.0~beta1), - libreoffice-dev-common (<< 1:5.2.6-2) + libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Conflicts: libreoffice (<< 1:5.2.5-2~), libreoffice-dev-doc (<< 1:5.2.5-2~) -Breaks: libreoffice-dev-common (<< 1:5.2.6-2) +Breaks: libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Description: office productivity suite -- SDK -- architecture-dependent parts LibreOffice is a full-featured office productivity suite that provides a near drop-in replacement for Microsoft(R) Office. diff -Nru libreoffice-5.2.7/debian/control.sdk.in libreoffice-5.2.7/debian/control.sdk.in --- libreoffice-5.2.7/debian/control.sdk.in 2017-03-31 13:21:33.000000000 +0200 +++ libreoffice-5.2.7/debian/control.sdk.in 2018-02-12 19:04:03.000000000 +0100 @@ -9,9 +9,9 @@ ${shlibs:Depends} Recommends: g++, ${java-common-depends}, ${java-runtime-depends} Suggests: libmythes-dev, libreofficekit-dev, libreoffice-dev-doc -Replaces: libreoffice-core (<< 1:4.1.0~beta1), libreoffice-common (<< 1:4.1.0~beta1), libreoffice-dev-common (<< 1:5.2.6-2) +Replaces: libreoffice-core (<< 1:4.1.0~beta1), libreoffice-common (<< 1:4.1.0~beta1), libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Conflicts: libreoffice-dev-doc (<< 1:5.2.5-2~), libreoffice (<< 1:5.2.5-2~) -Breaks: libreoffice-dev-common (<< 1:5.2.6-2) +Breaks: libreoffice-dev-common (<< 1:5.2.7-1+deb9u3~) Description: office productivity suite -- SDK -- architecture-dependent parts LibreOffice is a full-featured office productivity suite that provides a near drop-in replacement for Microsoft(R) Office. diff -Nru libreoffice-5.2.7/debian/patches/layout-footnote-use-after-free.diff libreoffice-5.2.7/debian/patches/layout-footnote-use-after-free.diff --- libreoffice-5.2.7/debian/patches/layout-footnote-use-after-free.diff 1970-01-01 01:00:00.000000000 +0100 +++ libreoffice-5.2.7/debian/patches/layout-footnote-use-after-free.diff 2018-02-09 07:37:10.000000000 +0100 @@ -0,0 +1,100 @@ +From c7782c7c27d85866872cc24a618df02504ff12ca Mon Sep 17 00:00:00 2001 +From: Michael Stahl <mst...@redhat.com> +Date: Thu, 22 Jun 2017 10:39:36 +0200 +Subject: tdf#101821 sw: fix layout footnote use-after-free in SwRootFrame + +The ClearSwLayouterEntries() accesses anchored objects and if they are +anchored in footnotes then RemoveFootnotes() has already deleted them. + +(regression from 962d0500c4debaef43e5f146e47e08c66d851562) + +Invalid write of size 1 + at 0x4143CCB3: SwAnchoredObject::SetTmpConsiderWrapInfluence(bool) (anchoredobject.cxx:739) + by 0x414D8A21: SwObjsMarkedAsTmpConsiderWrapInfluence::Clear() (objstmpconsiderwrapinfl.cxx:58) + by 0x414C943E: SwLayouter::ClearObjsTmpConsiderWrapInfluence(SwDoc const&) (layouter.cxx:401) + by 0x411DBE57: sw::DocumentLayoutManager::ClearSwLayouterEntries() (DocumentLayoutManager.cxx:504) + by 0x414D05D9: SwRootFrame::DestroyImpl() (newfrm.cxx:594) + by 0x41535AB3: SwFrame::DestroyFrame(SwFrame*) (ssfrm.cxx:389) + by 0x419E8171: std::_Sp_counted_deleter<SwRootFrame*, void (*)(SwFrame*), std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:464) + by 0x40EB6DB5: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:150) + by 0x40EB5E76: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:662) + by 0x419E65F9: std::__shared_ptr<SwRootFrame, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:928) + by 0x419E6615: std::shared_ptr<SwRootFrame>::~shared_ptr() (shared_ptr.h:93) + by 0x419E619D: SwViewShell::~SwViewShell() (vnew.cxx:285) + Address 0x5feb6eee is 334 bytes inside a block of size 488 free'd + at 0x4C2F21A: operator delete(void*) (vg_replace_malloc.c:576) + by 0x41488962: SwFlyAtContentFrame::~SwFlyAtContentFrame() (flyfrms.hxx:134) + by 0x41535AFC: SwFrame::DestroyFrame(SwFrame*) (ssfrm.cxx:391) + by 0x415360BD: SwLayoutFrame::DestroyImpl() (ssfrm.cxx:477) + by 0x41535AB3: SwFrame::DestroyFrame(SwFrame*) (ssfrm.cxx:389) + by 0x414A2FF4: sw_RemoveFootnotes(SwFootnoteBossFrame*, bool, bool) (ftnfrm.cxx:852) + by 0x414A3104: sw_RemoveFootnotes(SwFootnoteBossFrame*, bool, bool) (ftnfrm.cxx:874) + by 0x414A321A: SwRootFrame::RemoveFootnotes(SwPageFrame*, bool, bool) (ftnfrm.cxx:897) + by 0x414D0558: SwRootFrame::DestroyImpl() (newfrm.cxx:585) + by 0x41535AB3: SwFrame::DestroyFrame(SwFrame*) (ssfrm.cxx:389) + by 0x419E8171: std::_Sp_counted_deleter<SwRootFrame*, void (*)(SwFrame*), std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:464) + by 0x40EB6DB5: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:150) + by 0x40EB5E76: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:662) + by 0x419E65F9: std::__shared_ptr<SwRootFrame, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:928) + by 0x419E6615: std::shared_ptr<SwRootFrame>::~shared_ptr() (shared_ptr.h:93) + by 0x419E619D: SwViewShell::~SwViewShell() (vnew.cxx:285) + +Change-Id: I147f46d49c90de46189ad34feed66c289adddc15 +--- + sw/source/core/layout/newfrm.cxx | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx +index b5785c4..4de02e3 100644 +--- a/sw/source/core/layout/newfrm.cxx ++++ b/sw/source/core/layout/newfrm.cxx +@@ -573,16 +573,6 @@ void SwRootFrame::DestroyImpl() + { + mbTurboAllowed = false; + mpTurbo = nullptr; +- // fdo#39510 crash on document close with footnotes +- // Object ownership in writer and esp. in layout are a mess: Before the +- // document/layout split SwDoc and SwRootFrame were essentially one object +- // and magically/uncleanly worked around their common destruction by call +- // to SwDoc::IsInDtor() -- even from the layout. As of now destruction of +- // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrames +- // also searches backwards to find the master of footnotes, they must be +- // considered to be owned by the SwRootFrame and also be destroyed here, +- // before tearing down the (now footnote free) rest of the layout. +- RemoveFootnotes(nullptr, false, true); + + if(pBlink) + pBlink->FrameDelete( this ); +@@ -591,8 +581,11 @@ void SwRootFrame::DestroyImpl() + { + SwDoc *pDoc = pRegisteredInNonConst->GetDoc(); + pDoc->DelFrameFormat( pRegisteredInNonConst ); ++ // do this before calling RemoveFootnotes() because footnotes ++ // can contain anchored objects + pDoc->GetDocumentLayoutManager().ClearSwLayouterEntries(); + } ++ + delete mpDestroy; + mpDestroy = nullptr; + +@@ -606,6 +599,17 @@ void SwRootFrame::DestroyImpl() + // Some accessible shells are left => problems on second SwFrame::Destroy call + assert(0 == mnAccessibleShells); + ++ // fdo#39510 crash on document close with footnotes ++ // Object ownership in writer and esp. in layout are a mess: Before the ++ // document/layout split SwDoc and SwRootFrame were essentially one object ++ // and magically/uncleanly worked around their common destruction by call ++ // to SwDoc::IsInDtor() -- even from the layout. As of now destruction of ++ // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrames ++ // also searches backwards to find the master of footnotes, they must be ++ // considered to be owned by the SwRootFrame and also be destroyed here, ++ // before tearing down the (now footnote free) rest of the layout. ++ RemoveFootnotes(nullptr, false, true); ++ + SwLayoutFrame::DestroyImpl(); + } + +-- +cgit v1.1 + diff -Nru libreoffice-5.2.7/debian/patches/series libreoffice-5.2.7/debian/patches/series --- libreoffice-5.2.7/debian/patches/series 2017-03-31 13:21:33.000000000 +0200 +++ libreoffice-5.2.7/debian/patches/series 2018-02-09 07:37:10.000000000 +0100 @@ -35,3 +35,5 @@ no-openssl.diff m68k-java-arch.diff gtk3-opengl-slideshow.diff +WEBSERVICE-DDE.diff +layout-footnote-use-after-free.diff diff -Nru libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff --- libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff 1970-01-01 01:00:00.000000000 +0100 +++ libreoffice-5.2.7/debian/patches/WEBSERVICE-DDE.diff 2018-02-22 11:14:18.000000000 +0100 @@ -0,0 +1,1262 @@ +From d778cd0ce51aa9605dd4baaec711925c2a2bf418 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caol...@redhat.com> +Date: Wed, 10 Jan 2018 14:27:35 +0000 +Subject: [PATCH 1/6] limit WEBSERVICE to http[s] protocols +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +and like excel... + +'For protocols that aren’t supported, such as ftp:// or file://, WEBSERVICE +returns the #VALUE! error value.' + +Change-Id: I0e9c6fd3426fad56a199eafac48de9b0f23914b3 +Reviewed-on: https://gerrit.libreoffice.org/47776 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> +(cherry picked from commit a916fc0c0e0e8b10cb4158fa0fa173fe205d434a) +--- + sc/source/core/tool/interpr7.cxx | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx +index 2d48c6b..0d55e87 100644 +--- a/sc/source/core/tool/interpr7.cxx ++++ b/sc/source/core/tool/interpr7.cxx +@@ -14,6 +14,7 @@ + #include <rtl/strbuf.hxx> + #include <formula/errorcodes.hxx> + #include <svtools/miscopt.hxx> ++#include <tools/urlobj.hxx> + + #include <com/sun/star/ucb/XSimpleFileAccess3.hpp> + #include <com/sun/star/ucb/SimpleFileAccess.hpp> +@@ -241,6 +242,14 @@ void ScInterpreter::ScWebservice() + return; + } + ++ INetURLObject aObj(aURI, INetProtocol::File); ++ INetProtocol eProtocol = aObj.GetProtocol(); ++ if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) ++ { ++ PushError( formula::errNoValue ); ++ return; ++ } ++ + uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY ); + if(!xFileAccess.is()) + { +-- +1.9.1 + +From 293e442c945785ab11d4a6abf04039995af74709 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caol...@redhat.com> +Date: Thu, 11 Jan 2018 14:16:15 +0000 +Subject: [PATCH 2/6] Better handle ScDde formulas with missing dde-link + entries +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +typically each ScDde formula has a matching table:dde-link which +results in a ScDdeLink getting inserted during the load. If that dde-link +is missing then no ScDdeLink exists and ScDde() will create a new one without +cached content. So detect that ScDde is used in the freshing loaded ods +and defer fetching new content until the right time. + +only call GetHasMacroFunc to set SetHasMacroFunc + +and bHasMacroFunc is not accessed any other way, so this is an oxbow + +Reviewed-on: https://gerrit.libreoffice.org/47757 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +(cherry picked from commit b0597ba5d745974fce752e1b677451a19350d351) +Reviewed-on: https://gerrit.libreoffice.org/47818 +Reviewed-by: Eike Rathke <er...@redhat.com> +(cherry picked from commit 4ede45eb239b1604bca900c22481b7d13e4c2790) + +Conflicts: + sc/qa/unit/ucalc.cxx + sc/source/core/data/documen2.cxx + +Change-Id: I016b53288076d83dd49e92e245346a5f7f560522 +--- + sc/inc/document.hxx | 6 +++--- + sc/source/core/data/documen2.cxx | 2 +- + sc/source/core/data/formulacell.cxx | 8 ++++---- + sc/source/core/tool/interpr2.cxx | 8 +++++++- + sc/source/ui/docshell/docsh4.cxx | 2 ++ + sc/source/ui/view/tabvwsh4.cxx | 2 +- + 6 files changed, 18 insertions(+), 10 deletions(-) + +diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx +index e2fc885..252a7d1 100644 +--- a/sc/inc/document.hxx ++++ b/sc/inc/document.hxx +@@ -447,7 +447,7 @@ private: + // for detective update, is set for each change of a formula + bool bDetectiveDirty; + +- bool bHasMacroFunc; // valid only after loading ++ bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde + + sal_uInt8 nAsianCompression; + sal_uInt8 nAsianKerning; +@@ -1910,8 +1910,8 @@ public: + bool IsDetectiveDirty() const { return bDetectiveDirty; } + void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; } + +- bool GetHasMacroFunc() const { return bHasMacroFunc; } +- void SetHasMacroFunc(bool bSet) { bHasMacroFunc = bSet; } ++ bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; } ++ void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; } + + static bool CheckMacroWarn(); + +diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx +index bd8d567..ce8f3cc 100644 +--- a/sc/source/core/data/documen2.cxx ++++ b/sc/source/core/data/documen2.cxx +@@ -200,7 +200,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : + bInDtorClear( false ), + bExpandRefs( false ), + bDetectiveDirty( false ), +- bHasMacroFunc( false ), ++ bLinkFormulaNeedingCheck( false ), + nAsianCompression(SC_ASIANCOMPRESSION_INVALID), + nAsianKerning(SC_ASIANKERNING_INVALID), + bPastingDrawFromOtherDoc( false ), +diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx +index a9cfdec..a8d6f5e 100644 +--- a/sc/source/core/data/formulacell.cxx ++++ b/sc/source/core/data/formulacell.cxx +@@ -1363,10 +1363,10 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr + bChanged = true; + } + +- // Same as in Load: after loading, it must be known if ocMacro is in any formula +- // (for macro warning, CompileXML is called at the end of loading XML file) +- if ( !pDocument->GetHasMacroFunc() && pCode->HasOpCodeRPN( ocMacro ) ) +- pDocument->SetHasMacroFunc( true ); ++ // After loading, it must be known if ocDde is in any formula ++ // (for external links warning, CompileXML is called at the end of loading XML file) ++ if (!pDocument->HasLinkFormulaNeedingCheck() && pCode->HasOpCodeRPN(ocDde)) ++ pDocument->SetLinkFormulaNeedingCheck(true); + + //volatile cells must be added here for import + if( pCode->IsRecalcModeAlways() || pCode->IsRecalcModeForced() || +diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx +index 38523e5..6dc8660 100644 +--- a/sc/source/core/tool/interpr2.cxx ++++ b/sc/source/core/tool/interpr2.cxx +@@ -2520,8 +2520,14 @@ void ScInterpreter::ScDde() + pBindings->Invalidate( SID_LINKS ); // Link-Manager enablen + } + ++ //if the document was just loaded, but the ScDdeLink entry was missing, then ++ //don't update this link until the links are updated in response to the users ++ //decision ++ if (!pDok->HasLinkFormulaNeedingCheck()) ++ { + //TODO: evaluate asynchron ??? +- pLink->TryUpdate(); // TryUpdate doesn't call Update multiple times ++ pLink->TryUpdate(); // TryUpdate doesn't call Update multiple times ++ } + + if (pMyFormulaCell) + { +diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx +index 853692c..42344e0 100644 +--- a/sc/source/ui/docshell/docsh4.cxx ++++ b/sc/source/ui/docshell/docsh4.cxx +@@ -470,6 +470,8 @@ void ScDocShell::Execute( SfxRequest& rReq ) + rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); + rReq.Ignore(); + } ++ ++ rDoc.SetLinkFormulaNeedingCheck(false); + } + break; + +diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx +index a8f3197..6c5d5da 100644 +--- a/sc/source/ui/view/tabvwsh4.cxx ++++ b/sc/source/ui/view/tabvwsh4.cxx +@@ -1564,7 +1564,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode ) + if (!bLink) + { + const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager(); +- if (rMgr.hasDdeOrOleLinks() || rDoc.HasAreaLinks()) ++ if (rMgr.hasDdeOrOleLinks() || rDoc.HasAreaLinks() || rDoc.HasLinkFormulaNeedingCheck()) + bLink = true; + } + if (bLink) +-- +1.9.1 + +From e8c8627a61b429c2c4b1d37d27809695c2a275ca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caol...@redhat.com> +Date: Thu, 11 Jan 2018 20:43:28 +0000 +Subject: [PATCH 3/6] handle ocWebservice similarly to ocDde + +might have too much in here seeing as we don't need to worry about +ocWebservice calling into itself + +Reviewed-on: https://gerrit.libreoffice.org/47819 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Eike Rathke <er...@redhat.com> +(cherry picked from commit e1946d75a1095c2596d7815600454ff01fcd3270) + +Conflicts: + sc/source/core/tool/interpr7.cxx + sc/source/ui/docshell/documentlinkmgr.cxx + +Change-Id: I0145f38cc1c1f9ff514a496f7101d81cde9e7c67 +--- + sc/Library_sc.mk | 1 + + sc/inc/document.hxx | 2 +- + sc/inc/documentlinkmgr.hxx | 6 +- + sc/source/core/data/formulacell.cxx | 4 +- + sc/source/core/inc/webservicelink.hxx | 49 ++++++++++++++ + sc/source/core/tool/interpr7.cxx | 101 +++++++++++++++++++--------- + sc/source/core/tool/webservicelink.cxx | 106 ++++++++++++++++++++++++++++++ + sc/source/ui/docshell/docsh4.cxx | 2 +- + sc/source/ui/docshell/documentlinkmgr.cxx | 20 ++++-- + sc/source/ui/view/tabvwsh4.cxx | 2 +- + 10 files changed, 250 insertions(+), 43 deletions(-) + create mode 100644 sc/source/core/inc/webservicelink.hxx + create mode 100644 sc/source/core/tool/webservicelink.cxx + +diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk +index 0ef50c3..22f3160 100644 +--- a/sc/Library_sc.mk ++++ b/sc/Library_sc.mk +@@ -285,6 +285,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ + sc/source/core/tool/unitconv \ + sc/source/core/tool/userlist \ + sc/source/core/tool/viewopti \ ++ sc/source/core/tool/webservicelink \ + sc/source/core/tool/zforauto \ + sc/source/filter/xml/datastreamimport \ + sc/source/filter/xml/XMLCalculationSettingsContext \ +diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx +index 252a7d1..828f9833 100644 +--- a/sc/inc/document.hxx ++++ b/sc/inc/document.hxx +@@ -447,7 +447,7 @@ private: + // for detective update, is set for each change of a formula + bool bDetectiveDirty; + +- bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde ++ bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice + + sal_uInt8 nAsianCompression; + sal_uInt8 nAsianKerning; +diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx +index d5d801a..86dba66 100644 +--- a/sc/inc/documentlinkmgr.hxx ++++ b/sc/inc/documentlinkmgr.hxx +@@ -55,9 +55,9 @@ public: + bool idleCheckLinks(); + + bool hasDdeLinks() const; +- bool hasDdeOrOleLinks() const; ++ bool hasDdeOrOleOrWebServiceLinks() const; + +- bool updateDdeOrOleLinks(vcl::Window* pWin); ++ bool updateDdeOrOleOrWebServiceLinks(vcl::Window* pWin); + + void updateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem ); + +@@ -65,7 +65,7 @@ public: + + void disconnectDdeLinks(); + private: +- bool hasDdeOrOleLinks(bool bDde, bool bOle) const; ++ bool hasDdeOrOleOrWebServiceLinks(bool bDde, bool bOle, bool bWebService) const; + }; + + } +diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx +index a8d6f5e..7af4fb5 100644 +--- a/sc/source/core/data/formulacell.cxx ++++ b/sc/source/core/data/formulacell.cxx +@@ -1363,9 +1363,9 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr + bChanged = true; + } + +- // After loading, it must be known if ocDde is in any formula ++ // After loading, it must be known if ocDde/ocWebservice is in any formula + // (for external links warning, CompileXML is called at the end of loading XML file) +- if (!pDocument->HasLinkFormulaNeedingCheck() && pCode->HasOpCodeRPN(ocDde)) ++ if (!pDocument->HasLinkFormulaNeedingCheck() && (pCode->HasOpCodeRPN(ocDde) || pCode->HasOpCodeRPN(ocWebservice))) + pDocument->SetLinkFormulaNeedingCheck(true); + + //volatile cells must be added here for import +diff --git a/sc/source/core/inc/webservicelink.hxx b/sc/source/core/inc/webservicelink.hxx +new file mode 100644 +index 0000000..e61ebfd +--- /dev/null ++++ b/sc/source/core/inc/webservicelink.hxx +@@ -0,0 +1,49 @@ ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ ++/* ++ * This file is part of the LibreOffice project. ++ * ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. ++ */ ++ ++#ifndef INCLUDED_SC_SOURCE_CORE_INC_WEBSERVICE_HXX ++#define INCLUDED_SC_SOURCE_CORE_INC_WEBSERVICE_HXX ++ ++#include <address.hxx> ++#include <sfx2/lnkbase.hxx> ++#include <svl/broadcast.hxx> ++#include <types.hxx> ++ ++class ScDocument; ++ ++class ScWebServiceLink : public ::sfx2::SvBaseLink, public SvtBroadcaster ++{ ++private: ++ ScDocument* pDoc; ++ OUString aURL; // connection/ link data ++ bool bHasResult; // is set aResult is useful ++ OUString aResult; ++ ++public: ++ ScWebServiceLink(ScDocument* pD, const OUString& rURL); ++ virtual ~ScWebServiceLink() override; ++ ++ // SvBaseLink override: ++ virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(const OUString& rMimeType, ++ const css::uno::Any& rValue) override; ++ ++ // SvtBroadcaster override: ++ virtual void ListenersGone() override; ++ ++ // for interpreter: ++ ++ const OUString& GetResult() const { return aResult; } ++ bool HasResult() const { return bHasResult; } ++ ++ const OUString& GetURL() const { return aURL; } ++}; ++ ++#endif ++ ++/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ +diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx +index 0d55e87..b475b1c 100644 +--- a/sc/source/core/tool/interpr7.cxx ++++ b/sc/source/core/tool/interpr7.cxx +@@ -13,6 +13,7 @@ + #include "scmatrix.hxx" + #include <rtl/strbuf.hxx> + #include <formula/errorcodes.hxx> ++#include <sfx2/bindings.hxx> + #include <svtools/miscopt.hxx> + #include <tools/urlobj.hxx> + +@@ -24,6 +25,10 @@ + #include <datastreamgettime.hxx> + #include <dpobject.hxx> + #include <document.hxx> ++#include <tokenarray.hxx> ++#include <webservicelink.hxx> ++ ++#include <sc.hrc> + + #include <cstring> + #include <memory> +@@ -229,6 +234,22 @@ void ScInterpreter::ScFilterXML() + } + } + ++static ScWebServiceLink* lcl_GetWebServiceLink(const sfx2::LinkManager* pLinkMgr, const OUString& rURL) ++{ ++ size_t nCount = pLinkMgr->GetLinks().size(); ++ for (size_t i=0; i<nCount; ++i) ++ { ++ ::sfx2::SvBaseLink* pBase = pLinkMgr->GetLinks()[i].get(); ++ if (ScWebServiceLink* pLink = dynamic_cast<ScWebServiceLink*>(pBase)) ++ { ++ if (pLink->GetURL() == rURL) ++ return pLink; ++ } ++ } ++ ++ return nullptr; ++} ++ + void ScInterpreter::ScWebservice() + { + sal_uInt8 nParamCount = GetByte(); +@@ -246,52 +267,72 @@ void ScInterpreter::ScWebservice() + INetProtocol eProtocol = aObj.GetProtocol(); + if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) + { +- PushError( formula::errNoValue ); +- return; +- } +- +- uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY ); +- if(!xFileAccess.is()) +- { + PushError( formula::errNoValue ); + return; + } + +- uno::Reference< io::XInputStream > xStream; +- try { +- xStream = xFileAccess->openFileRead( aURI ); +- } +- catch (...) +- { +- // don't let any exceptions pass +- PushError( formula::errNoValue ); +- return; +- } +- if ( !xStream.is() ) ++ if (!mpLinkManager) + { + PushError( formula::errNoValue ); + return; + } + +- const sal_Int32 BUF_LEN = 8000; +- uno::Sequence< sal_Int8 > buffer( BUF_LEN ); +- OStringBuffer aBuffer( 64000 ); ++ // Need to reinterpret after loading (build links) ++ if (rArr.IsRecalcModeNormal()) ++ rArr.SetExclusiveRecalcModeOnLoad(); ++ ++ // while the link is not evaluated, idle must be disabled (to avoid circular references) ++ bool bOldEnabled = pDok->IsIdleEnabled(); ++ pDok->EnableIdle(false); ++ ++ // Get/ Create link object ++ ScWebServiceLink* pLink = lcl_GetWebServiceLink(mpLinkManager, aURI); + +- sal_Int32 nRead = 0; +- while ( ( nRead = xStream->readBytes( buffer, BUF_LEN ) ) == BUF_LEN ) ++ bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNONE); ++ ++ if (!pLink) + { +- aBuffer.append( reinterpret_cast< const char* >( buffer.getConstArray() ), nRead ); +- } ++ pLink = new ScWebServiceLink(pDok, aURI); ++ mpLinkManager->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, aURI); ++ if ( mpLinkManager->GetLinks().size() == 1 ) // the first one? ++ { ++ SfxBindings* pBindings = pDok->GetViewBindings(); ++ if (pBindings) ++ pBindings->Invalidate( SID_LINKS ); // Link-Manager enabled ++ } + +- if ( nRead > 0 ) ++ //if the document was just loaded, but the ScDdeLink entry was missing, then ++ //don't update this link until the links are updated in response to the users ++ //decision ++ if (!pDok->HasLinkFormulaNeedingCheck()) ++ { ++ pLink->Update(); ++ } ++ ++ if (pMyFormulaCell) ++ { ++ // StartListening after the Update to avoid circular references ++ pMyFormulaCell->StartListening(*pLink); ++ } ++ } ++ else + { +- aBuffer.append( reinterpret_cast< const char* >( buffer.getConstArray() ), nRead ); ++ if (pMyFormulaCell) ++ pMyFormulaCell->StartListening(*pLink); + } + +- xStream->closeInput(); ++ // If an new Error from Reschedule appears when the link is executed then reset the errorflag ++ if (pMyFormulaCell && pMyFormulaCell->GetRawError() != formula::errNONE && !bWasError) ++ pMyFormulaCell->SetErrCode(formula::errNONE); ++ ++ // check the value ++ if (pLink->HasResult()) ++ PushString(pLink->GetResult()); ++ else ++ PushError(formula::errNoValue); + +- OUString aContent = OStringToOUString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); +- PushString( aContent ); ++ pDok->EnableIdle(bOldEnabled); ++ mpLinkManager->CloseCachedComps(); + } + } + +diff --git a/sc/source/core/tool/webservicelink.cxx b/sc/source/core/tool/webservicelink.cxx +new file mode 100644 +index 0000000..82310f2 +--- /dev/null ++++ b/sc/source/core/tool/webservicelink.cxx +@@ -0,0 +1,106 @@ ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ ++/* ++ * This file is part of the LibreOffice project. ++ * ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. ++ */ ++ ++#include <comphelper/fileformat.h> ++#include <comphelper/string.hxx> ++#include <osl/thread.h> ++#include <sfx2/linkmgr.hxx> ++#include <sfx2/bindings.hxx> ++ ++#include <com/sun/star/ucb/XSimpleFileAccess3.hpp> ++#include <com/sun/star/ucb/SimpleFileAccess.hpp> ++#include <com/sun/star/io/XInputStream.hpp> ++ ++#include <webservicelink.hxx> ++#include <brdcst.hxx> ++#include <document.hxx> ++#include <scmatrix.hxx> ++#include <patattr.hxx> ++#include <rechead.hxx> ++#include <rangeseq.hxx> ++#include <sc.hrc> ++#include <hints.hxx> ++ ++ScWebServiceLink::ScWebServiceLink(ScDocument* pD, const OUString& rURL) ++ : ::sfx2::SvBaseLink(SfxLinkUpdateMode::ALWAYS, SotClipboardFormatId::STRING) ++ , pDoc(pD) ++ , aURL(rURL) ++ , bHasResult(false) ++{ ++} ++ ++ScWebServiceLink::~ScWebServiceLink() {} ++ ++sfx2::SvBaseLink::UpdateResult ScWebServiceLink::DataChanged(const OUString&, const css::uno::Any&) ++{ ++ aResult.clear(); ++ bHasResult = false; ++ ++ css::uno::Reference<css::ucb::XSimpleFileAccess3> xFileAccess( ++ css::ucb::SimpleFileAccess::create(comphelper::getProcessComponentContext()), ++ css::uno::UNO_QUERY); ++ if (!xFileAccess.is()) ++ return ERROR_GENERAL; ++ ++ css::uno::Reference<css::io::XInputStream> xStream; ++ try ++ { ++ xStream = xFileAccess->openFileRead(aURL); ++ } ++ catch (...) ++ { ++ // don't let any exceptions pass ++ return ERROR_GENERAL; ++ } ++ if (!xStream.is()) ++ return ERROR_GENERAL; ++ ++ const sal_Int32 BUF_LEN = 8000; ++ css::uno::Sequence<sal_Int8> buffer(BUF_LEN); ++ OStringBuffer aBuffer(64000); ++ ++ sal_Int32 nRead = 0; ++ while ((nRead = xStream->readBytes(buffer, BUF_LEN)) == BUF_LEN) ++ aBuffer.append(reinterpret_cast<const char*>(buffer.getConstArray()), nRead); ++ ++ if (nRead > 0) ++ aBuffer.append(reinterpret_cast<const char*>(buffer.getConstArray()), nRead); ++ ++ xStream->closeInput(); ++ ++ aResult = OStringToOUString(aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8); ++ bHasResult = true; ++ ++ // Something happened... ++ if (HasListeners()) ++ { ++ Broadcast(ScHint(SC_HINT_DATACHANGED, ScAddress())); ++ pDoc->TrackFormulas(); // must happen immediately ++ pDoc->StartTrackTimer(); ++ } ++ ++ return SUCCESS; ++} ++ ++void ScWebServiceLink::ListenersGone() ++{ ++ ScDocument* pStackDoc = pDoc; // member pDoc can't be used after removing the link ++ ++ sfx2::LinkManager* pLinkMgr = pDoc->GetLinkManager(); ++ pLinkMgr->Remove(this); // deletes this ++ ++ if (pLinkMgr->GetLinks().empty()) // deleted the last one ? ++ { ++ SfxBindings* pBindings = pStackDoc->GetViewBindings(); // don't use member pDoc! ++ if (pBindings) ++ pBindings->Invalidate(SID_LINKS); ++ } ++} ++ ++/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ +diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx +index 42344e0..0e7671b 100644 +--- a/sc/source/ui/docshell/docsh4.cxx ++++ b/sc/source/ui/docshell/docsh4.cxx +@@ -448,7 +448,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) + ReloadTabLinks(); + aDocument.UpdateExternalRefLinks(GetActiveDialogParent()); + +- bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleLinks(GetActiveDialogParent()); ++ bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleOrWebServiceLinks(GetActiveDialogParent()); + + if (bAnyDde) + { +diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx +index 520b854..b8a9df6 100644 +--- a/sc/source/ui/docshell/documentlinkmgr.cxx ++++ b/sc/source/ui/docshell/documentlinkmgr.cxx +@@ -20,6 +20,7 @@ + #include <documentlinkmgr.hxx> + #include <datastream.hxx> + #include <ddelink.hxx> ++#include <webservicelink.hxx> + #include <sc.hrc> + #include <scresid.hxx> + +@@ -115,15 +116,15 @@ bool DocumentLinkManager::idleCheckLinks() + + bool DocumentLinkManager::hasDdeLinks() const + { +- return hasDdeOrOleLinks(true, false); ++ return hasDdeOrOleOrWebServiceLinks(true, false, false); + } + +-bool DocumentLinkManager::hasDdeOrOleLinks() const ++bool DocumentLinkManager::hasDdeOrOleOrWebServiceLinks() const + { +- return hasDdeOrOleLinks(true, true); ++ return hasDdeOrOleOrWebServiceLinks(true, true, true); + } + +-bool DocumentLinkManager::hasDdeOrOleLinks(bool bDde, bool bOle) const ++bool DocumentLinkManager::hasDdeOrOleOrWebServiceLinks(bool bDde, bool bOle, bool bWebService) const + { + if (!mpImpl->mpLinkManager) + return false; +@@ -136,12 +137,14 @@ bool DocumentLinkManager::hasDdeOrOleLinks(bool bDde, bool bOle) const + return true; + if (bOle && dynamic_cast<SdrEmbedObjectLink*>(pBase)) + return true; ++ if (bWebService && dynamic_cast<ScWebServiceLink*>(pBase)) ++ return true; + } + + return false; + } + +-bool DocumentLinkManager::updateDdeOrOleLinks( vcl::Window* pWin ) ++bool DocumentLinkManager::updateDdeOrOleOrWebServiceLinks(vcl::Window* pWin) + { + if (!mpImpl->mpLinkManager) + return false; +@@ -163,6 +166,13 @@ bool DocumentLinkManager::updateDdeOrOleLinks( vcl::Window* pWin ) + continue; + } + ++ ScWebServiceLink* pWebserviceLink = dynamic_cast<ScWebServiceLink*>(pBase); ++ if (pWebserviceLink) ++ { ++ pWebserviceLink->Update(); ++ continue; ++ } ++ + ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase); + if (!pDdeLink) + continue; +diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx +index 6c5d5da..f203b13 100644 +--- a/sc/source/ui/view/tabvwsh4.cxx ++++ b/sc/source/ui/view/tabvwsh4.cxx +@@ -1564,7 +1564,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode ) + if (!bLink) + { + const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager(); +- if (rMgr.hasDdeOrOleLinks() || rDoc.HasAreaLinks() || rDoc.HasLinkFormulaNeedingCheck()) ++ if (rDoc.HasLinkFormulaNeedingCheck() || rDoc.HasAreaLinks() || rMgr.hasDdeOrOleOrWebServiceLinks()) + bLink = true; + } + if (bLink) +-- +1.9.1 + +From 66124bccff0a296d759bf51217f503281602717e Mon Sep 17 00:00:00 2001 +From: Eike Rathke <er...@redhat.com> +Date: Wed, 17 Jan 2018 22:22:55 +0100 +Subject: [PATCH 4/6] CheckLinkFormulaNeedingCheck() for .xls and .xlsx formula + cells +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + This is a combination of 3 commits. + +Move implementation to CheckLinkFormulaNeedingCheck() for further reuse + +(cherry picked from commit 55e484c7bcd3ef218e08d3fd93f97bf98fd8cb7f) + +CheckLinkFormulaNeedingCheck() for .xlsx cell formulas + +(cherry picked from commit f96dbc3dd9c33202f75e29ef49d962386595995d) + +CheckLinkFormulaNeedingCheck() for .xls cell formulas + +(cherry picked from commit 6bc48275558c3f76c4da25eb8af3c48583ac5599) + +a6dd195f7eb4d43483e87eeca59f651e7bf2dcb8 +2587fbc4fec39b6f2c8e733331815a2953dee308 + +Change-Id: I541d2b6e12a88371c064b901b00e71206ee0c18e +Reviewed-on: https://gerrit.libreoffice.org/48143 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +(cherry picked from commit 2bef4debcf7650f3b3922134dff0332d4a95da3f) +--- + sc/inc/document.hxx | 2 ++ + sc/source/core/data/documen8.cxx | 10 ++++++++++ + sc/source/core/data/formulacell.cxx | 3 +-- + sc/source/filter/excel/excform.cxx | 1 + + sc/source/filter/excel/excform8.cxx | 1 + + sc/source/filter/excel/impop.cxx | 1 + + sc/source/filter/oox/formulabuffer.cxx | 4 ++++ + 7 files changed, 20 insertions(+), 2 deletions(-) + +diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx +index 828f9833..c2f6fe8 100644 +--- a/sc/inc/document.hxx ++++ b/sc/inc/document.hxx +@@ -1912,6 +1912,8 @@ public: + + bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; } + void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; } ++ /** Check token array and set link check if ocDde/ocWebservice is contained. */ ++ SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode ); + + static bool CheckMacroWarn(); + +diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx +index a84c2d0..185a2aa 100644 +--- a/sc/source/core/data/documen8.cxx ++++ b/sc/source/core/data/documen8.cxx +@@ -88,6 +88,7 @@ + #include "stringutil.hxx" + #include <documentlinkmgr.hxx> + #include <scopetools.hxx> ++#include <tokenarray.hxx> + + #include <memory> + +@@ -1153,6 +1154,15 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode, + } + } + ++void ScDocument::CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode ) ++{ ++ if (HasLinkFormulaNeedingCheck()) ++ return; ++ ++ if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice)) ++ SetLinkFormulaNeedingCheck(true); ++} ++ + // TimerDelays etc. + void ScDocument::KeyInput( const KeyEvent& ) + { +diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx +index 7af4fb5..b7d8031 100644 +--- a/sc/source/core/data/formulacell.cxx ++++ b/sc/source/core/data/formulacell.cxx +@@ -1365,8 +1365,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr + + // After loading, it must be known if ocDde/ocWebservice is in any formula + // (for external links warning, CompileXML is called at the end of loading XML file) +- if (!pDocument->HasLinkFormulaNeedingCheck() && (pCode->HasOpCodeRPN(ocDde) || pCode->HasOpCodeRPN(ocWebservice))) +- pDocument->SetLinkFormulaNeedingCheck(true); ++ pDocument->CheckLinkFormulaNeedingCheck(*pCode); + + //volatile cells must be added here for import + if( pCode->IsRecalcModeAlways() || pCode->IsRecalcModeForced() || +diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx +index c319055..7fa0666 100644 +--- a/sc/source/filter/excel/excform.cxx ++++ b/sc/source/filter/excel/excform.cxx +@@ -157,6 +157,7 @@ void ImportExcel::Formula( + { + pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, *pResult); + pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8); ++ rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode()); + rDoc.getDoc().EnsureTable(aScPos.Tab()); + rDoc.setFormulaCell(aScPos, pCell); + SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell); +diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx +index bea8ba3..b5c9fef 100644 +--- a/sc/source/filter/excel/excform8.cxx ++++ b/sc/source/filter/excel/excform8.cxx +@@ -730,6 +730,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn, + << nMerk0 << ocClose; + aPool >> aStack; + pExtName->CreateDdeData( GetDoc(), aApplic, aTopic ); ++ GetDoc().SetLinkFormulaNeedingCheck(true); + } + } + break; +diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx +index 6d27232..1c25921 100644 +--- a/sc/source/filter/excel/impop.cxx ++++ b/sc/source/filter/excel/impop.cxx +@@ -867,6 +867,7 @@ void ImportExcel::Shrfmla() + + ScFormulaCell* pCell = new ScFormulaCell(pD, aPos, *pErgebnis); + pCell->GetCode()->WrapReference(aPos, EXC_MAXCOL8, EXC_MAXROW8); ++ rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode()); + rDoc.getDoc().EnsureTable(aPos.Tab()); + rDoc.setFormulaCell(aPos, pCell); + pCell->SetNeedNumberFormat(false); +diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx +index 41c99f8..b139ac9 100644 +--- a/sc/source/filter/oox/formulabuffer.cxx ++++ b/sc/source/filter/oox/formulabuffer.cxx +@@ -228,6 +228,10 @@ void applyCellFormulas( + continue; + + aCompiler.CompileTokenArray(); // Generate RPN tokens. ++ ++ // Check if ocDde/ocWebservice is in any formula for external links warning. ++ rDoc.getDoc().CheckLinkFormulaNeedingCheck(*pCode); ++ + ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode); + rDoc.setFormulaCell(aPos, pCell); + rCache.store(aPos, pCell); +-- +1.9.1 + +From 68cada33625321ba764f1fc8008aad5ebc8a44b7 Mon Sep 17 00:00:00 2001 +From: Eike Rathke <er...@redhat.com> +Date: Thu, 25 Jan 2018 13:20:27 +0100 +Subject: [PATCH 5/6] CheckLinkFormulaNeedingCheck() for conditional format + expressions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + This is a combination of 4 commits. + +Prepare CheckLinkFormulaNeedingCheck() to use either RPN or tokenized code + +Conditional format formulas aren't finally compiled until needed +so the check will have to operate on the tokenized expression +instead of RPN code. + +(cherry picked from commit faa0305ba3d0dc698fce4915d4f3a1fb52422380) + +CheckLinkFormulaNeedingCheck() for .ods conditional format expressions + +(cherry picked from commit 2930ba2ac5d9423f2848b968edcd8ddc71966186) + +CheckLinkFormulaNeedingCheck() for .xlsx conditional format expressions + +(cherry picked from commit fef24d9f999ee54d7936900485d97ff26656f517) + +CheckLinkFormulaNeedingCheck() for .xls conditional format expressions + +(cherry picked from commit af2a2a0c72db312902e466c36697b5c198041e82) + +45eb1ab5efa0ec9da2663f20427d2474ce300826 +31ede1a23223a798141a0891deeabd8cf88fff58 +afa112cc591b411d80ead48bf726788d361f6eb3 + +Change-Id: I68837e9bd33f125ab47b10b1a6fa18175abd1627 +Reviewed-on: https://gerrit.libreoffice.org/48719 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +(cherry picked from commit dc44111ad5965bf4179fc654b677e1e445dea2f0) +--- + sc/source/core/data/conditio.cxx | 6 ++++++ + sc/source/core/data/documen8.cxx | 17 +++++++++++++++-- + sc/source/filter/excel/xicontent.cxx | 6 ++++++ + sc/source/filter/oox/condformatbuffer.cxx | 2 ++ + 4 files changed, 29 insertions(+), 2 deletions(-) + +diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx +index d3d996d..922d7dd 100644 +--- a/sc/source/core/data/conditio.cxx ++++ b/sc/source/core/data/conditio.cxx +@@ -521,6 +521,12 @@ void ScConditionEntry::CompileXML() + Compile( GetExpression(aSrcPos, 0, 0, eTempGrammar1), + GetExpression(aSrcPos, 1, 0, eTempGrammar2), + aStrNmsp1, aStrNmsp2, eTempGrammar1, eTempGrammar2, true ); ++ ++ // Importing ocDde/ocWebservice? ++ if (pFormula1) ++ mpDoc->CheckLinkFormulaNeedingCheck(*pFormula1); ++ if (pFormula2) ++ mpDoc->CheckLinkFormulaNeedingCheck(*pFormula2); + } + + void ScConditionEntry::SetSrcString( const OUString& rNew ) +diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx +index 185a2aa..deb908f 100644 +--- a/sc/source/core/data/documen8.cxx ++++ b/sc/source/core/data/documen8.cxx +@@ -1159,8 +1159,21 @@ void ScDocument::CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode ) + if (HasLinkFormulaNeedingCheck()) + return; + +- if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice)) +- SetLinkFormulaNeedingCheck(true); ++ // Prefer RPN over tokenized formula if available. ++ if (rCode.GetCodeLen()) ++ { ++ if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice)) ++ SetLinkFormulaNeedingCheck(true); ++ } ++ else if (rCode.GetLen()) ++ { ++ if (rCode.HasOpCode(ocDde) || rCode.HasOpCode(ocWebservice)) ++ SetLinkFormulaNeedingCheck(true); ++ } ++ else ++ { ++ assert(!"called with empty ScTokenArray"); ++ } + } + + // TimerDelays etc. +diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx +index 05a142d..a863f9b 100644 +--- a/sc/source/filter/excel/xicontent.cxx ++++ b/sc/source/filter/excel/xicontent.cxx +@@ -663,7 +663,10 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm ) + rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize1, false, FT_CondFormat ); + // formula converter owns pTokArr -> create a copy of the token array + if( pTokArr ) ++ { + xTokArr1.reset( pTokArr->Clone() ); ++ GetDocRef().CheckLinkFormulaNeedingCheck( *xTokArr1); ++ } + } + + ::std::unique_ptr< ScTokenArray > pTokArr2; +@@ -674,7 +677,10 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm ) + rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize2, false, FT_CondFormat ); + // formula converter owns pTokArr -> create a copy of the token array + if( pTokArr ) ++ { + pTokArr2.reset( pTokArr->Clone() ); ++ GetDocRef().CheckLinkFormulaNeedingCheck( *pTokArr2); ++ } + } + + // *** create the Calc conditional formatting *** +diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx +index 1c1eadd..8526d7f 100644 +--- a/sc/source/filter/oox/condformatbuffer.cxx ++++ b/sc/source/filter/oox/condformatbuffer.cxx +@@ -875,11 +875,13 @@ void CondFormatRule::finalizeImport() + { + pTokenArray2.reset(new ScTokenArray()); + ScTokenConversion::ConvertToTokenArray( rDoc, *pTokenArray2.get(), maModel.maFormulas[ 1 ] ); ++ rDoc.CheckLinkFormulaNeedingCheck( *pTokenArray2.get()); + } + + ScTokenArray aTokenArray; + OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId ); + ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, maModel.maFormulas[ 0 ] ); ++ rDoc.CheckLinkFormulaNeedingCheck( aTokenArray); + ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(eOperator, + &aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName); + mpFormat->AddEntry(pNewEntry); +-- +1.9.1 + +From e1fce8c423bbd0f67a78e07f1c48d91a64018e9c Mon Sep 17 00:00:00 2001 +From: Eike Rathke <er...@redhat.com> +Date: Mon, 29 Jan 2018 18:19:33 +0100 +Subject: [PATCH 6/6] CheckLinkFormulaNeedingCheck() for named expressions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + This is a combination of 3 commits. + +CheckLinkFormulaNeedingCheck() for .ods named expressions + +This is specifically necessary for named expressions that are used +in conditional format formulas, for which RPN is generated at a +later stage, not during import. + +(cherry picked from commit eae9648e99be53ba441d9d8207aac6f3ce211ef2) + +CheckLinkFormulaNeedingCheck() for .xls named expressions + +(cherry picked from commit 8512f13c42ae3fbb287a555616fe10ff04295616) + +CheckLinkFormulaNeedingCheck() for .xlsx named expressions + +(cherry picked from commit a1f933ee2b9e23a505d937035821e9571cf4119c) + + Conflicts: + sc/source/filter/oox/defnamesbuffer.cxx + +e03cb5767c34f8157a492a6d6c3b0700d065052d +217c89822ab477a6c383d170ae739e44efd10fa3 + +Change-Id: I54ab8dc14f81d6b18b0d17f448187d19d8e396fc +Reviewed-on: https://gerrit.libreoffice.org/48858 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +(cherry picked from commit 908854a7b281454332af434be9468ec45d420030) +--- + sc/source/core/tool/rangenam.cxx | 8 +++++++- + sc/source/filter/excel/xiname.cxx | 3 +++ + sc/source/filter/oox/defnamesbuffer.cxx | 2 ++ + 3 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx +index 7626e16..d147b10 100644 +--- a/sc/source/core/tool/rangenam.cxx ++++ b/sc/source/core/tool/rangenam.cxx +@@ -64,9 +64,14 @@ ScRangeData::ScRangeData( ScDocument* pDok, + mnMaxCol (-1) + { + if (!rSymbol.isEmpty()) +- CompileRangeData( rSymbol, pDoc->IsImportingXML()); ++ { + // Let the compiler set an error on unknown names for a subsequent + // CompileUnresolvedXML(). ++ const bool bImporting = pDoc->IsImportingXML(); ++ CompileRangeData( rSymbol, bImporting); ++ if (bImporting) ++ pDoc->CheckLinkFormulaNeedingCheck( *pCode); ++ } + else + { + // #i63513#/#i65690# don't leave pCode as NULL. +@@ -199,6 +204,7 @@ void ScRangeData::CompileUnresolvedXML( sc::CompileFormulaContext& rCxt ) + // Don't let the compiler set an error for unknown names on final + // compile, errors are handled by the interpreter thereafter. + CompileRangeData( aSymbol, false); ++ rCxt.getDoc()->CheckLinkFormulaNeedingCheck( *pCode); + } + } + +diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx +index d096615..8decfc0 100644 +--- a/sc/source/filter/excel/xiname.cxx ++++ b/sc/source/filter/excel/xiname.cxx +@@ -265,7 +265,10 @@ void XclImpName::InsertName(const ScTokenArray* pArray) + } + } + if (pData) ++ { ++ GetDoc().CheckLinkFormulaNeedingCheck( *pData->GetCode()); + mpScData = pData; // cache for later use ++ } + } + + XclImpNameManager::XclImpNameManager( const XclImpRoot& rRoot ) : +diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx +index 9de5851..586511d 100644 +--- a/sc/source/filter/oox/defnamesbuffer.cxx ++++ b/sc/source/filter/oox/defnamesbuffer.cxx +@@ -39,6 +39,7 @@ + #include "tokenarray.hxx" + #include "tokenuno.hxx" + #include "compiler.hxx" ++#include "document.hxx" + + namespace oox { + namespace xls { +@@ -339,6 +340,7 @@ std::unique_ptr<ScTokenArray> DefinedName::getScTokens( + // after, a resulting error must be reset. + sal_uInt16 nErr = pArray->GetCodeError(); + aCompiler.CompileTokenArray(); ++ getScDocument().CheckLinkFormulaNeedingCheck( *pArray); + pArray->DelRPN(); + pArray->SetCodeError(nErr); + +-- +1.9.1 + +diff --git a/include/formula/errorcodes.hxx b/include/formula/errorcodes.hxx +index 173c744..5a5a8fd 100644 +--- a/include/formula/errorcodes.hxx ++++ b/include/formula/errorcodes.hxx +@@ -24,6 +24,7 @@ + + namespace formula { + ++const sal_uInt16 errNONE = 0; + const sal_uInt16 errIllegalChar = 501; + const sal_uInt16 errIllegalArgument = 502; + const sal_uInt16 errIllegalFPOperation = 503; // #NUM! + +From 4a412bdf0387cc2cb59d656d0738a63a286ec497 Mon Sep 17 00:00:00 2001 +From: Eike Rathke <er...@redhat.com> +Date: Mon, 19 Feb 2018 23:43:51 +0100 +Subject: Resolves: tdf#115710 let css::sheet::FunctionAccess execute + WEBSERVICE +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +... independent of a LinkManager that is not present in the +interim FunctionAccess document. FunctionAccess is executed by +extensions, Add-Ons and macros that the user gave permission +already. + +Change-Id: I9349a59ee24089c3657de7786b49e5e81946f175 +(cherry picked from commit 121fda77b0cc16d54607a1f5f7b26c0f1050284f) +Reviewed-on: https://gerrit.libreoffice.org/50020 +Tested-by: Jenkins <c...@libreoffice.org> +Reviewed-by: Caolán McNamara <caol...@redhat.com> +Tested-by: Caolán McNamara <caol...@redhat.com> +--- + sc/inc/document.hxx | 5 ++++- + sc/source/core/data/documen2.cxx | 7 +++++-- + sc/source/core/tool/interpr7.cxx | 28 +++++++++++++++++++++++++++- + sc/source/ui/unoobj/funcuno.cxx | 2 +- + 4 files changed, 37 insertions(+), 5 deletions(-) + +diff -urN sc-old/inc/document.hxx sc/inc/document.hxx +--- a/sc/inc/document.hxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/inc/document.hxx 2018-02-22 11:06:40.329105073 +0100 +@@ -233,7 +233,8 @@ + { + SCDOCMODE_DOCUMENT, + SCDOCMODE_CLIP, +- SCDOCMODE_UNDO ++ SCDOCMODE_UNDO, ++ SCDOCMODE_FUNCTIONACCESS + }; + + struct ScDocStat +@@ -420,6 +421,7 @@ + bool bCalculatingFormulaTree; + bool bIsClip; + bool bIsUndo; ++ bool bIsFunctionAccess; + bool bIsVisible; // set from view ctor + + bool bIsEmbedded; // display/adjust Embedded area? +@@ -1351,6 +1353,7 @@ + bool IsClipboard() const { return bIsClip; } + bool IsUndoEnabled() const { return mbUndoEnabled; } + SC_DLLPUBLIC void EnableUndo( bool bVal ); ++ bool IsFunctionAccess() const { return bIsFunctionAccess; } + + bool IsAdjustHeightEnabled() const { return mbAdjustHeightEnabled; } + void EnableAdjustHeight( bool bVal ) { mbAdjustHeightEnabled = bVal; } +diff -urN sc-old/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx +--- a/sc/source/core/data/documen2.cxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/source/core/data/documen2.cxx 2018-02-22 11:04:01.777343579 +0100 +@@ -180,12 +180,13 @@ + eHardRecalcState(HARDRECALCSTATE_OFF), + nVisibleTab( 0 ), + eLinkMode(LM_UNKNOWN), +- bAutoCalc( eMode == SCDOCMODE_DOCUMENT ), ++ bAutoCalc( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS ), + bAutoCalcShellDisabled( false ), + bForcedFormulaPending( false ), + bCalculatingFormulaTree( false ), + bIsClip( eMode == SCDOCMODE_CLIP ), + bIsUndo( eMode == SCDOCMODE_UNDO ), ++ bIsFunctionAccess( eMode == SCDOCMODE_FUNCTIONACCESS ), + bIsVisible( false ), + bIsEmbedded( false ), + bInsertingFromOtherDoc( false ), +@@ -222,7 +223,9 @@ + + eSrcSet = osl_getThreadTextEncoding(); + +- if ( eMode == SCDOCMODE_DOCUMENT ) ++ /* TODO: for SCDOCMODE_FUNCTIONACCESS it might not even be necessary to ++ * have all of these available. */ ++ if ( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS ) + { + xPoolHelper = new ScPoolHelper( this ); + +diff -urN sc-old/source/core/tool/interpr7.cxx sc/source/core/tool/interpr7.cxx +--- a/sc/source/core/tool/interpr7.cxx 2018-02-22 11:03:24.000000000 +0100 ++++ b/sc/source/core/tool/interpr7.cxx 2018-02-22 11:08:38.336920129 +0100 +@@ -250,6 +250,21 @@ + return nullptr; + } + ++static bool lcl_FunctionAccessLoadWebServiceLink( OUString& rResult, ScDocument* pDoc, const OUString& rURI ) ++{ ++ // For FunctionAccess service always force a changed data update. ++ ScWebServiceLink aLink( pDoc, rURI); ++ if (aLink.DataChanged( OUString(), css::uno::Any()) != sfx2::SvBaseLink::UpdateResult::SUCCESS) ++ return false; ++ ++ if (!aLink.HasResult()) ++ return false; ++ ++ rResult = aLink.GetResult(); ++ ++ return true; ++} ++ + void ScInterpreter::ScWebservice() + { + sal_uInt8 nParamCount = GetByte(); +@@ -273,7 +288,19 @@ + + if (!mpLinkManager) + { +- PushError( formula::errNoValue ); ++ if (!pDok->IsFunctionAccess() || pDok->HasLinkFormulaNeedingCheck()) ++ { ++ PushError( formula::errNoValue); ++ } ++ else ++ { ++ OUString aResult; ++ if (lcl_FunctionAccessLoadWebServiceLink( aResult, pDok, aURI)) ++ PushString( aResult); ++ else ++ PushError( formula::errNoValue); ++ } ++ + return; + } + +diff -urN sc-old/source/ui/unoobj/funcuno.cxx sc/source/ui/unoobj/funcuno.cxx +--- a/sc/source/ui/unoobj/funcuno.cxx 2018-02-22 11:01:38.905545605 +0100 ++++ b/sc/source/ui/unoobj/funcuno.cxx 2018-02-22 11:04:01.781343573 +0100 +@@ -74,7 +74,7 @@ + + ScDocument* ScTempDocSource::CreateDocument() + { +- ScDocument* pDoc = new ScDocument; // SCDOCMODE_DOCUMENT ++ ScDocument* pDoc = new ScDocument( SCDOCMODE_FUNCTIONACCESS ); + pDoc->MakeTable( 0 ); + return pDoc; + } diff -Nru libreoffice-5.2.7/debian/rules libreoffice-5.2.7/debian/rules --- libreoffice-5.2.7/debian/rules 2017-05-04 20:18:18.000000000 +0200 +++ libreoffice-5.2.7/debian/rules 2018-02-11 19:00:23.000000000 +0100 @@ -272,11 +272,12 @@ ifeq "$(ENABLE_JAVA)" "y" ifeq "$(JDK)" "default" ifeq "$(shell LANG=C /usr/lib/jvm/default-java/bin/java -version 2>&1 | tail -n 1 | awk '{ print $$1 }')" "OpenJDK" - RUN_MAKE_CHECK=y ifeq "$(DEB_HOST_ARCH)" "i386" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif ifeq "$(DEB_HOST_ARCH)" "amd64" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif RUN_PYTESTS=y @@ -285,9 +286,11 @@ ifeq "$(JDK)" "openjdk" RUN_MAKE_CHECK=y ifeq "$(DEB_HOST_ARCH)" "i386" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif ifeq "$(DEB_HOST_ARCH)" "amd64" + RUN_MAKE_CHECK=y ENABLE_JUNIT4=y endif RUN_PYTESTS=y @@ -576,9 +579,10 @@ IGNORE_MAKE_CHECK_FAILURES=- ifneq "$(JDK)" "gcj-jdk" - ifeq (i386,$(DEB_HOST_ARCH)) -IGNORE_MAKE_CHECK_FAILURES:= - endif +# disabled due to the Linux/Java Stack Clash fix regression... +# ifeq (i386,$(DEB_HOST_ARCH)) +#IGNORE_MAKE_CHECK_FAILURES:= +# endif ifeq (amd64,$(DEB_HOST_ARCH)) IGNORE_MAKE_CHECK_FAILURES:= endif @@ -2329,6 +2333,10 @@ $(PKGDIR)-dev-common/$(OOSDKDIR) mv $(PKGDIR)-dev/$(OOSDKDIR)/set* \ $(PKGDIR)-dev-common/$(OOSDKDIR) + # settings/dk.mk is not arch-indep + mkdir -p $(PKGDIR)-dev/$(OOSDKDIR)/settings + mv $(PKGDIR)-dev-common/$(OOSDKDIR)/settings/dk.mk \ + $(PKGDIR)-dev/$(OOSDKDIR)/settings mv $(PKGDIR)-dev/$(OOSDKDIR)/config* \ $(PKGDIR)-dev-common/$(OOSDKDIR) mv $(PKGDIR)-dev/$(OOSDKDIR)/index.html* \