xref: /trunk/main/dbaccess/source/ui/dlg/generalpage.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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_GENERALPAGE_HXX_
29 #define _DBAUI_GENERALPAGE_HXX_
30 
31 #ifndef _DBAUI_ADMINPAGES_HXX_
32 #include "adminpages.hxx"
33 #endif
34 #ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
35 #include "opendoccontrols.hxx"
36 #endif
37 #ifndef _SV_FIXED_HXX
38 #include <vcl/fixed.hxx>
39 #endif
40 #ifndef _SV_LSTBOX_HXX
41 #include <vcl/lstbox.hxx>
42 #endif
43 #ifndef _SV_EDIT_HXX
44 #include <vcl/edit.hxx>
45 #endif
46 #include <svtools/dialogcontrolling.hxx>
47 #include <memory>
48 
49 //.........................................................................
50 namespace dbaui
51 {
52 //.........................................................................
53     class IDatabaseSettingsDialog;
54     //=========================================================================
55     //= OGeneralPage
56     //=========================================================================
57     class OGeneralPage : public OGenericAdministrationPage
58     {
59         OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False);
60         ~OGeneralPage();
61 
62     public:
63         enum CreationMode
64         {
65             eCreateNew,
66             eConnectExternal,
67             eOpenExisting
68         };
69 
70         struct DocumentDescriptor
71         {
72             String  sURL;
73             String  sFilter;
74         };
75 
76     private:
77         // dialog controls
78         FixedText           m_aFTHeaderText;
79         FixedText           m_aFTHelpText;
80         FixedText           m_aFT_DatasourceTypeHeader;
81         RadioButton         m_aRB_CreateDatabase;
82         RadioButton         m_aRB_OpenDocument;
83         RadioButton         m_aRB_GetExistingDatabase;
84         FixedText           m_aFT_DocListLabel;
85         ::std::auto_ptr< OpenDocumentListBox >
86                             m_pLB_DocumentList;
87         OpenDocumentButton  m_aPB_OpenDocument;
88         FixedText           m_aTypePreLabel;
89         FixedText           m_aDatasourceTypeLabel;
90         ::std::auto_ptr< ListBox >
91                             m_pDatasourceType;
92         FixedText           m_aFTDataSourceAppendix;
93         FixedText           m_aTypePostLabel;
94         FixedText           m_aSpecialMessage;
95         sal_Bool            m_DBWizardMode;
96         String              m_sMySQLEntry;
97         CreationMode        m_eOriginalCreationMode;
98         DocumentDescriptor  m_aBrowsedDocument;
99 
100         ::svt::ControlDependencyManager
101                             m_aControlDependencies;
102         ::std::vector< ::rtl::OUString> m_aURLPrefixes;
103 
104 
105         ::dbaccess::ODsnTypeCollection*
106                             m_pCollection;  /// the DSN type collection instance
107         ::rtl::OUString     m_eCurrentSelection;    /// currently selected type
108         ::dbaccess::DATASOURCE_TYPE     m_eNotSupportedKnownType;   /// if a data source of an unsupported, but known type is encountered ....
109 
110         enum SPECIAL_MESSAGE
111         {
112             smNone,
113             smUnsupportedType
114         };
115         SPECIAL_MESSAGE     m_eLastMessage;
116 
117         Link                m_aTypeSelectHandler;   /// to be called if a new type is selected
118         Link                m_aCreationModeHandler; /// to be called if a new type is selected
119         Link                m_aDocumentSelectionHandler;    /// to be called when a document in the RecentDoc list is selected
120         Link                m_aChooseDocumentHandler;       /// to be called when a recent document has been definately chosen
121         sal_Bool            m_bDisplayingInvalid : 1;   // the currently displayed data source is deleted
122         sal_Bool            m_bUserGrabFocus : 1;
123         bool                m_bInitTypeList : 1;
124         bool                approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName );
125         void                insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName);
126 
127     public:
128         static SfxTabPage*  Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False);
129 
130         /// set a handler which gets called every time the user selects a new type
131         void            SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
132         void            SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; }
133         void            SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
134         void            SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
135         CreationMode    GetDatabaseCreationMode() const;
136 
137         DocumentDescriptor  GetSelectedDocument() const;
138 
139         /// get the currently selected datasource type
140         ::rtl::OUString     GetSelectedType() const { return m_eCurrentSelection; }
141 
142     protected:
143         // SfxTabPage overridables
144         virtual sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
145         virtual void Reset(const SfxItemSet& _rCoreAttrs);
146 
147         virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
148 
149         virtual void GetFocus();
150 
151         // <method>OGenericAdministrationPage::fillControls</method>
152         virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
153         // <method>OGenericAdministrationPage::fillWindows</method>
154         virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
155 
156     protected:
157 
158         void onTypeSelected(const ::rtl::OUString& _sURLPrefix);
159         void initializeTypeList();
160 
161         void implSetCurrentType( const ::rtl::OUString& _eType );
162 
163         void switchMessage(const ::rtl::OUString& _sURLPrefix);
164 
165         /// sets the the title of the parent dialog
166         void setParentTitle(const ::rtl::OUString& _sURLPrefix);
167 
168         DECL_LINK(OnDatasourceTypeSelected, ListBox*);
169         DECL_LINK(OnSetupModeSelected, RadioButton*);
170         DECL_LINK(OnDocumentSelected, ListBox*);
171         DECL_LINK(OnOpenDocument, PushButton*);
172     };
173 
174 //.........................................................................
175 }   // namespace dbaui
176 //.........................................................................
177 #endif // _DBAUI_GENERALPAGE_HXX_
178