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 :
38 : OUString m_eCurrentSelection; /// currently selected type
39 : ::dbaccess::DATASOURCE_TYPE
40 : m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered ....
41 :
42 : private:
43 : VclPtr<FixedText> m_pSpecialMessage;
44 :
45 : enum SPECIAL_MESSAGE
46 : {
47 : smNone,
48 : smUnsupportedType
49 : };
50 : SPECIAL_MESSAGE m_eLastMessage;
51 :
52 : Link<> m_aTypeSelectHandler; /// to be called if a new type is selected
53 : bool m_bDisplayingInvalid : 1; /// the currently displayed data source is deleted
54 : bool m_bInitTypeList : 1;
55 : bool approveDatasourceType( const OUString& _sURLPrefix, OUString& _inout_rDisplayName );
56 : void insertDatasourceTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
57 :
58 : protected:
59 : VclPtr<ListBox> m_pDatasourceType;
60 :
61 : ::dbaccess::ODsnTypeCollection*
62 : m_pCollection; /// the DSN type collection instance
63 :
64 : ::std::vector< OUString>
65 : m_aURLPrefixes;
66 :
67 : public:
68 : virtual ~OGeneralPage();
69 : virtual void dispose() SAL_OVERRIDE;
70 :
71 : /// set a handler which gets called every time the user selects a new type
72 0 : void SetTypeSelectHandler( const Link<>& _rHandler ) { m_aTypeSelectHandler = _rHandler; }
73 :
74 : /// get the currently selected datasource type
75 0 : OUString GetSelectedType() const { return m_eCurrentSelection; }
76 :
77 : protected:
78 : // SfxTabPage overridables
79 : virtual void Reset( const SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
80 :
81 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
82 : virtual OUString getDatasourceName( const SfxItemSet& _rSet );
83 : virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName );
84 :
85 : // <method>OGenericAdministrationPage::fillControls</method>
86 : virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE;
87 : // <method>OGenericAdministrationPage::fillWindows</method>
88 : virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE;
89 :
90 : void onTypeSelected(const OUString& _sURLPrefix);
91 : void initializeTypeList();
92 :
93 : void implSetCurrentType( const OUString& _eType );
94 :
95 : void switchMessage(const OUString& _sURLPrefix);
96 :
97 : /// sets the title of the parent dialog
98 : virtual void setParentTitle( const OUString& _sURLPrefix );
99 :
100 : DECL_LINK(OnDatasourceTypeSelected, ListBox*);
101 : };
102 :
103 : // OGeneralPageDialog
104 0 : class OGeneralPageDialog : public OGeneralPage
105 : {
106 : public:
107 : OGeneralPageDialog( vcl::Window* pParent, const SfxItemSet& _rItems );
108 :
109 : protected:
110 : virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
111 :
112 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
113 : virtual void setParentTitle( const OUString& _sURLPrefix ) SAL_OVERRIDE;
114 : };
115 :
116 : // OGeneralPageWizard
117 : class OGeneralPageWizard : public OGeneralPage
118 : {
119 : public:
120 : OGeneralPageWizard( vcl::Window* pParent, const SfxItemSet& _rItems );
121 : virtual ~OGeneralPageWizard();
122 : virtual void dispose() SAL_OVERRIDE;
123 : public:
124 : enum CreationMode
125 : {
126 : eCreateNew,
127 : eConnectExternal,
128 : eOpenExisting
129 : };
130 :
131 0 : struct DocumentDescriptor
132 : {
133 : OUString sURL;
134 : OUString sFilter;
135 : };
136 :
137 : private:
138 : // dialog controls
139 : VclPtr<RadioButton> m_pRB_CreateDatabase;
140 : VclPtr<RadioButton> m_pRB_OpenExistingDatabase;
141 : VclPtr<RadioButton> m_pRB_ConnectDatabase;
142 :
143 : VclPtr<FixedText> m_pFT_EmbeddedDBLabel;
144 : VclPtr<ListBox> m_pEmbeddedDBType;
145 :
146 : VclPtr<FixedText> m_pFT_DocListLabel;
147 : VclPtr<OpenDocumentListBox> m_pLB_DocumentList;
148 : VclPtr<OpenDocumentButton> m_pPB_OpenDatabase;
149 :
150 : // state
151 : DocumentDescriptor m_aBrowsedDocument;
152 : CreationMode m_eOriginalCreationMode;
153 :
154 : Link<OGeneralPageWizard *, void> m_aCreationModeHandler; /// to be called if a new type is selected
155 : Link<> m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected
156 : Link<> m_aChooseDocumentHandler; /// to be called when a recent document has been definitely chosen
157 :
158 : ::svt::ControlDependencyManager
159 : m_aControlDependencies;
160 :
161 : bool m_bInitEmbeddedDBList : 1;
162 : void insertEmbeddedDBTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
163 :
164 : public:
165 0 : void SetCreationModeHandler( const Link<OGeneralPageWizard *, void>& _rHandler ) { m_aCreationModeHandler = _rHandler; }
166 : CreationMode GetDatabaseCreationMode() const;
167 :
168 0 : void SetDocumentSelectionHandler( const Link<>& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
169 0 : void SetChooseDocumentHandler( const Link<>& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
170 : DocumentDescriptor GetSelectedDocument() const;
171 :
172 : protected:
173 : virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE;
174 :
175 : virtual void GetFocus() SAL_OVERRIDE;
176 :
177 : virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE;
178 : virtual OUString getDatasourceName( const SfxItemSet& _rSet ) SAL_OVERRIDE;
179 : virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName ) SAL_OVERRIDE;
180 :
181 : ::std::vector< OUString>
182 : m_aEmbeddedURLPrefixes;
183 :
184 : OUString getEmbeddedDBName( const SfxItemSet& _rSet );
185 : void initializeEmbeddedDBList();
186 :
187 : protected:
188 : DECL_LINK( OnEmbeddedDBTypeSelected, ListBox* );
189 : DECL_LINK( OnCreateDatabaseModeSelected, RadioButton* );
190 : DECL_LINK( OnSetupModeSelected, RadioButton* );
191 : DECL_LINK( OnDocumentSelected, ListBox* );
192 : DECL_LINK( OnOpenDocument, PushButton* );
193 : };
194 :
195 : } // namespace dbaui
196 : #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_GENERALPAGE_HXX
197 :
198 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|