1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10*96de5490SAndrew Rist *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19*96de5490SAndrew Rist *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "ConnectionPage.hxx"
28cdf0e10cSrcweir #include "DbAdminImpl.hxx"
29cdf0e10cSrcweir #include "DriverSettings.hxx"
30cdf0e10cSrcweir #include "adminpages.hxx"
31cdf0e10cSrcweir #include "dbadmin.hrc"
32cdf0e10cSrcweir #include "dbadmin.hxx"
33cdf0e10cSrcweir #include "dbu_dlg.hrc"
34cdf0e10cSrcweir #include <svl/stritem.hxx>
35cdf0e10cSrcweir #include <svl/eitem.hxx>
36cdf0e10cSrcweir #include <svl/intitem.hxx>
37cdf0e10cSrcweir #include "dbustrings.hrc"
38cdf0e10cSrcweir #include "dsitems.hxx"
39cdf0e10cSrcweir #include "dsnItem.hxx"
40cdf0e10cSrcweir #include "localresaccess.hxx"
41cdf0e10cSrcweir #include "optionalboolitem.hxx"
42cdf0e10cSrcweir #include "propertysetitem.hxx"
43cdf0e10cSrcweir #include "stringlistitem.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include <svl/eitem.hxx>
46cdf0e10cSrcweir #include <svl/intitem.hxx>
47cdf0e10cSrcweir #include <svl/stritem.hxx>
48cdf0e10cSrcweir #include <unotools/confignode.hxx>
49cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50cdf0e10cSrcweir
51cdf0e10cSrcweir //.........................................................................
52cdf0e10cSrcweir namespace dbaui
53cdf0e10cSrcweir {
54cdf0e10cSrcweir //.........................................................................
55cdf0e10cSrcweir using namespace com::sun::star::uno;
56cdf0e10cSrcweir using namespace com::sun::star::sdbc;
57cdf0e10cSrcweir using namespace com::sun::star::lang;
58cdf0e10cSrcweir using namespace com::sun::star::util;
59cdf0e10cSrcweir using namespace com::sun::star::beans;
60cdf0e10cSrcweir using namespace com::sun::star::container;
61cdf0e10cSrcweir
62cdf0e10cSrcweir //=========================================================================
63cdf0e10cSrcweir //= ODbAdminDialog
64cdf0e10cSrcweir //=========================================================================
DBG_NAME(ODbAdminDialog)65cdf0e10cSrcweir DBG_NAME(ODbAdminDialog)
66cdf0e10cSrcweir //-------------------------------------------------------------------------
67cdf0e10cSrcweir ODbAdminDialog::ODbAdminDialog(Window* _pParent
68cdf0e10cSrcweir , SfxItemSet* _pItems
69cdf0e10cSrcweir , const Reference< XMultiServiceFactory >& _rxORB
70cdf0e10cSrcweir )
71cdf0e10cSrcweir :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADMINISTRATION), _pItems)
72cdf0e10cSrcweir ,m_bApplied(sal_False)
73cdf0e10cSrcweir ,m_bUIEnabled( sal_True )
74cdf0e10cSrcweir ,m_nMainPageID( PAGE_CONNECTION )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir DBG_CTOR(ODbAdminDialog,NULL);
77cdf0e10cSrcweir
78cdf0e10cSrcweir m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
79cdf0e10cSrcweir
80cdf0e10cSrcweir // add the initial tab page
81cdf0e10cSrcweir AddTabPage( m_nMainPageID, String( ModuleRes( STR_PAGETITLE_GENERAL ) ), OConnectionTabPage::Create, NULL );
82cdf0e10cSrcweir
83cdf0e10cSrcweir // remove the reset button - it's meaning is much too ambiguous in this dialog
84cdf0e10cSrcweir RemoveResetButton();
85cdf0e10cSrcweir // no local resources needed anymore
86cdf0e10cSrcweir FreeResource();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir //-------------------------------------------------------------------------
~ODbAdminDialog()90cdf0e10cSrcweir ODbAdminDialog::~ODbAdminDialog()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir SetInputSet(NULL);
93cdf0e10cSrcweir DELETEZ(pExampleSet);
94cdf0e10cSrcweir
95cdf0e10cSrcweir DBG_DTOR(ODbAdminDialog,NULL);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir //-------------------------------------------------------------------------
Ok()98cdf0e10cSrcweir short ODbAdminDialog::Ok()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir SfxTabDialog::Ok();
101cdf0e10cSrcweir disabledUI();
102cdf0e10cSrcweir return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL;
103cdf0e10cSrcweir // TODO : AR_ERROR is not handled correctly, we always close the dialog here
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir //-------------------------------------------------------------------------
PageCreated(sal_uInt16 _nId,SfxTabPage & _rPage)107cdf0e10cSrcweir void ODbAdminDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir // register ourself as modified listener
110cdf0e10cSrcweir static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
111cdf0e10cSrcweir static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
112cdf0e10cSrcweir
113cdf0e10cSrcweir AdjustLayout();
114cdf0e10cSrcweir Window *pWin = GetViewWindow();
115cdf0e10cSrcweir if(pWin)
116cdf0e10cSrcweir pWin->Invalidate();
117cdf0e10cSrcweir
118cdf0e10cSrcweir SfxTabDialog::PageCreated(_nId, _rPage);
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir // -----------------------------------------------------------------------------
addDetailPage(sal_uInt16 _nPageId,sal_uInt16 _nTextId,CreateTabPage _pCreateFunc)122cdf0e10cSrcweir void ODbAdminDialog::addDetailPage(sal_uInt16 _nPageId, sal_uInt16 _nTextId, CreateTabPage _pCreateFunc)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir // open our own resource block, as the page titles are strings local to this block
125cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
126cdf0e10cSrcweir
127cdf0e10cSrcweir AddTabPage(_nPageId, String(ModuleRes(_nTextId)), _pCreateFunc, NULL);
128cdf0e10cSrcweir m_aCurrentDetailPages.push(_nPageId);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_selectDataSource(const::com::sun::star::uno::Any & _aDataSourceName)132cdf0e10cSrcweir void ODbAdminDialog::impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir m_pImpl->setDataSourceOrName(_aDataSourceName);
135cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
136cdf0e10cSrcweir impl_resetPages( xDatasource );
137cdf0e10cSrcweir
138cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION));
139cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
140cdf0e10cSrcweir ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet()));
141cdf0e10cSrcweir
142cdf0e10cSrcweir // and insert the new ones
143cdf0e10cSrcweir switch ( eType )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir case ::dbaccess::DST_DBASE:
146cdf0e10cSrcweir addDetailPage(PAGE_DBASE, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase);
147cdf0e10cSrcweir // bResetPasswordRequired = sal_True;
148cdf0e10cSrcweir break;
149cdf0e10cSrcweir
150cdf0e10cSrcweir case ::dbaccess::DST_ADO:
151cdf0e10cSrcweir addDetailPage(PAGE_ADO, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo);
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir
154cdf0e10cSrcweir case ::dbaccess::DST_FLAT:
155cdf0e10cSrcweir addDetailPage(PAGE_TEXT, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText);
156cdf0e10cSrcweir // bResetPasswordRequired = sal_True;
157cdf0e10cSrcweir break;
158cdf0e10cSrcweir
159cdf0e10cSrcweir case ::dbaccess::DST_ODBC:
160cdf0e10cSrcweir addDetailPage(PAGE_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC);
161cdf0e10cSrcweir break;
162cdf0e10cSrcweir
163cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_ODBC:
164cdf0e10cSrcweir addDetailPage(PAGE_MYSQL_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC);
165cdf0e10cSrcweir break;
166cdf0e10cSrcweir
167cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_JDBC:
168cdf0e10cSrcweir addDetailPage(PAGE_MYSQL_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC);
169cdf0e10cSrcweir break;
170cdf0e10cSrcweir
171cdf0e10cSrcweir case ::dbaccess::DST_ORACLE_JDBC:
172cdf0e10cSrcweir addDetailPage(PAGE_ORACLE_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC);
173cdf0e10cSrcweir break;
174cdf0e10cSrcweir
175cdf0e10cSrcweir case ::dbaccess::DST_ADABAS:
176cdf0e10cSrcweir // for adabas we have more than one page
177cdf0e10cSrcweir // CAUTION: the order of inserting pages matters.
178cdf0e10cSrcweir // the major detail page should be inserted last always (thus, it becomes the first page after
179cdf0e10cSrcweir // the general page)
180cdf0e10cSrcweir addDetailPage(PAGE_ADABAS, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdabas);
181cdf0e10cSrcweir break;
182cdf0e10cSrcweir
183cdf0e10cSrcweir case ::dbaccess::DST_LDAP:
184cdf0e10cSrcweir addDetailPage(PAGE_LDAP,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP);
185cdf0e10cSrcweir break;
186cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE1: /// first user defined driver
187cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE2:
188cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE3:
189cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE4:
190cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE5:
191cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE6:
192cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE7:
193cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE8:
194cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE9:
195cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE10:
196cdf0e10cSrcweir {
197cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
198cdf0e10cSrcweir String aTitle(ModuleRes(STR_PAGETITLE_ADVANCED));
199cdf0e10cSrcweir AddTabPage(PAGE_USERDRIVER, aTitle, ODriversSettings::CreateUser, 0, sal_False, 1);
200cdf0e10cSrcweir m_aCurrentDetailPages.push(PAGE_USERDRIVER);
201cdf0e10cSrcweir }
202cdf0e10cSrcweir break;
203cdf0e10cSrcweir default:
204cdf0e10cSrcweir break;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_resetPages(const Reference<XPropertySet> & _rxDatasource)209cdf0e10cSrcweir void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir // the selection is valid if and only if we have a datasource now
212cdf0e10cSrcweir GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is()));
213cdf0e10cSrcweir // (sal_False tells the tab pages to disable and reset all their controls, which is different
214cdf0e10cSrcweir // from "just set them to readonly")
215cdf0e10cSrcweir
216cdf0e10cSrcweir // reset the pages
217cdf0e10cSrcweir
218cdf0e10cSrcweir // prevent flicker
219cdf0e10cSrcweir SetUpdateMode(sal_False);
220cdf0e10cSrcweir
221cdf0e10cSrcweir // remove all items which relate to indirect properties from the input set
222cdf0e10cSrcweir // (without this, the following may happen: select an arbitrary data source where some indirect properties
223cdf0e10cSrcweir // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
224cdf0e10cSrcweir // the indirect property values of the first ds are shown in the second ds ...)
225cdf0e10cSrcweir const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties();
226cdf0e10cSrcweir for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin();
227cdf0e10cSrcweir aIndirect != rMap.end();
228cdf0e10cSrcweir ++aIndirect
229cdf0e10cSrcweir )
230cdf0e10cSrcweir GetInputSetImpl()->ClearItem( (sal_uInt16)aIndirect->first );
231cdf0e10cSrcweir
232cdf0e10cSrcweir // extract all relevant data from the property set of the data source
233cdf0e10cSrcweir m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl());
234cdf0e10cSrcweir
235cdf0e10cSrcweir // propagate this set as our new input set and reset the example set
236cdf0e10cSrcweir SetInputSet(GetInputSetImpl());
237cdf0e10cSrcweir delete pExampleSet;
238cdf0e10cSrcweir pExampleSet = new SfxItemSet(*GetInputSetImpl());
239cdf0e10cSrcweir
240cdf0e10cSrcweir // special case: MySQL Native does not have the generic PAGE_CONNECTION page
241cdf0e10cSrcweir
242cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION));
243cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
244cdf0e10cSrcweir if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
247cdf0e10cSrcweir AddTabPage( PAGE_MYSQL_NATIVE, String( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL );
248cdf0e10cSrcweir RemoveTabPage( PAGE_CONNECTION );
249cdf0e10cSrcweir m_nMainPageID = PAGE_MYSQL_NATIVE;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir ShowPage( m_nMainPageID );
253cdf0e10cSrcweir SfxTabPage* pConnectionPage = GetTabPage( m_nMainPageID );
254cdf0e10cSrcweir if ( pConnectionPage )
255cdf0e10cSrcweir pConnectionPage->Reset(*GetInputSetImpl());
256cdf0e10cSrcweir // if this is NULL, the page has not been created yet, which means we're called before the
257cdf0e10cSrcweir // dialog was displayed (probably from inside the ctor)
258cdf0e10cSrcweir
259cdf0e10cSrcweir SetUpdateMode(sal_True);
260cdf0e10cSrcweir }
261cdf0e10cSrcweir // -----------------------------------------------------------------------------
setTitle(const::rtl::OUString & _sTitle)262cdf0e10cSrcweir void ODbAdminDialog::setTitle(const ::rtl::OUString& _sTitle)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir SetText(_sTitle);
265cdf0e10cSrcweir }
266cdf0e10cSrcweir //-------------------------------------------------------------------------
enableConfirmSettings(bool _bEnable)267cdf0e10cSrcweir void ODbAdminDialog::enableConfirmSettings( bool _bEnable )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir (void)_bEnable;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir //-------------------------------------------------------------------------
saveDatasource()272cdf0e10cSrcweir sal_Bool ODbAdminDialog::saveDatasource()
273cdf0e10cSrcweir {
274cdf0e10cSrcweir return PrepareLeaveCurrentPage();
275cdf0e10cSrcweir }
276cdf0e10cSrcweir //-------------------------------------------------------------------------
implApplyChanges()277cdf0e10cSrcweir ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir if (!PrepareLeaveCurrentPage())
280cdf0e10cSrcweir { // the page did not allow us to leave
281cdf0e10cSrcweir return AR_KEEP;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir if ( !m_pImpl->saveChanges(*pExampleSet) )
285cdf0e10cSrcweir return AR_KEEP;
286cdf0e10cSrcweir
287cdf0e10cSrcweir if ( isUIEnabled() )
288cdf0e10cSrcweir ShowPage(GetCurPageId());
289cdf0e10cSrcweir // This does the usual ActivatePage, so the pages can save their current status.
290cdf0e10cSrcweir // This way, next time they're asked what has changed since now and here, they really
291cdf0e10cSrcweir // can compare with the status they have _now_ (not the one they had before this apply call).
292cdf0e10cSrcweir
293cdf0e10cSrcweir m_bApplied = sal_True;
294cdf0e10cSrcweir
295cdf0e10cSrcweir return AR_LEAVE_MODIFIED;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir //-------------------------------------------------------------------------
selectDataSource(const::com::sun::star::uno::Any & _aDataSourceName)298cdf0e10cSrcweir void ODbAdminDialog::selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir impl_selectDataSource(_aDataSourceName);
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
303cdf0e10cSrcweir // -----------------------------------------------------------------------------
getOutputSet() const304cdf0e10cSrcweir const SfxItemSet* ODbAdminDialog::getOutputSet() const
305cdf0e10cSrcweir {
306cdf0e10cSrcweir return GetExampleSet();
307cdf0e10cSrcweir }
308cdf0e10cSrcweir // -----------------------------------------------------------------------------
getWriteOutputSet()309cdf0e10cSrcweir SfxItemSet* ODbAdminDialog::getWriteOutputSet()
310cdf0e10cSrcweir {
311cdf0e10cSrcweir return pExampleSet;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir // -----------------------------------------------------------------------------
createConnection()314cdf0e10cSrcweir ::std::pair< Reference<XConnection>,sal_Bool> ODbAdminDialog::createConnection()
315cdf0e10cSrcweir {
316cdf0e10cSrcweir return m_pImpl->createConnection();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir // -----------------------------------------------------------------------------
getORB() const319cdf0e10cSrcweir Reference< XMultiServiceFactory > ODbAdminDialog::getORB() const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir return m_pImpl->getORB();
322cdf0e10cSrcweir }
323cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDriver()324cdf0e10cSrcweir Reference< XDriver > ODbAdminDialog::getDriver()
325cdf0e10cSrcweir {
326cdf0e10cSrcweir return m_pImpl->getDriver();
327cdf0e10cSrcweir }
328cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDatasourceType(const SfxItemSet & _rSet) const329cdf0e10cSrcweir ::rtl::OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const
330cdf0e10cSrcweir {
331cdf0e10cSrcweir return m_pImpl->getDatasourceType(_rSet);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir // -----------------------------------------------------------------------------
clearPassword()334cdf0e10cSrcweir void ODbAdminDialog::clearPassword()
335cdf0e10cSrcweir {
336cdf0e10cSrcweir m_pImpl->clearPassword();
337cdf0e10cSrcweir }
338cdf0e10cSrcweir //-------------------------------------------------------------------------
createItemSet(SfxItemSet * & _rpSet,SfxItemPool * & _rpPool,SfxPoolItem ** & _rppDefaults,::dbaccess::ODsnTypeCollection * _pTypeCollection)339cdf0e10cSrcweir SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir // just to be sure ....
342cdf0e10cSrcweir _rpSet = NULL;
343cdf0e10cSrcweir _rpPool = NULL;
344cdf0e10cSrcweir _rppDefaults = NULL;
345cdf0e10cSrcweir
346cdf0e10cSrcweir const ::rtl::OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US );
347cdf0e10cSrcweir // create and initialize the defaults
348cdf0e10cSrcweir _rppDefaults = new SfxPoolItem*[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1];
349cdf0e10cSrcweir SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults
350cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_NAME, String());
351cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String());
352cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONNECTURL, String());
353cdf0e10cSrcweir *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1));
354cdf0e10cSrcweir *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection);
355cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False);
356cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_READONLY, sal_False);
357cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_USER, String());
358cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_PASSWORD, String());
359cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_ADDITIONALOPTIONS, String());
360cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CHARSET, String());
361cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False);
362cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False);
363cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False);
364cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String());
365cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ',');
366cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"');
367cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.');
368cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, String());
369cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt"));
370cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True);
371cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_PARAMETERNAMESUBST, sal_False);
372cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_PORTNUMBER, 8100);
373cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SUPPRESSVERSIONCL, sal_False);
374cdf0e10cSrcweir *pCounter++ = new OPropertySetItem(DSID_DATASOURCE_UNO);
375cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CONN_SHUTSERVICE, sal_False);
376cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_DATAINC, 20);
377cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_CACHESIZE, 20);
378cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_CTRLUSER, String());
379cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_CTRLPWD, String());
380cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_USECATALOG, sal_False);
381cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_HOSTNAME, String());
382cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_BASEDN, String());
383cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389);
384cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100);
385cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SQL92CHECK, sal_False);
386cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_AUTOINCREMENTVALUE, String());
387cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_AUTORETRIEVEVALUE, String());
388cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_AUTORETRIEVEENABLED, sal_False);
389cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_APPEND_TABLE_ALIAS, sal_False);
390cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_MYSQL_PORTNUMBER, 3306);
391cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_IGNOREDRIVER_PRIV, sal_True);
392cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_BOOLEANCOMPARISON, 0);
393cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_ORACLE_PORTNUMBER, 1521);
394cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ENABLEOUTERJOIN, sal_True);
395cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CATALOG, sal_True);
396cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SCHEMA, sal_True);
397cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_INDEXAPPENDIX, sal_True);
398cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CONN_LDAP_USESSL, sal_False);
399cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DOCUMENT_URL, String());
400cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_DOSLINEENDS, sal_False);
401cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DATABASENAME, String());
402cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_AS_BEFORE_CORRNAME, sal_True);
403cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, sal_True);
404cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_IGNORECURRENCY, sal_False);
405cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_SOCKET, String());
406cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True);
407cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_NAMED_PIPE, String());
408cdf0e10cSrcweir *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT );
409cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_MAX_ROW_SCAN, 100);
410cdf0e10cSrcweir *pCounter++ = new SfxBoolItem( DSID_RESPECTRESULTSETTYPE,sal_False );
411cdf0e10cSrcweir
412cdf0e10cSrcweir // create the pool
413cdf0e10cSrcweir static SfxItemInfo __READONLY_DATA aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] =
414cdf0e10cSrcweir {
415cdf0e10cSrcweir {0,0},
416cdf0e10cSrcweir {0,0},
417cdf0e10cSrcweir {0,0},
418cdf0e10cSrcweir {0,0},
419cdf0e10cSrcweir {0,0},
420cdf0e10cSrcweir {0,0},
421cdf0e10cSrcweir {0,0},
422cdf0e10cSrcweir {0,0},
423cdf0e10cSrcweir {0,0},
424cdf0e10cSrcweir {0,0},
425cdf0e10cSrcweir {0,0},
426cdf0e10cSrcweir {0,0},
427cdf0e10cSrcweir {0,0},
428cdf0e10cSrcweir {0,0},
429cdf0e10cSrcweir {0,0},
430cdf0e10cSrcweir {0,0},
431cdf0e10cSrcweir {0,0},
432cdf0e10cSrcweir {0,0},
433cdf0e10cSrcweir {0,0},
434cdf0e10cSrcweir {0,0},
435cdf0e10cSrcweir {0,0},
436cdf0e10cSrcweir {0,0},
437cdf0e10cSrcweir {0,0},
438cdf0e10cSrcweir {0,0},
439cdf0e10cSrcweir {0,0},
440cdf0e10cSrcweir {0,0},
441cdf0e10cSrcweir {0,0},
442cdf0e10cSrcweir {0,0},
443cdf0e10cSrcweir {0,0},
444cdf0e10cSrcweir {0,0},
445cdf0e10cSrcweir {0,0},
446cdf0e10cSrcweir {0,0},
447cdf0e10cSrcweir {0,0},
448cdf0e10cSrcweir {0,0},
449cdf0e10cSrcweir {0,0},
450cdf0e10cSrcweir {0,0},
451cdf0e10cSrcweir {0,0},
452cdf0e10cSrcweir {0,0},
453cdf0e10cSrcweir {0,0},
454cdf0e10cSrcweir {0,0},
455cdf0e10cSrcweir {0,0},
456cdf0e10cSrcweir {0,0},
457cdf0e10cSrcweir {0,0},
458cdf0e10cSrcweir {0,0},
459cdf0e10cSrcweir {0,0},
460cdf0e10cSrcweir {0,0},
461cdf0e10cSrcweir {0,0},
462cdf0e10cSrcweir {0,0},
463cdf0e10cSrcweir {0,0},
464cdf0e10cSrcweir {0,0},
465cdf0e10cSrcweir {0,0},
466cdf0e10cSrcweir {0,0},
467cdf0e10cSrcweir {0,0},
468cdf0e10cSrcweir {0,0},
469cdf0e10cSrcweir {0,0},
470cdf0e10cSrcweir {0,0},
471cdf0e10cSrcweir {0,0},
472cdf0e10cSrcweir {0,0},
473cdf0e10cSrcweir {0,0},
474cdf0e10cSrcweir {0,0},
475cdf0e10cSrcweir {0,0}
476cdf0e10cSrcweir };
477cdf0e10cSrcweir
478cdf0e10cSrcweir OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == DSID_LAST_ITEM_ID,"Invalid Ids!");
479cdf0e10cSrcweir _rpPool = new SfxItemPool(String::CreateFromAscii("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID,
480cdf0e10cSrcweir aItemInfos, _rppDefaults);
481cdf0e10cSrcweir _rpPool->FreezeIdRanges();
482cdf0e10cSrcweir
483cdf0e10cSrcweir // and, finally, the set
484cdf0e10cSrcweir _rpSet = new SfxItemSet(*_rpPool, sal_True);
485cdf0e10cSrcweir
486cdf0e10cSrcweir return _rpSet;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir //-------------------------------------------------------------------------
destroyItemSet(SfxItemSet * & _rpSet,SfxItemPool * & _rpPool,SfxPoolItem ** & _rppDefaults)489cdf0e10cSrcweir void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir // _first_ delete the set (refering the pool)
492cdf0e10cSrcweir if (_rpSet)
493cdf0e10cSrcweir {
494cdf0e10cSrcweir delete _rpSet;
495cdf0e10cSrcweir _rpSet = NULL;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
498cdf0e10cSrcweir // delete the pool
499cdf0e10cSrcweir if (_rpPool)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir _rpPool->ReleaseDefaults(sal_True);
502cdf0e10cSrcweir // the "true" means delete the items, too
503cdf0e10cSrcweir SfxItemPool::Free(_rpPool);
504cdf0e10cSrcweir _rpPool = NULL;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir // reset the defaults ptr
508cdf0e10cSrcweir _rppDefaults = NULL;
509cdf0e10cSrcweir // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir //.........................................................................
513cdf0e10cSrcweir } // namespace dbaui
514cdf0e10cSrcweir //.........................................................................
515cdf0e10cSrcweir
516