dbaccess/UIConfig_dbaccess.mk                     |    1 
 dbaccess/inc/strings.hrc                          |    4 
 dbaccess/source/core/misc/dsntypes.cxx            |    3 
 dbaccess/source/inc/dsntypes.hxx                  |    1 
 dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx |  171 ++++++++++++++
 dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx |   54 ++++
 dbaccess/source/ui/dlg/DbAdminImpl.cxx            |   36 +++
 dbaccess/source/ui/dlg/dbadmin.cxx                |    2 
 dbaccess/source/ui/dlg/dbwizsetup.cxx             |    8 
 dbaccess/source/ui/inc/dbwizsetup.hxx             |    1 
 dbaccess/source/ui/inc/dsitems.hxx                |    3 
 dbaccess/uiconfig/ui/postgrespage.ui              |  253 ++++++++++++++++++++++
 solenv/sanitizers/ui/dbaccess.false               |    1 
 solenv/sanitizers/ui/dbaccess.suppr               |    1 
 14 files changed, 538 insertions(+), 1 deletion(-)

New commits:
commit afe99617707c92460e66486c0057ef327e8aa017
Author:     nirnay <nirnayko...@gmail.com>
AuthorDate: Tue Apr 18 15:05:25 2023 +0530
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 28 05:50:30 2023 +0200

    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.wegh...@posteo.de>

diff --git a/dbaccess/UIConfig_dbaccess.mk b/dbaccess/UIConfig_dbaccess.mk
index c0e6a28f895f..db2af00cff08 100644
--- a/dbaccess/UIConfig_dbaccess.mk
+++ b/dbaccess/UIConfig_dbaccess.mk
@@ -71,6 +71,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \
     dbaccess/uiconfig/ui/savedialog \
     dbaccess/uiconfig/ui/savemodifieddialog \
     dbaccess/uiconfig/ui/specialjdbcconnectionpage \
+    dbaccess/uiconfig/ui/postgrespage \
     dbaccess/uiconfig/ui/specialsettingspage \
     dbaccess/uiconfig/ui/sortdialog \
     dbaccess/uiconfig/ui/sqlexception \
diff --git a/dbaccess/inc/strings.hrc b/dbaccess/inc/strings.hrc
index aa902e592179..16669fe4ed9b 100644
--- a/dbaccess/inc/strings.hrc
+++ b/dbaccess/inc/strings.hrc
@@ -366,6 +366,7 @@
 #define STR_PAGETITLE_JDBC                          NC_("STR_PAGETITLE_JDBC", 
"Set up JDBC connection" )
 #define STR_PAGETITLE_ORACLE                        
NC_("STR_PAGETITLE_ORACLE", "Set up Oracle database connection" )
 #define STR_PAGETITLE_MYSQL                         NC_("STR_PAGETITLE_MYSQL", 
"Set up MySQL/MariaDB connection" )
+#define STR_PAGETITLE_POSTGRES                      
NC_("STR_PAGETITLE_POSTGRES", "Set up PostgreSQL connection" )
 #define STR_PAGETITLE_ODBC                          NC_("STR_PAGETITLE_ODBC", 
"Set up ODBC connection" )
 #define STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET       
