merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / inc / ControllerLockGuard.hxx
blob69044d4a2b3f46eb0f59afb56f450a9f3ed5663e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART2_CONTROLLERLOCKGUARD_HXX
28 #define CHART2_CONTROLLERLOCKGUARD_HXX
30 #include <com/sun/star/frame/XModel.hpp>
31 #include "charttoolsdllapi.hxx"
33 namespace chart
36 /** This guard calls lockControllers at the given Model in the CTOR and
37 unlockControllers in the DTOR. Using this ensures that controllers do not
38 remain locked when leaving a function even in case an exception is thrown.
40 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockGuard
42 public:
43 explicit ControllerLockGuard(
44 const ::com::sun::star::uno::Reference<
45 ::com::sun::star::frame::XModel > & xModel );
46 ~ControllerLockGuard();
48 private:
49 ::com::sun::star::uno::Reference<
50 ::com::sun::star::frame::XModel > m_xModel;
53 /** This helper class can be used to pass a locking mechanism to other objects
54 without exposing the full XModel to it.
56 Use the ControllerLockHelperGuard to lock/unlock the model during a block of
57 instructions.
59 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelper
61 public:
62 explicit ControllerLockHelper(
63 const ::com::sun::star::uno::Reference<
64 ::com::sun::star::frame::XModel > & xModel );
65 ~ControllerLockHelper();
67 SAL_DLLPRIVATE void lockControllers();
68 SAL_DLLPRIVATE void unlockControllers();
70 private:
71 ::com::sun::star::uno::Reference<
72 ::com::sun::star::frame::XModel > m_xModel;
75 /** This guard calls lockControllers at the given ControllerLockHelper in the
76 CTOR and unlockControllers in the DTOR. Using this ensures that controllers
77 do not remain locked when leaving a function even in case an exception is
78 thrown.
80 class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelperGuard
82 public:
83 explicit ControllerLockHelperGuard( ControllerLockHelper & rHelper );
84 ~ControllerLockHelperGuard();
86 private:
87 ControllerLockHelper & m_rHelper;
90 } // namespace chart
92 // CHART2_CONTROLLERLOCKGUARD_HXX
93 #endif