Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_GENERALPAGE_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_DLG_GENERALPAGE_HXX
22 :
23 : #include "adminpages.hxx"
24 : #include "opendoccontrols.hxx"
25 : #include <vcl/fixed.hxx>
26 : #include <vcl/lstbox.hxx>
27 : #include <vcl/edit.hxx>
28 : #include <svtools/dialogcontrolling.hxx>
29 :
30 : namespace dbaui
31 : {
32 : // OGeneralPage
33 : class OGeneralPage : public OGenericAdministrationPage
34 : {
35 : protected:
36 : OGeneralPage( vcl::Window* pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems );
37 : virtual ~OGeneralPage();
38 :
39 : OUString m_eCurrentSelection; /// currently selected type
40 : ::dbaccess::DATASOURCE_TYPE
41 : m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered ....
42 :
43 : private:
44 : FixedText* m_pSpecialMessage;
45 :
46 : enum SPECIAL_MESSAGE
47 : {
48 : smNone,
49 : smUnsupportedType
50 : };
51 : SPECIAL_MESSAGE m_eLastMessage;
52 :
53 : Link m_aTypeSelectHandler; /// to be called if a new type is selected
54 : bool m_bDisplayingInvalid : 1; /// the currently displayed data source is deleted
55 : bool m_bInitTypeList : 1;
56 : bool approveDatasourceType( const OUString& _sURLPrefix, OUString& _inout_rDisplayName );
57 : void insertDatasourceTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
58 :
59 : protected:
60 : ListBox* m_pDatasourceType;
61 :
62 : ::dbaccess::ODsnTypeCollection*
63 : m_pCollection; /// the DSN type collection instance
64 :
65 : ::std::vector< OUString>
66 : m_aURLPrefixes;
67 :
68 : public:
69 : /// set a handler which gets called every time the user selects a new type
70 0 : void SetTypeSelectHandler( const Link& _rHandler ) { m_aTypeSelectHandler = _rHandler; }
71 :
72 : /// get the currently selected datasource type
73 0 : OUString GetSelectedType() const { return m_eCurrentSelection; }
74 :
75 : protected:
76 : // SfxTabPage overridables
77 : virtual void Reset( const SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
78 :
79 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
80 : virtual OUString getDatasourceName( const SfxItemSet& _rSet );
81 : virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName );
82 :
83 : // <method>OGenericAdministrationPage::fillControls</method>
84 : virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE;
85 : // <method>OGenericAdministrationPage::fillWindows</method>
86 : virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE;
87 :
88 : void onTypeSelected(const OUString& _sURLPrefix);
89 : void initializeTypeList();
90 :
91 : void implSetCurrentType( const OUString& _eType );
92 :
93 : void switchMessage(const OUString& _sURLPrefix);
94 :
95 : /// sets the title of the parent dialog
96 : virtual void setParentTitle( const OUString& _sURLPrefix );
97 :
98 : DECL_LINK(OnDatasourceTypeSelected, ListBox*);
99 : };
100 :
101 : // OGeneralPageDialog
102 0 : class OGeneralPageDialog : public OGeneralPage
103 : {
104 : public:
105 : OGeneralPageDialog( vcl::Window* pParent, const SfxItemSet& _rItems );
106 :
107 : protected:
108 : virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
109 :
110 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
111 : virtual void setParentTitle( const OUString& _sURLPrefix ) SAL_OVERRIDE;
112 : };
113 :
114 : // OGeneralPageWizard
115 0 : class OGeneralPageWizard : public OGeneralPage
116 : {
117 : public:
118 : OGeneralPageWizard( vcl::Window* pParent, const SfxItemSet& _rItems );
119 :
120 : public:
121 : enum CreationMode
122 : {
123 : eCreateNew,
124 : eConnectExternal,
125 : eOpenExisting
126 : };
127 :
128 0 : struct DocumentDescriptor
129 : {
130 : OUString sURL;
131 : OUString sFilter;
132 : };
133 :
134 : private:
135 : // dialog controls
136 : RadioButton* m_pRB_CreateDatabase;
137 : RadioButton* m_pRB_OpenExistingDatabase;
138 : RadioButton* m_pRB_ConnectDatabase;
139 :
140 : FixedText* m_pFT_EmbeddedDBLabel;
141 : ListBox* m_pEmbeddedDBType;
142 :
143 : FixedText* m_pFT_DocListLabel;
144 : OpenDocumentListBox* m_pLB_DocumentList;
145 : OpenDocumentButton* m_pPB_OpenDatabase;
146 :
147 : // state
148 : DocumentDescriptor m_aBrowsedDocument;
149 : CreationMode m_eOriginalCreationMode;
150 :
151 : Link m_aCreationModeHandler; /// to be called if a new type is selected
152 : Link m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected
153 : Link m_aChooseDocumentHandler; /// to be called when a recent document has been definitely chosen
154 :
155 : ::svt::ControlDependencyManager
156 : m_aControlDependencies;
157 :
158 : bool m_bInitEmbeddedDBList : 1;
159 : void insertEmbeddedDBTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
160 :
161 : public:
162 0 : void SetCreationModeHandler( const Link& _rHandler ) { m_aCreationModeHandler = _rHandler; }
163 : CreationMode GetDatabaseCreationMode() const;
164 :
165 0 : void SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
166 0 : void SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
167 : DocumentDescriptor GetSelectedDocument() const;
168 :
169 : protected:
170 : virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
171 :
172 : virtual void GetFocus() SAL_OVERRIDE;
173 :
174 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
175 : virtual OUString getDatasourceName( const SfxItemSet& _rSet ) SAL_OVERRIDE;
176 : virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName ) SAL_OVERRIDE;
177 :
178 : ::std::vector< OUString>
179 : m_aEmbeddedURLPrefixes;
180 :
181 : virtual OUString getEmbeddedDBName( const SfxItemSet& _rSet );
182 : void initializeEmbeddedDBList();
183 :
184 : protected:
185 : DECL_LINK( OnEmbeddedDBTypeSelected, ListBox* );
186 : DECL_LINK( OnCreateDatabaseModeSelected, RadioButton* );
187 : DECL_LINK( OnSetupModeSelected, RadioButton* );
188 : DECL_LINK( OnDocumentSelected, ListBox* );
189 : DECL_LINK( OnOpenDocument, PushButton* );
190 : };
191 :
192 : } // namespace dbaui
193 : #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_GENERALPAGE_HXX
194 :
195 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|