1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef CHART2_CONTROLLERLOCKGUARD_HXX
24 #define CHART2_CONTROLLERLOCKGUARD_HXX
25 
26 #include <com/sun/star/frame/XModel.hpp>
27 #include "charttoolsdllapi.hxx"
28 
29 namespace chart
30 {
31 
32 /** This guard calls lockControllers at the given Model in the CTOR and
33     unlockControllers in the DTOR.  Using this ensures that controllers do not
34     remain locked when leaving a function even in case an exception is thrown.
35  */
36 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockGuard
37 {
38 public:
39 	explicit ControllerLockGuard(
40         const ::com::sun::star::uno::Reference<
41             ::com::sun::star::frame::XModel > & xModel );
42     ~ControllerLockGuard();
43 
44 private:
45     ::com::sun::star::uno::Reference<
46             ::com::sun::star::frame::XModel > m_xModel;
47 };
48 
49 /** This helper class can be used to pass a locking mechanism to other objects
50     without exposing the full XModel to it.
51 
52     Use the ControllerLockHelperGuard to lock/unlock the model during a block of
53     instructions.
54  */
55 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelper
56 {
57 public:
58     explicit ControllerLockHelper(
59         const ::com::sun::star::uno::Reference<
60             ::com::sun::star::frame::XModel > & xModel );
61     ~ControllerLockHelper();
62 
63     SAL_DLLPRIVATE void lockControllers();
64     SAL_DLLPRIVATE void unlockControllers();
65 
66 private:
67     ::com::sun::star::uno::Reference<
68             ::com::sun::star::frame::XModel > m_xModel;
69 };
70 
71 /** This guard calls lockControllers at the given ControllerLockHelper in the
72     CTOR and unlockControllers in the DTOR.  Using this ensures that controllers
73     do not remain locked when leaving a function even in case an exception is
74     thrown.
75  */
76 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelperGuard
77 {
78 public:
79 	explicit ControllerLockHelperGuard( ControllerLockHelper & rHelper );
80     ~ControllerLockHelperGuard();
81 
82 private:
83     ControllerLockHelper & m_rHelper;
84 };
85 
86 } //  namespace chart
87 
88 // CHART2_CONTROLLERLOCKGUARD_HXX
89 #endif
90