LibreOffice Module dbaccess (master) 1
ConnectionPageSetup.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
28
29namespace dbaui
30{
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;
38
39 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateDbaseTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
40 {
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 );
42 }
43
44 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateMSAccessTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
45 {
46 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE );
47 }
48
49 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateADOTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
50 {
51 return std::make_unique<OConnectionTabPageSetup>( pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL );
52 }
53
54 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateODBCTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
55 {
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 );
57 }
58
59 std::unique_ptr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateUserDefinedTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
60 {
61 return std::make_unique<OConnectionTabPageSetup>(pPage, pController, "dbaccess/ui/dbwizconnectionpage.ui", "ConnectionPage", _rAttrSet, TranslateId(), TranslateId(), STR_COMMONURL);
62 }
63
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"))
68 {
69
70 if (pHelpTextResId)
71 {
72 OUString sHelpText = DBA_RES(pHelpTextResId);
73 m_xHelpText->set_label(sHelpText);
74 }
75 else
76 m_xHelpText->hide();
77
78 if (pHeaderResId)
79 m_xHeaderText->set_label(DBA_RES(pHeaderResId));
80
81 if (pUrlResId)
82 {
83 OUString sLabelText = DBA_RES(pUrlResId);
84 m_xFT_Connection->set_label(sLabelText);
85 }
86 else
87 m_xFT_Connection->hide();
88
89 m_xConnectionURL->connect_changed(LINK(this, OConnectionTabPageSetup, OnEditModified));
90
92 }
93
95 {
96 }
97
98 void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
99 {
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
104 //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
105 // m_eType = ::dbaccess::DST_JDBC;
108 }
109
110 OConnectionHelper::implInitControls(_rSet, _bSaveValue);
111
113 //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
114 //{
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 // }
121 //}
122
124 }
125
127 {
128 return commitURL();
129 }
130
132 {
133 bool bChangedSomething = false;
134 fillString(*_rSet,m_xConnectionURL.get(), DSID_CONNECTURL, bChangedSomething);
135 return bChangedSomething;
136 }
137
139 {
141 return true;
142 return !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty();
143 }
144
146 {
147 SetRoadmapStateValue(checkTestConnection());
148 callModifiedHdl();
149 }
150
151} // namespace dbaui
152
153/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DATASOURCE_TYPE determineType(std::u16string_view _rDsn) const
Definition: dsntypes.cxx:299
virtual OUString getDatasourceType(const SfxItemSet &_rSet) const =0
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
std::unique_ptr< weld::Label > m_xFT_Connection
the DSN type collection instance
std::unique_ptr< OConnectionURLEdit > m_xConnectionURL
::dbaccess::ODsnTypeCollection * m_pCollection
implements the connection page of the data source properties dialog.
std::unique_ptr< weld::Label > m_xHelpText
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
virtual bool checkTestConnection() override
virtual ~OConnectionTabPageSetup() override
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
static std::unique_ptr< OGenericAdministrationPage > CreateADOTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rAttrSet)
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
static std::unique_ptr< OGenericAdministrationPage > CreateUserDefinedTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rAttrSet)
std::unique_ptr< weld::Label > m_xHeaderText
static std::unique_ptr< OGenericAdministrationPage > CreateDbaseTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rAttrSet)
OConnectionTabPageSetup(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const OUString &_rId, const SfxItemSet &_rCoreAttrs, TranslateId pHelpTextResId, TranslateId pHeaderResId, TranslateId pUrlResId)
static std::unique_ptr< OGenericAdministrationPage > CreateODBCTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rAttrSet)
static std::unique_ptr< OGenericAdministrationPage > CreateMSAccessTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rAttrSet)
IDatabaseSettingsDialog * m_pAdminDialog
Definition: adminpages.hxx:94
static void fillString(SfxItemSet &_rSet, const weld::Entry *pEdit, TypedWhichId< SfxStringItem > _nID, bool &_bChangedSomething)
fills the String value into the item set when the value changed.
Definition: adminpages.cxx:219
void SetRoadmapStateValue(bool _bDoEnable)
Definition: adminpages.hxx:142
virtual void callModifiedHdl(weld::Widget *=nullptr)
Definition: adminpages.hxx:157
#define DBA_RES(id)
#define DSID_CONNECTURL
Definition: dsitems.hxx:36
@ DST_POSTGRES
Definition: dsntypes.hxx:64
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)