diff options
Diffstat (limited to 'extensions/source/ole/unoobjw.cxx')
-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; |