1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX
23 #include <IDocumentTimerAccess.hxx>
24 #include <SwDocIdle.hxx>
26 #include <sal/types.h>
27 #include <tools/link.hxx>
33 class DocumentTimerManager final
: public IDocumentTimerAccess
38 None
, ///< document has no idle jobs to do
39 Busy
, ///< document is busy and idle jobs are postponed
45 DocumentTimerManager(SwDoc
& i_rSwdoc
);
46 virtual ~DocumentTimerManager() override
;
48 void StartIdling() override
;
50 void StopIdling() override
;
52 void BlockIdling() override
;
54 void UnblockIdling() override
;
56 bool IsDocIdle() const override
;
59 DocumentTimerManager(DocumentTimerManager
const&) = delete;
60 DocumentTimerManager
& operator=(DocumentTimerManager
const&) = delete;
62 /// Delay starting idle jobs to allow for post-load activity.
64 DECL_LINK(FireIdleJobsTimeout
, Timer
*, void);
66 DECL_LINK(DoIdleJobs
, Timer
*, void);
68 IdleJob
GetNextIdleJob() const;
72 sal_uInt32 m_nIdleBlockCount
; ///< Don't run the Idle, if > 0
73 bool m_bStartOnUnblock
; ///< true, if the last unblock should start the timer
75 Timer m_aFireIdleJobsTimer
;
76 bool m_bWaitForLokInit
; ///< true if we waited for LOK to initialize already.
79 inline bool DocumentTimerManager::IsDocIdle() const
81 return ((0 == m_nIdleBlockCount
) && (GetNextIdleJob() != IdleJob::Busy
));
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */