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( 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 : sal_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, sal_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( Window* pParent, const SfxItemSet& _rItems );
106 :
107 : protected:
108 : virtual bool FillItemSet( SfxItemSet& _rCoreAttrs ) SAL_OVERRIDE;
109 :
110 : virtual void implInitControls( const SfxItemSet& _rSet, sal_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( 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 : FixedText* m_pFT_HeaderText;
137 : FixedText* m_pFT_HelpText;
138 :
139 : RadioButton* m_pRB_CreateDatabase;
140 : RadioButton* m_pRB_OpenExistingDatabase;
141 : RadioButton* m_pRB_ConnectDatabase;
142 :
143 : FixedText* m_pFT_EmbeddedDBLabel;
144 : ListBox* m_pEmbeddedDBType;
145 :
146 : FixedText* m_pFT_DocListLabel;
147 : OpenDocumentListBox* m_pLB_DocumentList;
148 : OpenDocumentButton* m_pPB_OpenDatabase;
149 :
150 : // state
151 : DocumentDescriptor m_aBrowsedDocument;
152 : CreationMode m_eOriginalCreationMode;
153 :
154 : Link 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& _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, sal_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 : virtual 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: */
|