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