1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
39 #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
40 #include <com/sun/star/frame/XModel.hpp>
42 #include <cppuhelper/weakref.hxx>
43 /** === end UNO includes === **/
45 #ifndef INCLUDED_DBACCESSDLLAPI_H
46 #include "dbaccessdllapi.h"
48 //........................................................................
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
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
;
72 Controller m_xController
;
75 /** constructs the object, and connects the controller to the model
78 the model to which the controller should be connected
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
90 the model to which the controller should be connected
92 the controller which should be connected to the model
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
114 connect( NULL
, NULL
);
118 ModelControllerConnector();
119 ModelControllerConnector( const ModelControllerConnector
& _rSource
);
120 ModelControllerConnector
& operator=( const ModelControllerConnector
& _rSource
);
124 void impl_disconnect();
125 void impl_copyFrom( const ModelControllerConnector
& _rSource
);
128 //........................................................................
130 //........................................................................
132 #endif // DBACCESS_SOURCE_UI_INC_DOCUMENTCONTROLLER_HXX