Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
21 : : #define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
22 : :
23 : : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
24 : : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
25 : : #include <com/sun/star/frame/XController.hpp>
26 : : #include <com/sun/star/beans/XPropertySet.hpp>
27 : : #include <com/sun/star/uno/XComponentContext.hpp>
28 : : #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
29 : :
30 : : #include <connectivity/dbtools.hxx>
31 : : #include <tools/link.hxx>
32 : : #include <cppuhelper/implbase1.hxx>
33 : : #include <rtl/ref.hxx>
34 : :
35 : : //........................................................................
36 : : namespace pcr
37 : : {
38 : : //........................................................................
39 : :
40 : : class ISQLCommandAdapter;
41 : : //====================================================================
42 : : //= SQLCommandDesigner
43 : : //====================================================================
44 : : typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
45 : : > SQLCommandDesigner_Base;
46 : : /** encapsulates the code for calling and managing a query design frame, used
47 : : for interactively designing the Command property of a ->RowSet
48 : : */
49 : : class SQLCommandDesigner : public SQLCommandDesigner_Base
50 : : {
51 : : private:
52 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
53 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
54 : : ::dbtools::SharedConnection m_xConnection;
55 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xDesigner;
56 : : ::rtl::Reference< ISQLCommandAdapter > m_xObjectAdapter;
57 : : Link m_aCloseLink;
58 : :
59 : : public:
60 : : /** creates the instance, and immediately opens the SQL command design frame
61 : :
62 : : @param _rxContext
63 : : our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
64 : : @param _rxPropertyAdapter
65 : : an adapter to the object's SQL command related properties
66 : : @param _rConnection
67 : : the current connection of ->_rxRowSet. Must not be <NULL/>.
68 : : @param _rCloseLink
69 : : link to call when the component has been closed
70 : : @throws ::com::sun::star::lang::NullPointerException
71 : : if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
72 : : does not provide a valid component factory.
73 : : */
74 : : SQLCommandDesigner(
75 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
76 : : const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
77 : : const ::dbtools::SharedConnection& _rConnection,
78 : : const Link& _rCloseLink
79 : : );
80 : :
81 : : /** determines whether the SQL Command designer is currently active, i.e.
82 : : if there currently exists a frame which allows the user entering the SQL command
83 : : */
84 : 0 : inline bool isActive() const { return m_xDesigner.is(); }
85 : :
86 : : /** returns the property adapter used by the instance
87 : : */
88 : 0 : inline const ::rtl::Reference< ISQLCommandAdapter >& getPropertyAdapter() const { return m_xObjectAdapter; }
89 : :
90 : : /** raises the designer window to top
91 : : @precond
92 : : the designer is active (->isActive)
93 : : @precond
94 : : the instance is not disposed
95 : : */
96 : : void raise() const;
97 : :
98 : : /** suspends the designer
99 : : @precond
100 : : the designer is active (->isActive)
101 : : @precond
102 : : the instance is not disposed
103 : : */
104 : : bool suspend() const;
105 : :
106 : : /** disposes the instance so that it becomes non-functional
107 : : */
108 : : void dispose();
109 : :
110 : : protected:
111 : : // XPropertyChangeListener
112 : : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
113 : :
114 : : // XEventListener
115 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
116 : :
117 : : protected:
118 : : ~SQLCommandDesigner();
119 : :
120 : : /** opens a new frame for interactively designing an SQL command
121 : : @precond
122 : : the designer is not currently active (see ->isActive)
123 : : @precond
124 : : ->m_xConnection is not <NULL/>
125 : : */
126 : : void impl_doOpenDesignerFrame_nothrow();
127 : :
128 : : /** impl-version of ->raise
129 : : */
130 : : void impl_raise_nothrow() const;
131 : :
132 : : /** determines whether we are already disposed
133 : : */
134 : 0 : bool impl_isDisposed() const
135 : : {
136 : 0 : return !m_xContext.is();
137 : : }
138 : : /** checks whether we are already disposed
139 : : @throws ::com::sun::star::lang::DisposedException
140 : : if we in fact are disposed
141 : : */
142 : : void impl_checkDisposed_throw() const;
143 : :
144 : : /** create an empty top-level frame, which does not belong to the desktop's frame list
145 : : @precond
146 : : ->m_xORB is not <NULL/>
147 : : */
148 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
149 : : impl_createEmptyParentlessTask_nothrow() const;
150 : :
151 : : /** called whenever the component denoted by m_xDesigner has been closed
152 : : <em>by an external instance</em>
153 : : */
154 : : void impl_designerClosed_nothrow();
155 : :
156 : : /** closes the component denoted by m_xDesigner
157 : : @precond
158 : : our designer component is actually active (->isActive)
159 : : @precond
160 : : we're not disposed already
161 : : */
162 : : void impl_closeDesigner_nothrow();
163 : :
164 : : /** suspends our designer component
165 : : @precond
166 : : the designer component is actually active (->isActive)
167 : : @return
168 : : <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
169 : : */
170 : : bool impl_trySuspendDesigner_nothrow() const;
171 : :
172 : : /** gets the current value of the command property
173 : : */
174 : : ::rtl::OUString
175 : : impl_getCommandPropertyValue_nothrow();
176 : :
177 : : /** sets anew value for the command property
178 : : */
179 : : void impl_setCommandPropertyValue_nothrow( const ::rtl::OUString& _rCommand ) const;
180 : :
181 : : private:
182 : : SQLCommandDesigner(); // never implemented
183 : : SQLCommandDesigner( const SQLCommandDesigner& ); // never implemented
184 : : SQLCommandDesigner& operator=( const SQLCommandDesigner& ); // never implemented
185 : : };
186 : :
187 : : //====================================================================
188 : : //= ISQLCommandAdapter
189 : : //====================================================================
190 : : /** an adapter to forward changed SQL command property values to a component
191 : : */
192 : 0 : class ISQLCommandAdapter : public ::rtl::IReference
193 : : {
194 : : public:
195 : : /// retrieves the current SQL command of the component
196 : : virtual ::rtl::OUString getSQLCommand() const = 0;
197 : : /// retrieves the current value of the EscapeProcessing property of the component
198 : : virtual sal_Bool getEscapeProcessing() const = 0;
199 : :
200 : : /// sets a new SQL command
201 : : virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const = 0;
202 : : /// sets a new EscapeProcessing property value
203 : : virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const = 0;
204 : :
205 : : virtual ~ISQLCommandAdapter();
206 : : };
207 : :
208 : : //........................................................................
209 : : } // namespace pcr
210 : : //........................................................................
211 : :
212 : : #endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
213 : :
214 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|