tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / extensions / source / propctrlr / sqlcommanddesign.hxx
blob767506eca7bf503090815b74a83454c81a925c22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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>
34 namespace pcr
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
49 private:
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;
57 public:
58 /** creates the instance, and immediately opens the SQL command design frame
60 @param _rxContext
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
64 @param _rConnection
65 the current connection of ->_rxRowSet. Must not be <NULL/>.
66 @param _rCloseLink
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.
72 SQLCommandDesigner(
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
89 @precond
90 the designer is active (->isActive)
91 @precond
92 the instance is not disposed
94 void raise() const;
96 /** suspends the designer
97 @precond
98 the designer is active (->isActive)
99 @precond
100 the instance is not disposed
102 bool suspend() const;
104 /** disposes the instance so that it becomes non-functional
106 void dispose();
108 private:
109 // XPropertyChangeListener
110 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
112 // XEventListener
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
118 @precond
119 the designer is not currently active (see ->isActive)
120 @precond
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
142 @precond
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
149 @precond
150 our designer component is actually active (->isActive)
151 @precond
152 we're not disposed already
154 void impl_closeDesigner_nothrow();
156 /** suspends our designer component
157 @precond
158 the designer component is actually active (->isActive)
159 @return
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
175 public:
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;
190 } // namespace pcr
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */