bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / sidebar / MasterPageContainerQueue.hxx
blobe65c2891ffaf6df1a4b98e974ace34cbedb43af3
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_SD_SOURCE_UI_SIDEBAR_MASTERPAGECONTAINERQUEUE_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGECONTAINERQUEUE_HXX
23 #include "MasterPageContainer.hxx"
24 #include "MasterPageDescriptor.hxx"
26 #include <vcl/timer.hxx>
28 #include <memory>
30 namespace sd { namespace sidebar {
32 /** The queue stores and processes all requests from a MasterPageContainer
33 for the creation of previews.
34 The order of request processing and its timing is controlled by a
35 heuristic that uses values given with each request and which is
36 controlled by various parameters that are described below.
38 class MasterPageContainerQueue final
40 public:
41 class ContainerAdapter {
42 public:
43 virtual bool UpdateDescriptor (
44 const SharedMasterPageDescriptor& rpDescriptor,
45 bool bForcePageObject,
46 bool bForcePreview,
47 bool bSendEvents) = 0;
49 protected:
50 ~ContainerAdapter() {}
53 static MasterPageContainerQueue* Create (
54 const std::weak_ptr<ContainerAdapter>& rpContainer);
55 ~MasterPageContainerQueue();
57 /** This method is typically called for entries in the container for
58 which GetPreviewState() returns OS_CREATABLE. The creation of the
59 preview is then scheduled to be executed asynchronously at a later
60 point in time. When the preview is available the change listeners
61 will be notified.
63 bool RequestPreview (const SharedMasterPageDescriptor& rDescriptor);
65 /** Return <TRUE/> when there is a request currently in the queue for
66 the given token.
68 bool HasRequest (MasterPageContainer::Token aToken) const;
70 /** Return <TRUE/> when there is at least one request in the queue.
72 bool IsEmpty() const;
74 /** After this call the queue does not wait anymore for requests with
75 higher priority when only a small number of requests with lower
76 priority are present. This method should be called when all
77 templates are inserted into the MasterPageContainer.
79 void ProcessAllRequests();
81 private:
82 std::weak_ptr<ContainerAdapter> const mpWeakContainer;
83 class PreviewCreationRequest;
84 class RequestQueue;
85 std::unique_ptr<RequestQueue> mpRequestQueue;
86 Timer maDelayedPreviewCreationTimer;
87 sal_uInt32 mnRequestsServedCount;
89 // There are a couple of values that define various aspects of the
90 // heuristic that defines the order and timing in which requests for
91 // preview creation are processed.
93 /** The time to wait (in milliseconds) between the creation of previews.
95 static const sal_Int32 snDelayedCreationTimeout;
97 /** The time to wait when the system is not idle.
99 static const sal_Int32 snDelayedCreationTimeoutWhenNotIdle;
101 /** Requests for previews of master pages in a document have their
102 priority increased by this value.
104 static const sal_Int32 snMasterPagePriorityBoost;
106 /** When only requests which a priority lower than this threshold exist
107 and not many requests have been made yet then wait with processing
108 them until more requests are present.
110 static const sal_Int32 snWaitForMoreRequestsPriorityThreshold;
112 /** When only requests which a priority lower than a threshold exist
113 and not more requests than this number have been made or already
114 processed then wait with processing them until more requests are
115 present.
117 static sal_uInt32 snWaitForMoreRequestsCount;
119 explicit MasterPageContainerQueue (const std::weak_ptr<ContainerAdapter>& rpContainer);
120 void LateInit();
122 /** Calculate the priority that defines the order in which requests
123 are processed.
125 static sal_Int32 CalculatePriority (const SharedMasterPageDescriptor& rDescriptor);
127 DECL_LINK(DelayedPreviewCreation, Timer *, void);
130 } } // end of namespace sd::sidebar
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */