/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
short ODbAdminDialog::Ok()
{
SfxTabDialogController::Ok(); return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL; // TODO : AR_ERROR is not handled correctly, we always close the dialog here
}
// and insert the new ones switch ( eType )
{ case ::dbaccess::DST_DBASE:
addDetailPage(u"dbase"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase); break;
case ::dbaccess::DST_ADO:
addDetailPage(u"ado"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo); break;
case ::dbaccess::DST_FLAT:
addDetailPage(u"text"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText); break;
case ::dbaccess::DST_ODBC:
addDetailPage(u"odbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC); break;
case ::dbaccess::DST_MYSQL_ODBC:
addDetailPage(u"mysqlodbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC); break;
case ::dbaccess::DST_MYSQL_JDBC:
addDetailPage(u"mysqljdbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC); break;
case ::dbaccess::DST_ORACLE_JDBC:
addDetailPage(u"oraclejdbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC); break;
case ::dbaccess::DST_LDAP:
addDetailPage(u"ldap"_ustr,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP); break; case ::dbaccess::DST_USERDEFINE1: /// first user defined driver case ::dbaccess::DST_USERDEFINE2: case ::dbaccess::DST_USERDEFINE3: case ::dbaccess::DST_USERDEFINE4: case ::dbaccess::DST_USERDEFINE5: case ::dbaccess::DST_USERDEFINE6: case ::dbaccess::DST_USERDEFINE7: case ::dbaccess::DST_USERDEFINE8: case ::dbaccess::DST_USERDEFINE9: case ::dbaccess::DST_USERDEFINE10:
{
OUString aTitle(DBA_RES(STR_PAGETITLE_ADVANCED));
AddTabPage("user" + OUString::number(eType - dbaccess::DST_USERDEFINE1 + 1), aTitle, ODriversSettings::CreateUser);
} break; default: break;
}
}
void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource)
{ // the selection is valid if and only if we have a datasource now
GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is())); // (sal_False tells the tab pages to disable and reset all their controls, which is different // from "just set them to readonly")
// reset the pages
// prevent flicker
m_xDialog->freeze();
// remove all items which relate to indirect properties from the input set // (without this, the following may happen: select an arbitrary data source where some indirect properties // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, // the indirect property values of the first ds are shown in the second ds ...) const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); for (autoconst& elem : rMap)
GetInputSetImpl()->ClearItem( static_cast<sal_uInt16>(elem.first) );
// extract all relevant data from the property set of the data source
m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl());
// reset the example set
m_xExampleSet.reset(new SfxItemSet(*GetInputSetImpl()));
// special case: MySQL Native does not have the generic "advanced" page
SetCurPageId(m_sMainPageID);
SfxTabPage* pConnectionPage = GetTabPage(m_sMainPageID); if ( pConnectionPage )
pConnectionPage->Reset(GetInputSetImpl()); // if this is NULL, the page has not been created yet, which means we're called before the // dialog was displayed (probably from inside the ctor)
ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
{ if (!PrepareLeaveCurrentPage())
{ // the page did not allow us to leave return AR_KEEP;
}
if ( !m_pImpl->saveChanges(*m_xExampleSet) ) return AR_KEEP;
static std::unique_ptr<ItemInfoPackageAdminDlg> g_aItemInfoPackageAdminDlg; if (!g_aItemInfoPackageAdminDlg)
g_aItemInfoPackageAdminDlg.reset(new ItemInfoPackageAdminDlg); return *g_aItemInfoPackageAdminDlg;
}
void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
{ // just to be sure...
_rpSet = nullptr;
_rpPool = nullptr;
_rpPool = new SfxItemPool(u"DSAItemPool"_ustr);
// here we have to use the callback to create all needed default entries since // the DSID_TYPECOLLECTION needs the local given _pTypeCollection. Thus this will // be a ItemInfoDynamic created by SfxItemPool::registerItemInfoPackage. That // (and the contained Item) will be owned by the Pool and cleaned up when it goes // down (see SfxItemPool::cleanupItemInfos())
_rpPool->registerItemInfoPackage(
getItemInfoPackageAdminDlg(),
[&_pTypeCollection](sal_uInt16 nWhich)
{
SfxPoolItem* pRetval(nullptr); if (DSID_TYPECOLLECTION == nWhich)
pRetval = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection); return pRetval;
});
// and, finally, the set
_rpSet.reset(new SfxItemSet(*_rpPool));
}
void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool)
{ // _first_ delete the set (referring the pool)
_rpSet.reset();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.