/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "binaryany.hxx" #include "bridge.hxx" #include "currentcontext.hxx" #include "incomingrequest.hxx" #include "specialfunctionids.hxx" namespace binaryurp { IncomingRequest::IncomingRequest( rtl::Reference< Bridge > const & bridge, rtl::ByteSequence const & tid, OUString const & oid, css::uno::UnoInterfaceReference const & object, css::uno::TypeDescription const & type, sal_uInt16 functionId, bool synchronous, css::uno::TypeDescription const & member, bool setter, std::vector< BinaryAny > const & inArguments, bool currentContextMode, css::uno::UnoInterfaceReference const & currentContext): bridge_(bridge), tid_(tid), oid_(oid), object_(object), type_(type), functionId_(functionId), synchronous_(synchronous), member_(member), setter_(setter), inArguments_(inArguments), currentContextMode_(currentContextMode), currentContext_(currentContext) { assert(bridge.is()); assert(member.is()); assert(member.get()->bComplete); } IncomingRequest::~IncomingRequest() {} void IncomingRequest::execute() const { BinaryAny ret; std::vector< BinaryAny > outArgs; bool isExc; try { bool resetCc = false; css::uno::UnoInterfaceReference oldCc; if (currentContextMode_) { oldCc = current_context::get(); current_context::set(currentContext_); resetCc = true; } try { try { isExc = !execute_throw(&ret, &outArgs); } catch (const std::exception & e) { throw css::uno::RuntimeException( "caught C++ exception: " + o3tl::runtimeToOUString(e.what())); } } catch (const css::uno::RuntimeException &) { css::uno::Any exc(cppu::getCaughtException()); ret = bridge_->mapCppToBinaryAny(exc); isExc = true; } if (resetCc) { current_context::set(oldCc); } } catch (const css::uno::RuntimeException &) { css::uno::Any exc(cppu::getCaughtException()); ret = bridge_->mapCppToBinaryAny(exc); isExc = true; } if (synchronous_) { bridge_->decrementActiveCalls(); try { bridge_->getWriter()->queueReply( tid_, member_, setter_, isExc, ret, outArgs, false); return; } catch (const css::uno::RuntimeException & e) { SAL_INFO("binaryurp", "caught " << e); } catch (const std::exception & e) { SAL_INFO("binaryurp", "caught C++ exception " << e.what()); } bridge_->terminate(false); } else { if (isExc) { SAL_INFO("binaryurp", "oneway method raised exception"); } bridge_->decrementCalls(); } } static size_t size_t_round(size_t val) { return (val + (sizeof(size_t)-1)) & ~(sizeof(size_t)-1); } bool IncomingRequest::execute_throw( BinaryAny * returnValue, std::vector< BinaryAny > * outArguments) const { assert(returnValue != nullptr); assert( returnValue->getType().equals( css::uno::TypeDescription(cppu::UnoType::get()))); assert(outArguments != nullptr); assert(outArguments->empty()); bool isExc = false; switch (functionId_) { case SPECIAL_FUNCTION_ID_RESERVED: assert(false); // this cannot happen break; case SPECIAL_FUNCTION_ID_RELEASE: bridge_->releaseStub(oid_, type_); break; case SPECIAL_FUNCTION_ID_QUERY_INTERFACE: if (!object_.is()) { css::uno::Reference< css::uno::XInterface > ifc; css::uno::Reference< css::bridge::XInstanceProvider > prov( bridge_->getProvider()); if (prov.is()) { try { ifc = prov->getInstance(oid_); } catch (const css::container::NoSuchElementException & e) { SAL_INFO("binaryurp", "initial element " << oid_ << ": " << e); } } if (ifc.is()) { css::uno::UnoInterfaceReference unoIfc( static_cast< uno_Interface * >( bridge_->getCppToBinaryMapping().mapInterface( ifc.get(), (css::uno::TypeDescription( cppu::UnoType< css::uno::Reference< css::uno::XInterface > >::get()). get()))), SAL_NO_ACQUIRE); *returnValue = BinaryAny( css::uno::TypeDescription( cppu::UnoType< css::uno::Reference< css::uno::XInterface > >::get()), &unoIfc.m_pUnoI); } break; } [[fallthrough]]; default: { assert(object_.is()); css::uno::TypeDescription retType; std::vector< std::vector< char > > outBufs; std::vector< void * > args; switch (member_.get()->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: { css::uno::TypeDescription t( reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >( member_.get())-> pAttributeTypeRef); if (setter_) { assert(inArguments_.size() == 1); args.push_back(inArguments_[0].getValue(t)); } else { assert(inArguments_.empty()); retType = t; } break; } case typelib_TypeClass_INTERFACE_METHOD: { typelib_InterfaceMethodTypeDescription * mtd = reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( member_.get()); retType = css::uno::TypeDescription(mtd->pReturnTypeRef); std::vector< BinaryAny >::const_iterator i( inArguments_.begin()); for (sal_Int32 j = 0; j != mtd->nParams; ++j) { void * p; if (mtd->pParams[j].bIn) { p = i++->getValue( css::uno::TypeDescription( mtd->pParams[j].pTypeRef)); } else { outBufs.emplace_back(size_t_round( css::uno::TypeDescription( mtd->pParams[j].pTypeRef). get()->nSize)); p = outBufs.back().data(); } args.push_back(p); if (mtd->pParams[j].bOut) { outArguments->push_back(BinaryAny()); } } assert(i == inArguments_.end()); break; } default: assert(false); // this cannot happen break; } size_t nSize = 0; if (retType.is()) nSize = size_t_round(retType.get()->nSize); std::vector< char > retBuf(nSize); uno_Any exc; uno_Any * pexc = &exc; (*object_.get()->pDispatcher)( object_.get(), member_.get(), retBuf.empty() ? nullptr : retBuf.data(), args.empty() ? nullptr : args.data(), &pexc); isExc = pexc != nullptr; if (isExc) { *returnValue = BinaryAny( css::uno::TypeDescription( cppu::UnoType< css::uno::Any >::get()), &exc); uno_any_destruct(&exc, nullptr); } else { if (!retBuf.empty()) { *returnValue = BinaryAny(retType, retBuf.data()); uno_destructData(retBuf.data(), retType.get(), nullptr); } if (!outArguments->empty()) { assert( member_.get()->eTypeClass == typelib_TypeClass_INTERFACE_METHOD); typelib_InterfaceMethodTypeDescription * mtd = reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( member_.get()); std::vector< BinaryAny >::iterator i(outArguments->begin()); std::vector< std::vector< char > >::iterator j( outBufs.begin()); for (sal_Int32 k = 0; k != mtd->nParams; ++k) { if (mtd->pParams[k].bOut) { *i++ = BinaryAny( css::uno::TypeDescription( mtd->pParams[k].pTypeRef), args[k]); } if (!mtd->pParams[k].bIn) { uno_type_destructData( (j++)->data(), mtd->pParams[k].pTypeRef, nullptr); } } assert(i == outArguments->end()); assert(j == outBufs.end()); } } break; } } return !isExc; } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ table'>feature/calc-data-table LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-09-22tdf#146619 Recheck include/c* with IWYUGabor Kelemen
Change-Id: I0cf6f675483bddf82e7347b484a874c71963bfd7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156984 Tested-by: Jenkins Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
2023-07-02loplugin:singlevalfieldsNoel Grandin
Change-Id: I091fac5ed41b2fb58dee5e3e1b8dd805c8dc4966 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153813 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-02remove IEventNotificationHook from comphelper::OPropertySetNoel Grandin
this class is a copy of cppuhelper::OPropertySet, and this feature is unused in that class too, so we are not likely to need it Change-Id: I9e3f0f7d786052f87f5a18c67e9b78409752fd99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149942 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-31simplify subclasses of comphelper::OPropertySetHelperNoel Grandin
they should deal in terms of the fast property IDS, they should not need to override setPropertyValueImpl, so just remove this, and standardise on the subclasses overriding setFastPropertyValueImpl Change-Id: I190955ccc4ae3e07dd481a1044f3c074dd1a40aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149836 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-31make some method in comphelper::OPropertySetHelper finalNoel Grandin
Change-Id: Ia745a0d7568cf8f9180ed2e28cfd11da94cd186a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149834 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-13convert UnoControlModel and friends to use std::mutexNoel Grandin
Which means creating a variant of the cppuhelper::OPropertySetHelper helper class which uses a std::mutex. Since we can do virtual base classes now (which the original could not), use that and a new helper class comphelper::UnoImplBase to share std::mutex m_aMutex; bool m_bDisposing; fields that the OPropertySetHelper wants to share with the parent class. Change-Id: I05ad465a3d3653ed4e109137e3e1c58190da8d97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148474 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>