Update ooo320-m1
[ooovba.git] / dbaccess / inc / documentcontroller.hxx
blob08b461b1de0190716d6510cc7527f07fbf0e7120
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: documentcontroller.hxx,v $
10 * $Revision: 1.3.2.2 $
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 ************************************************************************/
32 #ifndef DBACCESS_SOURCE_UI_INC_DOCUMENTCONTROLLER_HXX
33 #define DBACCESS_SOURCE_UI_INC_DOCUMENTCONTROLLER_HXX
35 /** === begin UNO includes === **/
36 #ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
37 #include <com/sun/star/frame/XController.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
40 #include <com/sun/star/frame/XModel.hpp>
41 #endif
42 #include <cppuhelper/weakref.hxx>
43 /** === end UNO includes === **/
45 #ifndef INCLUDED_DBACCESSDLLAPI_H
46 #include "dbaccessdllapi.h"
47 #endif
48 //........................................................................
49 namespace dbaui
51 //........................................................................
53 //====================================================================
54 //= ModelControllerConnector
55 //====================================================================
56 /** a helper class for controllers associated with an ->XModel
58 Instances of this class take an ->XModel, which they connect to at
59 construction time (->XModel::connectController), and disconnect from
60 at destruction time (->XModel::disconnectController).
62 Additionally, they keep the controller alive (by being a CloseVetoListener)
63 as long as they themself are alive.
65 class DBACCESS_DLLPUBLIC ModelControllerConnector
67 private:
68 typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > Model;
69 typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > Controller;
71 Model m_xModel;
72 Controller m_xController;
74 public:
75 /** constructs the object, and connects the controller to the model
77 @param _rxModel
78 the model to which the controller should be connected
79 @param _rxController
80 the controller which should be connected to the model
82 ModelControllerConnector(
83 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxModel,
84 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
87 /** connects the controller to the model
89 @param _rxModel
90 the model to which the controller should be connected
91 @param _rxController
92 the controller which should be connected to the model
94 void connect(
95 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxModel,
96 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
99 /** destroys the object, and disconnects the controller from the model
101 ~ModelControllerConnector();
103 /** determines whether the object is empty
105 inline bool empty() const { return !m_xController.is(); }
107 /** clears the object
109 The controller is disconnected from the model, and references to the model and the controller
110 are released.
112 inline void clear()
114 connect( NULL, NULL );
117 public:
118 ModelControllerConnector();
119 ModelControllerConnector( const ModelControllerConnector& _rSource );
120 ModelControllerConnector& operator=( const ModelControllerConnector& _rSource );
122 private:
123 void impl_connect();
124 void impl_disconnect();
125 void impl_copyFrom( const ModelControllerConnector& _rSource );
128 //........................................................................
129 } // namespace dbaui
130 //........................................................................
132 #endif // DBACCESS_SOURCE_UI_INC_DOCUMENTCONTROLLER_HXX