xref: /aoo41x/main/sc/inc/chartlock.hxx (revision 38d50f7b)
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 
24 #ifndef SC_CHARTLOCK_HXX
25 #define SC_CHARTLOCK_HXX
26 
27 
28 #include <vcl/timer.hxx>
29 
30 #include <cppuhelper/weakref.hxx>
31 #include <com/sun/star/frame/XModel.hpp>
32 
33 #include <memory>
34 
35 class ScDocument;
36 
37 /** All current charts in the calc will be locked in constructor and unlocked in destructor.
38 */
39 class ScChartLockGuard
40 {
41 public:
42 					ScChartLockGuard( ScDocument* pDoc );
43 	virtual			~ScChartLockGuard();
44 
45     void            AlsoLockThisChart( const ::com::sun::star::uno::Reference<
46                         ::com::sun::star::frame::XModel >& xModel );
47 
48 private:
49     std::vector< ::com::sun::star::uno::WeakReference<
50         ::com::sun::star::frame::XModel > > maChartModels;
51 
52     ScChartLockGuard();
53     ScChartLockGuard( const ScChartLockGuard& );
54 };
55 
56 /** Use this to lock all charts in the calc for a little time.
57     They will unlock automatically unless you call StartOrContinueLocking() again.
58 */
59 class ScTemporaryChartLock
60 {
61 public:
62 					ScTemporaryChartLock( ScDocument* pDoc );
63 	virtual			~ScTemporaryChartLock();
64 
65 	void			StartOrContinueLocking();
66     void			StopLocking();
67     void            AlsoLockThisChart( const ::com::sun::star::uno::Reference<
68                         ::com::sun::star::frame::XModel >& xModel );
69 
70 private:
71     ScDocument* 	                    mpDoc;
72     Timer			                    maTimer;
73 	std::auto_ptr< ScChartLockGuard >   mapScChartLockGuard;
74 
75 	DECL_LINK( TimeoutHdl, Timer* );
76 
77     ScTemporaryChartLock();
78     ScTemporaryChartLock( const ScTemporaryChartLock& );
79 };
80 
81 
82 #endif
83