NC_("STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET", "Set up Writer Document or 
Spreadsheet connection" )
 #define STR_PAGETITLE_AUTHENTIFICATION              
NC_("STR_PAGETITLE_AUTHENTIFICATION", "Set up user authentication" )
@@ -397,6 +398,9 @@
 #define STR_SPREADSHEET_HELPTEXT                    
NC_("STR_SPREADSHEET_HELPTEXT", "Click 'Browse...' to select a %PRODUCTNAME 
spreadsheet or Microsoft Excel workbook.\n%PRODUCTNAME will open this file in 
read-only mode." )
 #define STR_SPREADSHEETPATH                         NC_("STR_SPREADSHEETPATH", 
"~Location and file name" )
 
+#define STR_POSTGRES_HEADERTEXT                     
NC_("STR_POSTGRES_HEADERTEXT", "Set up connection to a POSTGRESQL database 
using GUI" )
+#define STR_POSTGRES_HELPTEXT                       
NC_("STR_POSTGRES_HELPTEXT", "Please enter the required information to connect 
to a PostgreSQL database either through by filling the hostname,port number and 
server OR by filling the connection string.\nPlease contact your system 
administrator if you are unsure about the following settings.")
+#define STR_POSTGRES_DEFAULT                        
NC_("STR_POSTGRES_DEFAULT", "Default: 5432")
 #define STR_COMMAND_EXECUTED_SUCCESSFULLY           
NC_("STR_COMMAND_EXECUTED_SUCCESSFULLY", "Command successfully executed." )
 #define STR_DIRECTSQL_CONNECTIONLOST                
NC_("STR_DIRECTSQL_CONNECTIONLOST", "The connection to the database has been 
lost. This dialog will be closed.")
 
diff --git a/dbaccess/source/core/misc/dsntypes.cxx 
b/dbaccess/source/core/misc/dsntypes.cxx
index 28f89b4c7b26..cfeaad56a671 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -446,6 +446,9 @@ void ODsnTypeCollection::fillPageIds(std::u16string_view 
_sURL,std::vector<sal_I
         case DST_ORACLE_JDBC:
             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE);
             break;
+        case DST_POSTGRES:
+            _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_POSTGRES);
+            break;
         case DST_LDAP:
             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP);
             break;
diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx
index 7bc664f10d85..d77a4020e53c 100644
--- a/dbaccess/source/inc/dsntypes.hxx
+++ b/dbaccess/source/inc/dsntypes.hxx
@@ -96,6 +96,7 @@ enum DATASOURCE_TYPE
 #define PAGE_DBSETUPWIZARD_FINAL                     16
 #define PAGE_DBSETUPWIZARD_USERDEFINED               17
 #define PAGE_DBSETUPWIZARD_MYSQL_NATIVE              18
+#define PAGE_DBSETUPWIZARD_POSTGRES                  19
 
 // ODsnTypeCollection
 class OOO_DLLPUBLIC_DBA ODsnTypeCollection final
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx 
b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
index a5041ae2af12..3537eddc9038 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -39,6 +39,9 @@
 #include "TextConnectionHelper.hxx"
 #include <osl/diagnose.h>
 
+#include <IItemSetHelper.hxx>
+#include <comphelper/string.hxx>
+
 namespace dbaui
 {
 using namespace ::com::sun::star;
@@ -499,6 +502,174 @@ using namespace ::com::sun::star;
         return std::make_unique<OJDBCConnectionPageSetup>(pPage, pController, 
_rAttrSet);
     }
 
+    // OPostgresConnectionPageSetup
+    OPostgresConnectionPageSetup::OPostgresConnectionPageSetup( 
weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& 
_rCoreAttrs ,sal_uInt16 _nPortId, TranslateId pDefaultPortResId, TranslateId 
pHelpTextResId, TranslateId pHeaderTextResId, TranslateId pConnectionTextResId)
+        : OGenericAdministrationPage(pPage, pController, 
"dbaccess/ui/postgrespage.ui", "SpecialPostgresPage", _rCoreAttrs)
+        , m_nPortId(_nPortId)
+        , m_xHeaderText(m_xBuilder->weld_label("header"))
+        , m_xFTHelpText(m_xBuilder->weld_label("helpLabel"))
+        , m_xFTDatabasename(m_xBuilder->weld_label("dbNameLabel"))
+        , m_xETDatabasename(m_xBuilder->weld_entry("dbNameEntry"))
+        , m_xFTHostname(m_xBuilder->weld_label("hostNameLabel"))
+        , m_xETHostname(m_xBuilder->weld_entry("hostNameEntry"))
+        , m_xFTPortNumber(m_xBuilder->weld_label("portNumLabel"))
+        , m_xFTDefaultPortNumber(m_xBuilder->weld_label("portNumDefLabel"))
+        , m_xNFPortNumber(m_xBuilder->weld_spin_button("portNumEntry"))
+        , m_xFTConnection(m_xBuilder->weld_label("connectionStringLabel"))
+        , m_xConnectionURL(new 
OConnectionURLEdit(m_xBuilder->weld_entry("browseurl"), 
m_xBuilder->weld_label("browselabel")))
+        // , m_pCollection(nullptr)
+    {
+        m_xFTConnection->set_label(DBA_RES(pConnectionTextResId));
+        m_xFTDefaultPortNumber->set_label(DBA_RES(pDefaultPortResId));
+        OUString sHelpText = DBA_RES(pHelpTextResId);
+        m_xFTHelpText->set_label(sHelpText);
+        //TODO this code snippet is redundant
+        m_xHeaderText->set_label(DBA_RES(pHeaderTextResId));
+
+        m_xETDatabasename->connect_changed(LINK(this, 
OGenericAdministrationPage, OnControlEntryModifyHdl));
+        m_xETHostname->connect_changed(LINK(this, OGenericAdministrationPage, 
OnControlEntryModifyHdl));
+        m_xNFPortNumber->connect_value_changed(LINK(this, 
OGenericAdministrationPage, OnControlSpinButtonModifyHdl));
+        const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const 
DbuTypeCollectionItem*>( _rCoreAttrs.GetItem(DSID_TYPECOLLECTION) );
+        if (pCollectionItem)
+            m_pCollection = pCollectionItem->getCollection();
+        OSL_ENSURE(m_pCollection, "OConnectionHelper::OConnectionHelper : 
really need a DSN type collection !");
+        m_xConnectionURL->SetTypeCollection(m_pCollection);
+
+        SetRoadmapStateValue(false);
+    }
+
+    OPostgresConnectionPageSetup::~OPostgresConnectionPageSetup()
+    {
+    }
+
+    std::unique_ptr<OGenericAdministrationPage> 
OPostgresConnectionPageSetup::CreatePostgresTabPage( weld::Container* pPage, 
weld::DialogController* pController, const SfxItemSet& _rAttrSet )
+    {
+        return std::make_unique<OPostgresConnectionPageSetup>(pPage, 
pController,
+                                                          _rAttrSet,
+                                                          
DSID_POSTGRES_PORTNUMBER,
+                                                          STR_POSTGRES_DEFAULT,
+                                                          
STR_POSTGRES_HELPTEXT,
+                                                          
STR_POSTGRES_HEADERTEXT,
+                                                          STR_COMMONURL);
+    }
+
+    void OPostgresConnectionPageSetup::fillControls(std::vector< 
std::unique_ptr<ISaveValueWrapper> >& _rControlList)
+    {
+        _rControlList.emplace_back(new 
OSaveValueWidgetWrapper<weld::Entry>(m_xETDatabasename.get()));
+        _rControlList.emplace_back( new 
OSaveValueWidgetWrapper<OConnectionURLEdit>( m_xConnectionURL.get() ) );
+        _rControlList.emplace_back(new 
OSaveValueWidgetWrapper<weld::Entry>(m_xETHostname.get()));
+        _rControlList.emplace_back(new 
OSaveValueWidgetWrapper<weld::SpinButton>(m_xNFPortNumber.get()));
+    }
+
+    bool OPostgresConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
+    {
+        bool bChangedSomething = false;
+        fillString(*_rSet,m_xConnectionURL.get(), DSID_CONNECTURL, 
bChangedSomething);
+        
fillString(*_rSet,m_xETHostname.get(),DSID_CONN_HOSTNAME,bChangedSomething);
+        
fillString(*_rSet,m_xETDatabasename.get(),DSID_DATABASENAME,bChangedSomething);
+        fillInt32(*_rSet,m_xNFPortNumber.get(),m_nPortId,bChangedSomething );
+        return bChangedSomething;
+    }
+
+    void OPostgresConnectionPageSetup::fillWindows(std::vector< 
std::unique_ptr<ISaveValueWrapper> >& _rControlList)
+    {
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTHelpText.get()));
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTDatabasename.get()));
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTHostname.get()));
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTPortNumber.get()));
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTDefaultPortNumber.get()));
+        _rControlList.emplace_back(new 
ODisableWidgetWrapper<weld::Label>(m_xFTConnection.get()));
+    }
+
+    void OPostgresConnectionPageSetup::implInitControls(const SfxItemSet& 
_rSet, bool _bSaveValue)
+    {
+        // check whether or not the selection is invalid or readonly (invalid 
implies readonly, but not vice versa)
+        SetRoadmapStateValue(true);
+        bool bValid, bReadonly;
+        getFlags(_rSet, bValid, bReadonly);
+
+        m_xFTConnection->show();
+        m_xConnectionURL->show();
+        m_xConnectionURL->ShowPrefix( false);
+
+        const SfxStringItem* pDatabaseName = 
_rSet.GetItem<SfxStringItem>(DSID_DATABASENAME);
+        const SfxStringItem* pUrlItem = 
_rSet.GetItem<SfxStringItem>(DSID_CONNECTURL);
+        const SfxStringItem* pHostName = 
_rSet.GetItem<SfxStringItem>(DSID_CONN_HOSTNAME);
+        const SfxInt32Item* pPortNumber = 
_rSet.GetItem<SfxInt32Item>(m_nPortId);
+
+        if ( bValid )
+        {
+            m_xETDatabasename->set_text(pDatabaseName->GetValue());
+            m_xETDatabasename->save_value();
+
+            OUString sUrl = pUrlItem->GetValue();
+            setURL( sUrl );
+            m_xConnectionURL->save_value();
+
+            m_xETHostname->set_text(pHostName->GetValue());
+            m_xETHostname->save_value();
+
+            m_xNFPortNumber->set_value(pPortNumber->GetValue());
+            m_xNFPortNumber->save_value();
+        }
+
+        OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+
+        callModifiedHdl();
+    }
+
+    bool OPostgresConnectionPageSetup::commitPage( 
::vcl::WizardTypes::CommitPageReason /*_eReason*/ )
+    {
+        return commitURL();
+    }
+
+    bool OPostgresConnectionPageSetup::commitURL()
+    {
+        OUString sURL = m_xConnectionURL->GetTextNoPrefix();
+        setURLNoPrefix(sURL);
+        m_xConnectionURL->SaveValueNoPrefix();
+        return true;
+    }
+
+    void OPostgresConnectionPageSetup::impl_setURL( std::u16string_view _rURL, 
bool _bPrefix )
+    {
+        OUString sURL( comphelper::string::stripEnd(_rURL, '*') );
+        OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_setURL: have no 
interpreter for the URLs!" );
+        if ( _bPrefix )
+            m_xConnectionURL->SetText( sURL );
+        else
+            m_xConnectionURL->SetTextNoPrefix( sURL );
+    }
+
+    void OPostgresConnectionPageSetup::setURLNoPrefix( std::u16string_view 
_rURL )
+    {
+        impl_setURL( _rURL,false);
+    }
+
+    void OPostgresConnectionPageSetup::setURL( std::u16string_view _rURL )
+    {
+        impl_setURL( _rURL, true);
+    }
+
+    OUString OPostgresConnectionPageSetup::getURLNoPrefix( ) const
+    {
+        return impl_getURL();
+    }
+
+    OUString OPostgresConnectionPageSetup::impl_getURL() const
+    {
+        // get the pure text
+        OUString sURL = m_xConnectionURL->GetTextNoPrefix();
+        OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_getURL: have no 
interpreter for the URLs!" );
+        return sURL;
+    }
+
+    IMPL_LINK_NOARG(OPostgresConnectionPageSetup, OnEditModified, 
weld::Entry&, void)
+    {
+        SetRoadmapStateValue(true);
+        callModifiedHdl();
+    }
+
     // OMySQLJDBCConnectionPageSetup
     OJDBCConnectionPageSetup::OJDBCConnectionPageSetup(weld::Container* pPage, 
weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
         : OConnectionTabPageSetup(pPage, pController, 
"dbaccess/ui/jdbcconnectionpage.ui", "JDBCConnectionPage", rCoreAttrs,
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx 
b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
index 8bc367602fd9..15904be754f0 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
@@ -25,6 +25,8 @@
 #include "admincontrols.hxx"
 #include "TextConnectionHelper.hxx"
 
+#include <curledit.hxx>
+
 namespace dbaui
 {
     class ODbTypeWizDialogSetup;
@@ -214,6 +216,58 @@ namespace dbaui
         DECL_LINK(OnSetupModeSelected, weld::Toggleable&, void);
     };
 
+    // OPostgresPageSetup
+    class OPostgresConnectionPageSetup final : public 
OGenericAdministrationPage
+    {
+    public:
+        OPostgresConnectionPageSetup(weld::Container* pPage, 
weld::DialogController* pController
+                                        , const SfxItemSet& _rCoreAttrs
+                                        , sal_uInt16 _nPortId
+                                        , TranslateId pDefaultPortResId
+                                        , TranslateId pHelpTextResId
+                                        , TranslateId pHeaderTextResId
+                                        , TranslateId pConnectionTextResId );
+    virtual ~OPostgresConnectionPageSetup() override;
+    static std::unique_ptr<OGenericAdministrationPage> CreatePostgresTabPage( 
weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& 
_rAttrSet );
+    ::dbaccess::ODsnTypeCollection* m_pCollection;
+
+    private:
+        DECL_LINK(OnEditModified, weld::Entry&, void);
+        virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) override;
+        virtual void implInitControls(const SfxItemSet& _rSet, bool 
_bSaveValue) override;
+        virtual void fillControls(std::vector< 
std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
+        virtual void fillWindows(std::vector< 
std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
+        virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason 
) override;
+
+        sal_uInt16              m_nPortId;
+
+        std::unique_ptr<weld::Label> m_xHeaderText;
+        std::unique_ptr<weld::Label> m_xFTHelpText;
+        std::unique_ptr<weld::Label> m_xFTDatabasename;
+        std::unique_ptr<weld::Entry> m_xETDatabasename;
+        std::unique_ptr<weld::Label> m_xFTHostname;
+        std::unique_ptr<weld::Entry> m_xETHostname;
+        std::unique_ptr<weld::Label> m_xFTPortNumber;
+        std::unique_ptr<weld::Label> m_xFTDefaultPortNumber;
+        std::unique_ptr<weld::SpinButton> m_xNFPortNumber;
+
+        std::unique_ptr<weld::Label> m_xFTConnection;
+        std::unique_ptr<OConnectionURLEdit> m_xConnectionURL;
+
+        /** used for the connection URL
+            @param  _rURL
+                The URL to check.
+        */
+        void        impl_setURL( std::u16string_view _rURL, bool _bPrefix );
+        void        setURLNoPrefix( std::u16string_view _rURL );
+        void        setURL( std::u16string_view _rURL );
+        OUString    getURLNoPrefix( ) const;
+        OUString    impl_getURL() const;
+        bool        commitURL();
+
+    };
+
+
     // OAuthentificationPageSetup
     class OAuthentificationPageSetup final : public OGenericAdministrationPage
     {
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;
     }
diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx 
b/dbaccess/source/ui/dlg/dbadmin.cxx
index a8a1ce1e51bd..cd741e56051b 100644
--- a/dbaccess/source/ui/dlg/dbadmin.cxx
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -335,6 +335,7 @@ void 
ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Ref
     *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT );
     *pCounter++ = new SfxInt32Item(DSID_MAX_ROW_SCAN, 100);
     *pCounter++ = new SfxBoolItem( DSID_RESPECTRESULTSETTYPE,false );
+    *pCounter++ = new SfxInt32Item(DSID_POSTGRES_PORTNUMBER, 5432);
 
     // create the pool
     static SfxItemInfo const aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID 
+ 1] =
@@ -399,6 +400,7 @@ void 
ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Ref
         {0,false},
         {0,false},
         {0,false},
+        {0,false},
     };
 
     OSL_ENSURE(std::size(aItemInfos) == DSID_LAST_ITEM_ID,"Invalid Ids!");
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx 
b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 8bee3588952e..69662a17bcc6 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -106,6 +106,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(weld::Window* 
_pParent
     , m_sRM_JDBCText( DBA_RES( STR_PAGETITLE_JDBC ) )
     , m_sRM_MySQLNativePageTitle( DBA_RES( STR_PAGETITLE_MYSQL_NATIVE ) )
     , m_sRM_OracleText( DBA_RES( STR_PAGETITLE_ORACLE ) )
+    , m_sRM_PostgresText( DBA_RES( STR_PAGETITLE_POSTGRES ) )
     , m_sRM_MySQLText( DBA_RES( STR_PAGETITLE_MYSQL ) )
     , m_sRM_ODBCText( DBA_RES( STR_PAGETITLE_ODBC ) )
     , m_sRM_DocumentOrSpreadSheetText( DBA_RES( 
STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET ) )
@@ -213,6 +214,9 @@ OUString 
ODbTypeWizDialogSetup::getStateDisplayName(WizardState _nState) const
         case PAGE_DBSETUPWIZARD_ORACLE:
             sRoadmapItem = m_sRM_OracleText;
             break;
+        case PAGE_DBSETUPWIZARD_POSTGRES:
+            sRoadmapItem = m_sRM_PostgresText;
+            break;
         case PAGE_DBSETUPWIZARD_MYSQL_INTRO:
             sRoadmapItem = m_sRM_MySQLText;
             break;
@@ -507,6 +511,10 @@ std::unique_ptr<BuilderPage> 
ODbTypeWizDialogSetup::createPage(WizardState _nSta
             xPage = 
OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage(pPageContainer, 
this, *m_pOutSet);
             break;
 
+        case PAGE_DBSETUPWIZARD_POSTGRES:
+            xPage = 
OPostgresConnectionPageSetup::CreatePostgresTabPage(pPageContainer, this, 
*m_pOutSet);
+            break;
+
         case PAGE_DBSETUPWIZARD_LDAP:
             xPage = 
OLDAPConnectionPageSetup::CreateLDAPTabPage(pPageContainer, this, *m_pOutSet);
             break;
diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx 
b/dbaccess/source/ui/inc/dbwizsetup.hxx
index f902f35e4c9b..50f463fac42a 100644
--- a/dbaccess/source/ui/inc/dbwizsetup.hxx
+++ b/dbaccess/source/ui/inc/dbwizsetup.hxx
@@ -71,6 +71,7 @@ private:
     OUString                m_sRM_JDBCText;
     OUString                m_sRM_MySQLNativePageTitle;
     OUString                m_sRM_OracleText;
+    OUString                m_sRM_PostgresText;
     OUString                m_sRM_MySQLText;
     OUString                m_sRM_ODBCText;
     OUString                m_sRM_DocumentOrSpreadSheetText;
diff --git a/dbaccess/source/ui/inc/dsitems.hxx 
b/dbaccess/source/ui/inc/dsitems.hxx
index 09410d31b83f..8b7971d80a66 100644
--- a/dbaccess/source/ui/inc/dsitems.hxx
+++ b/dbaccess/source/ui/inc/dsitems.hxx
@@ -85,11 +85,12 @@ typedef sal_Int32   ItemID;
 #define DSID_PRIMARY_KEY_SUPPORT    58
 #define DSID_MAX_ROW_SCAN           59
 #define DSID_RESPECTRESULTSETTYPE   60
+#define DSID_POSTGRES_PORTNUMBER    61
     // don't forget to adjust DSID_LAST_ITEM_ID below!
 
 // item range. Adjust this if you introduce new items above
 
 #define DSID_FIRST_ITEM_ID  DSID_NAME
-#define DSID_LAST_ITEM_ID   DSID_RESPECTRESULTSETTYPE
+#define DSID_LAST_ITEM_ID   DSID_POSTGRES_PORTNUMBER
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/uiconfig/ui/postgrespage.ui 
b/dbaccess/uiconfig/ui/postgrespage.ui
new file mode 100644
index 000000000000..41fd74c35133
--- /dev/null
+++ b/dbaccess/uiconfig/ui/postgrespage.ui
@@ -0,0 +1,253 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="dba">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="upper">1000000000000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkBox" id="SpecialPostgresPage">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="border_width">6</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">12</property>
+    <child>
+      <object class="GtkLabel" id="header">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">start</property>
+        <property name="margin_bottom">6</property>
+        <child internal-child="accessible">
+          <object class="AtkObject">
+            <property name="label" translatable="yes" 
context="specialpostgrespage|header">Set up connection to a PostgreSQL 
database</property>
+            <property name="AtkObject::accessible-role">static</property>
+          </object>
+        </child>
+        <attributes>
+          <attribute name="weight" value="bold"/>
+        </attributes>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="helpLabel">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child internal-child="accessible">
+          <object class="AtkObject">
+            <property name="label" translatable="yes" 
context="specialpostgrespage|helpLabel">Please enter the required information 
to connect to a PostgreSQL database. Please contact your system administrator 
if you are unsure about the following settings. </property>
+            <property name="AtkObject::accessible-role">static</property>
+          </object>
+        </child>
+        <property name="wrap">True</property>
+        <property name="width_chars">72</property>
+        <property name="max_width_chars">72</property>
+        <property name="xalign">0</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <!-- n-columns=1 n-rows=1 -->
+      <object class="GtkGrid" id="grid1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="row_spacing">6</property>
+        <property name="column_spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="dbNameLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes" 
context="specialpostgrespage|dbNameLabel">_Database name:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">dbNameEntry</property>
+            <property name="xalign">1</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="hostNameLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes" 
context="specialpostgrespage|hostNameLabel">_Server:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">hostNameEntry</property>
+            <property name="xalign">1</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="portNumLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes" 
context="specialpostgrespage|portNumLabel">_Port number:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">portNumEntry</property>
+            <property name="xalign">1</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkEntry" id="dbNameEntry">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="truncate-multiline">True</property>
+            <property name="activates_default">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkEntry" id="hostNameEntry">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="truncate-multiline">True</property>
+            <property name="activates_default">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkSpinButton" id="portNumEntry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="activates_default">True</property>
+                <property name="truncate-multiline">True</property>
+                <property name="adjustment">adjustment1</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="portNumDefLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" 
context="specialpostgrespage|portNumDefLabel">Default: 5432</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+    <child>
+      <!-- n-columns=2 n-rows=1 -->
+      <object class="GtkGrid" id="grid2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="row_spacing">6</property>
+        <property name="column_spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="connectionStringLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes" 
context="specialpostgrespage|connectionStringLabel">And/OR Enter the 
DBMS/diver-specific connection string here</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">browseurl</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <!-- n-columns=2 n-rows=1 -->
+          <object class="GtkGrid" id ="grid3">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <child>
+              <object class="GtkEntry" id="browseurl">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="activates-default">True</property>
+                <property name="truncate-multiline">True</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="browselabel">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">3</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/solenv/sanitizers/ui/dbaccess.false 
b/solenv/sanitizers/ui/dbaccess.false
new file mode 100644
index 000000000000..f32c3bd4d214
--- /dev/null
+++ b/solenv/sanitizers/ui/dbaccess.false
@@ -0,0 +1 @@
+dbaccess/uiconfig/ui/postgrespage.ui://GtkLabel[@id='browselabel'] orphan-label
diff --git a/solenv/sanitizers/ui/dbaccess.suppr 
b/solenv/sanitizers/ui/dbaccess.suppr
index cf67d5b78842..24cd73d00a7a 100644
--- a/solenv/sanitizers/ui/dbaccess.suppr
+++ b/solenv/sanitizers/ui/dbaccess.suppr
@@ -54,6 +54,7 @@ 
dbaccess/uiconfig/ui/savedialog.ui://GtkLabel[@id='descriptionft'] orphan-label
 dbaccess/uiconfig/ui/specialjdbcconnectionpage.ui://GtkLabel[@id='header'] 
orphan-label
 dbaccess/uiconfig/ui/specialjdbcconnectionpage.ui://GtkLabel[@id='helpLabel'] 
orphan-label
 
dbaccess/uiconfig/ui/specialjdbcconnectionpage.ui://GtkLabel[@id='portNumDefLabel']
 orphan-label
+dbaccess/uiconfig/ui/postgrespage.ui://GtkLabel[@id='portNumDefLabel'] 
orphan-label
 dbaccess/uiconfig/ui/sortdialog.ui://GtkLabel[@id='label2'] orphan-label
 dbaccess/uiconfig/ui/sortdialog.ui://GtkLabel[@id='label3'] orphan-label
 dbaccess/uiconfig/ui/sortdialog.ui://GtkLabel[@id='label4'] orphan-label

Reply via email to