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 INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
21 #define INCLUDED_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>
34 #include <salhelper/simplereferenceobject.hxx>
41 class ISQLCommandAdapter
;
43 //= SQLCommandDesigner
45 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::beans::XPropertyChangeListener
46 > SQLCommandDesigner_Base
;
47 /** encapsulates the code for calling and managing a query design frame, used
48 for interactively designing the Command property of a ->RowSet
50 class SQLCommandDesigner
: public SQLCommandDesigner_Base
53 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
54 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiComponentFactory
> m_xORB
;
55 ::dbtools::SharedConnection m_xConnection
;
56 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> m_xDesigner
;
57 ::rtl::Reference
< ISQLCommandAdapter
> m_xObjectAdapter
;
61 /** creates the instance, and immediately opens the SQL command design frame
64 our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
65 @param _rxPropertyAdapter
66 an adapter to the object's SQL command related properties
68 the current connection of ->_rxRowSet. Must not be <NULL/>.
70 link to call when the component has been closed
71 @throws ::com::sun::star::lang::NullPointerException
72 if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
73 does not provide a valid component factory.
76 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
77 const ::rtl::Reference
< ISQLCommandAdapter
>& _rxPropertyAdapter
,
78 const ::dbtools::SharedConnection
& _rConnection
,
79 const Link
<>& _rCloseLink
82 /** determines whether the SQL Command designer is currently active, i.e.
83 if there currently exists a frame which allows the user entering the SQL command
85 inline bool isActive() const { return m_xDesigner
.is(); }
87 /** returns the property adapter used by the instance
89 inline const ::rtl::Reference
< ISQLCommandAdapter
>& getPropertyAdapter() const { return m_xObjectAdapter
; }
91 /** raises the designer window to top
93 the designer is active (->isActive)
95 the instance is not disposed
99 /** suspends the designer
101 the designer is active (->isActive)
103 the instance is not disposed
105 bool suspend() const;
107 /** disposes the instance so that it becomes non-functional
112 // XPropertyChangeListener
113 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
116 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual ~SQLCommandDesigner();
121 /** opens a new frame for interactively designing an SQL command
123 the designer is not currently active (see ->isActive)
125 ->m_xConnection is not <NULL/>
127 void impl_doOpenDesignerFrame_nothrow();
129 /** impl-version of ->raise
131 void impl_raise_nothrow() const;
133 /** determines whether we are already disposed
135 bool impl_isDisposed() const
137 return !m_xContext
.is();
139 /** checks whether we are already disposed
140 @throws ::com::sun::star::lang::DisposedException
141 if we in fact are disposed
143 void impl_checkDisposed_throw() const;
145 /** create an empty top-level frame, which does not belong to the desktop's frame list
147 ->m_xORB is not <NULL/>
149 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>
150 impl_createEmptyParentlessTask_nothrow() const;
152 /** called whenever the component denoted by m_xDesigner has been closed
153 <em>by an external instance</em>
155 void impl_designerClosed_nothrow();
157 /** closes the component denoted by m_xDesigner
159 our designer component is actually active (->isActive)
161 we're not disposed already
163 void impl_closeDesigner_nothrow();
165 /** suspends our designer component
167 the designer component is actually active (->isActive)
169 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
171 bool impl_trySuspendDesigner_nothrow() const;
173 /** gets the current value of the command property
176 impl_getCommandPropertyValue_nothrow();
178 /** sets anew value for the command property
180 void impl_setCommandPropertyValue_nothrow( const OUString
& _rCommand
) const;
183 SQLCommandDesigner( const SQLCommandDesigner
& ) SAL_DELETED_FUNCTION
;
184 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ) SAL_DELETED_FUNCTION
;
188 //= ISQLCommandAdapter
190 /** an adapter to forward changed SQL command property values to a component
192 class ISQLCommandAdapter
: public salhelper::SimpleReferenceObject
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 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 bool _bEscapeProcessing
) const = 0;
205 virtual ~ISQLCommandAdapter();
212 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */