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