1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX 29 #define DBACCESS_DATABASE_OBJECT_VIEW_HXX 30 31 #ifndef _RTL_USTRING_HXX_ 32 #include <rtl/ustring.hxx> 33 #endif 34 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 35 #include <com/sun/star/sdbc/XConnection.hpp> 36 #endif 37 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ 38 #include <com/sun/star/sdbc/XDataSource.hpp> 39 #endif 40 #ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ 41 #include <com/sun/star/frame/XDispatch.hpp> 42 #endif 43 #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ 44 #include <com/sun/star/lang/XComponent.hpp> 45 #endif 46 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 47 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48 #endif 49 #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ 50 #include <com/sun/star/frame/XComponentLoader.hpp> 51 #endif 52 #ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ 53 #include <com/sun/star/frame/XFrame.hpp> 54 #endif 55 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 56 #include <com/sun/star/beans/PropertyValue.hpp> 57 #endif 58 #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ 59 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 60 #endif 61 #ifndef _COM_SUN_STAR_SDB_APPLICATION_XDATABASEDOCUMENTUI_HPP_ 62 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> 63 #endif 64 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ 65 #include <com/sun/star/uno/Sequence.hxx> 66 #endif 67 #include <comphelper/namedvaluecollection.hxx> 68 69 #include <boost/shared_ptr.hpp> 70 71 72 // ......................................................................... 73 namespace dbaui 74 { 75 // ......................................................................... 76 /** encapsulates access to the view of a database object. 77 78 @todo 79 this is to be merged with the OLinkedDocumentAccess class 80 */ 81 class DatabaseObjectView 82 { 83 private: 84 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 85 m_xORB; 86 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > 87 m_xParentFrame; 88 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XComponentLoader > 89 m_xFrameLoader; 90 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI > 91 m_xApplication; 92 ::rtl::OUString m_sComponentURL; 93 94 95 private: 96 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > 97 doDispatch( 98 const ::comphelper::NamedValueCollection& i_rDispatchArgs 99 ); 100 101 protected: 102 /** creates the desired view 103 104 The default implementation will call <member>fillDispatchArgs</member>, followed 105 by <member>doDispatch</member>. 106 107 @param _rDataSource 108 the data source, as passed to the <member>createNew</member> or <member>openExisting</member> method. 109 @param _rObjectName 110 the name of the object for which the view is to be opened, 111 or an empty string if a view for a new object should be created. 112 @param _rCreationArgs 113 the arguments for the view's creation 114 */ 115 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView( 116 const ::com::sun::star::uno::Any& _rDataSource, 117 const ::rtl::OUString& _rObjectName, 118 const ::comphelper::NamedValueCollection& i_rCreationArgs 119 ); 120 121 virtual void fillDispatchArgs( 122 ::comphelper::NamedValueCollection& i_rDispatchArgs, 123 const ::com::sun::star::uno::Any& _rDataSource, 124 const ::rtl::OUString& _rObjectName 125 ); 126 127 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& 128 getApplicationUI() const { return m_xApplication; } 129 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 130 getConnection() const; 131 132 public: 133 DatabaseObjectView( 134 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 135 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, 136 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame, 137 const ::rtl::OUString& _rComponentURL 138 ); 139 virtual ~DatabaseObjectView(){} 140 141 /** sets the target frame into which the view should be loaded. 142 143 By default, the view is loaded into a top-level frame not being part of the 144 Desktop. 145 */ 146 void setTargetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame ) 147 { 148 m_xFrameLoader.set( _rxFrame, ::com::sun::star::uno::UNO_QUERY ); 149 } 150 151 /** opens a view for a to-be-created object 152 153 @param _xDataSource 154 the data source for which a new object is to be created 155 @return 156 the controller of the newly created document 157 */ 158 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > 159 createNew( 160 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _xDataSource, 161 const ::comphelper::NamedValueCollection& i_rDispatchArgs = ::comphelper::NamedValueCollection() 162 ); 163 164 /** opens a view for an existent object 165 166 @param _xDataSource 167 the data source for which a new object is to be created 168 @param _rObjectName 169 the name of the object to be edited 170 @param _rArgs 171 Additional settings which should be forwarded to the frame 172 @return 173 the frame into which the view has been loaded 174 */ 175 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > 176 openExisting( 177 const ::com::sun::star::uno::Any& _aDataSource, 178 const ::rtl::OUString& _rName, 179 const ::comphelper::NamedValueCollection& i_rDispatchArgs 180 ); 181 }; 182 183 //====================================================================== 184 //= QueryDesigner 185 //====================================================================== 186 class QueryDesigner : public DatabaseObjectView 187 { 188 protected: 189 sal_Int32 m_nCommandType; 190 191 protected: 192 virtual void fillDispatchArgs( 193 ::comphelper::NamedValueCollection& i_rDispatchArgs, 194 const ::com::sun::star::uno::Any& _aDataSource, 195 const ::rtl::OUString& _rObjectName 196 ); 197 198 public: 199 QueryDesigner( 200 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 201 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, 202 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame, 203 bool _bCreateView 204 ); 205 }; 206 207 //====================================================================== 208 //= TableDesigner 209 //====================================================================== 210 class TableDesigner : public DatabaseObjectView 211 { 212 protected: 213 virtual void fillDispatchArgs( 214 ::comphelper::NamedValueCollection& i_rDispatchArgs, 215 const ::com::sun::star::uno::Any& _aDataSource, 216 const ::rtl::OUString& _rObjectName 217 ); 218 219 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView( 220 const ::com::sun::star::uno::Any& _rDataSource, 221 const ::rtl::OUString& _rObjectName, 222 const ::comphelper::NamedValueCollection& i_rCreationArgs 223 ); 224 225 public: 226 TableDesigner( 227 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 228 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, 229 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame 230 ); 231 232 private: 233 /** retrieves the table designer component as provided by the connection, if any 234 @param _rTableName 235 the name of the table for which a designer is to be obtained 236 @return 237 the designer component, as provided by the connection, or <NULL/>, if the connection 238 does not provide a specialized designer. 239 @see com::sun::star::sdb::application::XTableUIProvider 240 */ 241 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 242 impl_getConnectionProvidedDesigner_nothrow( const ::rtl::OUString& _rTableName ); 243 }; 244 245 //====================================================================== 246 //= ResultSetBrowser 247 //====================================================================== 248 class ResultSetBrowser : public DatabaseObjectView 249 { 250 private: 251 sal_Bool m_bTable; 252 253 protected: 254 virtual void fillDispatchArgs( 255 ::comphelper::NamedValueCollection& i_rDispatchArgs, 256 const ::com::sun::star::uno::Any& _aDataSource, 257 const ::rtl::OUString& _rQualifiedName 258 ); 259 260 public: 261 ResultSetBrowser( 262 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 263 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, 264 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame, 265 sal_Bool _bTable 266 ); 267 268 }; 269 //====================================================================== 270 //= RelationDesigner 271 //====================================================================== 272 class RelationDesigner : public DatabaseObjectView 273 { 274 public: 275 RelationDesigner( 276 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 277 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, 278 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame 279 ); 280 }; 281 // ......................................................................... 282 } // namespace dbaui 283 // ......................................................................... 284 285 #endif // DBACCESS_DATABASE_OBJECT_VIEW_HXX 286 287