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