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 <rtl/ustring.hxx>
23 #include <com/sun/star/sdbc/XConnection.hpp>
24 #include <com/sun/star/sdbc/XDataSource.hpp>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/frame/XComponentLoader.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <comphelper/namedvaluecollection.hxx>
34 /** encapsulates access to the view of a database object.
37 this is to be merged with the OLinkedDocumentAccess class
39 class DatabaseObjectView
42 css::uno::Reference
< css::uno::XComponentContext
>
44 css::uno::Reference
< css::frame::XFrame
>
46 css::uno::Reference
< css::frame::XComponentLoader
>
48 css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>
50 OUString m_sComponentURL
;
53 css::uno::Reference
< css::lang::XComponent
>
55 const ::comphelper::NamedValueCollection
& i_rDispatchArgs
59 /** creates the desired view
61 The default implementation will call <member>fillDispatchArgs</member>, followed
62 by <member>doDispatch</member>.
65 the data source, as passed to the <member>createNew</member> or <member>openExisting</member> method.
67 the name of the object for which the view is to be opened,
68 or an empty string if a view for a new object should be created.
70 the arguments for the view's creation
72 virtual css::uno::Reference
< css::lang::XComponent
> doCreateView(
73 const css::uno::Any
& _rDataSource
,
74 const OUString
& _rObjectName
,
75 const ::comphelper::NamedValueCollection
& i_rCreationArgs
78 virtual void fillDispatchArgs(
79 ::comphelper::NamedValueCollection
& i_rDispatchArgs
,
80 const css::uno::Any
& _rDataSource
,
81 const OUString
& _rObjectName
84 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>&
85 getApplicationUI() const { return m_xApplication
; }
86 css::uno::Reference
< css::sdbc::XConnection
>
87 getConnection() const;
91 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
92 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& _rxApplication
,
93 const css::uno::Reference
< css::frame::XFrame
>& _rxParentFrame
,
94 OUString _sComponentURL
96 virtual ~DatabaseObjectView(){}
98 /** sets the target frame into which the view should be loaded.
100 By default, the view is loaded into a top-level frame not being part of the
103 void setTargetFrame( const css::uno::Reference
< css::frame::XFrame
>& _rxFrame
)
105 m_xFrameLoader
.set( _rxFrame
, css::uno::UNO_QUERY
);
108 /** opens a view for a to-be-created object
111 the data source for which a new object is to be created
113 the controller of the newly created document
115 css::uno::Reference
< css::lang::XComponent
>
117 const css::uno::Reference
< css::sdbc::XDataSource
>& _xDataSource
,
118 const ::comphelper::NamedValueCollection
& i_rDispatchArgs
= ::comphelper::NamedValueCollection()
121 /** opens a view for an existent object
124 the data source for which a new object is to be created
126 the name of the object to be edited
128 Additional settings which should be forwarded to the frame
130 the frame into which the view has been loaded
132 css::uno::Reference
< css::lang::XComponent
>
134 const css::uno::Any
& _aDataSource
,
135 const OUString
& _rName
,
136 const ::comphelper::NamedValueCollection
& i_rDispatchArgs
141 class QueryDesigner final
: public DatabaseObjectView
143 sal_Int32 m_nCommandType
;
145 virtual void fillDispatchArgs(
146 ::comphelper::NamedValueCollection
& i_rDispatchArgs
,
147 const css::uno::Any
& _aDataSource
,
148 const OUString
& _rObjectName
153 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
154 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& _rxApplication
,
155 const css::uno::Reference
< css::frame::XFrame
>& _rxParentFrame
,
161 class TableDesigner
: public DatabaseObjectView
164 virtual void fillDispatchArgs(
165 ::comphelper::NamedValueCollection
& i_rDispatchArgs
,
166 const css::uno::Any
& _aDataSource
,
167 const OUString
& _rObjectName
170 virtual css::uno::Reference
< css::lang::XComponent
> doCreateView(
171 const css::uno::Any
& _rDataSource
,
172 const OUString
& _rObjectName
,
173 const ::comphelper::NamedValueCollection
& i_rCreationArgs
178 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
179 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& _rxApplication
,
180 const css::uno::Reference
< css::frame::XFrame
>& _rxParentFrame
184 /** retrieves the table designer component as provided by the connection, if any
186 the name of the table for which a designer is to be obtained
188 the designer component, as provided by the connection, or <NULL/>, if the connection
189 does not provide a specialized designer.
190 @see css::sdb::application::XTableUIProvider
192 css::uno::Reference
< css::uno::XInterface
>
193 impl_getConnectionProvidedDesigner_nothrow( const OUString
& _rTableName
);
197 class ResultSetBrowser
: public DatabaseObjectView
203 virtual void fillDispatchArgs(
204 ::comphelper::NamedValueCollection
& i_rDispatchArgs
,
205 const css::uno::Any
& _aDataSource
,
206 const OUString
& _rQualifiedName
211 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
212 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& _rxApplication
,
213 const css::uno::Reference
< css::frame::XFrame
>& _rxParentFrame
,
219 class RelationDesigner
: public DatabaseObjectView
223 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
224 const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& _rxApplication
,
225 const css::uno::Reference
< css::frame::XFrame
>& _rxParentFrame
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */