diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-06-06 18:53:35 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-06-06 20:23:40 +0200 |
commit | 8015cd21bae6faa8a8d53acf63fe59b375ab6382 (patch) | |
tree | f83ea6e102631eab5fdbeb747bb433f09dfdcd73 /extensions | |
parent | 13328a36d68c4141219d9cc549e6d76e108e6076 (diff) |
tdf#118026: Use ooo::vba::XCollection instead of css::container::XEnumeration
An object returned by XCollection::Item() is of the right "VBA" kind
that we want. One returned by XEnumeration::nextElement() is not.
Change-Id: I26132a7d0f2638a61f2711b941386a889fabea72
Reviewed-on: https://gerrit.libreoffice.org/55392
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/ole/unoobjw.cxx | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index 8ea36470d243..8b78f1df5beb 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -71,6 +71,7 @@ #include <com/sun/star/script/XInvocation2.hpp> #include <com/sun/star/script/MemberType.hpp> #include <com/sun/star/reflection/XIdlReflection.hpp> +#include <ooo/vba/XCollection.hpp> #include <ooo/vba/XConnectable.hpp> #include <ooo/vba/XConnectionPoint.hpp> #include <ooo/vba/XSink.hpp> @@ -1150,6 +1151,7 @@ STDMETHODIMP InterfaceOleWrapper::GetIDsOfNames(REFIID /*riid*/, if (iter == m_nameToDispIdMap.end()) { ret = DISP_E_UNKNOWNNAME; + SAL_INFO("extensions.olebridge", " " << name << ": UNKNOWN"); } else { @@ -1995,6 +1997,7 @@ class CXEnumVariant : public IEnumVARIANT, { public: CXEnumVariant() + : mnIndex(1) // ooo::vba::XCollection index starts at one { } @@ -2025,10 +2028,10 @@ public: // Creates and initializes the enumerator void Init(InterfaceOleWrapper* pInterfaceOleWrapper, - const Reference< XEnumeration > xEnumeration) + const Reference<ooo::vba::XCollection > xCollection) { mpInterfaceOleWrapper = pInterfaceOleWrapper; - mxEnumeration = xEnumeration; + mxCollection = xCollection; } // IEnumVARIANT @@ -2057,14 +2060,18 @@ public: while (celt > 0) { - if (!mxEnumeration->hasMoreElements()) + if (mnIndex >= mxCollection->getCount()) return S_FALSE; - Any aElement = mxEnumeration->nextElement(); + + Any aIndex; + aIndex <<= mnIndex; + Any aElement = mxCollection->Item(aIndex, Any()); mpInterfaceOleWrapper->anyToVariant(rgVar, aElement); // rgVar->pdispVal->AddRef(); ?? if (pCeltFetched) (*pCeltFetched)++; rgVar++; + mnIndex++; celt--; } return S_OK; @@ -2072,7 +2079,8 @@ public: virtual HRESULT STDMETHODCALLTYPE Reset() override { - return E_NOTIMPL; + mnIndex = 1; + return S_OK; } virtual HRESULT STDMETHODCALLTYPE STDMETHODCALLTYPE Skip(ULONG celt) override @@ -2081,9 +2089,9 @@ public: while (celt > 0) { - if (!mxEnumeration->hasMoreElements()) + if (mnIndex >= mxCollection->getCount()) return S_FALSE; - mxEnumeration->nextElement(); + mnIndex++; celt--; } return S_OK; @@ -2091,7 +2099,8 @@ public: private: InterfaceOleWrapper* mpInterfaceOleWrapper; - Reference<XEnumeration> mxEnumeration; + Reference<ooo::vba::XCollection> mxCollection; + sal_Int32 mnIndex; }; class Sink : public cppu::WeakImplHelper<ooo::vba::XSink> @@ -2663,12 +2672,10 @@ HRESULT InterfaceOleWrapper::InvokeGeneral( DISPID dispidMember, unsigned short if( !pvarResult) return E_POINTER; - Reference< XEnumerationAccess > xEnumerationAccess(m_xOrigin, UNO_QUERY_THROW); - if (!xEnumerationAccess.is()) + Reference< ooo::vba::XCollection> xCollection(m_xOrigin, UNO_QUERY); + if (!xCollection.is()) return DISP_E_MEMBERNOTFOUND; - Reference< XEnumeration > xEnumeration = xEnumerationAccess->createEnumeration(); - CComObject<CXEnumVariant>* pEnumVar; ret = CComObject<CXEnumVariant>::CreateInstance(&pEnumVar); @@ -2677,7 +2684,7 @@ HRESULT InterfaceOleWrapper::InvokeGeneral( DISPID dispidMember, unsigned short pEnumVar->AddRef(); - pEnumVar->Init(this, xEnumeration); + pEnumVar->Init(this, xCollection); pvarResult->vt = VT_UNKNOWN; pvarResult->punkVal = nullptr; |