/src/libreoffice/vcl/source/edit/IdleFormatter.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
22 | | #include <vcl/weld.hxx> |
23 | | |
24 | | #include "IdleFormatter.hxx" |
25 | | #include "TextLine.hxx" |
26 | | |
27 | | #include <cstddef> |
28 | | #include <utility> |
29 | | |
30 | | IdleFormatter::IdleFormatter() |
31 | 0 | : Idle("vcl::TextEngine mpIdleFormatter") |
32 | 0 | , mpView(nullptr) |
33 | 0 | , mnRestarts(0) |
34 | 0 | { |
35 | 0 | SetPriority(TaskPriority::HIGH_IDLE); |
36 | 0 | } |
37 | | |
38 | | IdleFormatter::~IdleFormatter() |
39 | 0 | { |
40 | 0 | mpView = nullptr; |
41 | 0 | } |
42 | | |
43 | | void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ) |
44 | 0 | { |
45 | 0 | mpView = pV; |
46 | |
|
47 | 0 | if ( IsActive() ) |
48 | 0 | mnRestarts++; |
49 | |
|
50 | 0 | if ( mnRestarts > nMaxRestarts ) |
51 | 0 | { |
52 | 0 | mnRestarts = 0; |
53 | 0 | Invoke(); |
54 | 0 | } |
55 | 0 | else |
56 | 0 | { |
57 | 0 | Start(); |
58 | 0 | } |
59 | 0 | } |
60 | | |
61 | | void IdleFormatter::ForceTimeout() |
62 | 0 | { |
63 | 0 | if ( IsActive() ) |
64 | 0 | { |
65 | 0 | Stop(); |
66 | 0 | mnRestarts = 0; |
67 | 0 | Invoke(); |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |