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 3195a18594SAndre Fischer AsynchronousCall::AsynchronousCall (const Action& rAction) 3295a18594SAndre Fischer : maAction(rAction), 3395a18594SAndre Fischer mnCallId(0) 3495a18594SAndre Fischer { 3595a18594SAndre Fischer } 3695a18594SAndre Fischer 3795a18594SAndre Fischer 3895a18594SAndre Fischer 3995a18594SAndre Fischer 4095a18594SAndre Fischer AsynchronousCall::~AsynchronousCall (void) 4195a18594SAndre Fischer { 4295a18594SAndre Fischer CancelRequest(); 4395a18594SAndre Fischer } 4495a18594SAndre Fischer 4595a18594SAndre Fischer 4695a18594SAndre Fischer 4795a18594SAndre Fischer 4895a18594SAndre Fischer void AsynchronousCall::RequestCall (const Action& rAction) 4995a18594SAndre Fischer { 5095a18594SAndre Fischer CancelRequest(); 5195a18594SAndre Fischer maAction = rAction; 5295a18594SAndre Fischer RequestCall(); 5395a18594SAndre Fischer } 5495a18594SAndre Fischer 5595a18594SAndre Fischer 5695a18594SAndre Fischer 5795a18594SAndre Fischer 5895a18594SAndre Fischer void AsynchronousCall::RequestCall (void) 5995a18594SAndre Fischer { 6095a18594SAndre Fischer if (mnCallId == 0) 6195a18594SAndre Fischer { 6295a18594SAndre Fischer Link aLink (LINK(this, AsynchronousCall, HandleUserCall)); 6395a18594SAndre Fischer mnCallId = Application::PostUserEvent(aLink); 6495a18594SAndre Fischer } 6595a18594SAndre Fischer } 6695a18594SAndre Fischer 6795a18594SAndre Fischer 6895a18594SAndre Fischer 6995a18594SAndre Fischer 7095a18594SAndre Fischer void AsynchronousCall::CancelRequest (void) 7195a18594SAndre Fischer { 7295a18594SAndre Fischer if (mnCallId != 0) 7395a18594SAndre Fischer { 7495a18594SAndre Fischer Application::RemoveUserEvent(mnCallId); 75*d64288eaSAndre Fischer mnCallId = 0; 7695a18594SAndre Fischer } 7795a18594SAndre Fischer } 7895a18594SAndre Fischer 7995a18594SAndre Fischer 8095a18594SAndre Fischer 8195a18594SAndre Fischer 8295a18594SAndre Fischer IMPL_LINK(AsynchronousCall, HandleUserCall, void*, EMPTYARG ) 8395a18594SAndre Fischer { 8495a18594SAndre Fischer mnCallId = 0; 8595a18594SAndre Fischer if (maAction) 8695a18594SAndre Fischer maAction(); 8795a18594SAndre Fischer 8895a18594SAndre Fischer return sal_True; 8995a18594SAndre Fischer } 9095a18594SAndre Fischer 9195a18594SAndre Fischer 9295a18594SAndre Fischer } } // end of namespace sfx2::sidebar 9395a18594SAndre Fischer 94