1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbui.hxx"
26 #ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
27 #include "DBSetupConnectionPages.hxx"
28 #endif
29 #ifndef _DBAUI_SQLMESSAGE_HXX_
30 #include "sqlmessage.hxx"
31 #endif
32 #ifndef _DBU_RESOURCE_HRC_
33 #include "dbu_resource.hrc"
34 #endif
35 #include "AutoControlsDef.hrc"
36 #ifndef _DBAUI_DBADMINSETUP_HRC_
37 #include "dbadminsetup.hrc"
38 #endif
39 #ifndef _SFXITEMSET_HXX
40 #include <svl/itemset.hxx>
41 #endif
42 #ifndef _SFXSTRITEM_HXX
43 #include <svl/stritem.hxx>
44 #endif
45 #ifndef _SFXENUMITEM_HXX
46 #include <svl/eitem.hxx>
47 #endif
48 #ifndef _SFXINTITEM_HXX
49 #include <svl/intitem.hxx>
50 #endif
51 #ifndef _DBAUI_DATASOURCEITEMS_HXX_
52 #include "dsitems.hxx"
53 #endif
54 #include "dsnItem.hxx"
55 #ifndef _DBA_DBACCESS_HELPID_HRC_
56 #include "dbaccess_helpid.hrc"
57 #endif
58 #ifndef _DBAUI_LOCALRESACCESS_HXX_
59 #include "localresaccess.hxx"
60 #endif
61 #ifndef _SV_MSGBOX_HXX
62 #include <vcl/msgbox.hxx>
63 #endif
64 #ifndef _SV_MNEMONIC_HXX
65 #include <vcl/mnemonic.hxx>
66 #endif
67 #ifndef _SVTOOLS_CJKOPTIONS_HXX
68 #include <svl/cjkoptions.hxx>
69 #endif
70 #include <jvmaccess/virtualmachine.hxx>
71 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
72 #include <connectivity/CommonTools.hxx>
73 #endif
74 #ifndef DBAUI_DRIVERSETTINGS_HXX
75 #include "DriverSettings.hxx"
76 #endif
77 #ifndef _DBAUI_DBADMIN_HXX_
78 #include "dbadmin.hxx"
79 #endif
80 #ifndef _COMPHELPER_TYPES_HXX_
81 #include <comphelper/types.hxx>
82 #endif
83 
84 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
85 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
86 #endif
87 // #106016# ------------------------------------
88 #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
89 #include <com/sun/star/task/XInteractionHandler.hpp>
90 #endif
91 #include <com/sun/star/sdbc/XDriverAccess.hpp>
92 #include "dbustrings.hrc"
93 #ifndef SVTOOLS_FILENOTATION_HXX_
94 #include <svl/filenotation.hxx>
95 #endif
96 
97 #include <unotools/localfilehelper.hxx>
98 #include <unotools/ucbhelper.hxx>
99 #include <ucbhelper/commandenvironment.hxx>
100 #include "finteraction.hxx"
101 #include <connectivity/CommonTools.hxx>
102 #include "dbaccess_helpid.hrc"
103 #include <unotools/pathoptions.hxx>
104 #include <svtools/roadmapwizard.hxx>
105 #include "TextConnectionHelper.hxx"
106 
107 
108 //.........................................................................
109 namespace dbaui
110 {
111 //.........................................................................
112 using namespace ::com::sun::star;
113 //	using namespace ::com::sun::star::ucb;
114 //	using namespace ::com::sun::star::ui::dialogs;
115 //	using namespace ::com::sun::star::sdbc;
116 //	using namespace ::com::sun::star::beans;
117 //	using namespace ::com::sun::star::lang;
118 //	using namespace ::com::sun::star::container;
119 //	using namespace ::dbtools;
120 //	using namespace ::svt;
121 
CreateTextTabPage(Window * pParent,const SfxItemSet & _rAttrSet)122 	OGenericAdministrationPage*	OTextConnectionPageSetup::CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
123     {
124         return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) );
125     }
126 
127 
128 	//========================================================================
129 	//= OTextConnectionPageSetup
130 	//========================================================================
DBG_NAME(OTextConnectionPageSetup)131 DBG_NAME(OTextConnectionPageSetup)
132 //------------------------------------------------------------------------
133 	OTextConnectionPageSetup::OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
134 		:OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_TEXT, _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE)
135 	{
136         DBG_CTOR(OTextConnectionPageSetup,NULL);
137 
138         m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_SEPARATORS );
139         m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) );
140 
141         FreeResource();
142 	}
143 
144 
145 	// -----------------------------------------------------------------------
~OTextConnectionPageSetup()146 	OTextConnectionPageSetup::~OTextConnectionPageSetup()
147 	{
148         DELETEZ(m_pTextConnectionHelper);
149 
150         DBG_DTOR(OTextConnectionPageSetup,NULL);
151     }
152 
153     IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/)
154     {
155         SetRoadmapStateValue((m_pTextConnectionHelper->GetExtension().Len() > 0) && OConnectionTabPageSetup::checkTestConnection());
156 	    callModifiedHdl();
157         return sal_True;
158     }
159 
160 
checkTestConnection()161     bool OTextConnectionPageSetup::checkTestConnection()
162     {
163         bool bDoEnable = OConnectionTabPageSetup::checkTestConnection();
164         bDoEnable = (m_pTextConnectionHelper->GetExtension().Len() > 0) && bDoEnable;
165         return bDoEnable;
166     }
167 
168     // -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)169 	void OTextConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
170 	{
171 		OConnectionTabPageSetup::fillControls(_rControlList);
172         m_pTextConnectionHelper->fillControls(_rControlList);
173 	}
174 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)175 	void OTextConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
176 	{
177 		OConnectionTabPageSetup::fillWindows(_rControlList);
178         m_pTextConnectionHelper->fillWindows(_rControlList);
179 	}
180 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)181 	void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
182 	{
183 		// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
184 		sal_Bool bValid, bReadonly;
185 		getFlags(_rSet, bValid, bReadonly);
186         OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue);
187 		m_pTextConnectionHelper->implInitControls(_rSet, bValid);
188 	}
189 
190 
191 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)192 	sal_Bool OTextConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
193 	{
194         sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
195 		bChangedSomething = m_pTextConnectionHelper->FillItemSet(_rSet, bChangedSomething);
196 		return bChangedSomething;
197 	}
198 
199 
prepareLeave()200     sal_Bool OTextConnectionPageSetup::prepareLeave(){
201         return m_pTextConnectionHelper->prepareLeave();
202     }
203 
204 
CreateLDAPTabPage(Window * pParent,const SfxItemSet & _rAttrSet)205     OGenericAdministrationPage*	OLDAPConnectionPageSetup::CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
206     {
207         return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) );
208     }
209 
210 
211 	//========================================================================
212 	//= OLDAPPageSetup
213 	//========================================================================
OLDAPConnectionPageSetup(Window * pParent,const SfxItemSet & _rCoreAttrs)214 	OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
215         :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_LDAP), _rCoreAttrs)
216         ,m_aFTHeaderText        (this, ModuleRes(FT_LDAP_HEADERTEXT))
217         ,m_aFTHelpText          (this, ModuleRes(FT_LDAP_HELPTEXT))
218 		,m_aFTHostServer	    (this, ModuleRes(FT_AUTOHOSTNAME))
219 		,m_aETHostServer	    (this, ModuleRes(ET_AUTOHOSTNAME))
220         ,m_aFTBaseDN			(this, ModuleRes(FT_AUTOBASEDN))
221 		,m_aETBaseDN		    (this, ModuleRes(ET_AUTOBASEDN))
222 		,m_aFTPortNumber		(this, ModuleRes(FT_AUTOPORTNUMBER))
223 		,m_aNFPortNumber	    (this, ModuleRes(NF_AUTOPORTNUMBER))
224         ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
225         ,m_aCBUseSSL            (this, ModuleRes(CB_WIZ_USESSL))
226     {
227         SetControlFontWeight(&m_aFTHeaderText);
228         m_aFTDefaultPortNumber.SetText(String(ModuleRes(STR_LDAP_DEFAULT)));
229         m_aETHostServer.SetModifyHdl(getControlModifiedLink());
230 		m_aETBaseDN.SetModifyHdl(getControlModifiedLink());
231 		m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
232         m_aCBUseSSL.SetToggleHdl(getControlModifiedLink());
233         SetRoadmapStateValue(sal_False);
234 		FreeResource();
235 	}
236 
237 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)238 	sal_Bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
239 	{
240    		sal_Bool bChangedSomething = sal_False;
241 		fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN, bChangedSomething);
242 		fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
243 
244         if ( m_aETHostServer.GetText() != m_aETHostServer.GetSavedValue() )
245         {
246             DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
247             ::dbaccess::ODsnTypeCollection* pCollection = NULL;
248 		    if (pCollectionItem)
249 			    pCollection = pCollectionItem->getCollection();
250 		    DBG_ASSERT(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
251 
252             String sUrl = pCollection->getPrefix( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:ldap:")));
253             sUrl += m_aETHostServer.GetText();
254             _rSet.Put(SfxStringItem(DSID_CONNECTURL, sUrl));
255             bChangedSomething = sal_True;
256         }
257 
258         // fillString(_rSet,&m_aETHostServer, DSID_CONNECTURL, bChangedSomething);
259         fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
260         return bChangedSomething;
261 	}
262 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)263 	void OLDAPConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
264 	{
265 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostServer));
266         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN));
267 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
268 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL));
269 	}
270 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)271 	void OLDAPConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
272 	{
273 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
274         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostServer));
275         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTBaseDN));
276 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
277 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
278     }
279 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)280 	void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
281 	{
282 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
283 		sal_Bool bValid, bReadonly;
284 		getFlags(_rSet, bValid, bReadonly);
285 
286 
287 		SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True);
288 		SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
289 
290 		if ( bValid )
291 		{
292 			m_aETBaseDN.SetText(pBaseDN->GetValue());
293 			m_aNFPortNumber.SetValue(pPortNumber->GetValue());
294 		}
295    		OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
296 		callModifiedHdl();
297 	}
298 
299     // -----------------------------------------------------------------------
300 	IMPL_LINK(OLDAPConnectionPageSetup, OnEditModified, Edit*, /*_pEdit*/)
301 	{
302         sal_Bool bRoadmapState = ((m_aETHostServer.GetText().Len() != 0 ) && ( m_aETBaseDN.GetText().Len() != 0 ) && (m_aFTPortNumber.GetText().Len() != 0 ));
303         SetRoadmapStateValue(bRoadmapState);
304 		callModifiedHdl();
305 		return 0L;
306 	}
307 
308 
309     // ----------------------------------------------------------------------- //OGenericAdministrationPage*
CreateMySQLIntroTabPage(Window * _pParent,const SfxItemSet & _rAttrSet)310 	OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet )
311 	{
312 		return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) );
313 	}
314 
DBG_NAME(OMySQLIntroPageSetup)315 DBG_NAME(OMySQLIntroPageSetup)
316 
317     OMySQLIntroPageSetup::OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
318             :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_MYSQL_INTRO), _rCoreAttrs)
319             ,m_aRB_ODBCDatabase(this, ModuleRes(RB_CONNECTVIAODBC))
320             ,m_aRB_JDBCDatabase(this, ModuleRes(RB_CONNECTVIAJDBC))
321             ,m_aRB_NATIVEDatabase(this, ModuleRes(RB_CONNECTVIANATIVE))
322             ,m_aFT_ConnectionMode(this, ModuleRes(FT_MYSQLCONNECTIONMODE))
323             ,m_aFT_Helptext(this, ModuleRes(FT_MYSQL_HELPTEXT))
324             ,m_aFT_Headertext(this, ModuleRes(FT_MYSQL_HEADERTEXT))
325     {
326         DBG_CTOR(OMySQLIntroPageSetup,NULL);
327 
328         SetControlFontWeight(&m_aFT_Headertext);
329    		m_aRB_ODBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
330    		m_aRB_JDBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
331         m_aRB_NATIVEDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
332 		FreeResource();
333 	}
334 
335     IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/)
336     {
337         maClickHdl.Call( this );
338         return true;
339     }
340 
341 	// -----------------------------------------------------------------------
~OMySQLIntroPageSetup()342 	OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
343 	{
344 
345         DBG_DTOR(OMySQLIntroPageSetup,NULL);
346     }
347 
348 
349 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool)350 	void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
351 	{
352         // show the "Connect directly" option only if the driver is installed
353         DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
354         bool bHasMySQLNative = ( pCollectionItem != NULL ) && pCollectionItem->getCollection()->hasDriver( "sdbc:mysqlc:" );
355         if ( bHasMySQLNative )
356             m_aRB_NATIVEDatabase.Show();
357 
358         // if any of the options is checked, then there's nothing to do
359         if ( m_aRB_ODBCDatabase.IsChecked() || m_aRB_JDBCDatabase.IsChecked() || m_aRB_NATIVEDatabase.IsChecked() )
360             return;
361 
362         // prefer "native" or "JDBC"
363         if ( bHasMySQLNative )
364             m_aRB_NATIVEDatabase.Check();
365         else
366             m_aRB_JDBCDatabase.Check();
367 	}
368 
369 
370 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > &)371 	void OMySQLIntroPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
372 	{
373 	}
374 
375 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > &)376 	void OMySQLIntroPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
377 	{
378     }
379 
380 
381 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet &)382 	sal_Bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet& /*_rSet*/)
383 	{
384         OSL_ENSURE(sal_False,"Who called me?! Please ask oj for more information.");
385 		return sal_True;
386 	}
387 
388 
getMySQLMode()389     OMySQLIntroPageSetup::ConnectionType OMySQLIntroPageSetup::getMySQLMode()
390     {
391         if (m_aRB_JDBCDatabase.IsChecked())
392             return VIA_JDBC;
393         else if (m_aRB_NATIVEDatabase.IsChecked())
394             return VIA_NATIVE;
395         else
396             return VIA_ODBC;
397     }
398 
399 	// =======================================================================
400     // = MySQLNativeSetupPage
401 	// =======================================================================
402 	// -----------------------------------------------------------------------
MySQLNativeSetupPage(Window * _pParent,const SfxItemSet & _rCoreAttrs)403     MySQLNativeSetupPage::MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs )
404 		:OGenericAdministrationPage( _pParent, ModuleRes( PAGE_DBWIZARD_MYSQL_NATIVE ), _rCoreAttrs )
405         ,m_aHeader              ( this, ModuleRes( FT_SETUP_WIZARD_HEADER ) )
406         ,m_aHelpText            ( this, ModuleRes( FT_SETUP_WIZARD_HELP ) )
407         ,m_aMySQLSettings       ( *this, getControlModifiedLink() )
408     {
409         SetControlFontWeight( &m_aHeader );
410 
411         LayoutHelper::positionBelow( m_aHelpText, m_aMySQLSettings, UnrelatedControls, 0 );
412         m_aMySQLSettings.Show();
413 
414         SetRoadmapStateValue(sal_False);
415 		FreeResource();
416     }
417 
418 	// -----------------------------------------------------------------------
Create(Window * pParent,const SfxItemSet & _rAttrSet)419     OGenericAdministrationPage* MySQLNativeSetupPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
420     {
421         return new MySQLNativeSetupPage( pParent, _rAttrSet );
422     }
423 
424 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)425 	void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
426     {
427         m_aMySQLSettings.fillControls( _rControlList );
428     }
429 
430 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)431     void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
432     {
433         _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHelpText ) );
434         m_aMySQLSettings.fillWindows( _rControlList );
435     }
436 
437 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)438 	sal_Bool MySQLNativeSetupPage::FillItemSet( SfxItemSet& _rSet )
439 	{
440         return m_aMySQLSettings.FillItemSet( _rSet );
441 	}
442 
443 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)444 	void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
445 	{
446         m_aMySQLSettings.implInitControls( _rSet );
447 
448 		OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
449 
450 		OnModified( NULL );
451 	}
452 
453 	// -----------------------------------------------------------------------
getControlModifiedLink()454     Link MySQLNativeSetupPage::getControlModifiedLink()
455     {
456         return LINK( this, MySQLNativeSetupPage, OnModified );
457     }
458 
459     // -----------------------------------------------------------------------
IMPL_LINK(MySQLNativeSetupPage,OnModified,Edit *,_pEdit)460 	IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit )
461 	{
462         SetRoadmapStateValue( m_aMySQLSettings.canAdvance() );
463 
464         return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit );
465 	}
466 
467 	//========================================================================
468 	//= OMySQLJDBCConnectionPageSetup
469 	//========================================================================
OGeneralSpecialJDBCConnectionPageSetup(Window * pParent,sal_uInt16 _nResId,const SfxItemSet & _rCoreAttrs,sal_uInt16 _nPortId,sal_uInt16 _nDefaultPortResId,sal_uInt16 _nHelpTextResId,sal_uInt16 _nHeaderTextResId,sal_uInt16 _nDriverClassId)470 	OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,sal_uInt16 _nResId, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, sal_uInt16 _nDefaultPortResId, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderTextResId, sal_uInt16 _nDriverClassId)
471 		:OGenericAdministrationPage(pParent, ModuleRes(_nResId), _rCoreAttrs)
472         ,m_aFTHelpText          (this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
473         ,m_aFTDatabasename	    (this, ModuleRes(FT_AUTODATABASENAME))
474 		,m_aETDatabasename	    (this, ModuleRes(ET_AUTODATABASENAME))
475         ,m_aFTHostname		    (this, ModuleRes(FT_AUTOHOSTNAME))
476 		,m_aETHostname		    (this, ModuleRes(ET_AUTOHOSTNAME))
477 		,m_aFTPortNumber	    (this, ModuleRes(FT_AUTOPORTNUMBER))
478         ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
479 		,m_aNFPortNumber	    (this, ModuleRes(NF_AUTOPORTNUMBER))
480 		,m_aFTDriverClass	    (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
481 		,m_aETDriverClass	    (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
482 		,m_aPBTestJavaDriver	(this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
483 		,m_nPortId(_nPortId)
484 	{
485         m_aFTDriverClass.SetText(String(ModuleRes(_nDriverClassId)));
486 
487         m_aFTDefaultPortNumber.SetText(String(ModuleRes(_nDefaultPortResId)));
488         String sHelpText = String(ModuleRes(_nHelpTextResId));
489         m_aFTHelpText.SetText(sHelpText);
490         //TODO this code snippet is redundant
491         SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId);
492 
493 		m_aETDatabasename.SetModifyHdl(getControlModifiedLink());
494         m_aETHostname.SetModifyHdl(getControlModifiedLink());
495 		m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
496 
497 	    m_aETDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified));
498 	    m_aPBTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl));
499 
500         SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
501         SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
502 	    ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
503 	    if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() )
504         {
505             m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
506         }
507 
508         SetRoadmapStateValue(sal_False);
509 		FreeResource();
510 	}
511 
512 
513 	// -----------------------------------------------------------------------
CreateMySQLJDBCTabPage(Window * pParent,const SfxItemSet & _rAttrSet)514 	OGenericAdministrationPage*	OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
515 	{
516 		return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
517                                                          PAGE_DBWIZARD_MYSQL_JDBC,
518                                                          _rAttrSet,
519                                                          DSID_MYSQL_PORTNUMBER ,
520                                                          STR_MYSQL_DEFAULT,
521                                                          STR_MYSQLJDBC_HELPTEXT,
522                                                          STR_MYSQLJDBC_HEADERTEXT,
523                                                          STR_MYSQL_DRIVERCLASSTEXT) );
524 	}
525 
526 	// -----------------------------------------------------------------------
CreateOracleJDBCTabPage(Window * pParent,const SfxItemSet & _rAttrSet)527 	OGenericAdministrationPage*	OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
528 	{
529 		return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
530                                                           PAGE_DBWIZARD_ORACLE,
531                                                           _rAttrSet,
532                                                           DSID_ORACLE_PORTNUMBER,
533                                                           STR_ORACLE_DEFAULT,
534                                                           STR_ORACLE_HELPTEXT,
535                                                           STR_ORACLE_HEADERTEXT,
536                                                           STR_ORACLE_DRIVERCLASSTEXT) );
537 	}
538 
539 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)540 	void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
541 	{
542 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDatabasename));
543         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
544 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostname));
545 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
546 	}
547 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)548 	void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
549 	{
550 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
551 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDatabasename));
552         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
553 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
554 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
555         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
556 	}
557 
558 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)559 	sal_Bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
560 	{
561 		sal_Bool bChangedSomething = sal_False;
562 	    fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
563 		fillString(_rSet,&m_aETHostname,DSID_CONN_HOSTNAME,bChangedSomething);
564 		fillString(_rSet,&m_aETDatabasename,DSID_DATABASENAME,bChangedSomething);
565         fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething );
566 		return bChangedSomething;
567 	}
568 
569 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)570 	void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
571 	{
572 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
573 		sal_Bool bValid, bReadonly;
574 		getFlags(_rSet, bValid, bReadonly);
575 
576 		SFX_ITEMSET_GET(_rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True);
577 		SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
578 		SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
579 		SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True);
580 
581 		if ( bValid )
582 		{
583 		    m_aETDatabasename.SetText(pDatabaseName->GetValue());
584 		    m_aETDatabasename.ClearModifyFlag();
585 
586 		    m_aETDriverClass.SetText(pDrvItem->GetValue());
587 		    m_aETDriverClass.ClearModifyFlag();
588 
589 			m_aETHostname.SetText(pHostName->GetValue());
590 			m_aETHostname.ClearModifyFlag();
591 
592 			m_aNFPortNumber.SetValue(pPortNumber->GetValue());
593 			m_aNFPortNumber.ClearModifyFlag();
594 		}
595 		OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
596 
597 		// to get the correct value when saveValue was called by base class
598 		if ( !m_aETDriverClass.GetText().Len() )
599 		{
600 			m_aETDriverClass.SetText(m_sDefaultJdbcDriverName);
601 			m_aETDriverClass.SetModifyFlag();
602 		}
603 		callModifiedHdl();
604 
605         sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
606         SetRoadmapStateValue(bRoadmapState);
607 	}
608 
609 	// -----------------------------------------------------------------------
610 	IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
611 	{
612 		OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
613 
614 		sal_Bool bSuccess = sal_False;
615 		try
616 		{
617 			if ( m_aETDriverClass.GetText().Len() )
618 			{
619 // TODO chage jvmaccess
620 				::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
621 				bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
622 			}
623 		}
624         catch(::com::sun::star::uno::Exception&)
625 		{
626 		}
627 
628 		sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
629 		OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
630 		aMsg.Execute();
631 		return 0L;
632 	}
633 
634     // -----------------------------------------------------------------------
IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup,OnEditModified,Edit *,_pEdit)635 	IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
636 	{
637 		if ( _pEdit == &m_aETDriverClass )
638 			m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
639         sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
640         SetRoadmapStateValue(bRoadmapState);
641 		callModifiedHdl();
642 		return 0L;
643 	}
644 
645 	// -----------------------------------------------------------------------
CreateJDBCTabPage(Window * pParent,const SfxItemSet & _rAttrSet)646 	OGenericAdministrationPage*	OJDBCConnectionPageSetup::CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
647 	{
648 		return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet));
649 	}
650 
651 
652 	//========================================================================
653 	//= OMySQLJDBCConnectionPageSetup
654 	//========================================================================
OJDBCConnectionPageSetup(Window * pParent,const SfxItemSet & _rCoreAttrs)655 	OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs)
656 		:OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_JDBC, _rCoreAttrs, STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL)
657         ,m_aFTDriverClass	    (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
658 		,m_aETDriverClass	    (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
659 		,m_aPBTestJavaDriver	(this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
660 	{
661         m_aETDriverClass.SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
662 		m_aPBTestJavaDriver.SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
663 		FreeResource();
664 	}
665 
666 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)667 	void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
668 	{
669         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
670 	}
671 
672 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)673 	void OJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
674 	{
675         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
676 	}
677 
678 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)679 	sal_Bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
680 	{
681 		sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
682 		fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
683 		return bChangedSomething;
684 	}
685 
686 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)687 	void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
688 	{
689 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
690 		sal_Bool bValid, bReadonly;
691 		getFlags(_rSet, bValid, bReadonly);
692 
693 		SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
694 
695 		if ( bValid )
696 		{
697             if ( !pDrvItem->GetValue().Len() )
698             {
699                 String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
700                 if ( sDefaultJdbcDriverName.Len() )
701                 {
702                     m_aETDriverClass.SetText(sDefaultJdbcDriverName);
703 			        m_aETDriverClass.SetModifyFlag();
704                 } // if ( sDefaultJdbcDriverName.Len() )
705             } // if ( !pJdbcDrvItem->GetValue().Len() )
706             else
707             {
708 			    m_aETDriverClass.SetText(pDrvItem->GetValue());
709 			    m_aETDriverClass.ClearModifyFlag();
710             }
711 		}
712         sal_Bool bEnable = pDrvItem->GetValue().Len() != 0;
713         m_aPBTestJavaDriver.Enable(bEnable);
714 		OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
715 
716         SetRoadmapStateValue(checkTestConnection());
717     }
718 
719 
checkTestConnection()720 	bool OJDBCConnectionPageSetup::checkTestConnection()
721 	{
722 		OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
723 		sal_Bool bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
724 		bEnableTestConnection = bEnableTestConnection && (m_aETDriverClass.GetText().Len() != 0);
725         return bEnableTestConnection;
726 //		m_aTestConnection.Enable(bEnableTestConnection);
727 	}
728 
729 
730 	// -----------------------------------------------------------------------
731 	IMPL_LINK(OJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
732 	{
733 		OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
734 		sal_Bool bSuccess = sal_False;
735 		try
736 		{
737 			if ( m_aETDriverClass.GetText().Len() )
738 			{
739 // TODO chage jvmaccess
740 				::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
741 				bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
742 			}
743 		}
744         catch(::com::sun::star::uno::Exception&)
745 		{
746 		}
747 
748 		sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
749 		OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
750 		aMsg.Execute();
751 		return 0L;
752 	}
753 
754 	// -----------------------------------------------------------------------
IMPL_LINK(OJDBCConnectionPageSetup,OnEditModified,Edit *,_pEdit)755 	IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
756 	{
757 		if ( _pEdit == &m_aETDriverClass )
758 			m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
759         SetRoadmapStateValue(checkTestConnection());
760 		// tell the listener we were modified
761 		callModifiedHdl();
762 		return 0L;
763 	}
764 
765 
CreateSpreadSheetTabPage(Window * pParent,const SfxItemSet & _rAttrSet)766 	OGenericAdministrationPage*	OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
767     {
768         return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) );
769     }
770 
DBG_NAME(OSpreadSheetConnectionPageSetup)771 DBG_NAME(OSpreadSheetConnectionPageSetup)
772 
773 	OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
774 		:OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_SPREADSHEET, _rCoreAttrs, STR_SPREADSHEET_HELPTEXT, STR_SPREADSHEET_HEADERTEXT, STR_SPREADSHEETPATH)
775             , m_aCBPasswordrequired(this, ModuleRes(CB_SPREADSHEETPASSWORDREQUIRED))
776     {
777         DBG_CTOR(OSpreadSheetConnectionPageSetup,NULL);
778 
779    		m_aCBPasswordrequired.SetToggleHdl(getControlModifiedLink());
780 		FreeResource();
781 	}
782 
783 
784 	// -----------------------------------------------------------------------
~OSpreadSheetConnectionPageSetup()785 	OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
786 	{
787 
788         DBG_DTOR(OSpreadSheetConnectionPageSetup,NULL);
789     }
790 
791 
fillWindows(::std::vector<ISaveValueWrapper * > &)792 	void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
793 	{
794 	}
795 
796 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)797 	void OSpreadSheetConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
798 	{
799         OConnectionTabPageSetup::fillControls(_rControlList);
800 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordrequired));
801 
802     }
803 
804 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)805 	void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
806 	{
807         OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
808 	}
809 
810 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)811 	sal_Bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
812 	{
813         sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
814 		fillBool(_rSet,&m_aCBPasswordrequired,DSID_PASSWORDREQUIRED,bChangedSomething);
815         return bChangedSomething;
816 	}
817 
CreateAuthentificationTabPage(Window * pParent,const SfxItemSet & _rAttrSet)818 	OGenericAdministrationPage*	OAuthentificationPageSetup::CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
819     {
820         return ( new OAuthentificationPageSetup( pParent, _rAttrSet) );
821     }
822 
DBG_NAME(OAuthentificationPageSetup)823 DBG_NAME(OAuthentificationPageSetup)
824 
825 	OAuthentificationPageSetup::OAuthentificationPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
826         :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_AUTHENTIFICATION), _rCoreAttrs )
827         , m_aFTHelpText             (this, ModuleRes(FT_AUTHENTIFICATIONHELPTEXT))
828         , m_aFTHeaderText           (this, ModuleRes(FT_AUTHENTIFICATIONHEADERTEXT))
829 		, m_aFTUserName             (this, ModuleRes(FT_GENERALUSERNAME))
830 		, m_aETUserName             (this, ModuleRes(ET_GENERALUSERNAME))
831 		, m_aCBPasswordRequired     (this, ModuleRes(CB_GENERALPASSWORDREQUIRED))
832         , m_aPBTestConnection       (this, ModuleRes(PB_TESTCONNECTION))
833     {
834         DBG_CTOR(OAuthentificationPageSetup,NULL);
835 
836         SetControlFontWeight(&m_aFTHeaderText);
837 		m_aETUserName.SetModifyHdl(getControlModifiedLink());
838 		m_aCBPasswordRequired.SetClickHdl(getControlModifiedLink());
839    		m_aPBTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl));
840 		FreeResource();
841 
842         LayoutHelper::fitSizeRightAligned( m_aPBTestConnection );
843 	}
844 
845 
846 	// -----------------------------------------------------------------------
~OAuthentificationPageSetup()847 	OAuthentificationPageSetup::~OAuthentificationPageSetup()
848 	{
849 
850         DBG_DTOR(OAuthentificationPageSetup,NULL);
851     }
852 
853 
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)854 	void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
855 	{
856         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
857         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTUserName));
858 		_rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPBTestConnection));
859 	}
860 
861 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)862 	void OAuthentificationPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
863 	{
864 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETUserName));
865 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordRequired));
866     }
867 
868 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool)869 	void OAuthentificationPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
870 	{
871         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
872 		sal_Bool bValid, bReadonly;
873 		getFlags(_rSet, bValid, bReadonly);
874         SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
875         SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
876 
877         m_aETUserName.SetText(pUidItem->GetValue());
878 	    m_aCBPasswordRequired.Check(pAllowEmptyPwd->GetValue());
879 
880         m_aETUserName.ClearModifyFlag();
881 	}
882 
883 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)884 	sal_Bool OAuthentificationPageSetup::FillItemSet( SfxItemSet& _rSet )
885 	{
886 		sal_Bool bChangedSomething = sal_False;
887 
888 		if (m_aETUserName.GetText() != m_aETUserName.GetSavedValue())
889 		{
890 			_rSet.Put(SfxStringItem(DSID_USER, m_aETUserName.GetText()));
891 			_rSet.Put(SfxStringItem(DSID_PASSWORD, String()));
892 			bChangedSomething = sal_True;
893 		}
894 		fillBool(_rSet,&m_aCBPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
895         return bChangedSomething;
896 	}
897 
898 
CreateFinalDBTabPageSetup(Window * pParent,const SfxItemSet & _rAttrSet)899 	OGenericAdministrationPage*	OFinalDBPageSetup::CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet)
900     {
901         return ( new OFinalDBPageSetup( pParent, _rAttrSet) );
902     }
903 
DBG_NAME(OFinalDBPageSetup)904 DBG_NAME(OFinalDBPageSetup)
905 
906 	OFinalDBPageSetup::OFinalDBPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
907     :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_FINAL), _rCoreAttrs )
908     , m_aFTFinalHeader              (this, ModuleRes(FT_FINALHEADER))
909     , m_aFTFinalHelpText            (this, ModuleRes(FT_FINALHELPTEXT))
910     , m_aRBRegisterDataSource       (this, ModuleRes(RB_REGISTERDATASOURCE))
911     , m_aRBDontregisterDataSource   (this, ModuleRes(RB_DONTREGISTERDATASOURCE))
912     , m_aFTAdditionalSettings       (this, ModuleRes(FT_ADDITIONALSETTINGS))
913     , m_aCBOpenAfterwards           (this, ModuleRes(CB_OPENAFTERWARDS))
914     , m_aCBStartTableWizard         (this, ModuleRes(CB_STARTTABLEWIZARD))
915     , m_aFTFinalText                (this, ModuleRes(FT_FINALTEXT))
916     {
917         DBG_CTOR(OFinalDBPageSetup,NULL);
918 
919         String stext = m_aFTFinalHeader.GetText();
920         SetControlFontWeight(&m_aFTFinalHeader);
921 		m_aCBOpenAfterwards.SetClickHdl(LINK(this, OFinalDBPageSetup, OnOpenSelected));
922 		m_aCBStartTableWizard.SetClickHdl(getControlModifiedLink());
923 		m_aRBRegisterDataSource.SetState(sal_True);
924         FreeResource();
925 
926         sal_Int32 nUnrelatedHeight  = LogicToPixel( Size( 0, UNRELATED_CONTROLS ), MAP_APPFONT ).Height();
927         sal_Int32 nRelatedHeight    = LogicToPixel( Size( 0, RELATED_CONTROLS ), MAP_APPFONT ).Height();
928 
929         ::std::pair<Window*,sal_Int32> pWindows[] = {
930             ::std::pair<Window*,sal_Int32>(&m_aFTFinalHelpText,nRelatedHeight)
931             ,::std::pair<Window*,sal_Int32>(&m_aRBRegisterDataSource,nRelatedHeight)
932             ,::std::pair<Window*,sal_Int32>(&m_aRBDontregisterDataSource,nUnrelatedHeight)
933             ,::std::pair<Window*,sal_Int32>(&m_aFTAdditionalSettings,nRelatedHeight)
934             ,::std::pair<Window*,sal_Int32>(&m_aCBOpenAfterwards,nRelatedHeight)
935             ,::std::pair<Window*,sal_Int32>(&m_aCBStartTableWizard,nUnrelatedHeight)
936             ,::std::pair<Window*,sal_Int32>(&m_aFTFinalText,nUnrelatedHeight)
937         };
938 
939         Point aPos(m_aFTFinalHeader.GetPosPixel());
940         Size aStart(m_aFTFinalHeader.GetSizePixel());
941         aPos.Y() += aStart.Height() + nUnrelatedHeight;
942 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
943 		for (sal_Int32 i=0; i < nCount; ++i)
944 		{
945             aPos.X() = pWindows[i].first->GetPosPixel().X();
946             Size aSize = pWindows[i].first->GetSizePixel();
947             FixedText* pText = dynamic_cast<FixedText*>(pWindows[i].first);
948             if ( pText )
949                 aSize = pText->CalcMinimumSize(aSize.Width());
950             pWindows[i].first->SetPosSizePixel(aPos,aSize);
951             aPos.Y() += aSize.Height() + pWindows[i].second;
952         }
953 	}
954 
955 
956 	// -----------------------------------------------------------------------
~OFinalDBPageSetup()957 	OFinalDBPageSetup::~OFinalDBPageSetup()
958 	{
959 
960         DBG_DTOR(OFinalDBPageSetup,NULL);
961     }
962 
IsDatabaseDocumentToBeRegistered()963     sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered()
964     {
965         return m_aRBRegisterDataSource.IsChecked() && m_aRBRegisterDataSource.IsEnabled();
966     }
967 
IsDatabaseDocumentToBeOpened()968     sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened()
969     {
970         return m_aCBOpenAfterwards.IsChecked() && m_aCBOpenAfterwards.IsEnabled();
971     }
972 
IsTableWizardToBeStarted()973     sal_Bool OFinalDBPageSetup::IsTableWizardToBeStarted()
974     {
975         return m_aCBStartTableWizard.IsChecked() && m_aCBStartTableWizard.IsEnabled();
976     }
977 
978 
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)979 	void OFinalDBPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
980 	{
981         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHeader));
982         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHelpText));
983         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTAdditionalSettings));
984         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalText));
985     }
986 
987 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)988 	void OFinalDBPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
989 	{
990 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBOpenAfterwards));
991 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBStartTableWizard));
992 		_rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBRegisterDataSource));
993 		_rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBDontregisterDataSource));
994     }
995 
996 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet &,sal_Bool)997 	void OFinalDBPageSetup::implInitControls(const SfxItemSet& /*_rSet*/, sal_Bool /*_bSaveValue*/)
998 	{
999         m_aCBOpenAfterwards.Check();
1000 	}
1001 
enableTableWizardCheckBox(sal_Bool _bSupportsTableCreation)1002     void OFinalDBPageSetup::enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation)
1003     {
1004         m_aCBStartTableWizard.Enable(_bSupportsTableCreation);
1005     }
1006 
1007 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet &)1008 	sal_Bool OFinalDBPageSetup::FillItemSet( SfxItemSet& /*_rSet*/ )
1009 	{
1010         return sal_True;
1011 	}
1012 	// -----------------------------------------------------------------------------
IMPL_LINK(OFinalDBPageSetup,OnOpenSelected,CheckBox *,_pBox)1013 	IMPL_LINK(OFinalDBPageSetup, OnOpenSelected, CheckBox*, _pBox)
1014     {
1015 		m_aCBStartTableWizard.Enable( _pBox->IsEnabled() && _pBox->IsChecked() );
1016 		callModifiedHdl();
1017 		// outta here
1018 		return 0L;
1019 	}
1020 //.........................................................................
1021 }
1022 // namespace dbaui
1023 //.........................................................................
1024