Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "AsynchronousCall.hxx"
20 :
21 : #include <vcl/svapp.hxx>
22 :
23 :
24 : namespace sfx2 { namespace sidebar {
25 :
26 4700 : AsynchronousCall::AsynchronousCall (void)
27 : : maAction(),
28 4700 : mnCallId(0)
29 : {
30 4700 : }
31 :
32 9400 : AsynchronousCall::AsynchronousCall (const Action& rAction)
33 : : maAction(rAction),
34 9400 : mnCallId(0)
35 : {
36 9400 : }
37 :
38 28200 : AsynchronousCall::~AsynchronousCall (void)
39 : {
40 14100 : CancelRequest();
41 14100 : }
42 :
43 5293 : void AsynchronousCall::RequestCall (void)
44 : {
45 5293 : if (mnCallId == 0)
46 : {
47 4742 : Link aLink (LINK(this, AsynchronousCall, HandleUserCall));
48 4742 : mnCallId = Application::PostUserEvent(aLink);
49 : }
50 5293 : }
51 :
52 28793 : void AsynchronousCall::CancelRequest (void)
53 : {
54 28793 : if (mnCallId != 0)
55 : {
56 3954 : Application::RemoveUserEvent(mnCallId);
57 3954 : mnCallId = 0;
58 : }
59 28793 : }
60 :
61 1576 : IMPL_LINK(AsynchronousCall, HandleUserCall, void*, EMPTYARG )
62 : {
63 788 : mnCallId = 0;
64 788 : if (maAction)
65 788 : maAction();
66 :
67 788 : return sal_True;
68 : }
69 :
70 951 : } } // end of namespace sfx2::sidebar
71 :
72 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|