1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbui.hxx"
26
27 #ifndef DBAUI_UNODIRECTSQL_HXX
28 #include "unoDirectSql.hxx"
29 #endif
30 #ifndef _DBU_REGHELPER_HXX_
31 #include "dbu_reghelper.hxx"
32 #endif
33 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
34 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_CONNECTION_XCONNECTION_HPP_
40 #include <com/sun/star/connection/XConnection.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
43 #include <com/sun/star/container/XNamed.hpp>
44 #endif
45 #ifndef _DBACCESS_UI_DIRECTSQL_HXX_
46 #include "directsql.hxx"
47 #endif
48 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
49 #include "dbustrings.hrc"
50 #endif
51 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
52 #include "datasourceconnector.hxx"
53 #endif
54 #ifndef TOOLS_DIAGNOSE_EX_H
55 #include <tools/diagnose_ex.h>
56 #endif
57
58
createRegistryInfo_ODirectSQLDialog()59 extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog()
60 {
61 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration;
62 }
63
64 //.........................................................................
65 namespace dbaui
66 {
67 //.........................................................................
68
69 using namespace ::com::sun::star::uno;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star::beans;
72 using namespace ::com::sun::star::container;
73 using namespace ::com::sun::star::sdbcx;
74 using namespace ::com::sun::star::sdbc;
75 using namespace ::com::sun::star::sdb;
76
77 //=====================================================================
78 //= ODirectSQLDialog
79 //=====================================================================
DBG_NAME(ODirectSQLDialog)80 DBG_NAME(ODirectSQLDialog)
81 //---------------------------------------------------------------------
82 ODirectSQLDialog::ODirectSQLDialog(const Reference< XMultiServiceFactory >& _rxORB)
83 :ODirectSQLDialog_BASE( _rxORB )
84 {
85 DBG_CTOR(ODirectSQLDialog,NULL);
86
87 }
88
89 //---------------------------------------------------------------------
~ODirectSQLDialog()90 ODirectSQLDialog::~ODirectSQLDialog()
91 {
92
93 DBG_DTOR(ODirectSQLDialog,NULL);
94 }
95
96 //---------------------------------------------------------------------
97 IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog )
98
99 //---------------------------------------------------------------------
100 IMPLEMENT_SERVICE_INFO1_STATIC( ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog", SERVICE_SDB_DIRECTSQLDIALOG )
101
102 //---------------------------------------------------------------------
IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(ODirectSQLDialog)103 IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog )
104
105 //---------------------------------------------------------------------
106 Dialog* ODirectSQLDialog::createDialog(Window* _pParent)
107 {
108 // obtain all the objects needed for the dialog
109 Reference< XConnection > xConnection = m_xActiveConnection;
110 if ( !xConnection.is() )
111 {
112 try
113 {
114 // the connection the row set is working with
115 ODatasourceConnector aDSConnector(m_aContext.getLegacyServiceFactory(),_pParent);
116 xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
117 }
118 catch( const Exception& )
119 {
120 DBG_UNHANDLED_EXCEPTION();
121 }
122 }
123 if ( !xConnection.is() )
124 // can't create the dialog if I have improper settings
125 return NULL;
126
127 return new DirectSQLDialog( _pParent, xConnection);
128 }
129 //---------------------------------------------------------------------
implInitialize(const Any & _rValue)130 void ODirectSQLDialog::implInitialize(const Any& _rValue)
131 {
132 PropertyValue aProperty;
133 if (_rValue >>= aProperty)
134 {
135 if (0 == aProperty.Name.compareToAscii("InitialSelection"))
136 {
137 OSL_VERIFY( aProperty.Value >>= m_sInitialSelection );
138 return;
139 }
140 else if (0 == aProperty.Name.compareToAscii("ActiveConnection"))
141 {
142 m_xActiveConnection.set( aProperty.Value, UNO_QUERY );
143 OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
144 return;
145 }
146 }
147 ODirectSQLDialog_BASE::implInitialize(_rValue);
148 }
149 //.........................................................................
150 } // namespace dbaui
151 //.........................................................................
152
153