195a18594SAndre Fischer /************************************************************** 295a18594SAndre Fischer * 395a18594SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 495a18594SAndre Fischer * or more contributor license agreements. See the NOTICE file 595a18594SAndre Fischer * distributed with this work for additional information 695a18594SAndre Fischer * regarding copyright ownership. The ASF licenses this file 795a18594SAndre Fischer * to you under the Apache License, Version 2.0 (the 895a18594SAndre Fischer * "License"); you may not use this file except in compliance 995a18594SAndre Fischer * with the License. You may obtain a copy of the License at 1095a18594SAndre Fischer * 1195a18594SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1295a18594SAndre Fischer * 1395a18594SAndre Fischer * Unless required by applicable law or agreed to in writing, 1495a18594SAndre Fischer * software distributed under the License is distributed on an 1595a18594SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1695a18594SAndre Fischer * KIND, either express or implied. See the License for the 1795a18594SAndre Fischer * specific language governing permissions and limitations 1895a18594SAndre Fischer * under the License. 1995a18594SAndre Fischer * 2095a18594SAndre Fischer *************************************************************/ 2195a18594SAndre Fischer 2295a18594SAndre Fischer #include "precompiled_sfx2.hxx" 2395a18594SAndre Fischer 2495a18594SAndre Fischer #include "AsynchronousCall.hxx" 2595a18594SAndre Fischer 2695a18594SAndre Fischer #include <vcl/svapp.hxx> 2795a18594SAndre Fischer 2895a18594SAndre Fischer 2995a18594SAndre Fischer namespace sfx2 { namespace sidebar { 3095a18594SAndre Fischer 31*3091fa8aSAndre Fischer AsynchronousCall::AsynchronousCall (void) 32*3091fa8aSAndre Fischer : maAction(), 33*3091fa8aSAndre Fischer mnCallId(0) 34*3091fa8aSAndre Fischer { 35*3091fa8aSAndre Fischer } 36*3091fa8aSAndre Fischer 37*3091fa8aSAndre Fischer 38*3091fa8aSAndre Fischer 39*3091fa8aSAndre Fischer 4095a18594SAndre Fischer AsynchronousCall::AsynchronousCall (const Action& rAction) 4195a18594SAndre Fischer : maAction(rAction), 4295a18594SAndre Fischer mnCallId(0) 4395a18594SAndre Fischer { 4495a18594SAndre Fischer } 4595a18594SAndre Fischer 4695a18594SAndre Fischer 4795a18594SAndre Fischer 4895a18594SAndre Fischer 4995a18594SAndre Fischer AsynchronousCall::~AsynchronousCall (void) 5095a18594SAndre Fischer { 5195a18594SAndre Fischer CancelRequest(); 5295a18594SAndre Fischer } 5395a18594SAndre Fischer 5495a18594SAndre Fischer 5595a18594SAndre Fischer 5695a18594SAndre Fischer 5795a18594SAndre Fischer void AsynchronousCall::RequestCall (const Action& rAction) 5895a18594SAndre Fischer { 5995a18594SAndre Fischer CancelRequest(); 6095a18594SAndre Fischer maAction = rAction; 6195a18594SAndre Fischer RequestCall(); 6295a18594SAndre Fischer } 6395a18594SAndre Fischer 6495a18594SAndre Fischer 6595a18594SAndre Fischer 6695a18594SAndre Fischer 6795a18594SAndre Fischer void AsynchronousCall::RequestCall (void) 6895a18594SAndre Fischer { 6995a18594SAndre Fischer if (mnCallId == 0) 7095a18594SAndre Fischer { 7195a18594SAndre Fischer Link aLink (LINK(this, AsynchronousCall, HandleUserCall)); 7295a18594SAndre Fischer mnCallId = Application::PostUserEvent(aLink); 7395a18594SAndre Fischer } 7495a18594SAndre Fischer } 7595a18594SAndre Fischer 7695a18594SAndre Fischer 7795a18594SAndre Fischer 7895a18594SAndre Fischer 7995a18594SAndre Fischer void AsynchronousCall::CancelRequest (void) 8095a18594SAndre Fischer { 8195a18594SAndre Fischer if (mnCallId != 0) 8295a18594SAndre Fischer { 8395a18594SAndre Fischer Application::RemoveUserEvent(mnCallId); 84d64288eaSAndre Fischer mnCallId = 0; 8595a18594SAndre Fischer } 8695a18594SAndre Fischer } 8795a18594SAndre Fischer 8895a18594SAndre Fischer 8995a18594SAndre Fischer 9095a18594SAndre Fischer 9195a18594SAndre Fischer IMPL_LINK(AsynchronousCall, HandleUserCall, void*, EMPTYARG ) 9295a18594SAndre Fischer { 9395a18594SAndre Fischer mnCallId = 0; 9495a18594SAndre Fischer if (maAction) 9595a18594SAndre Fischer maAction(); 9695a18594SAndre Fischer 9795a18594SAndre Fischer return sal_True; 9895a18594SAndre Fischer } 9995a18594SAndre Fischer 10095a18594SAndre Fischer 10195a18594SAndre Fischer } } // end of namespace sfx2::sidebar 10295a18594SAndre Fischer 103