1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
23 #include "controlwizard.hxx"
24 #include "commonpagesdbp.hxx"
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
37 struct OListComboSettings
: public OControlWizardSettings
39 OUString sListContentTable
;
40 OUString sListContentField
;
41 OUString sLinkedFormField
;
42 OUString sLinkedListField
;
45 class OListComboWizard
: public OControlWizard
48 OListComboSettings m_aSettings
;
50 bool m_bHadDataSelection
: 1;
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
59 OListComboSettings
& getSettings() { return m_aSettings
; }
61 bool isListBox() const { return m_bListBox
; }
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
;
71 virtual bool approveControl(sal_Int16 _nClassId
) SAL_OVERRIDE
;
73 WizardState
getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK
: LCW_STATE_COMBODBFIELD
; }
76 void implApplySettings();
79 class OLCPage
: public OControlWizardPage
82 OLCPage(OListComboWizard
* _pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
)
83 : OControlWizardPage(_pParent
, rID
, rUIXMLDescription
)
88 OListComboSettings
& getSettings() { return static_cast<OListComboWizard
*>(getDialog())->getSettings(); }
89 bool isListBox() { return static_cast<OListComboWizard
*>(getDialog())->isListBox(); }
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
);
98 class OContentTableSelection
: public OLCPage
101 VclPtr
<ListBox
> m_pSelectTable
;
104 OContentTableSelection( OListComboWizard
* _pParent
);
105 virtual ~OContentTableSelection();
106 virtual void dispose() SAL_OVERRIDE
;
109 // TabPage overridables
110 virtual void ActivatePage() SAL_OVERRIDE
;
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
;
118 DECL_LINK( OnTableDoubleClicked
, ListBox
* );
119 DECL_LINK( OnTableSelected
, ListBox
* );
122 class OContentFieldSelection
: public OLCPage
125 VclPtr
<ListBox
> m_pSelectTableField
;
126 VclPtr
<Edit
> m_pDisplayedField
;
127 VclPtr
<FixedText
> m_pInfo
;
131 OContentFieldSelection( OListComboWizard
* _pParent
);
132 virtual ~OContentFieldSelection();
133 virtual void dispose() SAL_OVERRIDE
;
136 DECL_LINK( OnFieldSelected
, ListBox
* );
137 DECL_LINK( OnTableDoubleClicked
, ListBox
* );
139 // TabPage overridables
140 virtual void ActivatePage() SAL_OVERRIDE
;
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
;
148 class OLinkFieldsPage
: public OLCPage
151 VclPtr
<ComboBox
> m_pValueListField
;
152 VclPtr
<ComboBox
> m_pTableField
;
156 OLinkFieldsPage( OListComboWizard
* _pParent
);
157 virtual ~OLinkFieldsPage();
158 virtual void dispose() SAL_OVERRIDE
;
161 // TabPage overridables
162 virtual void ActivatePage() SAL_OVERRIDE
;
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
;
170 void implCheckFinish();
172 DECL_LINK(OnSelectionModified
, void*);
175 class OComboDBFieldPage
: public ODBFieldPage
178 OComboDBFieldPage( OControlWizard
* _pParent
);
181 OListComboSettings
& getSettings() { return static_cast<OListComboWizard
*>(getDialog())->getSettings(); }
183 // TabPage overridables
184 virtual void ActivatePage() SAL_OVERRIDE
;
186 // OWizardPage overridables
187 virtual bool canAdvance() const SAL_OVERRIDE
;
189 // ODBFieldPage overridables
190 virtual OUString
& getDBFieldSetting() SAL_OVERRIDE
;
197 #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */