xref: /AOO42X/main/dbaccess/source/ui/dlg/ConnectionHelper.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONHELPER_HXX
25cdf0e10cSrcweir #define DBAUI_CONNECTIONHELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBAUI_ADMINPAGES_HXX_
28cdf0e10cSrcweir #include "adminpages.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENT_HXX
31cdf0e10cSrcweir #include <ucbhelper/content.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _DBAUI_CURLEDIT_HXX_
34cdf0e10cSrcweir #include "curledit.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _SFX_FILEDLGHELPER_HXX
37cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag)    \
42cdf0e10cSrcweir     if (editcontrol.GetText() != editcontrol.GetSavedValue())           \
43cdf0e10cSrcweir     {                                                                   \
44cdf0e10cSrcweir         itemset.Put(SfxStringItem(itemid, editcontrol.GetText()));      \
45cdf0e10cSrcweir         modifiedflag = sal_True;                                        \
46cdf0e10cSrcweir     }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //.........................................................................
49cdf0e10cSrcweir namespace dbaui
50cdf0e10cSrcweir {
51cdf0e10cSrcweir //.........................................................................
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     // #106016# --------------
54cdf0e10cSrcweir     enum IS_PATH_EXIST
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         PATH_NOT_EXIST = 0,
57cdf0e10cSrcweir         PATH_EXIST,
58cdf0e10cSrcweir         PATH_NOT_KNOWN
59cdf0e10cSrcweir     };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     class IDatabaseSettingsDialog;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     class OConnectionHelper : public OGenericAdministrationPage
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         sal_Bool            m_bUserGrabFocus : 1;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     public:
68cdf0e10cSrcweir         OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs);
69cdf0e10cSrcweir         virtual ~OConnectionHelper();
70cdf0e10cSrcweir         FixedText           m_aFT_Connection;
71cdf0e10cSrcweir         OConnectionURLEdit  m_aConnectionURL;
72cdf0e10cSrcweir         PushButton          m_aPB_Connection;
73cdf0e10cSrcweir         ::rtl::OUString     m_eType;          // the type can't be changed in this class, so we hold it as member.
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     public:
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         // setting/retrieving the current connection URL
78cdf0e10cSrcweir         // necessary because for some types, the URL must be decoded for display purposes
79cdf0e10cSrcweir         ::dbaccess::ODsnTypeCollection* m_pCollection;  /// the DSN type collection instance
80cdf0e10cSrcweir         virtual long    PreNotify( NotifyEvent& _rNEvt );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         // <method>OGenericAdministrationPage::fillControls</method>
83cdf0e10cSrcweir         virtual void    fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
84cdf0e10cSrcweir         // <method>OGenericAdministrationPage::fillWindows</method>
85cdf0e10cSrcweir         virtual void    fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
86cdf0e10cSrcweir         virtual void    implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         // setting/retrieving the current connection URL
90cdf0e10cSrcweir         // necessary because for some types, the URL must be decoded for display purposes
91cdf0e10cSrcweir         //String        getURL( OConnectionURLEdit* _m_pConnection ) const;
92cdf0e10cSrcweir         //void      setURL( const String& _rURL, OConnectionURLEdit* _m_pConnection );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         String      getURLNoPrefix( ) const;
95cdf0e10cSrcweir         void        setURLNoPrefix( const String& _rURL );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         /** checks if the path is existence
98cdf0e10cSrcweir             @param  _rURL
99cdf0e10cSrcweir                 The URL to check.
100cdf0e10cSrcweir         */
101cdf0e10cSrcweir         sal_Int32   checkPathExistence(const String& _rURL);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         IS_PATH_EXIST   pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const;
105cdf0e10cSrcweir         sal_Bool        createDirectoryDeep(const String& _rPathNormalized);
106cdf0e10cSrcweir         sal_Bool        commitURL();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         /** opens the FileOpen dialog and asks for a FileName
109cdf0e10cSrcweir             @param  _aFileOpen
110cdf0e10cSrcweir                 Executes the file open dialog, which must be filled from caller.
111cdf0e10cSrcweir         */
112cdf0e10cSrcweir         void askForFileName(::sfx2::FileDialogHelper& _aFileOpen);
113cdf0e10cSrcweir 
SetServiceFactory(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> _rxORB)114cdf0e10cSrcweir         virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
115cdf0e10cSrcweir         {
116cdf0e10cSrcweir             OGenericAdministrationPage::SetServiceFactory(_rxORB);
117cdf0e10cSrcweir         }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     protected:
120cdf0e10cSrcweir         void            setURL( const String& _rURL );
121cdf0e10cSrcweir         virtual bool    checkTestConnection();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     private:
124cdf0e10cSrcweir         DECL_LINK(OnBrowseConnections, PushButton*);
125cdf0e10cSrcweir         StringBag   getInstalledAdabasDBDirs(const String &_rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude);
126cdf0e10cSrcweir         StringBag   getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);
127cdf0e10cSrcweir         String      impl_getURL( sal_Bool _bPrefix ) const;
128cdf0e10cSrcweir         void        impl_setURL( const String& _rURL, sal_Bool _bPrefix );
129cdf0e10cSrcweir         void        implUpdateURLDependentStates() const;
130cdf0e10cSrcweir     };
131cdf0e10cSrcweir 
132cdf0e10cSrcweir //.........................................................................
133cdf0e10cSrcweir }   // namespace dbaui
134cdf0e10cSrcweir //.........................................................................
135cdf0e10cSrcweir 
136cdf0e10cSrcweir #endif // DBAUI_CONNECTIONHELPER_HXX
137