merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / uno / unoDirectSql.cxx
blobd0ff8f0f396023b48489d856fa6a8b6b08b4cc28
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoDirectSql.cxx,v $
10 * $Revision: 1.7.142.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef DBAUI_UNODIRECTSQL_HXX
35 #include "unoDirectSql.hxx"
36 #endif
37 #ifndef _DBU_REGHELPER_HXX_
38 #include "dbu_reghelper.hxx"
39 #endif
40 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
41 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
44 #include <com/sun/star/container/XNameAccess.hpp>
45 #endif
46 #ifndef _COM_SUN_STAR_CONNECTION_XCONNECTION_HPP_
47 #include <com/sun/star/connection/XConnection.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
50 #include <com/sun/star/container/XNamed.hpp>
51 #endif
52 #ifndef _DBACCESS_UI_DIRECTSQL_HXX_
53 #include "directsql.hxx"
54 #endif
55 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
56 #include "dbustrings.hrc"
57 #endif
58 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
59 #include "datasourceconnector.hxx"
60 #endif
61 #ifndef TOOLS_DIAGNOSE_EX_H
62 #include <tools/diagnose_ex.h>
63 #endif
66 extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog()
68 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration;
71 //.........................................................................
72 namespace dbaui
74 //.........................................................................
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::lang;
78 using namespace ::com::sun::star::beans;
79 using namespace ::com::sun::star::container;
80 using namespace ::com::sun::star::sdbcx;
81 using namespace ::com::sun::star::sdbc;
82 using namespace ::com::sun::star::sdb;
84 //=====================================================================
85 //= ODirectSQLDialog
86 //=====================================================================
87 DBG_NAME(ODirectSQLDialog)
88 //---------------------------------------------------------------------
89 ODirectSQLDialog::ODirectSQLDialog(const Reference< XMultiServiceFactory >& _rxORB)
90 :ODirectSQLDialog_BASE( _rxORB )
92 DBG_CTOR(ODirectSQLDialog,NULL);
96 //---------------------------------------------------------------------
97 ODirectSQLDialog::~ODirectSQLDialog()
100 DBG_DTOR(ODirectSQLDialog,NULL);
103 //---------------------------------------------------------------------
104 IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog )
106 //---------------------------------------------------------------------
107 IMPLEMENT_SERVICE_INFO1_STATIC( ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog", SERVICE_SDB_DIRECTSQLDIALOG )
109 //---------------------------------------------------------------------
110 IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog )
112 //---------------------------------------------------------------------
113 Dialog* ODirectSQLDialog::createDialog(Window* _pParent)
115 // obtain all the objects needed for the dialog
116 Reference< XConnection > xConnection = m_xActiveConnection;
117 if ( !xConnection.is() )
121 // the connection the row set is working with
122 ODatasourceConnector aDSConnector(m_aContext.getLegacyServiceFactory(),_pParent);
123 xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
125 catch( const Exception& )
127 DBG_UNHANDLED_EXCEPTION();
130 if ( !xConnection.is() )
131 // can't create the dialog if I have improper settings
132 return NULL;
134 return new DirectSQLDialog( _pParent, xConnection);
136 //---------------------------------------------------------------------
137 void ODirectSQLDialog::implInitialize(const Any& _rValue)
139 PropertyValue aProperty;
140 if (_rValue >>= aProperty)
142 if (0 == aProperty.Name.compareToAscii("InitialSelection"))
144 OSL_VERIFY( aProperty.Value >>= m_sInitialSelection );
145 return;
147 else if (0 == aProperty.Name.compareToAscii("ActiveConnection"))
149 m_xActiveConnection.set( aProperty.Value, UNO_QUERY );
150 OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
151 return;
154 ODirectSQLDialog_BASE::implInitialize(_rValue);
156 //.........................................................................
157 } // namespace dbaui
158 //.........................................................................