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/implbase.hxx>
33 #include <rtl/ref.hxx>
34 #include <salhelper/simplereferenceobject.hxx>
41 class ISQLCommandAdapter
;
43 //= SQLCommandDesigner
45 typedef ::cppu::WeakImplHelper
< css::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 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
54 css::uno::Reference
< css::lang::XMultiComponentFactory
> m_xORB
;
55 ::dbtools::SharedConnection m_xConnection
;
56 css::uno::Reference
< css::frame::XController
> m_xDesigner
;
57 ::rtl::Reference
< ISQLCommandAdapter
> m_xObjectAdapter
;
58 Link
<SQLCommandDesigner
&,void> m_aCloseLink
;
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 css::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 css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
,
77 const ::rtl::Reference
< ISQLCommandAdapter
>& _rxPropertyAdapter
,
78 const ::dbtools::SharedConnection
& _rConnection
,
79 const Link
<SQLCommandDesigner
&,void>& _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 bool isActive() const { return m_xDesigner
.is(); }
87 /** returns the property adapter used by the instance
89 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 css::beans::PropertyChangeEvent
& evt
) override
;
116 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
119 virtual ~SQLCommandDesigner() override
;
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 css::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 css::uno::Reference
< css::frame::XFrame
>
150 impl_createEmptyParentlessTask_nothrow() const;
152 /** closes the component denoted by m_xDesigner
154 our designer component is actually active (->isActive)
156 we're not disposed already
158 void impl_closeDesigner_nothrow();
160 /** suspends our designer component
162 the designer component is actually active (->isActive)
164 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
166 bool impl_trySuspendDesigner_nothrow() const;
169 SQLCommandDesigner( const SQLCommandDesigner
& ) = delete;
170 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ) = delete;
174 //= ISQLCommandAdapter
176 /** an adapter to forward changed SQL command property values to a component
178 class ISQLCommandAdapter
: public salhelper::SimpleReferenceObject
181 /// retrieves the current SQL command of the component
182 virtual OUString
getSQLCommand() const = 0;
183 /// retrieves the current value of the EscapeProcessing property of the component
184 virtual bool getEscapeProcessing() const = 0;
186 /// sets a new SQL command
187 virtual void setSQLCommand( const OUString
& _rCommand
) const = 0;
188 /// sets a new EscapeProcessing property value
189 virtual void setEscapeProcessing( const bool _bEscapeProcessing
) const = 0;
191 virtual ~ISQLCommandAdapter() override
;
198 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */