lotuswordpro/source/filter/lwpchangemgr.cxx | 2 lotuswordpro/source/filter/lwpfrib.cxx | 18 ++++ lotuswordpro/source/filter/lwpfrib.hxx | 4 + sc/Library_sc.mk | 1 sc/inc/document.hxx | 6 - sc/inc/documentlinkmgr.hxx | 6 - sc/qa/unit/ucalc.cxx | 2 sc/source/core/data/documen2.cxx | 2 sc/source/core/data/formulacell.cxx | 8 +- sc/source/core/inc/webservicelink.hxx | 49 ++++++++++++ sc/source/core/tool/interpr2.cxx | 8 +- sc/source/core/tool/interpr7.cxx | 105 +++++++++++++++++++-------- sc/source/core/tool/webservicelink.cxx | 106 ++++++++++++++++++++++++++++ sc/source/ui/docshell/arealink.cxx | 2 sc/source/ui/docshell/docsh4.cxx | 4 - sc/source/ui/docshell/documentlinkmgr.cxx | 20 +++-- sc/source/ui/view/tabvwsh4.cxx | 2 17 files changed, 291 insertions(+), 54 deletions(-)
New commits: commit 7b23a94f8e94400b347ecfddc8be86143cf12b23 Author: Caolán McNamara <[email protected]> Date: Thu Jan 11 20:43:28 2018 +0000 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 <[email protected]> Reviewed-by: Eike Rathke <[email protected]> (cherry picked from commit e1946d75a1095c2596d7815600454ff01fcd3270) Signed-off-by: Andras Timar <[email protected]> Change-Id: I0145f38cc1c1f9ff514a496f7101d81cde9e7c67 diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index a36b6a9fc37e..2eeab50eaa64 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 9a0b41a58785..671528d8d43c 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -449,7 +449,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 d5d801a4aeb2..86dba66f2d3d 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 8b3cb09b515d..dbd472272048 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1379,9 +1379,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 000000000000..e61ebfdb4347 --- /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 9112c24e7584..e2f562848a31 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> @@ -235,6 +240,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(); @@ -242,7 +263,7 @@ void ScInterpreter::ScWebservice() { OUString aURI = GetString().getString(); - if(aURI.isEmpty()) + if (aURI.isEmpty()) { PushError( FormulaError::NoValue ); return; @@ -252,52 +273,72 @@ void ScInterpreter::ScWebservice() INetProtocol eProtocol = aObj.GetProtocol(); if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) { - PushError( FormulaError::NoValue ); + PushError(FormulaError::NoValue); return; } - uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY ); - if(!xFileAccess.is()) + if (!mpLinkManager) { - PushError( FormulaError::NoValue ); + PushError(FormulaError::NoValue); return; } - uno::Reference< io::XInputStream > xStream; - try { - xStream = xFileAccess->openFileRead( aURI ); - } - catch (...) - { - // don't let any exceptions pass - PushError( FormulaError::NoValue ); - return; - } - if ( !xStream.is() ) - { - PushError( FormulaError::NoValue ); - return; - } + // Need to reinterpret after loading (build links) + if (rArr.IsRecalcModeNormal()) + rArr.SetExclusiveRecalcModeOnLoad(); - const sal_Int32 BUF_LEN = 8000; - uno::Sequence< sal_Int8 > buffer( BUF_LEN ); - OStringBuffer aBuffer( 64000 ); + // while the link is not evaluated, idle must be disabled (to avoid circular references) + bool bOldEnabled = pDok->IsIdleEnabled(); + pDok->EnableIdle(false); - sal_Int32 nRead = 0; - while ( ( nRead = xStream->readBytes( buffer, BUF_LEN ) ) == BUF_LEN ) + // Get/ Create link object + ScWebServiceLink* pLink = lcl_GetWebServiceLink(mpLinkManager, aURI); + + bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != FormulaError::NONE); + + 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 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 ( nRead > 0 ) + 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() != FormulaError::NONE && !bWasError) + pMyFormulaCell->SetErrCode(FormulaError::NONE); + + // check the value + if (pLink->HasResult()) + PushString(pLink->GetResult()); + else + PushError(FormulaError::NoValue); - 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 000000000000..0d9e32cdef60 --- /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(SFX_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 9f87407590c0..5677e613db97 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -458,7 +458,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 520b8542afc0..b8a9df65cb6b 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 3c768527e8e0..0a0b3ff97fe3 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1576,7 +1576,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) commit 3139914eb6379837fbf309642a63371128042db1 Author: Caolán McNamara <[email protected]> Date: Thu Jan 11 14:16:15 2018 +0000 Better handle ScDde formulas with missing dde-link entries 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 <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit b0597ba5d745974fce752e1b677451a19350d351) Reviewed-on: https://gerrit.libreoffice.org/47818 Reviewed-by: Eike Rathke <[email protected]> (cherry picked from commit 4ede45eb239b1604bca900c22481b7d13e4c2790) Signed-off-by: Andras Timar <[email protected]> Change-Id: I016b53288076d83dd49e92e245346a5f7f560522 diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 911e441a0d14..9a0b41a58785 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -449,7 +449,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; @@ -1940,8 +1940,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; } void SetRangeOverflowType(sal_uInt32 nType) { nRangeOverflowType = nType; } bool HasRangeOverflow() const { return nRangeOverflowType != 0; } diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 9e0f9496b9d4..174e738f2924 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6264,7 +6264,7 @@ void Test::testEmptyCalcDocDefaults() CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IdleCalcTextWidth() ); CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsIdleEnabled() ); CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsDetectiveDirty() ); - CPPUNIT_ASSERT_EQUAL( false, m_pDoc->GetHasMacroFunc() ); + CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasLinkFormulaNeedingCheck() ); CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsChartListenerCollectionNeedsUpdate() ); CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasRangeOverflow() ); diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index ef319256e858..c6016cc15320 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 73d31106ab19..8b3cb09b515d 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1379,10 +1379,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 c40623320b3d..7f215495538b 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -2742,8 +2742,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 7fa1b98b6664..9f87407590c0 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -480,6 +480,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 9c5b80646e78..3c768527e8e0 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1576,7 +1576,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) commit c78cd9e8edb93ea0ce66106f100400959f9142f0 Author: Caolán McNamara <[email protected]> Date: Fri Jan 12 09:43:41 2018 +0000 ofz#5254 Bad-cast Change-Id: I318d441d841dd4c783f87ac2f3f699852e8b1039 Reviewed-on: https://gerrit.libreoffice.org/47805 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit f8a1dd7ae35ea0307a9282378a9300897df6fb42) Signed-off-by: Andras Timar <[email protected]> diff --git a/lotuswordpro/source/filter/lwpchangemgr.cxx b/lotuswordpro/source/filter/lwpchangemgr.cxx index ee1906865eb0..3816d8f52339 100644 --- a/lotuswordpro/source/filter/lwpchangemgr.cxx +++ b/lotuswordpro/source/filter/lwpchangemgr.cxx @@ -89,6 +89,7 @@ LwpChangeMgr::LwpChangeMgr() m_pFribMap = &m_DocFribMap; m_ChangeList.clear(); } + LwpChangeMgr::~LwpChangeMgr() { m_pFribMap=nullptr; @@ -102,6 +103,7 @@ void LwpChangeMgr::AddChangeFrib(LwpFrib* pFrib) m_nCounter++; OUString sID = "ct"+ OUString::number(m_nCounter); m_pFribMap->insert(std::pair<LwpFrib*,OUString>(pFrib,sID)); + pFrib->Register(m_pFribMap); } OUString LwpChangeMgr::GetChangeID(LwpFrib* pFrib) diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx index 3b41993f735f..6cb34aa2167a 100644 --- a/lotuswordpro/source/filter/lwpfrib.cxx +++ b/lotuswordpro/source/filter/lwpfrib.cxx @@ -86,7 +86,8 @@ LwpFrib::LwpFrib(LwpPara* pPara) - : m_pPara(pPara) + : m_pFribMap(nullptr) + , m_pPara(pPara) , m_pNext(nullptr) , m_nFribType(0) , m_pModifiers(nullptr) @@ -99,6 +100,7 @@ LwpFrib::LwpFrib(LwpPara* pPara) LwpFrib::~LwpFrib() { + Deregister(); } LwpFrib* LwpFrib::CreateFrib(LwpPara* pPara, LwpObjectStream* pObjStrm, sal_uInt8 fribtag,sal_uInt8 editID) @@ -447,4 +449,18 @@ XFColor LwpFrib::GetHighlightColor() return pGlobal->GetHighlightColor(m_nEditor); } +void LwpFrib::Register(std::map<LwpFrib*,OUString>* pFribMap) +{ + m_pFribMap = pFribMap; +} + +void LwpFrib::Deregister() +{ + if (m_pFribMap) + { + m_pFribMap->erase(this); + m_pFribMap = nullptr; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lotuswordpro/source/filter/lwpfrib.hxx b/lotuswordpro/source/filter/lwpfrib.hxx index 70258c8e86be..a51be22f50ba 100644 --- a/lotuswordpro/source/filter/lwpfrib.hxx +++ b/lotuswordpro/source/filter/lwpfrib.hxx @@ -96,6 +96,7 @@ public: OUString GetEditor(); XFColor GetHighlightColor(); protected: + std::map<LwpFrib*,OUString>* m_pFribMap; LwpPara* m_pPara; LwpFrib* m_pNext; sal_uInt8 m_nFribType; @@ -118,6 +119,9 @@ public: REV_INSERT =0, REV_DELETE = 1, }; + + void Register(std::map<LwpFrib*,OUString>* pFribMap); + void Deregister(); private: static void ReadModifiers(LwpObjectStream* pObjStrm,ModifierInfo* pModInfo); protected: commit 932508baccd9b97c761980d36ae45e1ae0d85157 Author: Caolán McNamara <[email protected]> Date: Fri Jan 12 10:48:59 2018 +0000 VclPtr, missing dispose Change-Id: I790cd8be0d461d4c82c9b1c64e334bd37115dcaf Reviewed-on: https://gerrit.libreoffice.org/47803 Tested-by: Jenkins <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> (cherry picked from commit 06a2ffe863501e8bef88cd0201bd5e8d73e92242) Signed-off-by: Andras Timar <[email protected]> diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index d5b486afdb4b..8aa8fdbe7bc3 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -88,7 +88,7 @@ void ScAreaLink::Edit(vcl::Window* pParent, const Link<SvBaseLink&,void>& /* rEn ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); - VclPtr<AbstractScLinkedAreaDlg> pDlg = pFact->CreateScLinkedAreaDlg(pParent); + ScopedVclPtr<AbstractScLinkedAreaDlg> pDlg(pFact->CreateScLinkedAreaDlg(pParent)); OSL_ENSURE(pDlg, "Dialog create fail!"); pDlg->InitFromOldLink( aFileName, aFilterName, aOptions, aSourceArea, GetRefreshDelay() ); pImpl->m_pDialog = pDlg; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
