tdf#158056 Connect to MS Access .mdb files by mean of ACE.OLEDB.12.0 provider

* Modify the code so that all connections to MS Access files, both .mdb
and .accdb are made with the provider "Microsoft.ACE.OLEDB.12.0".
* Remove all references to the "Microsoft.Jet.OLEDB.4.0" provider to clean
up the code.
* Leave only one entry "Microsoft Access" in the Connection Wizard, which
would work for .mdb and .accdb files.
* Remove the entry "Microsoft Access 2007" from the Connection Wizard,
since it is no longer needed.

Change-Id: If523712d071199d61e0c994b35291d3a69246ad1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165756
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
jucasaca 2024-04-03 18:15:39 +02:00 committed by Mike Kaganski
parent e1268721d4
commit 7edca7dc74
12 changed files with 13 additions and 64 deletions

View file

@ -214,7 +214,7 @@
</node> </node>
</node> </node>
</node> </node>
<node oor:name="sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*" oor:op="replace"> <node oor:name="sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=*" oor:op="replace">
<prop oor:name="Driver"> <prop oor:name="Driver">
<value>com.sun.star.comp.sdbc.ado.ODriver</value> <value>com.sun.star.comp.sdbc.ado.ODriver</value>
</prop> </prop>
@ -340,7 +340,7 @@
</node> </node>
<node oor:name="Extension" oor:op="replace"> <node oor:name="Extension" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string"> <prop oor:name="Value" oor:type="xs:string">
<value>mdb</value> <value></value>
</prop> </prop>
</node> </node>
<node oor:name="SupportsColumnDescription" oor:op="replace"> <node oor:name="SupportsColumnDescription" oor:op="replace">
@ -350,20 +350,5 @@
</node> </node>
</node> </node>
</node> </node>
<node oor:name="sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=*" oor:op="replace">
<prop oor:name="ParentURLPattern">
<value>sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">Microsoft Access 2007</value>
</prop>
<node oor:name="MetaData">
<node oor:name="Extension" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
</node>
</node>
</node> </node>
</oor:component-data> </oor:component-data>

View file

@ -121,9 +121,9 @@ void OConnection::construct(std::u16string_view url,const Sequence< PropertyValu
WpADOProperties aProps = m_aAdoConnection.get_Properties(); WpADOProperties aProps = m_aAdoConnection.get_Properties();
if(aProps.IsValid()) if(aProps.IsValid())
{ {
OTools::putValue(aProps, std::u16string_view(u"Jet OLEDB:ODBC Parsing"), true); OTools::putValue(aProps, std::u16string_view(u"ACE OLEDB:ODBC Parsing"), true);
OLEVariant aVar( OLEVariant aVar(
OTools::getValue(aProps, std::u16string_view(u"Jet OLEDB:Engine Type"))); OTools::getValue(aProps, std::u16string_view(u"ACE OLEDB:Engine Type")));
if(!aVar.isNull() && !aVar.isEmpty()) if(!aVar.isNull() && !aVar.isEmpty())
m_nEngineType = aVar.getInt32(); m_nEngineType = aVar.getInt32();
} }
@ -184,7 +184,7 @@ OUString SAL_CALL OConnection::nativeSQL( const OUString& _sql )
WpADOProperties aProps = m_aAdoConnection.get_Properties(); WpADOProperties aProps = m_aAdoConnection.get_Properties();
if(aProps.IsValid()) if(aProps.IsValid())
{ {
OTools::putValue(aProps, std::u16string_view(u"Jet OLEDB:ODBC Parsing"), true); OTools::putValue(aProps, std::u16string_view(u"ACE OLEDB:ODBC Parsing"), true);
WpADOCommand aCommand; WpADOCommand aCommand;
aCommand.Create(); aCommand.Create();
aCommand.put_ActiveConnection(static_cast<IDispatch*>(m_aAdoConnection)); aCommand.put_ActiveConnection(static_cast<IDispatch*>(m_aAdoConnection));

View file

@ -293,7 +293,6 @@
#define STR_JDBCDRIVER_SUCCESS NC_("STR_JDBCDRIVER_SUCCESS", "The JDBC driver was loaded successfully.") #define STR_JDBCDRIVER_SUCCESS NC_("STR_JDBCDRIVER_SUCCESS", "The JDBC driver was loaded successfully.")
#define STR_JDBCDRIVER_NO_SUCCESS NC_("STR_JDBCDRIVER_NO_SUCCESS", "The JDBC driver could not be loaded.") #define STR_JDBCDRIVER_NO_SUCCESS NC_("STR_JDBCDRIVER_NO_SUCCESS", "The JDBC driver could not be loaded.")
#define STR_MSACCESS_FILTERNAME NC_("STR_MSACCESS_FILTERNAME", "MS Access file") #define STR_MSACCESS_FILTERNAME NC_("STR_MSACCESS_FILTERNAME", "MS Access file")
#define STR_MSACCESS_2007_FILTERNAME NC_("STR_MSACCESS_2007_FILTERNAME", "MS Access 2007 file")
#define STR_FIREBIRD_FILTERNAME NC_("STR_FIREBIRD_FILTERNAME", "Firebird Database") #define STR_FIREBIRD_FILTERNAME NC_("STR_FIREBIRD_FILTERNAME", "Firebird Database")
#define STR_RSC_CHARSETS NC_("STR_RSC_CHARSETS", "System") #define STR_RSC_CHARSETS NC_("STR_RSC_CHARSETS", "System")

View file

@ -228,8 +228,7 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
_rsHostname = sUrl.getToken(0,'/'); _rsHostname = sUrl.getToken(0,'/');
_sDatabaseName = sUrl.copy(sUrl.lastIndexOf('/')+1); _sDatabaseName = sUrl.copy(sUrl.lastIndexOf('/')+1);
} }
else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=") else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:"))
|| _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=") )
{ {
OUString sNewFileName; OUString sNewFileName;
if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None ) if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None )
@ -339,9 +338,6 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(std::u16string_view _rDsn) con
{ {
if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:")) if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:"))
{ {
if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;"))
return DST_MSACCESS_2007;
else
return DST_MSACCESS; return DST_MSACCESS;
} }
return DST_ADO; return DST_ADO;
@ -455,7 +451,6 @@ void ODsnTypeCollection::fillPageIds(std::u16string_view _sURL,std::vector<sal_I
_rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP); _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP);
break; break;
case DST_MSACCESS: case DST_MSACCESS:
case DST_MSACCESS_2007:
_rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS); _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS);
break; break;
case DST_OUTLOOKEXP: case DST_OUTLOOKEXP:

View file

@ -55,7 +55,6 @@ enum DATASOURCE_TYPE
DST_EVOLUTION_LDAP = 19, DST_EVOLUTION_LDAP = 19,
DST_KAB = 20, DST_KAB = 20,
DST_MACAB = 21, DST_MACAB = 21,
DST_MSACCESS_2007 = 22,
DST_EMBEDDED_HSQLDB = 23, DST_EMBEDDED_HSQLDB = 23,
DST_MYSQL_NATIVE = 24, DST_MYSQL_NATIVE = 24,
DST_MYSQL_NATIVE_DIRECT = 25, DST_MYSQL_NATIVE_DIRECT = 25,

View file

