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 .
22 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
23 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
24 #include <com/sun/star/frame/XController.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <connectivity/dbtools.hxx>
28 #include <tools/link.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <rtl/ref.hxx>
31 #include <salhelper/simplereferenceobject.hxx>
38 class ISQLCommandAdapter
;
40 //= SQLCommandDesigner
42 typedef ::cppu::WeakImplHelper
< css::beans::XPropertyChangeListener
43 > SQLCommandDesigner_Base
;
44 /** encapsulates the code for calling and managing a query design frame, used
45 for interactively designing the Command property of a ->RowSet
47 class SQLCommandDesigner final
: public SQLCommandDesigner_Base
50 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
51 css::uno::Reference
< css::lang::XMultiComponentFactory
> m_xORB
;
52 ::dbtools::SharedConnection m_xConnection
;
53 css::uno::Reference
< css::frame::XController
> m_xDesigner
;
54 ::rtl::Reference
< ISQLCommandAdapter
> m_xObjectAdapter
;
55 Link
<SQLCommandDesigner
&,void> m_aCloseLink
;
58 /** creates the instance, and immediately opens the SQL command design frame
61 our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
62 @param _rxPropertyAdapter
63 an adapter to the object's SQL command related properties
65 the current connection of ->_rxRowSet. Must not be <NULL/>.
67 link to call when the component has been closed
68 @throws css::lang::NullPointerException
69 if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
70 does not provide a valid component factory.
73 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
,
74 const ::rtl::Reference
< ISQLCommandAdapter
>& _rxPropertyAdapter
,
75 ::dbtools::SharedConnection _aConnection
,
76 const Link
<SQLCommandDesigner
&,void>& _rCloseLink
79 /** determines whether the SQL Command designer is currently active, i.e.
80 if there currently exists a frame which allows the user entering the SQL command
82 bool isActive() const { return m_xDesigner
.is(); }
84 /** returns the property adapter used by the instance
86 const ::rtl::Reference
< ISQLCommandAdapter
>& getPropertyAdapter() const { return m_xObjectAdapter
; }
88 /** raises the designer window to top
90 the designer is active (->isActive)
92 the instance is not disposed
96 /** suspends the designer
98 the designer is active (->isActive)
100 the instance is not disposed
102 bool suspend() const;
104 /** disposes the instance so that it becomes non-functional
109 // XPropertyChangeListener
110 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
113 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
115 virtual ~SQLCommandDesigner() override
;
117 /** opens a new frame for interactively designing an SQL command
119 the designer is not currently active (see ->isActive)
121 ->m_xConnection is not <NULL/>
123 void impl_doOpenDesignerFrame_nothrow();
125 /** impl-version of ->raise
127 void impl_raise_nothrow() const;
129 /** determines whether we are already disposed
131 bool impl_isDisposed() const
133 return !m_xContext
.is();
135 /** checks whether we are already disposed
136 @throws css::lang::DisposedException
137 if we in fact are disposed
139 void impl_checkDisposed_throw() const;
141 /** create an empty top-level frame, which does not belong to the desktop's frame list
143 ->m_xORB is not <NULL/>
145 css::uno::Reference
< css::frame::XFrame
>
146 impl_createEmptyParentlessTask_nothrow() const;
148 /** closes the component denoted by m_xDesigner
150 our designer component is actually active (->isActive)
152 we're not disposed already
154 void impl_closeDesigner_nothrow();
156 /** suspends our designer component
158 the designer component is actually active (->isActive)
160 <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
162 bool impl_trySuspendDesigner_nothrow() const;
164 SQLCommandDesigner( const SQLCommandDesigner
& ) = delete;
165 SQLCommandDesigner
& operator=( const SQLCommandDesigner
& ) = delete;
169 //= ISQLCommandAdapter
171 /** an adapter to forward changed SQL command property values to a component
173 class ISQLCommandAdapter
: public salhelper::SimpleReferenceObject
176 /// retrieves the current SQL command of the component
177 virtual OUString
getSQLCommand() const = 0;
178 /// retrieves the current value of the EscapeProcessing property of the component
179 virtual bool getEscapeProcessing() const = 0;
181 /// sets a new SQL command
182 virtual void setSQLCommand( const OUString
& _rCommand
) const = 0;
183 /// sets a new EscapeProcessing property value
184 virtual void setEscapeProcessing( const bool _bEscapeProcessing
) const = 0;
186 virtual ~ISQLCommandAdapter() override
;
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */