1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
30 #define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
32 /** === begin UNO includes === **/
33 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
34 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
35 #include <com/sun/star/frame/XController.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
39 /** === end UNO includes === **/
41 #include <connectivity/dbtools.hxx>
42 #include <tools/link.hxx>
43 #include <cppuhelper/implbase1.hxx>
44 #include <rtl/ref.hxx>
46 //........................................................................
49 //........................................................................
51 class ISQLCommandAdapter
;
52 //====================================================================
53 //= SQLCommandDesigner
54 //====================================================================
55 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::beans::XPropertyChangeListener
56 > SQLCommandDesigner_Base
;
57 /** encapsulates the code for calling and managing a query design frame, used
58 for interactively designing the Command property of a ->RowSet
60 class SQLCommandDesigner
: public SQLCommandDesigner_Base
63 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiComponentFactory
> m_xORB
;
65 ::dbtools::SharedConnection m_xConnection
;
66 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> m_xDesigner
;
67 ::rtl::Reference
< ISQLCommandAdapter
> m_xObjectAdapter
;
71 /** creates the instance, and immediately opens the SQL command design frame
74 our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
75 @param _rxPropertyAdapter
76 an adapter to the object's SQL command related properties
78 the current connection of ->_rxRowSet. Must not be <NULL/>.
80 link to call when the component has been closed
81 @throws ::com::sun::star::lang::NullPointerException
82 if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
83 does not provide a valid component factory.
86 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
87 const ::rtl::Reference
< ISQLCommandAdapter
>& _rxPropertyAdapter
,
88 const ::dbtools::SharedConnection
& _rConnection
,
89 const Link
& _rCloseLink
92 /** determines whether the SQL Command designer is currently active, i.e.
93 if there currently exists a frame which allows the user entering the SQL command
95 inline bool isActive() const { return m_xDesigner
.is(); }
97 /** returns the property adapter used by the instance
99 inline const ::rtl::Reference
< ISQLCommandAdapter
>& getPropertyAdapter() const { return m_xObjectAdapter
; }
101 /** raises the designer window to top
103 the designer is active (->isActive)
105 the instance is not disposed
109 /** suspends the designer
111 the designer is active (->isActive)
113 the instance is not disposed
115 bool suspend() const;
117 /** disposes the instance so that it becomes non-functional
122 // XPropertyChangeListener
123 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw (::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
129 ~SQLCommandDesigner();
131 /** opens a new frame for interactively designing an SQL command
133 the designer is not currently active (see ->isActive)
135 ->m_xConnection is not <NULL/>
137 void impl_doOpenDesignerFrame_nothrow();
139 /** impl-version of ->raise
141 void impl_raise_nothrow() const;
143 /** determines whether we are already disposed
145 bool impl_isDisposed() const
147 return !m_xContext
.is();
149 /** checks whether we are already disposed
150 @throws ::com::sun::star::lang::DisposedException
151 if we in fact are disposed
153 void impl_checkDisposed_throw() const;
155 /** create an empty top-level frame, which does not belong to the desktop's frame list
157 ->m_xORB is not <NULL/>
159 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>
160 impl_createEmptyParentlessTask_nothrow() const;
162 /** called whenever the component denoted by m_xDesigner has been closed
163 <em>by an external instance</em>
165 void impl_designerClosed_nothrow();
167 /** closes the component denoted by m_xDesigner
169 our designer component is actually active (->isActive)
171 we're not disposed already
173 void impl_closeDesigner_nothrow();
175 /** suspends our designer component
177 the designer component is actually active (->isActive)
179 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
181 bool impl_trySuspendDesigner_nothrow() const;
183 /** gets the current value of the command property
186 impl_getCommandPropertyValue_nothrow();
188 /** sets anew value for the command property
190 void impl_setCommandPropertyValue_nothrow( const ::rtl::OUString
& _rCommand
) const;
193 SQLCommandDesigner(); // never implemented
194 SQLCommandDesigner( const SQLCommandDesigner
& ); // never implemented
195 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ); // never implemented
198 //====================================================================
199 //= ISQLCommandAdapter
200 //====================================================================
201 /** an adapter to forward changed SQL command property values to a component
203 class ISQLCommandAdapter
: public ::rtl::IReference
206 /// retrieves the current SQL command of the component
207 virtual ::rtl::OUString
getSQLCommand() const = 0;
208 /// retrieves the current value of the EscapeProcessing property of the component
209 virtual sal_Bool
getEscapeProcessing() const = 0;
211 /// sets a new SQL command
212 virtual void setSQLCommand( const ::rtl::OUString
& _rCommand
) const = 0;
213 /// sets a new EscapeProcessing property value
214 virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing
) const = 0;
216 virtual ~ISQLCommandAdapter();
219 //........................................................................
221 //........................................................................
223 #endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */