1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef DBAUI_CONNECTIONHELPER_HXX
29 #define DBAUI_CONNECTIONHELPER_HXX
30 
31 #ifndef _DBAUI_ADMINPAGES_HXX_
32 #include "adminpages.hxx"
33 #endif
34 #ifndef _UCBHELPER_CONTENT_HXX
35 #include <ucbhelper/content.hxx>
36 #endif
37 #ifndef _DBAUI_CURLEDIT_HXX_
38 #include "curledit.hxx"
39 #endif
40 #ifndef _SFX_FILEDLGHELPER_HXX
41 #include <sfx2/filedlghelper.hxx>
42 #endif
43 
44 
45 #define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag)	\
46 	if (editcontrol.GetText() != editcontrol.GetSavedValue())			\
47 	{																	\
48 		itemset.Put(SfxStringItem(itemid, editcontrol.GetText()));		\
49 		modifiedflag = sal_True;										\
50 	}
51 
52 //.........................................................................
53 namespace dbaui
54 {
55 //.........................................................................
56 
57 	// #106016# --------------
58 	enum IS_PATH_EXIST
59 	{
60 		PATH_NOT_EXIST = 0,
61 		PATH_EXIST,
62 		PATH_NOT_KNOWN
63 	};
64 
65     class IDatabaseSettingsDialog;
66 
67 	class OConnectionHelper : public OGenericAdministrationPage
68 	{
69 		sal_Bool			m_bUserGrabFocus : 1;
70 
71     public:
72         OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs);
73 		virtual ~OConnectionHelper();
74         FixedText			m_aFT_Connection;
75 		OConnectionURLEdit	m_aConnectionURL;
76         PushButton			m_aPB_Connection;
77 		::rtl::OUString     m_eType;          // the type can't be changed in this class, so we hold it as member.
78 
79 	public:
80 
81         // setting/retrieving the current connection URL
82 		// necessary because for some types, the URL must be decoded for display purposes
83 		::dbaccess::ODsnTypeCollection*	m_pCollection;	/// the DSN type collection instance
84 		virtual long    PreNotify( NotifyEvent& _rNEvt );
85 
86 		// <method>OGenericAdministrationPage::fillControls</method>
87 		virtual void    fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
88 		// <method>OGenericAdministrationPage::fillWindows</method>
89 		virtual void    fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
90 		virtual void    implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
91 
92 
93 		// setting/retrieving the current connection URL
94 		// necessary because for some types, the URL must be decoded for display purposes
95         //String		getURL( OConnectionURLEdit* _m_pConnection ) const;
96 		//void		setURL( const String& _rURL, OConnectionURLEdit* _m_pConnection );
97 
98         String		getURLNoPrefix( ) const;
99         void		setURLNoPrefix( const String& _rURL );
100 
101         /** checks if the path is existence
102 			@param	_rURL
103 				The URL to check.
104 		*/
105 		sal_Int32	checkPathExistence(const String& _rURL);
106 
107 
108         IS_PATH_EXIST	pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const;
109 		sal_Bool		createDirectoryDeep(const String& _rPathNormalized);
110         sal_Bool		commitURL();
111 
112 		/** opens the FileOpen dialog and asks for a FileName
113 			@param	_aFileOpen
114 				Executes the file open dialog, which must be filled from caller.
115 		*/
116 		void askForFileName(::sfx2::FileDialogHelper& _aFileOpen);
117 
118    		virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
119 		{
120 			OGenericAdministrationPage::SetServiceFactory(_rxORB);
121 		}
122 
123     protected:
124 		void		    setURL( const String& _rURL );
125 		virtual bool    checkTestConnection();
126 
127     private:
128 		DECL_LINK(OnBrowseConnections, PushButton*);
129 		StringBag   getInstalledAdabasDBDirs(const String &_rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude);
130 		StringBag   getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);
131         String		impl_getURL( sal_Bool _bPrefix ) const;
132 		void		impl_setURL( const String& _rURL, sal_Bool _bPrefix );
133         void        implUpdateURLDependentStates() const;
134     };
135 
136 //.........................................................................
137 }	// namespace dbaui
138 //.........................................................................
139 
140 #endif // DBAUI_CONNECTIONHELPER_HXX
141