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_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
21 : #define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
22 :
23 : #include "controlwizard.hxx"
24 : #include "commonpagesdbp.hxx"
25 :
26 :
27 : namespace dbp
28 : {
29 :
30 :
31 : #define LCW_STATE_DATASOURCE_SELECTION 0
32 : #define LCW_STATE_TABLESELECTION 1
33 : #define LCW_STATE_FIELDSELECTION 2
34 : #define LCW_STATE_FIELDLINK 3
35 : #define LCW_STATE_COMBODBFIELD 4
36 :
37 :
38 : //= OListComboSettings
39 :
40 0 : struct OListComboSettings : public OControlWizardSettings
41 : {
42 : OUString sListContentTable;
43 : OUString sListContentField;
44 : OUString sLinkedFormField;
45 : OUString sLinkedListField;
46 : };
47 :
48 :
49 : //= OListComboWizard
50 :
51 0 : class OListComboWizard : public OControlWizard
52 : {
53 : protected:
54 : OListComboSettings m_aSettings;
55 : bool m_bListBox : 1;
56 : bool m_bHadDataSelection : 1;
57 :
58 : public:
59 : OListComboWizard(
60 : vcl::Window* _pParent,
61 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
62 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
63 : );
64 :
65 0 : OListComboSettings& getSettings() { return m_aSettings; }
66 :
67 0 : bool isListBox() const { return m_bListBox; }
68 :
69 : protected:
70 : // OWizardMachine overridables
71 : virtual ::svt::OWizardPage* createPage( WizardState _nState ) SAL_OVERRIDE;
72 : virtual WizardState determineNextState( WizardState _nCurrentState ) const SAL_OVERRIDE;
73 : virtual void enterState( WizardState _nState ) SAL_OVERRIDE;
74 : virtual bool leaveState( WizardState _nState ) SAL_OVERRIDE;
75 : virtual bool onFinish() SAL_OVERRIDE;
76 :
77 : virtual bool approveControl(sal_Int16 _nClassId) SAL_OVERRIDE;
78 :
79 0 : WizardState getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK : LCW_STATE_COMBODBFIELD; }
80 :
81 : private:
82 : void implApplySettings();
83 : };
84 :
85 : //= OLCPage
86 0 : class OLCPage : public OControlWizardPage
87 : {
88 : public:
89 0 : OLCPage(OListComboWizard* _pParent, const OString& rID, const OUString& rUIXMLDescription)
90 0 : : OControlWizardPage(_pParent, rID, rUIXMLDescription)
91 : {
92 0 : }
93 :
94 : protected:
95 0 : OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
96 0 : bool isListBox() { return static_cast<OListComboWizard*>(getDialog())->isListBox(); }
97 :
98 : protected:
99 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
100 : getTables(bool _bNeedIt);
101 : ::com::sun::star::uno::Sequence< OUString >
102 : getTableFields(bool _bNeedIt);
103 : };
104 :
105 :
106 : //= OContentTableSelection
107 :
108 0 : class OContentTableSelection : public OLCPage
109 : {
110 : protected:
111 : ListBox *m_pSelectTable;
112 :
113 : public:
114 : OContentTableSelection( OListComboWizard* _pParent );
115 :
116 : protected:
117 : // TabPage overridables
118 : virtual void ActivatePage() SAL_OVERRIDE;
119 :
120 : // OWizardPage overridables
121 : virtual void initializePage() SAL_OVERRIDE;
122 : virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
123 : virtual bool canAdvance() const SAL_OVERRIDE;
124 :
125 : protected:
126 : DECL_LINK( OnTableDoubleClicked, ListBox* );
127 : DECL_LINK( OnTableSelected, ListBox* );
128 : };
129 :
130 :
131 : //= OContentFieldSelection
132 :
133 0 : class OContentFieldSelection : public OLCPage
134 : {
135 : protected:
136 : ListBox *m_pSelectTableField;
137 : Edit *m_pDisplayedField;
138 : FixedText *m_pInfo;
139 :
140 :
141 : public:
142 : OContentFieldSelection( OListComboWizard* _pParent );
143 :
144 : protected:
145 : DECL_LINK( OnFieldSelected, ListBox* );
146 : DECL_LINK( OnTableDoubleClicked, ListBox* );
147 :
148 : // TabPage overridables
149 : virtual void ActivatePage() SAL_OVERRIDE;
150 :
151 : // OWizardPage overridables
152 : virtual void initializePage() SAL_OVERRIDE;
153 : virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
154 : virtual bool canAdvance() const SAL_OVERRIDE;
155 : };
156 :
157 :
158 : //= OLinkFieldsPage
159 :
160 0 : class OLinkFieldsPage : public OLCPage
161 : {
162 : protected:
163 : ComboBox *m_pValueListField;
164 : ComboBox *m_pTableField;
165 :
166 :
167 : public:
168 : OLinkFieldsPage( OListComboWizard* _pParent );
169 :
170 : protected:
171 : // TabPage overridables
172 : virtual void ActivatePage() SAL_OVERRIDE;
173 :
174 : // OWizardPage overridables
175 : virtual void initializePage() SAL_OVERRIDE;
176 : virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
177 : virtual bool canAdvance() const SAL_OVERRIDE;
178 :
179 : private:
180 : void implCheckFinish();
181 :
182 : DECL_LINK(OnSelectionModified, void*);
183 : };
184 :
185 :
186 : //= OComboDBFieldPage
187 :
188 0 : class OComboDBFieldPage : public ODBFieldPage
189 : {
190 : public:
191 : OComboDBFieldPage( OControlWizard* _pParent );
192 :
193 : protected:
194 0 : OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
195 :
196 : // TabPage overridables
197 : virtual void ActivatePage() SAL_OVERRIDE;
198 :
199 : // OWizardPage overridables
200 : virtual bool canAdvance() const SAL_OVERRIDE;
201 :
202 : // ODBFieldPage overridables
203 : virtual OUString& getDBFieldSetting() SAL_OVERRIDE;
204 : };
205 :
206 :
207 : } // namespace dbp
208 :
209 :
210 : #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|