Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / dbaccess / source / ui / dlg / ConnectionPageSetup.cxx
blobf27225c003be63ae47a2f871763d2d20a4fd5432
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ConnectionPageSetup.hxx"
21 #include <strings.hrc>
22 #include <core_resource.hxx>
23 #include <IItemSetHelper.hxx>
24 #include <svl/itemset.hxx>
25 #include <dsitems.hxx>
26 #include <svl/filenotation.hxx>
27 #include <com/sun/star/ucb/XProgressHandler.hpp>
29 namespace dbaui
31 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateDbaseTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
33 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE );
36 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateMSAccessTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
38 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE );
41 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateADOTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
43 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL );
46 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateODBCTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
48 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE );
51 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateUserDefinedTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
53 return std::make_unique<OConnectionTabPageSetup>(pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, TranslateId(), TranslateId(), STR_COMMONURL);
56 OConnectionTabPageSetup::OConnectionTabPageSetup(weld::Container* pPage, weld::DialogController* pController, const OUString& _rUIXMLDescription, const OUString& _rId, const SfxItemSet& _rCoreAttrs, TranslateId pHelpTextResId, TranslateId pHeaderResId, TranslateId pUrlResId)
57 : OConnectionHelper(pPage, pController, _rUIXMLDescription, _rId, _rCoreAttrs)
58 , m_xHelpText(m_xBuilder->weld_label(u"helptext"_ustr))
59 , m_xHeaderText(m_xBuilder->weld_label(u"header"_ustr))
62 if (pHelpTextResId)
64 OUString sHelpText = DBA_RES(pHelpTextResId);
65 m_xHelpText->set_label(sHelpText);
67 else
68 m_xHelpText->hide();
70 if (pHeaderResId)
71 m_xHeaderText->set_label(DBA_RES(pHeaderResId));
73 if (pUrlResId)
75 OUString sLabelText = DBA_RES(pUrlResId);
76 m_xFT_Connection->set_label(sLabelText);
78 else
79 m_xFT_Connection->hide();
81 m_xConnectionURL->connect_changed(LINK(this, OConnectionTabPageSetup, OnEditModified));
83 SetRoadmapStateValue(false);
86 OConnectionTabPageSetup::~OConnectionTabPageSetup()
90 void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
92 m_eType = m_pAdminDialog->getDatasourceType(_rSet);
93 // special handling for oracle, this can only happen
94 // if the user enters the same url as used for Oracle and we are on the JDBC path
95 //! TODO
96 //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
97 // m_eType = ::dbaccess::DST_JDBC;
98 if(m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES){
99 SetRoadmapStateValue(true);
102 OConnectionHelper::implInitControls(_rSet, _bSaveValue);
104 //! TODO
105 //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
107 // OUString sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
108 // FixedText* ppTextControls[] ={&m_aFT_Connection};
109 // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
110 // {
111 // ppTextControls[i]->SetText(sDisplayName);
112 // }
115 callModifiedHdl();
118 bool OConnectionTabPageSetup::commitPage( ::vcl::WizardTypes::CommitPageReason /*_eReason*/ )
120 return commitURL();
123 bool OConnectionTabPageSetup::FillItemSet(SfxItemSet* _rSet)
125 bool bChangedSomething = false;
126 fillString(*_rSet,m_xConnectionURL.get(), DSID_CONNECTURL, bChangedSomething);
127 return bChangedSomething;
130 bool OConnectionTabPageSetup::checkTestConnection()
132 if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES )
133 return true;
134 return !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty();
137 IMPL_LINK_NOARG(OConnectionTabPageSetup, OnEditModified, weld::Entry&, void)
139 SetRoadmapStateValue(checkTestConnection());
140 callModifiedHdl();
143 } // namespace dbaui
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */