summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/dlg/DbAdminImpl.cxx
diff options
context:
space:
mode:
authornirnay <nirnaykorde@gmail.com>2023-04-18 15:05:25 +0530
committerMichael Weghorn <m.weghorn@posteo.de>2023-04-28 05:50:30 +0200
commitafe99617707c92460e66486c0057ef327e8aa017 (patch)
treea165edd2d25a209848c68ef0af7f517de0ff108f /dbaccess/source/ui/dlg/DbAdminImpl.cxx
parent2e57755f72907e4bb604a8ba32edbd6c253ee57c (diff)
tdf#43369: Specific UI for collecting PostgreSQL connection settings
strings.hrc is used to add the text visible in the GUI and hence coressponding strings have been defined for postgres GUI. dsntypes.cxx since a new GUI page has been created for postgres a new page routing has been inserted instead of it going to default Since oracle jdbc and mysql jdbc have almost the same GUI the oracle jdbc was used as reference since there is no middle page between the target GUI page, unlike in mysql jdbc. dsntypes.hxx corressponding page id has been added for postgres for routing. dbadmin.cxx new default postgres port id has been added added just like MySQL and defined like all. dsitems.hxx contains the DSID used dbadmin.cxx dbwizsetup.cxx this where the GUI page is being called for generation dbwizsetup.hxx holds the title page string UIConfig_dbaccess.mk includes the new postgres page postgrespage.ui is the UI page where the GUI part has been refered from specialjdbcconnectionpage.ui and the connection string has been taken from dbwizconnectionpage.ui instead of adding a label and edit option so that connection string prefix is handled in the GUI with pre-existing curledit.cxx DBSetupConnectionPage.hxx holds the declaration of all the functions called in the coressponding cxx file. The declaration is a mix of OGeneralSpecialJDBCConnectionPageSetup class from where the GUI is being handled and since there is no test connection from postgres the test driver has not been implemented, OConnectionTabPageSetup from which commit page has been inspired and OConnectionHelper is used to handle the connectionstring just like in the original class minus the file based system implementation. DbAdminminImpl.cxx is where the data is retrevied from GUI and and pasted at the back of the connection string which is now a usual postgres connection string. dbaccess.suppr the supression has been added for gtklabel of postgres which have no corresponding entry widget. Change-Id: Id60fd02a56b10c1cb9b09c9302c6ddf170be8493 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150546 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'dbaccess/source/ui/dlg/DbAdminImpl.cxx')
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 97210e843b00..176eb0a9be49 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -62,6 +62,7 @@
#include <iterator>
#include <functional>
#include <o3tl/functional.hxx>
+#include <comphelper/string.hxx>
namespace dbaui
{
@@ -523,6 +524,38 @@ OUString ODbDataSourceAdministrationHelper::getConnectionURL() const
sNewUrl = pCollection->cutPrefix(pUrlItem->GetValue()) + lcl_createHostWithPort(nullptr,pPortNumber);
}
break;
+ case ::dbaccess::DST_POSTGRES:
+ {
+ sNewUrl = pCollection->cutPrefix(pUrlItem->GetValue());
+ OUString rURL(comphelper::string::stripEnd(pUrlItem->GetValue(), '*'));
+ const SfxStringItem* pHostName = m_pItemSetHelper->getOutputSet()->GetItem<SfxStringItem>(DSID_CONN_HOSTNAME);
+ const SfxInt32Item* pPortNumber = m_pItemSetHelper->getOutputSet()->GetItem<SfxInt32Item>(DSID_POSTGRES_PORTNUMBER);
+ const SfxStringItem* pDatabaseName = m_pItemSetHelper->getOutputSet()->GetItem<SfxStringItem>(DSID_DATABASENAME);
+ if (pHostName && pHostName->GetValue().getLength())
+ {
+ OUString hostname( pHostName->GetValue() );
+ hostname = hostname.replaceAll( "\\", "\\\\");
+ hostname = hostname.replaceAll( "\'", "\\'");
+ hostname = "'" + hostname + "'";
+ rURL += " host=" + hostname;
+ }
+ if (pPortNumber && pPortNumber->GetValue())
+ {
+ OUString port = "'" + OUString::number(pPortNumber->GetValue()) + "'";
+ rURL += " port=" + port;
+ }
+ if (pDatabaseName && pDatabaseName->GetValue().getLength())
+ {
+ OUString dbname( pDatabaseName->GetValue() );
+ dbname = dbname.replaceAll( "\\", "\\\\");
+ dbname = dbname.replaceAll( "\'", "\\'");
+ dbname = "'" + dbname + "'";
+ rURL += " dbname=" + dbname;
+ }
+ sNewUrl = rURL;
+ return sNewUrl;
+ }
+ break;
case ::dbaccess::DST_JDBC:
// run through
default:
@@ -1000,6 +1033,9 @@ void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest)
case ::dbaccess::DST_LDAP:
nPortNumberId = DSID_CONN_LDAP_PORTNUMBER;
break;
+ case ::dbaccess::DST_POSTGRES:
+ nPortNumberId = DSID_POSTGRES_PORTNUMBER;
+ break;
default:
break;
}