Update ooo320-m1
[ooovba.git] / extensions / source / propctrlr / sqlcommanddesign.hxx
blobdcc1dfcb580d51c6aaea5b20adfbd6c477878a2d
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: sqlcommanddesign.hxx,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
32 #define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
36 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
37 #include <com/sun/star/frame/XController.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
41 /** === end UNO includes === **/
43 #include <connectivity/dbtools.hxx>
44 #include <tools/link.hxx>
45 #include <cppuhelper/implbase1.hxx>
46 #include <rtl/ref.hxx>
48 //........................................................................
49 namespace pcr
51 //........................................................................
53 class ISQLCommandAdapter;
54 //====================================================================
55 //= SQLCommandDesigner
56 //====================================================================
57 typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
58 > SQLCommandDesigner_Base;
59 /** encapsulates the code for calling and managing a query design frame, used
60 for interactively designing the Command property of a ->RowSet
62 class SQLCommandDesigner : public SQLCommandDesigner_Base
64 private:
65 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
66 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
67 ::dbtools::SharedConnection m_xConnection;
68 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xDesigner;
69 ::rtl::Reference< ISQLCommandAdapter > m_xObjectAdapter;
70 Link m_aCloseLink;
72 public:
73 /** creates the instance, and immediately opens the SQL command design frame
75 @param _rxContext
76 our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
77 @param _rxPropertyAdapter
78 an adapter to the object's SQL command related properties
79 @param _rConnection
80 the current connection of ->_rxRowSet. Must not be <NULL/>.
81 @param _rCloseLink
82 link to call when the component has been closed
83 @throws ::com::sun::star::lang::NullPointerException
84 if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
85 does not provide a valid component factory.
87 SQLCommandDesigner(
88 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
89 const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
90 const ::dbtools::SharedConnection& _rConnection,
91 const Link& _rCloseLink
94 /** determines whether the SQL Command designer is currently active, i.e.
95 if there currently exists a frame which allows the user entering the SQL command
97 inline bool isActive() const { return m_xDesigner.is(); }
99 /** returns the property adapter used by the instance
101 inline const ::rtl::Reference< ISQLCommandAdapter >& getPropertyAdapter() const { return m_xObjectAdapter; }
103 /** raises the designer window to top
104 @precond
105 the designer is active (->isActive)
106 @precond
107 the instance is not disposed
109 void raise() const;
111 /** suspends the designer
112 @precond
113 the designer is active (->isActive)
114 @precond
115 the instance is not disposed
117 bool suspend() const;
119 /** disposes the instance so that it becomes non-functional
121 void dispose();
123 protected:
124 // XPropertyChangeListener
125 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
127 // XEventListener
128 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
130 protected:
131 ~SQLCommandDesigner();
133 /** opens a new frame for interactively designing an SQL command
134 @precond
135 the designer is not currently active (see ->isActive)
136 @precond
137 ->m_xConnection is not <NULL/>
139 void impl_doOpenDesignerFrame_nothrow();
141 /** impl-version of ->raise
143 void impl_raise_nothrow() const;
145 /** determines whether we are already disposed
147 bool impl_isDisposed() const
149 return !m_xContext.is();
151 /** checks whether we are already disposed
152 @throws ::com::sun::star::lang::DisposedException
153 if we in fact are disposed
155 void impl_checkDisposed_throw() const;
157 /** create an empty top-level frame, which does not belong to the desktop's frame list
158 @precond
159 ->m_xORB is not <NULL/>
161 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
162 impl_createEmptyParentlessTask_nothrow() const;
164 /** called whenever the component denoted by m_xDesigner has been closed
165 <em>by an external instance</em>
167 void impl_designerClosed_nothrow();
169 /** closes the component denoted by m_xDesigner
170 @precond
171 our designer component is actually active (->isActive)
172 @precond
173 we're not disposed already
175 void impl_closeDesigner_nothrow();
177 /** suspends our designer component
178 @precond
179 the designer component is actually active (->isActive)
180 @return
181 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
183 bool impl_trySuspendDesigner_nothrow() const;
185 /** gets the current value of the command property
187 ::rtl::OUString
188 impl_getCommandPropertyValue_nothrow();
190 /** sets anew value for the command property
192 void impl_setCommandPropertyValue_nothrow( const ::rtl::OUString& _rCommand ) const;
194 private:
195 SQLCommandDesigner(); // never implemented
196 SQLCommandDesigner( const SQLCommandDesigner& ); // never implemented
197 SQLCommandDesigner& operator=( const SQLCommandDesigner& ); // never implemented
200 //====================================================================
201 //= ISQLCommandAdapter
202 //====================================================================
203 /** an adapter to forward changed SQL command property values to a component
205 class ISQLCommandAdapter : public ::rtl::IReference
207 public:
208 /// retrieves the current SQL command of the component
209 virtual ::rtl::OUString getSQLCommand() const = 0;
210 /// retrieves the current value of the EscapeProcessing property of the component
211 virtual sal_Bool getEscapeProcessing() const = 0;
213 /// sets a new SQL command
214 virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const = 0;
215 /// sets a new EscapeProcessing property value
216 virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const = 0;
218 virtual ~ISQLCommandAdapter();
221 //........................................................................
222 } // namespace pcr
223 //........................................................................
225 #endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX