core.git: Branch 'libreoffice-24-2' - dbaccess/source
dbaccess/source/ui/relationdesign/RTableConnection.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 3079e0c1ff781c77b0b279dea9ec97a5a24e5b92 Author: Caolán McNamara AuthorDate: Wed May 8 09:37:59 2024 +0100 Commit: Xisco Fauli CommitDate: Wed May 8 13:42:22 2024 +0200 return early on empty ORelationTableConnectionData* we test for pData existing, but it it doesn't then we continue and will typically dereference it, so test looks inverted Change-Id: Iddcab25d5620942bb617bd1e9985322f5e497839 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167331 Reviewed-by: Caolán McNamara Tested-by: Jenkins (cherry picked from commit 0b97bfa88ffebf31778f0f68e883e046822cd264) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167313 Reviewed-by: Xisco Fauli diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx index ba60ae54661b..4b8086f5111f 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx @@ -51,7 +51,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const to { OTableConnection::Draw(rRenderContext, rRect); ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get()); -if (pData && (pData->GetCardinality() == Cardinality::Undefined)) +if (!pData || pData->GetCardinality() == Cardinality::Undefined) return; // search lines for top line
core.git: Branch 'libreoffice-24-2' - dbaccess/source
dbaccess/source/ui/relationdesign/RTableConnectionData.cxx |5 +++-- dbaccess/source/ui/relationdesign/RelationTableView.cxx| 10 ++ 2 files changed, 9 insertions(+), 6 deletions(-) New commits: commit eb045cc529f0e7b17e7e3bc913f2ab1748247966 Author: Pierre AuthorDate: Sat Apr 13 19:19:50 2024 +0200 Commit: Xisco Fauli CommitDate: Mon May 6 10:23:20 2024 +0200 tdf#160375 Base displays and gives the full name of the table Change-Id: Icc8c6d85cc5a88461b7bd02487513e0e864bacef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166093 Reviewed-by: Pierre Vacher Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 2fb7c0b8213c..9651a89c9f09 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -256,7 +256,8 @@ bool ORelationTableConnectionData::Update() xKey->setPropertyValue(PROPERTY_NAME,Any(sKeyName)); xKey->setPropertyValue(PROPERTY_TYPE,Any(KeyType::FOREIGN)); - xKey->setPropertyValue(PROPERTY_REFERENCEDTABLE,Any(getReferencedTable()->GetTableName())); +// get the full name of the tables to ensure uniqueness across catalogs and schema + xKey->setPropertyValue(PROPERTY_REFERENCEDTABLE,Any(getReferencedTable()->GetComposedName())); xKey->setPropertyValue(PROPERTY_UPDATERULE, Any(GetUpdateRules())); xKey->setPropertyValue(PROPERTY_DELETERULE, Any(GetDeleteRules())); } @@ -301,7 +302,7 @@ bool ORelationTableConnectionData::Update() { OUString sReferencedTable; xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable; -if ( sReferencedTable == getReferencedTable()->GetTableName() ) +if ( sReferencedTable == getReferencedTable()->GetComposedName() ) { xColSup.set(xKey,UNO_QUERY_THROW); try diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index 6c96d3952047..da82719b7a23 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -108,7 +108,8 @@ void ORelationTableView::ReSync() // it should be cleaned up, including its data in the document pTabWin->clearListBox(); pTabWin.disposeAndClear(); -arrInvalidTables.push_back(pData->GetTableName()); +// get the full name of the tables to ensure uniqueness across catalogs and schema +arrInvalidTables.push_back(pData->GetComposedName()); std::erase(rTabWinDataList, *aIter); continue; @@ -132,9 +133,9 @@ void ORelationTableView::ReSync() if ( !arrInvalidTables.empty() ) { // do the tables to the connection exist? -OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetTableName(); +OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetComposedName(); bool bInvalid = std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end(); -strTabExistenceTest = pTabConnData->getReferencedTable()->GetTableName(); +strTabExistenceTest = pTabConnData->getReferencedTable()->GetComposedName(); bInvalid = bInvalid || std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end(); if (bInvalid) @@ -290,7 +291,8 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin } // enter the new data structure into DocShell -TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName )); +// show the table's full name as window name to ensure uniqueness across catalogs and schema +TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName, _rComposedName )); pNewTabWinData->ShowAll(false); // link new window into the window list
core.git: Branch 'libreoffice-24-2' - dbaccess/source
dbaccess/source/ui/misc/UITools.cxx| 45 + dbaccess/source/ui/misc/WCopyTable.cxx |1 dbaccess/source/ui/tabledesign/TableController.cxx |4 - 3 files changed, 31 insertions(+), 19 deletions(-) New commits: commit c94c724d0ba9da6f6bacd6e9c6025ad0759d9658 Author: Mike Kaganski AuthorDate: Tue Mar 19 16:48:19 2024 +0500 Commit: Christian Lohmaier CommitDate: Thu Apr 11 19:17:42 2024 +0200 Related: tdf#108057 Use autoincrement for automatically added primary key This partially undoes commit 24940e2c3717ad7b07d43db4f08cf7e09cfcc22f (#100599# #95927# check if row is readonly and disable autoincrement column for auto primarykey, 2002-06-27), enabling autoincrement again. Make sure to use the largest type that supports autoincrement. Change-Id: I4dfdbfb0c3d9b94c7634082b029c6e66aa01c782 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165027 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit c07548447a564b2d142cc439a124b76e6a71dfbd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165001 Reviewed-by: Christian Lohmaier diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 483afced1082..910baad617df 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1047,29 +1047,40 @@ void setEvalDateFormatForFormatter(Reference< css::util::XNumberFormatter > cons } } +static bool TypeIsGreater(const TOTypeInfoSP& lhs, const TOTypeInfoSP& rhs) +{ +assert(lhs); +if (!rhs) +return true; +if (lhs->nNumPrecRadix == rhs->nNumPrecRadix) +return lhs->nPrecision > rhs->nPrecision; +if (lhs->nPrecision == rhs->nPrecision) +return lhs->nNumPrecRadix > rhs->nNumPrecRadix; +if ((lhs->nNumPrecRadix > rhs->nNumPrecRadix) == (lhs->nPrecision > rhs->nPrecision)) +return lhs->nPrecision > rhs->nPrecision; +return std::pow(lhs->nNumPrecRadix, lhs->nPrecision) + > std::pow(rhs->nNumPrecRadix, rhs->nPrecision); +} + TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo) { -TOTypeInfoSP pTypeInfo; -// first we search for a type which supports autoIncrement +TOTypeInfoSP pTypeInfo, pFallback; +// first we search for a largest type which supports autoIncrement for (auto const& elem : _rTypeInfo) { -// OJ: we don't want to set an autoincrement column to be key -// because we don't have the possibility to know how to create -// such auto increment column later on -// so until we know how to do it, we create a column without autoincrement -// therefore we have searched -if ( elem.second->nType == DataType::INTEGER ) -{ -pTypeInfo = elem.second; // alternative -break; -} -else if ( !pTypeInfo && elem.second->nType == DataType::DOUBLE ) -pTypeInfo = elem.second; // alternative -else if ( !pTypeInfo && elem.second->nType == DataType::REAL ) -pTypeInfo = elem.second; // alternative +if (elem.second->bAutoIncrement && TypeIsGreater(elem.second, pTypeInfo)) +pTypeInfo = elem.second; +if (pTypeInfo) +continue; +if (elem.second->nType == DataType::INTEGER) +pFallback = elem.second; // default alternative +else if (!pFallback && elem.second->nType == DataType::DOUBLE) +pFallback = elem.second; // alternative +else if (!pFallback && elem.second->nType == DataType::REAL) +pFallback = elem.second; // alternative } if ( !pTypeInfo ) // just a fallback -pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo); +pTypeInfo = pFallback ? pFallback : queryTypeInfoByType(DataType::VARCHAR, _rTypeInfo); OSL_ENSURE(pTypeInfo,"checkColumns: can't find a type which is usable as a key!"); return pTypeInfo; diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 29be8774747b..a2737543c705 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -737,6 +737,7 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) OFieldDescription* pField = new OFieldDescription(); pField->SetName(m_aKeyName); pField->FillFromTypeInfo(pTypeInfo,true,true); +pField->SetAutoIncrement(pTypeInfo->bAutoIncrement); pField->SetPrimaryKey(true); m_bAddPKFirstTime = false; insertColumn(0,pField); diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 7e13ba566bb2..fd53297cad00 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesig
core.git: Branch 'libreoffice-24-2' - dbaccess/source
dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx |6 +++- dbaccess/source/ui/dlg/dbwizsetup.cxx |3 ++ dbaccess/source/ui/dlg/generalpage.cxx| 32 ++ 3 files changed, 23 insertions(+), 18 deletions(-) New commits: commit 8e0bb9dadb9ef77f693cf6d334843cfb9b4701a3 Author: Mike Kaganski AuthorDate: Tue Mar 19 11:47:14 2024 +0500 Commit: Adolfo Jayme Barrientos CommitDate: Thu Mar 28 06:37:08 2024 +0100 tdf#103068: make sure to update and use current MySQL connection type 1. Don't set selection in OGeneralPageWizard::getEmbeddedDBName. The method should only provide a name of an embedded database - either in the passed set, or the default one; the activation of controls and related actions will be done in the calling implInitControls. This makes sure, that ODbTypeWizDialogSetup::m_sURL doesn't get rewritten unnecessarily, keeping the current preference intact. 2. In ODbTypeWizDialogSetup::activateDatabasePath, do not use the hardcoded MySQL URL from the control, if the current value of m_sURL is already a MySQL one. This allows to keep the selected kind intact. 3. In OMySQLIntroPageSetup::implInitControls, do not assume that the existing selection means that there's nothing to do. The page keeps the selection, even when the wizard's active path was changed; and so, the wizard's idea which page to show next may differ from the selection. Just make sure to update the setup mode. Change-Id: Iad98d54a615dccc58b2852a1c0d8aefad6b0b898 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164987 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 1e66905c840dbee0a67e444fca80bdacfcb6e6b2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165000 Reviewed-by: Adolfo Jayme Barrientos diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index 22cdefdd6c31..ad81680ba421 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -239,9 +239,13 @@ using namespace ::com::sun::star; if ( bHasMySQLNative ) m_xNATIVEDatabase->show(); -// if any of the options is checked, then there's nothing to do +// tdf#103068: if any of the options is checked, then just update the selected kind: +// it could happen that the selection and the wizard path are not in sync if ( m_xODBCDatabase->get_active() || m_xJDBCDatabase->get_active() || m_xNATIVEDatabase->get_active() ) +{ +maClickHdl.Call(this); return; +} // prefer "native" or "JDBC" if ( bHasMySQLNative ) diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 720892e2a015..2fb260e18e75 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -312,6 +312,9 @@ void ODbTypeWizDialogSetup::activateDatabasePath() { OUString sOld = m_sURL; m_sURL = m_pGeneralPage->GetSelectedType(); +if (m_sURL.startsWith("sdbc:mysql:") && sOld.startsWith("sdbc:mysql:")) +m_sURL = sOld; // The type of MySQL connection was already set elsewhere; just use it, + // instead of the hardcoded one from the selector DataSourceInfoConverter::convert(getORB(), m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource()); ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL)); if (eType == ::dbaccess::DST_UNKNOWN) diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index a2a48158c56d..bb308845528e 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -226,31 +226,29 @@ namespace dbaui 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 the selection is invalid, disable everything - -implSetCurrentType( OUString() ); +if (!bValid) +return {}; // compare the DSN prefix with the registered ones -OUString sDisplayName; - -if (m_pCollection && bValid) -{ -implSetCurrentType( dbaccess::ODsnTypeCollection::getEmbeddedDatabase() ); -sDisplayName = m_pCollection->getTypeDisplayName( m_eCurrentSelection ); -onTypeSelected(m_eCurrentSelection); -} - -// select the correct datasource type -if ( dbaccess::ODsnTypeCollection::isEmbeddedDatabase( m_eCurrentSelec