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