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 .
22 #include "controlwizard.hxx"
23 #include "commonpagesdbp.hxx"
25 using vcl::WizardTypes::WizardState
;
26 using vcl::WizardTypes::CommitPageReason
;
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 final
: public OControlWizard
47 OListComboSettings m_aSettings
;
49 bool m_bHadDataSelection
: 1;
53 weld::Window
* pParent
,
54 const css::uno::Reference
< css::beans::XPropertySet
>& _rxObjectModel
,
55 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
58 OListComboSettings
& getSettings() { return m_aSettings
; }
60 bool isListBox() const { return m_bListBox
; }
63 // OWizardMachine overridables
64 virtual std::unique_ptr
<BuilderPage
> createPage( WizardState _nState
) override
;
65 virtual WizardState
determineNextState( WizardState _nCurrentState
) const override
;
66 virtual void enterState( WizardState _nState
) override
;
67 virtual bool leaveState( WizardState _nState
) override
;
68 virtual bool onFinish() override
;
70 virtual bool approveControl(sal_Int16 _nClassId
) override
;
72 WizardState
getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK
: LCW_STATE_COMBODBFIELD
; }
74 void implApplySettings();
77 class OLCPage
: public OControlWizardPage
80 OLCPage(weld::Container
* pPage
, OListComboWizard
* pWizard
, const OUString
& rUIXMLDescription
, const OUString
& rID
)
81 : OControlWizardPage(pPage
, pWizard
, rUIXMLDescription
, rID
)
86 OListComboSettings
& getSettings() { return static_cast<OListComboWizard
*>(getDialog())->getSettings(); }
87 bool isListBox() { return static_cast<OListComboWizard
*>(getDialog())->isListBox(); }
90 css::uno::Reference
< css::container::XNameAccess
> getTables() const;
91 css::uno::Sequence
< OUString
> getTableFields();
94 class OContentTableSelection final
: public OLCPage
96 std::unique_ptr
<weld::TreeView
> m_xSelectTable
;
99 explicit OContentTableSelection(weld::Container
* pPage
, OListComboWizard
* pWizard
);
100 virtual ~OContentTableSelection() override
;
103 // BuilderPage overridables
104 virtual void Activate() override
;
106 // OWizardPage overridables
107 virtual void initializePage() override
;
108 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason
) override
;
109 virtual bool canAdvance() const override
;
111 DECL_LINK( OnTableDoubleClicked
, weld::TreeView
&, bool );
112 DECL_LINK( OnTableSelected
, weld::TreeView
&, void );
115 class OContentFieldSelection final
: public OLCPage
117 std::unique_ptr
<weld::TreeView
> m_xSelectTableField
;
118 std::unique_ptr
<weld::Entry
> m_xDisplayedField
;
119 std::unique_ptr
<weld::Label
> m_xInfo
;
122 explicit OContentFieldSelection(weld::Container
* pPage
, OListComboWizard
* pWizard
);
123 virtual ~OContentFieldSelection() override
;
126 DECL_LINK( OnFieldSelected
, weld::TreeView
&, void );
127 DECL_LINK( OnTableDoubleClicked
, weld::TreeView
&, bool );
129 // OWizardPage overridables
130 virtual void initializePage() override
;
131 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason
) override
;
132 virtual bool canAdvance() const override
;
135 class OLinkFieldsPage final
: public OLCPage
137 std::unique_ptr
<weld::ComboBox
> m_xValueListField
;
138 std::unique_ptr
<weld::ComboBox
> m_xTableField
;
141 explicit OLinkFieldsPage(weld::Container
* pPage
, OListComboWizard
* pWizard
);
142 virtual ~OLinkFieldsPage() override
;
145 // BuilderPage overridables
146 virtual void Activate() override
;
148 // OWizardPage overridables
149 virtual void initializePage() override
;
150 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason
) override
;
151 virtual bool canAdvance() const override
;
153 void implCheckFinish();
155 DECL_LINK(OnSelectionModified
, weld::ComboBox
&, void);
158 class OComboDBFieldPage
: public ODBFieldPage
161 explicit OComboDBFieldPage(weld::Container
* pPage
, OControlWizard
* pWizard
);
164 // BuilderPage overridables
165 virtual void Activate() override
;
167 // OWizardPage overridables
168 virtual bool canAdvance() const override
;
170 // ODBFieldPage overridables
171 virtual OUString
& getDBFieldSetting() override
;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */