blob: f27931dcbf0989accc5fa7bd79fb881fa941022c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* -*- 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/.
*/
#include <sfx2/asyncfunc.hxx>
#include <comphelper/servicehelper.hxx>
#include <com/sun/star/uno/Reference.hxx>
namespace
{
class theAsyncFuncUnoTunnelId : public rtl::Static<UnoTunnelIdInit, theAsyncFuncUnoTunnelId>
{
};
}
AsyncFunc::AsyncFunc(const std::function<void()>& rAsyncFunc)
: m_pAsyncFunc(rAsyncFunc)
{
}
AsyncFunc::~AsyncFunc() {}
void AsyncFunc::Execute()
{
if (m_pAsyncFunc)
m_pAsyncFunc();
}
const css::uno::Sequence<sal_Int8>& AsyncFunc::getUnoTunnelId()
{
return theAsyncFuncUnoTunnelId::get().getSeq();
}
AsyncFunc* AsyncFunc::getImplementation(const css::uno::Reference<css::uno::XInterface>& xInterface)
{
css::uno::Reference<css::lang::XUnoTunnel> xUnoTunnel(xInterface, css::uno::UNO_QUERY);
if (xUnoTunnel.is())
{
return reinterpret_cast<AsyncFunc*>(xUnoTunnel->getSomething(AsyncFunc::getUnoTunnelId()));
}
return nullptr;
}
//XUnoTunnel
sal_Int64 SAL_CALL AsyncFunc::getSomething(const css::uno::Sequence<sal_Int8>& rId)
{
if (rId.getLength() == 16
&& 0 == memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16))
{
return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
}
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|