2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-30 12:23:25 +00:00
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-04-21 19:23:07 +00:00
|
|
|
|
|
|
|
#include "refreshtimer.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
ScRefreshTimerProtector::ScRefreshTimerProtector( ScRefreshTimerControl * const * pp )
|
|
|
|
:
|
|
|
|
ppControl( pp )
|
|
|
|
{
|
|
|
|
if ( ppControl && *ppControl )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
(*ppControl)->SetAllowRefresh( false );
|
2001-04-21 19:23:07 +00:00
|
|
|
// wait for any running refresh in another thread to finnish
|
2010-10-16 03:15:13 -05:00
|
|
|
::osl::MutexGuard aGuard( (*ppControl)->GetMutex() );
|
2001-04-21 19:23:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ScRefreshTimer::~ScRefreshTimer()
|
|
|
|
{
|
|
|
|
if ( IsActive() )
|
|
|
|
Stop();
|
|
|
|
RemoveFromControl();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScRefreshTimer::SetRefreshDelay( sal_uLong nSeconds )
|
2001-04-21 19:23:07 +00:00
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bActive = IsActive();
|
2001-04-21 19:23:07 +00:00
|
|
|
if ( bActive && !nSeconds )
|
|
|
|
Stop();
|
|
|
|
SetTimeout( nSeconds * 1000 );
|
|
|
|
if ( !bActive && nSeconds )
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScRefreshTimer::Timeout()
|
|
|
|
{
|
|
|
|
if ( ppControl && *ppControl && (*ppControl)->IsRefreshAllowed() )
|
|
|
|
{
|
|
|
|
// now we COULD make the call in another thread ...
|
2010-10-16 03:15:13 -05:00
|
|
|
::osl::MutexGuard aGuard( (*ppControl)->GetMutex() );
|
2001-04-21 19:23:07 +00:00
|
|
|
maTimeoutHdl.Call( this );
|
|
|
|
// restart from now on, don't execute immediately again if timed out
|
|
|
|
// a second time during refresh
|
|
|
|
if ( IsActive() )
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|