fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / dlg / ConnectionPageSetup.cxx
blobfd82603a2c3d3da77595ecacd35f0742d2221374
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 "dbu_dlg.hrc"
22 #include <svl/itemset.hxx>
23 #include <unotools/pathoptions.hxx>
24 #include <svl/stritem.hxx>
25 #include <svl/eitem.hxx>
26 #include <svl/intitem.hxx>
27 #include "dsitems.hxx"
28 #include "dbaccess_helpid.hrc"
29 #include "localresaccess.hxx"
30 #include <osl/process.h>
31 #include <vcl/msgbox.hxx>
32 #include "dbadmin.hxx"
33 #include <comphelper/types.hxx>
34 #include <vcl/stdtext.hxx>
35 #include "sqlmessage.hxx"
36 #include "odbcconfig.hxx"
37 #include "dsselect.hxx"
38 #include <svl/filenotation.hxx>
39 #include "dbustrings.hrc"
40 #include <com/sun/star/sdbc/XRow.hpp>
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/task/XInteractionHandler.hpp>
43 #include <com/sun/star/ucb/XProgressHandler.hpp>
44 #include <com/sun/star/sdbc/XConnection.hpp>
45 #include "UITools.hxx"
46 #include <unotools/localfilehelper.hxx>
47 #include <unotools/ucbhelper.hxx>
48 #include <ucbhelper/commandenvironment.hxx>
49 #include "finteraction.hxx"
50 #include <connectivity/CommonTools.hxx>
51 #include <sfx2/docfilt.hxx>
52 #include <vcl/mnemonic.hxx>
54 namespace dbaui
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::ucb;
58 using namespace ::com::sun::star::ui::dialogs;
59 using namespace ::com::sun::star::sdbc;
60 using namespace ::com::sun::star::beans;
61 using namespace ::com::sun::star::lang;
62 using namespace ::com::sun::star::container;
63 using namespace ::dbtools;
64 using namespace ::svt;
66 VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
68 return VclPtr<OConnectionTabPageSetup>::Create ( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE );
71 VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
73 return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE );
76 VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
78 return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL );
81 VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
83 return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE );
86 VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
88 return VclPtr<OConnectionTabPageSetup>::Create( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL );
91 OConnectionTabPageSetup::OConnectionTabPageSetup(vcl::Window* pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId)
92 :OConnectionHelper(pParent, _rId, _rUIXMLDescription, _rCoreAttrs)
93 ,m_bUserGrabFocus(true)
95 get(m_pHelpText, "helptext");
96 get(m_pHeaderText, "header");
98 if ( USHRT_MAX != _nHelpTextResId )
100 OUString sHelpText = ModuleRes(_nHelpTextResId);
101 m_pHelpText->SetText(sHelpText);
103 else
104 m_pHelpText->Hide();
106 if ( USHRT_MAX != _nHeaderResId )
107 m_pHeaderText->SetText(ModuleRes(_nHeaderResId));
109 if ( USHRT_MAX != _nUrlResId )
111 OUString sLabelText = ModuleRes(_nUrlResId);
112 m_pFT_Connection->SetText(sLabelText);
114 else
115 m_pFT_Connection->Hide();
117 m_pConnectionURL->SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified));
119 SetRoadmapStateValue(false);
122 OConnectionTabPageSetup::~OConnectionTabPageSetup()
124 disposeOnce();
127 void OConnectionTabPageSetup::dispose()
129 m_pHelpText.clear();
130 m_pHeaderText.clear();
131 OConnectionHelper::dispose();
134 void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
136 m_eType = m_pAdminDialog->getDatasourceType(_rSet);
137 // special handling for oracle, this can only happen
138 // if the user enters the same url as used for Oracle and we are on the JDBC path
139 //! TODO
140 //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
141 // m_eType = ::dbaccess::DST_JDBC;
143 OConnectionHelper::implInitControls(_rSet, _bSaveValue);
145 //! TODO
146 //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
148 // OUString sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
149 // FixedText* ppTextControls[] ={&m_aFT_Connection};
150 // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
151 // {
152 // ppTextControls[i]->SetText(sDisplayName);
153 // }
156 callModifiedHdl();
159 bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ )
161 return commitURL();
164 bool OConnectionTabPageSetup::FillItemSet(SfxItemSet* _rSet)
166 bool bChangedSomething = false;
167 fillString(*_rSet,m_pConnectionURL, DSID_CONNECTURL, bChangedSomething);
168 return bChangedSomething;
170 bool OConnectionTabPageSetup::checkTestConnection()
172 return !m_pConnectionURL->IsVisible() || !m_pConnectionURL->GetTextNoPrefix().isEmpty();
175 IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/)
177 SetRoadmapStateValue(checkTestConnection());
178 callModifiedHdl();
179 return 0L;
181 } // namespace dbaui
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */