android: Update app icon to new startcenter icon
[LibreOffice.git] / dbaccess / source / ui / dlg / ConnectionPageSetup.cxx
blob33ea535a1dd86ca01fba2b7662d99f517050ede9
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 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::ucb;
33 using namespace ::com::sun::star::ui::dialogs;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::container;
37 using namespace ::svt;
39 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateDbaseTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
41 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE );
44 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateMSAccessTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
46 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE );
49 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateADOTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
51 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL );
54 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateODBCTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
56 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE );
59 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateUserDefinedTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
61 return std::make_unique<OConnectionTabPageSetup>(pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, TranslateId(), TranslateId(), STR_COMMONURL);
64 OConnectionTabPageSetup::OConnectionTabPageSetup(weld::Container* pPage, weld::DialogController* pController, const OUString& _rUIXMLDescription, const OUString& _rId, const SfxItemSet& _rCoreAttrs, TranslateId pHelpTextResId, TranslateId pHeaderResId, TranslateId pUrlResId)
65 : OConnectionHelper(pPage, pController, _rUIXMLDescription, _rId, _rCoreAttrs)
66 , m_xHelpText(m_xBuilder->weld_label("helptext"))
67 , m_xHeaderText(m_xBuilder->weld_label("header"))
70 if (pHelpTextResId)
72 OUString sHelpText = DBA_RES(pHelpTextResId);
73 m_xHelpText->set_label(sHelpText);
75 else
76 m_xHelpText->hide();
78 if (pHeaderResId)
79 m_xHeaderText->set_label(DBA_RES(pHeaderResId));
81 if (pUrlResId)
83 OUString sLabelText = DBA_RES(pUrlResId);
84 m_xFT_Connection->set_label(sLabelText);
86 else
87 m_xFT_Connection->hide();
89 m_xConnectionURL->connect_changed(LINK(this, OConnectionTabPageSetup, OnEditModified));
91 SetRoadmapStateValue(false);
94 OConnectionTabPageSetup::~OConnectionTabPageSetup()
98 void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
100 m_eType = m_pAdminDialog->getDatasourceType(_rSet);
101 // special handling for oracle, this can only happen
102 // if the user enters the same url as used for Oracle and we are on the JDBC path
103 //! TODO
104 //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
105 // m_eType = ::dbaccess::DST_JDBC;
106 if(m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES){
107 SetRoadmapStateValue(true);
110 OConnectionHelper::implInitControls(_rSet, _bSaveValue);
112 //! TODO
113 //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
115 // OUString sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
116 // FixedText* ppTextControls[] ={&m_aFT_Connection};
117 // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
118 // {
119 // ppTextControls[i]->SetText(sDisplayName);
120 // }
123 callModifiedHdl();
126 bool OConnectionTabPageSetup::commitPage( ::vcl::WizardTypes::CommitPageReason /*_eReason*/ )
128 return commitURL();
131 bool OConnectionTabPageSetup::FillItemSet(SfxItemSet* _rSet)
133 bool bChangedSomething = false;
134 fillString(*_rSet,m_xConnectionURL.get(), DSID_CONNECTURL, bChangedSomething);
135 return bChangedSomething;
138 bool OConnectionTabPageSetup::checkTestConnection()
140 if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_POSTGRES )
141 return true;
142 return !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty();
145 IMPL_LINK_NOARG(OConnectionTabPageSetup, OnEditModified, weld::Entry&, void)
147 SetRoadmapStateValue(checkTestConnection());
148 callModifiedHdl();
151 } // namespace dbaui
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */