LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - AsynchronousCall.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 29 82.8 %
Date: 2014-04-11 Functions: 7 8 87.5 %
Legend: Lines: hit not hit

          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          17 : AsynchronousCall::AsynchronousCall (void)
      27             :     : maAction(),
      28          17 :       mnCallId(0)
      29             : {
      30          17 : }
      31             : 
      32             : 
      33             : 
      34             : 
      35          34 : AsynchronousCall::AsynchronousCall (const Action& rAction)
      36             :     : maAction(rAction),
      37          34 :       mnCallId(0)
      38             : {
      39          34 : }
      40             : 
      41             : 
      42             : 
      43             : 
      44         102 : AsynchronousCall::~AsynchronousCall (void)
      45             : {
      46          51 :     CancelRequest();
      47          51 : }
      48             : 
      49             : 
      50             : 
      51             : 
      52           0 : void AsynchronousCall::RequestCall (const Action& rAction)
      53             : {
      54           0 :     CancelRequest();
      55           0 :     maAction = rAction;
      56           0 :     RequestCall();
      57           0 : }
      58             : 
      59             : 
      60             : 
      61             : 
      62          50 : void AsynchronousCall::RequestCall (void)
      63             : {
      64          50 :     if (mnCallId == 0)
      65             :     {
      66          28 :         Link aLink (LINK(this, AsynchronousCall, HandleUserCall));
      67          28 :         mnCallId = Application::PostUserEvent(aLink);
      68             :     }
      69          50 : }
      70             : 
      71             : 
      72             : 
      73             : 
      74         135 : void AsynchronousCall::CancelRequest (void)
      75             : {
      76         135 :     if (mnCallId != 0)
      77             :     {
      78          17 :         Application::RemoveUserEvent(mnCallId);
      79          17 :         mnCallId = 0;
      80             :     }
      81         135 : }
      82             : 
      83             : 
      84             : 
      85             : 
      86          22 : IMPL_LINK(AsynchronousCall, HandleUserCall, void*, EMPTYARG )
      87             : {
      88          11 :     mnCallId = 0;
      89          11 :     if (maAction)
      90          11 :         maAction();
      91             : 
      92          11 :     return sal_True;
      93             : }
      94             : 
      95             : 
      96             : } } // end of namespace sfx2::sidebar
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10