@ -217,22 +217,11 @@ namespace dbaui
::sfx2::FileDialogHelper aFileDlg( ::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
FileDialogFlags::NONE, GetFrameWeld()); FileDialogFlags::NONE, GetFrameWeld());
aFileDlg.AddFilter(sFilterName,"*.mdb;*.mde"); aFileDlg.AddFilter(sFilterName,"*.accdb;*.accde;*.mdb;*.mde");
aFileDlg.SetCurrentFilter(sFilterName); aFileDlg.SetCurrentFilter(sFilterName);
askForFileName(aFileDlg); askForFileName(aFileDlg);
} }
break; break;
case ::dbaccess::DST_MSACCESS_2007:
{
OUString sFilterName2(DBA_RES (STR_MSACCESS_2007_FILTERNAME));
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
FileDialogFlags::NONE, GetFrameWeld());
aFileDlg.AddFilter(sFilterName2,"*.accdb;*.accde");
aFileDlg.SetCurrentFilter(sFilterName2);
askForFileName(aFileDlg);
}
break;
case ::dbaccess::DST_MYSQL_ODBC: case ::dbaccess::DST_MYSQL_ODBC:
case ::dbaccess::DST_ODBC: case ::dbaccess::DST_ODBC:
{ {
@ -659,7 +648,7 @@ namespace dbaui
const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_WRITER == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) ) if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_WRITER == eType) || ( ::dbaccess::DST_MSACCESS == eType) )
{ {
if( pathExists(sURL, true) == PATH_NOT_EXIST ) if( pathExists(sURL, true) == PATH_NOT_EXIST )
{ {

View file

@ -105,7 +105,6 @@ namespace dbaui
m_xFT_Connection->set_label(DBA_RES(STR_COMMONURL)); m_xFT_Connection->set_label(DBA_RES(STR_COMMONURL));
break; break;
case ::dbaccess::DST_MSACCESS: case ::dbaccess::DST_MSACCESS:
case ::dbaccess::DST_MSACCESS_2007:
m_xFT_Connection->set_label(DBA_RES(STR_MSACCESS_MDB_FILE)); m_xFT_Connection->set_label(DBA_RES(STR_MSACCESS_MDB_FILE));
m_xConnectionURL->set_help_id(HID_DSADMIN_MSACCESS_MDB_FILE); m_xConnectionURL->set_help_id(HID_DSADMIN_MSACCESS_MDB_FILE);
break; break;

View file

@ -465,7 +465,6 @@ OUString ODbDataSourceAdministrationHelper::getConnectionURL() const
case ::dbaccess::DST_WRITER: case ::dbaccess::DST_WRITER:
break; break;
case ::dbaccess::DST_MSACCESS: case ::dbaccess::DST_MSACCESS:
case ::dbaccess::DST_MSACCESS_2007:
{ {
OUString sFileName = pCollection->cutPrefix(pUrlItem->GetValue()); OUString sFileName = pCollection->cutPrefix(pUrlItem->GetValue());
OUString sNewFileName; OUString sNewFileName;

View file

@ -137,7 +137,6 @@ WizardState ODbTypeWizDialog::determineNextState( WizardState _nCurrentState ) c
case ::dbaccess::DST_KAB: case ::dbaccess::DST_KAB:
case ::dbaccess::DST_MACAB: case ::dbaccess::DST_MACAB:
case ::dbaccess::DST_MSACCESS: case ::dbaccess::DST_MSACCESS:
case ::dbaccess::DST_MSACCESS_2007:
case ::dbaccess::DST_JDBC: case ::dbaccess::DST_JDBC:
case ::dbaccess::DST_CALC: case ::dbaccess::DST_CALC:
case ::dbaccess::DST_WRITER: case ::dbaccess::DST_WRITER:

View file

@ -485,7 +485,6 @@ enum class DBConnURIType
CALC, CALC,
DBASE, DBASE,
FLAT, FLAT,
MSJET,
MSACE, MSACE,
WRITER WRITER
}; };

View file

@ -891,8 +891,7 @@
#define STR_FILTER_DOC NC_("STR_FILTER_DOC", "Microsoft Word") #define STR_FILTER_DOC NC_("STR_FILTER_DOC", "Microsoft Word")
#define STR_FILTER_TXT NC_("STR_FILTER_TXT", "Plain text") #define STR_FILTER_TXT NC_("STR_FILTER_TXT", "Plain text")
#define STR_FILTER_CSV NC_("STR_FILTER_CSV", "Text Comma Separated") #define STR_FILTER_CSV NC_("STR_FILTER_CSV", "Text Comma Separated")
#define STR_FILTER_MDB NC_("STR_FILTER_MDB", "Microsoft Access") #define STR_FILTER_ACCDB NC_("STR_FILTER_ACCDB", "Microsoft Access")
#define STR_FILTER_ACCDB NC_("STR_FILTER_ACCDB", "Microsoft Access 2007")
#define ST_CONFIGUREMAIL NC_("ST_CONFIGUREMAIL", "In order to be able to send mail merge documents by email, %PRODUCTNAME requires information about the email account to be used.\n\nDo you want to enter email account information now?") #define ST_CONFIGUREMAIL NC_("ST_CONFIGUREMAIL", "In order to be able to send mail merge documents by email, %PRODUCTNAME requires information about the email account to be used.\n\nDo you want to enter email account information now?")
#define ST_FILTERNAME NC_("ST_FILTERNAME", "%PRODUCTNAME Address List (.csv)") #define ST_FILTERNAME NC_("ST_FILTERNAME", "%PRODUCTNAME Address List (.csv)")

View file

@ -2571,11 +2571,8 @@ DBConnURIType GetDBunoType(const INetURLObject &rURL)
type = DBConnURIType::FLAT; type = DBConnURIType::FLAT;
} }
#ifdef _WIN32 #ifdef _WIN32
else if (sExt.equalsIgnoreAsciiCase("mdb") || sExt.equalsIgnoreAsciiCase("mde")) else if (sExt.equalsIgnoreAsciiCase("accdb") || sExt.equalsIgnoreAsciiCase("accde")
{ || sExt.equalsIgnoreAsciiCase("mdb") || sExt.equalsIgnoreAsciiCase("mde"))
type = DBConnURIType::MSJET;
}
else if (sExt.equalsIgnoreAsciiCase("accdb") || sExt.equalsIgnoreAsciiCase("accde"))
{ {
type = DBConnURIType::MSACE; type = DBConnURIType::MSACE;
} }
@ -2631,14 +2628,6 @@ uno::Any GetDBunoURI(const INetURLObject &rURL, DBConnURIType& rType)
aUrlTmp.GetMainURL(INetURLObject::DecodeMechanism::NONE); aUrlTmp.GetMainURL(INetURLObject::DecodeMechanism::NONE);
aURLAny <<= sDBURL; aURLAny <<= sDBURL;
} }
break;
case DBConnURIType::MSJET:
#ifdef _WIN32
{
OUString sDBURL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + rURL.PathToFileName());
aURLAny <<= sDBURL;
}
#endif
break; break;
case DBConnURIType::MSACE: case DBConnURIType::MSACE:
#ifdef _WIN32 #ifdef _WIN32
@ -2698,7 +2687,6 @@ OUString LoadAndRegisterDataSource_Impl(DBConnURIType type, const uno::Reference
aTableFilterAny <<= aFilters; aTableFilterAny <<= aFilters;
} }
break; break;
case DBConnURIType::MSJET:
case DBConnURIType::MSACE: case DBConnURIType::MSACE:
aSuppressVersionsAny <<= true; aSuppressVersionsAny <<= true;
break; break;
@ -2805,8 +2793,7 @@ OUString SwDBManager::LoadAndRegisterDataSource(weld::Window* pParent, SwDocShel
{ SwResId(STR_FILTER_TXT), "*.txt" }, { SwResId(STR_FILTER_TXT), "*.txt" },
{ SwResId(STR_FILTER_CSV), "*.csv" }, { SwResId(STR_FILTER_CSV), "*.csv" },
#ifdef _WIN32 #ifdef _WIN32
{ SwResId(STR_FILTER_MDB), "*.mdb;*.mde" }, { SwResId(STR_FILTER_ACCDB), "*.accdb;*.accde;*.mdb;*.mde" },
{ SwResId(STR_FILTER_ACCDB), "*.accdb;*.accde" },
#endif #endif
}; };