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>
29 #include <connectivity/dbtools.hxx>
30 #include <tools/link.hxx>
31 #include <cppuhelper/implbase.hxx>
32 #include <rtl/ref.hxx>
33 #include <salhelper/simplereferenceobject.hxx>
40 class ISQLCommandAdapter
;
42 //= SQLCommandDesigner
44 typedef ::cppu::WeakImplHelper
< css::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 final
: public SQLCommandDesigner_Base
52 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
53 css::uno::Reference
< css::lang::XMultiComponentFactory
> m_xORB
;
54 ::dbtools::SharedConnection m_xConnection
;
55 css::uno::Reference
< css::frame::XController
> m_xDesigner
;
56 ::rtl::Reference
< ISQLCommandAdapter
> m_xObjectAdapter
;
57 Link
<SQLCommandDesigner
&,void> m_aCloseLink
;
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 css::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 css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
,
76 const ::rtl::Reference
< ISQLCommandAdapter
>& _rxPropertyAdapter
,
77 const ::dbtools::SharedConnection
& _rConnection
,
78 const Link
<SQLCommandDesigner
&,void>& _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 bool isActive() const { return m_xDesigner
.is(); }
86 /** returns the property adapter used by the instance
88 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 css::beans::PropertyChangeEvent
& evt
) override
;
115 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
117 virtual ~SQLCommandDesigner() override
;
119 /** opens a new frame for interactively designing an SQL command
121 the designer is not currently active (see ->isActive)
123 ->m_xConnection is not <NULL/>
125 void impl_doOpenDesignerFrame_nothrow();
127 /** impl-version of ->raise
129 void impl_raise_nothrow() const;
131 /** determines whether we are already disposed
133 bool impl_isDisposed() const
135 return !m_xContext
.is();
137 /** checks whether we are already disposed
138 @throws css::lang::DisposedException
139 if we in fact are disposed
141 void impl_checkDisposed_throw() const;
143 /** create an empty top-level frame, which does not belong to the desktop's frame list
145 ->m_xORB is not <NULL/>
147 css::uno::Reference
< css::frame::XFrame
>
148 impl_createEmptyParentlessTask_nothrow() const;
150 /** closes the component denoted by m_xDesigner
152 our designer component is actually active (->isActive)
154 we're not disposed already
156 void impl_closeDesigner_nothrow();
158 /** suspends our designer component
160 the designer component is actually active (->isActive)
162 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
164 bool impl_trySuspendDesigner_nothrow() const;
166 SQLCommandDesigner( const SQLCommandDesigner
& ) = delete;
167 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ) = delete;
171 //= ISQLCommandAdapter
173 /** an adapter to forward changed SQL command property values to a component
175 class ISQLCommandAdapter
: public salhelper::SimpleReferenceObject
178 /// retrieves the current SQL command of the component
179 virtual OUString
getSQLCommand() const = 0;
180 /// retrieves the current value of the EscapeProcessing property of the component
181 virtual bool getEscapeProcessing() const = 0;
183 /// sets a new SQL command
184 virtual void setSQLCommand( const OUString
& _rCommand
) const = 0;
185 /// sets a new EscapeProcessing property value
186 virtual void setEscapeProcessing( const bool _bEscapeProcessing
) const = 0;
188 virtual ~ISQLCommandAdapter() override
;
195 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */