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 #ifndef ADABASUI_NEWDB_HXX
25 #include "ANewDb.hxx"
26 #endif
27 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
28 #include <cppuhelper/typeprovider.hxx>
29 #endif
30 #ifndef _DBHELPER_DBEXCEPTION_HXX_
31 #include <connectivity/dbexception.hxx>
32 #endif
33 #ifndef adabasui_ADABAS_CREATEDB_HXX
34 #include "AdabasNewDb.hxx"
35 #endif
36 #ifndef adabasui_SHARED_DBUSTRINGS_HRC
37 #include "adabasuistrings.hrc"
38 #endif
39 #ifndef _SV_MSGBOX_HXX
40 #include <vcl/msgbox.hxx>
41 #endif
42
43 using namespace adabasui;
44 using namespace dbtools;
45
46 using namespace ::com::sun::star::sdbc;
47 using namespace ::com::sun::star::sdbcx;
48 using namespace ::com::sun::star::sdb;
49
createRegistryInfo_OAdabasCreateDialog()50 extern "C" void SAL_CALL createRegistryInfo_OAdabasCreateDialog()
51 {
52 static OMultiInstanceAutoRegistration< OAdabasCreateDialog > aAutoRegistration;
53 }
54
55
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star::beans;
59
60 //=========================================================================
61 //-------------------------------------------------------------------------
OAdabasCreateDialog(const Reference<XMultiServiceFactory> & _rxORB)62 OAdabasCreateDialog::OAdabasCreateDialog(const Reference< XMultiServiceFactory >& _rxORB)
63 :OAdabasCreateDialogBase(_rxORB)
64 ,m_pDialog(NULL)
65 {
66 registerProperty(PROPERTY_CREATECATALOG, PROPERTY_ID_CREATECATALOG, PropertyAttribute::TRANSIENT,&m_xCreateCatalog, ::getCppuType(&m_xCreateCatalog));
67 registerProperty(PROPERTY_DATABASENAME, PROPERTY_ID_DATABASENAME, PropertyAttribute::TRANSIENT,&m_sDatabaseName, ::getCppuType(&m_sDatabaseName));
68 registerProperty(PROPERTY_CONTROL_USER, PROPERTY_ID_CONTROL_USER, PropertyAttribute::TRANSIENT,&m_sControlUser, ::getCppuType(&m_sControlUser));
69 registerProperty(PROPERTY_CONTROL_PASSWORD, PROPERTY_ID_CONTROL_PASSWORD, PropertyAttribute::TRANSIENT,&m_sControlPassword, ::getCppuType(&m_sControlPassword));
70 registerProperty(PROPERTY_USER, PROPERTY_ID_USER, PropertyAttribute::TRANSIENT,&m_sUser, ::getCppuType(&m_sUser));
71 registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, PropertyAttribute::TRANSIENT,&m_sUserPassword, ::getCppuType(&m_sUserPassword));
72 registerProperty(PROPERTY_CACHESIZE, PROPERTY_ID_CACHESIZE, PropertyAttribute::TRANSIENT,&m_nCacheSize, ::getCppuType(&m_nCacheSize));
73 }
74
75 //-------------------------------------------------------------------------
getImplementationId()76 Sequence<sal_Int8> SAL_CALL OAdabasCreateDialog::getImplementationId( ) throw(RuntimeException)
77 {
78 static ::cppu::OImplementationId aId;
79 return aId.getImplementationId();
80 }
81
82 //-------------------------------------------------------------------------
Create(const Reference<XMultiServiceFactory> & _rxFactory)83 Reference< XInterface > SAL_CALL OAdabasCreateDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
84 {
85 return *(new OAdabasCreateDialog(_rxFactory));
86 }
87
88 //-------------------------------------------------------------------------
getImplementationName()89 ::rtl::OUString SAL_CALL OAdabasCreateDialog::getImplementationName() throw(RuntimeException)
90 {
91 return getImplementationName_Static();
92 }
93
94 //-------------------------------------------------------------------------
getImplementationName_Static()95 ::rtl::OUString OAdabasCreateDialog::getImplementationName_Static() throw(RuntimeException)
96 {
97 return ::rtl::OUString::createFromAscii("org.openoffice.comp.adabasui.AdabasCreateDialog");
98 }
99
100 //-------------------------------------------------------------------------
getSupportedServiceNames()101 ::comphelper::StringSequence SAL_CALL OAdabasCreateDialog::getSupportedServiceNames() throw(RuntimeException)
102 {
103 return getSupportedServiceNames_Static();
104 }
105
106 //-------------------------------------------------------------------------
getSupportedServiceNames_Static()107 ::comphelper::StringSequence OAdabasCreateDialog::getSupportedServiceNames_Static() throw(RuntimeException)
108 {
109 ::comphelper::StringSequence aSupported(1);
110 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.AdabasCreationDialog");
111 return aSupported;
112 }
113
114 //-------------------------------------------------------------------------
getPropertySetInfo()115 Reference<XPropertySetInfo> SAL_CALL OAdabasCreateDialog::getPropertySetInfo() throw(RuntimeException)
116 {
117 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
118 return xInfo;
119 }
120
121 //-------------------------------------------------------------------------
getInfoHelper()122 ::cppu::IPropertyArrayHelper& OAdabasCreateDialog::getInfoHelper()
123 {
124 return *const_cast<OAdabasCreateDialog*>(this)->getArrayHelper();
125 }
126
127 //------------------------------------------------------------------------------
createArrayHelper() const128 ::cppu::IPropertyArrayHelper* OAdabasCreateDialog::createArrayHelper( ) const
129 {
130 Sequence< Property > aProps;
131 describeProperties(aProps);
132 return new ::cppu::OPropertyArrayHelper(aProps);
133 }
134
135 //------------------------------------------------------------------------------
createDialog(Window * _pParent)136 Dialog* OAdabasCreateDialog::createDialog(Window* _pParent)
137 {
138 if(!m_xCreateCatalog.is())
139 throw SQLException();
140 m_pDialog = new OAdabasNewDbDlg(_pParent,m_xCreateCatalog,m_aContext.getLegacyServiceFactory());
141 return m_pDialog;
142 }
143 // -----------------------------------------------------------------------------
executedDialog(sal_Int16 _nExecutionResult)144 void OAdabasCreateDialog::executedDialog(sal_Int16 _nExecutionResult)
145 {
146 if(m_pDialog && _nExecutionResult == RET_OK)
147 { // fill the variables
148 m_sDatabaseName = m_pDialog->GetDatabaseName();
149 m_sControlUser = m_pDialog->GetControlUser();
150 m_sControlPassword = m_pDialog->GetControlPassword();
151 m_sUser = m_pDialog->GetUser();
152 m_sUserPassword = m_pDialog->GetUserPassword();
153 m_nCacheSize = m_pDialog->GetCacheSize();
154 }
155 }
156 // -----------------------------------------------------------------------------
157
158