/* -*- 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 .
*/
void OGeneralPage::onTypeSelected(const OUString& _sURLPrefix)
{ // the new URL text as indicated by the selection history
implSetCurrentType( _sURLPrefix );
// notify our listener that our type selection has changed (if so) // FIXME: how to detect that it did not changed? (fdo#62937)
setParentTitle( m_eCurrentSelection );
onTypeSelected( m_eCurrentSelection );
// a special message for the current page state
switchMessage( m_eCurrentSelection );
OUString OGeneralPageWizard::getEmbeddedDBName( const SfxItemSet& _rSet )
{ if (!m_pCollection) return {}; // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly;
getFlags( _rSet, bValid, bReadonly ); if (!bValid) return {};
// compare the DSN prefix with the registered ones
OUString sDBURL; if (const SfxStringItem* pUrlItem = _rSet.GetItem<SfxStringItem>(DSID_CONNECTURL)) if (dbaccess::ODsnTypeCollection::isEmbeddedDatabase(pUrlItem->GetValue()))
sDBURL = pUrlItem->GetValue(); if (sDBURL.isEmpty())
sDBURL = dbaccess::ODsnTypeCollection::getEmbeddedDatabase();
OUString sDisplayName = m_pCollection->getTypeDisplayName(sDBURL);
// ensure presence of the correct datasource type if (!sDisplayName.isEmpty() && m_xEmbeddedDBType->find_text(sDisplayName) == -1)
{ // this indicates it's really a type which is known in general, but not supported on the current platform // show a message saying so // eSpecialMessage = smUnsupportedType;
insertEmbeddedDBTypeEntryData(sDBURL, sDisplayName);
}
return sDisplayName;
}
OUString OGeneralPage::getDatasourceName( const SfxItemSet& _rSet )
{ // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly;
getFlags( _rSet, bValid, bReadonly );
// if the selection is invalid, disable everything
OUString sConnectURL; if ( bValid )
{ // collect some items and some values const SfxStringItem* pUrlItem = _rSet.GetItem<SfxStringItem>(DSID_CONNECTURL);
assert( pUrlItem );
sConnectURL = pUrlItem->GetValue();
}
implSetCurrentType( OUString() );
// compare the DSN prefix with the registered ones
OUString sDisplayName;
// select the correct datasource type if ( approveDatasourceType( m_eCurrentSelection, sDisplayName )
&& m_xDatasourceType->find_text(sDisplayName) == -1 )
{ // this indicates it's really a type which is known in general, but not supported on the current platform // show a message saying so // eSpecialMessage = smUnsupportedType;
insertDatasourceTypeEntryData( m_eCurrentSelection, sDisplayName );
}
return sDisplayName;
}
// For the databaseWizard we only have one entry for the MySQL Database, // because we have a separate tabpage to retrieve the respective datasource type // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary // representative for all MySQl databases) // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of // databases to connect to. bool OGeneralPage::approveDatasourceType( std::u16string_view _sURLPrefix, OUString& _inout_rDisplayName )
{ return approveDatasourceType( m_pCollection->determineType(_sURLPrefix), _inout_rDisplayName );
}
bool OGeneralPage::approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName )
{ if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT )
{ // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if // this driver is installed if ( m_pCollection->hasDriver( u"sdbc:mysql:mysqlc:" ) )
_inout_rDisplayName.clear();
}
void OGeneralPage::Reset(const SfxItemSet* _rCoreAttrs)
{ // reset all locale data
implSetCurrentType( OUString() ); // this ensures that our type selection link will be called, even if the new one is the same as the // current one
OGenericAdministrationPage::Reset(_rCoreAttrs);
}
IMPL_LINK( OGeneralPageWizard, OnEmbeddedDBTypeSelected, weld::ComboBox&, _rBox, void )
{ // get the type from the entry data const sal_Int32 nSelected = _rBox.get_active(); if (o3tl::make_unsigned(nSelected) >= m_aEmbeddedURLPrefixes.size() )
{
SAL_WARN("dbaccess.ui.generalpage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix"); return;
} const OUString sURLPrefix = m_aEmbeddedURLPrefixes[ nSelected ];
setParentTitle( sURLPrefix ); // let the impl method do all the stuff
onTypeSelected( sURLPrefix ); // tell the listener we were modified
callModifiedHdl();
}
IMPL_LINK( OGeneralPage, OnDatasourceTypeSelected, weld::ComboBox&, _rBox, void )
{ // get the type from the entry data const sal_Int32 nSelected = _rBox.get_active(); if (nSelected == -1) return; if (o3tl::make_unsigned(nSelected) >= m_aURLPrefixes.size() )
{
SAL_WARN("dbaccess.ui.generalpage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectedEntryPos(): no corresponding URL prefix"); return;
} const OUString sURLPrefix = m_aURLPrefixes[ nSelected ];
setParentTitle( sURLPrefix ); // let the impl method do all the stuff
onTypeSelected( sURLPrefix ); // tell the listener we were modified
callModifiedHdl();
}
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly );
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) bool bValid, bReadonly;
getFlags( _rSet, bValid, bReadonly );
OUString sPath = aFileDlg.GetPath(); // check for aFileDlg.GetCurrentFilter used to be here but current fpicker filter // can be set to anything, see tdf#125267 how this breaks if other value // than 'ODF Database' is selected. Let's therefore check only if wildcard matches if (pFilter && !pFilter->GetWildcard().Matches(sPath))
{
OUString sMessage(DBA_RES(STR_ERR_USE_CONNECT_TO));
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
sMessage));
xInfoBox->run();
m_xRB_ConnectDatabase->set_active(true);
OnSetupModeSelected( *m_xRB_ConnectDatabase ); return;
}
m_aBrowsedDocumentURL = sPath;
m_aChooseDocumentHandler.Call( *this );
}
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.