merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / framework / configuration / ChangeRequestQueueProcessor.hxx
blob599a55183b8673569fa707e7c9242fc3825139b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChangeRequestQueueProcessor.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_FRAMEWORK_CHANGE_REQUEST_QUEUE_PROCESSOR_HXX
32 #define SD_FRAMEWORK_CHANGE_REQUEST_QUEUE_PROCESSOR_HXX
34 #include "ChangeRequestQueue.hxx"
35 #include <osl/mutex.hxx>
36 #include <rtl/ref.hxx>
37 #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp>
38 #include <com/sun/star/drawing/framework/ConfigurationChangeEvent.hpp>
40 #include <cppuhelper/interfacecontainer.hxx>
41 #include <tools/link.hxx>
43 #include <boost/shared_ptr.hpp>
45 namespace sd { namespace framework {
47 class ConfigurationController;
48 class ConfigurationUpdater;
50 /** The ChangeRequestQueueProcessor ownes the ChangeRequestQueue and
51 processes the configuration change requests.
53 When after processing one entry the queue is empty then the
54 XConfigurationController::update() method is called so that the changes
55 made to the local XConfiguration reference are reflected by the UI.
57 Queue entries are processed asynchronously by calling PostUserEvent().
59 class ChangeRequestQueueProcessor
61 public:
62 /** The queue processor is created with a reference to an
63 ConfigurationController so that its UpdateConfiguration() method can
64 be called when the queue becomes empty.
66 ChangeRequestQueueProcessor (
67 const ::rtl::Reference<ConfigurationController>& rxController,
68 const ::boost::shared_ptr<ConfigurationUpdater>& rpUpdater);
69 ~ChangeRequestQueueProcessor (void);
71 /** Sets the configuration who will be changed by subsequent change
72 requests. This method should be called only by the configuration
73 controller who owns the configuration.
75 void SetConfiguration (
76 const ::com::sun::star::uno::Reference<
77 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
79 /** The given request is appended to the end of the queue and will
80 eventually be processed when all other entries in front of it have
81 been processed.
83 void AddRequest (const ::com::sun::star::uno::Reference<
84 ::com::sun::star::drawing::framework::XConfigurationChangeRequest>& rxRequest);
86 /** Returns </TRUE> when the queue is empty.
88 bool IsEmpty (void) const;
90 /** Process all events in the queue synchronously.
92 <p>This method is typically called when the framework is shut down
93 to establish an empty configuration.</p>
95 void ProcessUntilEmpty (void);
97 /** Process the first event in queue.
99 void ProcessOneEvent (void);
101 /** Remove all events from the queue.
103 <p>This method is typically called when the framework is shut down
104 to avoid the processing of still pending activation requests.</p>
106 void Clear (void);
108 private:
109 mutable ::osl::Mutex maMutex;
111 ChangeRequestQueue maQueue;
113 /** The id returned by the last PostUserEvent() call. This id is stored
114 so that a pending user event can be removed whent he queue processor
115 is destroyed.
117 sal_uIntPtr mnUserEventId;
119 ::com::sun::star::uno::Reference<
120 ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration;
122 ::rtl::Reference<ConfigurationController> mpConfigurationController;
124 ::boost::shared_ptr<ConfigurationUpdater> mpConfigurationUpdater;
126 /** Initiate the processing of the entries in the queue. The actual
127 processing starts asynchronously.
129 void StartProcessing (void);
131 /** Callback function for the PostUserEvent() call.
133 DECL_LINK(ProcessEvent,void*);
137 } } // end of namespace sd::framework
139 #endif