1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
21 #define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
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>
30 #include <connectivity/dbtools.hxx>
31 #include <tools/link.hxx>
32 #include <cppuhelper/implbase1.hxx>
33 #include <rtl/ref.hxx>
35 //........................................................................
38 //........................................................................
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
49 class SQLCommandDesigner
: public SQLCommandDesigner_Base
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
;
60 /** creates the instance, and immediately opens the SQL command design frame
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
67 the current connection of ->_rxRowSet. Must not be <NULL/>.
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.
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
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
84 inline bool isActive() const { return m_xDesigner
.is(); }
86 /** returns the property adapter used by the instance
88 inline const ::rtl::Reference
< ISQLCommandAdapter
>& getPropertyAdapter() const { return m_xObjectAdapter
; }
90 /** raises the designer window to top
92 the designer is active (->isActive)
94 the instance is not disposed
98 /** suspends the designer
100 the designer is active (->isActive)
102 the instance is not disposed
104 bool suspend() const;
106 /** disposes the instance so that it becomes non-functional
111 // XPropertyChangeListener
112 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw (::com::sun::star::uno::RuntimeException
);
115 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
118 ~SQLCommandDesigner();
120 /** opens a new frame for interactively designing an SQL command
122 the designer is not currently active (see ->isActive)
124 ->m_xConnection is not <NULL/>
126 void impl_doOpenDesignerFrame_nothrow();
128 /** impl-version of ->raise
130 void impl_raise_nothrow() const;
132 /** determines whether we are already disposed
134 bool impl_isDisposed() const
136 return !m_xContext
.is();
138 /** checks whether we are already disposed
139 @throws ::com::sun::star::lang::DisposedException
140 if we in fact are disposed
142 void impl_checkDisposed_throw() const;
144 /** create an empty top-level frame, which does not belong to the desktop's frame list
146 ->m_xORB is not <NULL/>
148 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>
149 impl_createEmptyParentlessTask_nothrow() const;
151 /** called whenever the component denoted by m_xDesigner has been closed
152 <em>by an external instance</em>
154 void impl_designerClosed_nothrow();
156 /** closes the component denoted by m_xDesigner
158 our designer component is actually active (->isActive)
160 we're not disposed already
162 void impl_closeDesigner_nothrow();
164 /** suspends our designer component
166 the designer component is actually active (->isActive)
168 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
170 bool impl_trySuspendDesigner_nothrow() const;
172 /** gets the current value of the command property
175 impl_getCommandPropertyValue_nothrow();
177 /** sets anew value for the command property
179 void impl_setCommandPropertyValue_nothrow( const OUString
& _rCommand
) const;
182 SQLCommandDesigner(); // never implemented
183 SQLCommandDesigner( const SQLCommandDesigner
& ); // never implemented
184 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ); // never implemented
187 //====================================================================
188 //= ISQLCommandAdapter
189 //====================================================================
190 /** an adapter to forward changed SQL command property values to a component
192 class ISQLCommandAdapter
: public ::rtl::IReference
195 /// retrieves the current SQL command of the component
196 virtual OUString
getSQLCommand() const = 0;
197 /// retrieves the current value of the EscapeProcessing property of the component
198 virtual sal_Bool
getEscapeProcessing() const = 0;
200 /// sets a new SQL command
201 virtual void setSQLCommand( const OUString
& _rCommand
) const = 0;
202 /// sets a new EscapeProcessing property value
203 virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing
) const = 0;
205 virtual ~ISQLCommandAdapter();
208 //........................................................................
210 //........................................................................
212 #endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */