Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / DocumentTimerManager.hxx
blob895aa4b86b150723b3a07e440b73d4bd71204905
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 class SwDoc;
31 namespace sw
33 class DocumentTimerManager final : public IDocumentTimerAccess
35 public:
36 enum class IdleJob
38 None, ///< document has no idle jobs to do
39 Busy, ///< document is busy and idle jobs are postponed
40 Grammar,
41 Layout,
42 Fields,
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;
58 private:
59 DocumentTimerManager(DocumentTimerManager const&) = delete;
60 DocumentTimerManager& operator=(DocumentTimerManager const&) = delete;
62 /// Delay starting idle jobs to allow for post-load activity.
63 /// Used by LOK only.
64 DECL_LINK(FireIdleJobsTimeout, Timer*, void);
66 DECL_LINK(DoIdleJobs, Timer*, void);
68 IdleJob GetNextIdleJob() const;
70 SwDoc& m_rDoc;
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
74 SwDocIdle m_aDocIdle;
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));
85 #endif
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */