LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/toolpanel/controls - MasterPageContainerQueue.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       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             : #ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_QUEUE_HXX
      21             : #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_QUEUE_HXX
      22             : 
      23             : #include "MasterPageContainer.hxx"
      24             : #include "MasterPageDescriptor.hxx"
      25             : 
      26             : #include <boost/scoped_ptr.hpp>
      27             : #include <boost/weak_ptr.hpp>
      28             : 
      29             : namespace sd { namespace toolpanel { namespace controls {
      30             : 
      31             : 
      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.
      37             : */
      38             : class MasterPageContainerQueue
      39             : {
      40             : public:
      41           0 :     class ContainerAdapter {
      42             :     public:
      43             :         virtual bool UpdateDescriptor (
      44             :             const SharedMasterPageDescriptor& rpDescriptor,
      45             :             bool bForcePageObject,
      46             :             bool bForcePreview,
      47             :             bool bSendEvents) = 0;
      48             : 
      49             :     protected:
      50           0 :         ~ContainerAdapter() {}
      51             :     };
      52             : 
      53             :     static MasterPageContainerQueue* Create (
      54             :         const ::boost::weak_ptr<ContainerAdapter>& rpContainer);
      55             :     virtual ~MasterPageContainerQueue (void);
      56             : 
      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.
      62             :     */
      63             :     bool RequestPreview (const SharedMasterPageDescriptor& rDescriptor);
      64             : 
      65             :     /** Return <TRUE/> when there is a request currently in the queue for
      66             :         the given token.
      67             :     */
      68             :     bool HasRequest (MasterPageContainer::Token aToken) const;
      69             : 
      70             :     /** Return <TRUE/> when there is at least one request in the queue.
      71             :     */
      72             :     bool IsEmpty (void) const;
      73             : 
      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.
      78             :     */
      79             :     void ProcessAllRequests (void);
      80             : 
      81             : private:
      82             :     ::boost::weak_ptr<ContainerAdapter> mpWeakContainer;
      83             :     class PreviewCreationRequest;
      84             :     class RequestQueue;
      85             :     ::boost::scoped_ptr<RequestQueue> mpRequestQueue;
      86             :     Timer maDelayedPreviewCreationTimer;
      87             :     sal_uInt32 mnRequestsServedCount;
      88             : 
      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.
      92             : 
      93             :     /** The time to wait (in milliseconds) between the creation of previews.
      94             :     */
      95             :     static const sal_Int32 snDelayedCreationTimeout;
      96             : 
      97             :     /** The time to wait when the system is not idle.
      98             :     */
      99             :     static const sal_Int32 snDelayedCreationTimeoutWhenNotIdle;
     100             : 
     101             :     /** Requests for previews of master pages in a document have their
     102             :         priority increased by this value.
     103             :     */
     104             :     static const sal_Int32 snMasterPagePriorityBoost;
     105             : 
     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.
     109             :     */
     110             :     static const sal_Int32 snWaitForMoreRequestsPriorityThreshold;
     111             : 
     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.
     116             :     */
     117             :     static sal_uInt32 snWaitForMoreRequestsCount;
     118             : 
     119             :     MasterPageContainerQueue (const ::boost::weak_ptr<ContainerAdapter>& rpContainer);
     120             :     void LateInit (void);
     121             : 
     122             :     /** Calculate the priority that defines the order in which requests
     123             :         are processed.
     124             :     */
     125             :     sal_Int32 CalculatePriority (const SharedMasterPageDescriptor& rDescriptor) const;
     126             : 
     127             :     DECL_LINK(DelayedPreviewCreation, Timer *);
     128             : };
     129             : 
     130             : } } } // end of namespace ::sd::toolpanel::controls
     131             : 
     132             : #endif
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10