Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DATABASEOBJECTVIEW_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_DATABASEOBJECTVIEW_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 : #include <com/sun/star/sdbc/XConnection.hpp>
25 : #include <com/sun/star/sdbc/XDataSource.hpp>
26 : #include <com/sun/star/frame/XDispatch.hpp>
27 : #include <com/sun/star/lang/XComponent.hpp>
28 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 : #include <com/sun/star/frame/XComponentLoader.hpp>
30 : #include <com/sun/star/frame/XFrame.hpp>
31 : #include <com/sun/star/beans/PropertyValue.hpp>
32 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
33 : #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
34 : #include <com/sun/star/uno/Sequence.hxx>
35 : #include <com/sun/star/uno/XComponentContext.hpp>
36 : #include <comphelper/namedvaluecollection.hxx>
37 :
38 : #include <boost/shared_ptr.hpp>
39 :
40 : namespace dbaui
41 : {
42 : /** encapsulates access to the view of a database object.
43 :
44 : @todo
45 : this is to be merged with the OLinkedDocumentAccess class
46 : */
47 : class DatabaseObjectView
48 : {
49 : private:
50 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
51 : m_xORB;
52 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
53 : m_xParentFrame;
54 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XComponentLoader >
55 : m_xFrameLoader;
56 : ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
57 : m_xApplication;
58 : OUString m_sComponentURL;
59 :
60 : private:
61 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
62 : doDispatch(
63 : const ::comphelper::NamedValueCollection& i_rDispatchArgs
64 : );
65 :
66 : protected:
67 : /** creates the desired view
68 :
69 : The default implementation will call <member>fillDispatchArgs</member>, followed
70 : by <member>doDispatch</member>.
71 :
72 : @param _rDataSource
73 : the data source, as passed to the <member>createNew</member> or <member>openExisting</member> method.
74 : @param _rObjectName
75 : the name of the object for which the view is to be opened,
76 : or an empty string if a view for a new object should be created.
77 : @param _rCreationArgs
78 : the arguments for the view's creation
79 : */
80 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView(
81 : const ::com::sun::star::uno::Any& _rDataSource,
82 : const OUString& _rObjectName,
83 : const ::comphelper::NamedValueCollection& i_rCreationArgs
84 : );
85 :
86 : virtual void fillDispatchArgs(
87 : ::comphelper::NamedValueCollection& i_rDispatchArgs,
88 : const ::com::sun::star::uno::Any& _rDataSource,
89 : const OUString& _rObjectName
90 : );
91 :
92 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >&
93 0 : getApplicationUI() const { return m_xApplication; }
94 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
95 : getConnection() const;
96 :
97 : public:
98 : DatabaseObjectView(
99 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
100 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
101 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
102 : const OUString& _rComponentURL
103 : );
104 0 : virtual ~DatabaseObjectView(){}
105 :
106 : /** sets the target frame into which the view should be loaded.
107 :
108 : By default, the view is loaded into a top-level frame not being part of the
109 : Desktop.
110 : */
111 0 : void setTargetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame )
112 : {
113 0 : m_xFrameLoader.set( _rxFrame, ::com::sun::star::uno::UNO_QUERY );
114 0 : }
115 :
116 : /** opens a view for a to-be-created object
117 :
118 : @param _xDataSource
119 : the data source for which a new object is to be created
120 : @return
121 : the controller of the newly created document
122 : */
123 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
124 : createNew(
125 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _xDataSource,
126 : const ::comphelper::NamedValueCollection& i_rDispatchArgs = ::comphelper::NamedValueCollection()
127 : );
128 :
129 : /** opens a view for an existent object
130 :
131 : @param _xDataSource
132 : the data source for which a new object is to be created
133 : @param _rObjectName
134 : the name of the object to be edited
135 : @param _rArgs
136 : Additional settings which should be forwarded to the frame
137 : @return
138 : the frame into which the view has been loaded
139 : */
140 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
141 : openExisting(
142 : const ::com::sun::star::uno::Any& _aDataSource,
143 : const OUString& _rName,
144 : const ::comphelper::NamedValueCollection& i_rDispatchArgs
145 : );
146 : };
147 :
148 : // QueryDesigner
149 0 : class QueryDesigner : public DatabaseObjectView
150 : {
151 : protected:
152 : sal_Int32 m_nCommandType;
153 :
154 : protected:
155 : virtual void fillDispatchArgs(
156 : ::comphelper::NamedValueCollection& i_rDispatchArgs,
157 : const ::com::sun::star::uno::Any& _aDataSource,
158 : const OUString& _rObjectName
159 : ) SAL_OVERRIDE;
160 :
161 : public:
162 : QueryDesigner(
163 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
164 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
165 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
166 : bool _bCreateView
167 : );
168 : };
169 :
170 : // TableDesigner
171 0 : class TableDesigner : public DatabaseObjectView
172 : {
173 : protected:
174 : virtual void fillDispatchArgs(
175 : ::comphelper::NamedValueCollection& i_rDispatchArgs,
176 : const ::com::sun::star::uno::Any& _aDataSource,
177 : const OUString& _rObjectName
178 : ) SAL_OVERRIDE;
179 :
180 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView(
181 : const ::com::sun::star::uno::Any& _rDataSource,
182 : const OUString& _rObjectName,
183 : const ::comphelper::NamedValueCollection& i_rCreationArgs
184 : ) SAL_OVERRIDE;
185 :
186 : public:
187 : TableDesigner(
188 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
189 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
190 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame
191 : );
192 :
193 : private:
194 : /** retrieves the table designer component as provided by the connection, if any
195 : @param _rTableName
196 : the name of the table for which a designer is to be obtained
197 : @return
198 : the designer component, as provided by the connection, or <NULL/>, if the connection
199 : does not provide a specialized designer.
200 : @see com::sun::star::sdb::application::XTableUIProvider
201 : */
202 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
203 : impl_getConnectionProvidedDesigner_nothrow( const OUString& _rTableName );
204 : };
205 :
206 : // ResultSetBrowser
207 0 : class ResultSetBrowser : public DatabaseObjectView
208 : {
209 : private:
210 : sal_Bool m_bTable;
211 :
212 : protected:
213 : virtual void fillDispatchArgs(
214 : ::comphelper::NamedValueCollection& i_rDispatchArgs,
215 : const ::com::sun::star::uno::Any& _aDataSource,
216 : const OUString& _rQualifiedName
217 : ) SAL_OVERRIDE;
218 :
219 : public:
220 : ResultSetBrowser(
221 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
222 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
223 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
224 : sal_Bool _bTable
225 : );
226 :
227 : };
228 : // RelationDesigner
229 0 : class RelationDesigner : public DatabaseObjectView
230 : {
231 : public:
232 : RelationDesigner(
233 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
234 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
235 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame
236 : );
237 : };
238 : } // namespace dbaui
239 :
240 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DATABASEOBJECTVIEW_HXX
241 :
242 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|