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 #ifndef DBAUI_CONNECTIONHELPER_HXX
25 #define DBAUI_CONNECTIONHELPER_HXX
26 
27 #ifndef _DBAUI_ADMINPAGES_HXX_
28 #include "adminpages.hxx"
29 #endif
30 #ifndef _UCBHELPER_CONTENT_HXX
31 #include <ucbhelper/content.hxx>
32 #endif
33 #ifndef _DBAUI_CURLEDIT_HXX_
34 #include "curledit.hxx"
35 #endif
36 #ifndef _SFX_FILEDLGHELPER_HXX
37 #include <sfx2/filedlghelper.hxx>
38 #endif
39 
40 
41 #define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag)	\
42 	if (editcontrol.GetText() != editcontrol.GetSavedValue())			\
43 	{																	\
44 		itemset.Put(SfxStringItem(itemid, editcontrol.GetText()));		\
45 		modifiedflag = sal_True;										\
46 	}
47 
48 //.........................................................................
49 namespace dbaui
50 {
51 //.........................................................................
52 
53 	// #106016# --------------
54 	enum IS_PATH_EXIST
55 	{
56 		PATH_NOT_EXIST = 0,
57 		PATH_EXIST,
58 		PATH_NOT_KNOWN
59 	};
60 
61     class IDatabaseSettingsDialog;
62 
63 	class OConnectionHelper : public OGenericAdministrationPage
64 	{
65 		sal_Bool			m_bUserGrabFocus : 1;
66 
67     public:
68         OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs);
69 		virtual ~OConnectionHelper();
70         FixedText			m_aFT_Connection;
71 		OConnectionURLEdit	m_aConnectionURL;
72         PushButton			m_aPB_Connection;
73 		::rtl::OUString     m_eType;          // the type can't be changed in this class, so we hold it as member.
74 
75 	public:
76 
77         // setting/retrieving the current connection URL
78 		// necessary because for some types, the URL must be decoded for display purposes
79 		::dbaccess::ODsnTypeCollection*	m_pCollection;	/// the DSN type collection instance
80 		virtual long    PreNotify( NotifyEvent& _rNEvt );
81 
82 		// <method>OGenericAdministrationPage::fillControls</method>
83 		virtual void    fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
84 		// <method>OGenericAdministrationPage::fillWindows</method>
85 		virtual void    fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
86 		virtual void    implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
87 
88 
89 		// setting/retrieving the current connection URL
90 		// necessary because for some types, the URL must be decoded for display purposes
91         //String		getURL( OConnectionURLEdit* _m_pConnection ) const;
92 		//void		setURL( const String& _rURL, OConnectionURLEdit* _m_pConnection );
93 
94         String		getURLNoPrefix( ) const;
95         void		setURLNoPrefix( const String& _rURL );
96 
97         /** checks if the path is existence
98 			@param	_rURL
99 				The URL to check.
100 		*/
101 		sal_Int32	checkPathExistence(const String& _rURL);
102 
103 
104         IS_PATH_EXIST	pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const;
105 		sal_Bool		createDirectoryDeep(const String& _rPathNormalized);
106         sal_Bool		commitURL();
107 
108 		/** opens the FileOpen dialog and asks for a FileName
109 			@param	_aFileOpen
110 				Executes the file open dialog, which must be filled from caller.
111 		*/
112 		void askForFileName(::sfx2::FileDialogHelper& _aFileOpen);
113 
SetServiceFactory(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> _rxORB)114    		virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
115 		{
116 			OGenericAdministrationPage::SetServiceFactory(_rxORB);
117 		}
118 
119     protected:
120 		void		    setURL( const String& _rURL );
121 		virtual bool    checkTestConnection();
122 
123     private:
124 		DECL_LINK(OnBrowseConnections, PushButton*);
125 		StringBag   getInstalledAdabasDBDirs(const String &_rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude);
126 		StringBag   getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);
127         String		impl_getURL( sal_Bool _bPrefix ) const;
128 		void		impl_setURL( const String& _rURL, sal_Bool _bPrefix );
129         void        implUpdateURLDependentStates() const;
130     };
131 
132 //.........................................................................
133 }	// namespace dbaui
134 //.........................................................................
135 
136 #endif // DBAUI_CONNECTIONHELPER_HXX
137