Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / dbpilots / listcombowizard.hxx
blob6fad3011006b091d94e86ca4c6fe33518131449d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
26 using vcl::WizardTypes::WizardState;
27 using vcl::WizardTypes::CommitPageReason;
29 namespace dbp
32 #define LCW_STATE_DATASOURCE_SELECTION 0
33 #define LCW_STATE_TABLESELECTION 1
34 #define LCW_STATE_FIELDSELECTION 2
35 #define LCW_STATE_FIELDLINK 3
36 #define LCW_STATE_COMBODBFIELD 4
38 struct OListComboSettings : public OControlWizardSettings
40 OUString sListContentTable;
41 OUString sListContentField;
42 OUString sLinkedFormField;
43 OUString sLinkedListField;
46 class OListComboWizard final : public OControlWizard
48 OListComboSettings m_aSettings;
49 bool m_bListBox : 1;
50 bool m_bHadDataSelection : 1;
52 public:
53 OListComboWizard(
54 weld::Window* pParent,
55 const css::uno::Reference< css::beans::XPropertySet >& _rxObjectModel,
56 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
59 OListComboSettings& getSettings() { return m_aSettings; }
61 bool isListBox() const { return m_bListBox; }
63 private:
64 // OWizardMachine overridables
65 virtual std::unique_ptr<BuilderPage> createPage( WizardState _nState ) override;
66 virtual WizardState determineNextState( WizardState _nCurrentState ) const override;
67 virtual void enterState( WizardState _nState ) override;
68 virtual bool leaveState( WizardState _nState ) override;
69 virtual bool onFinish() override;
71 virtual bool approveControl(sal_Int16 _nClassId) override;
73 WizardState getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK : LCW_STATE_COMBODBFIELD; }
75 void implApplySettings();
78 class OLCPage : public OControlWizardPage
80 public:
81 OLCPage(weld::Container* pPage, OListComboWizard* pWizard, const OUString& rUIXMLDescription, const OString& rID)
82 : OControlWizardPage(pPage, pWizard, rUIXMLDescription, rID)
86 protected:
87 OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
88 bool isListBox() { return static_cast<OListComboWizard*>(getDialog())->isListBox(); }
90 protected:
91 css::uno::Reference< css::container::XNameAccess > getTables() const;
92 css::uno::Sequence< OUString > getTableFields();
95 class OContentTableSelection final : public OLCPage
97 std::unique_ptr<weld::TreeView> m_xSelectTable;
99 public:
100 explicit OContentTableSelection(weld::Container* pPage, OListComboWizard* pWizard);
101 virtual ~OContentTableSelection() override;
103 private:
104 // BuilderPage overridables
105 virtual void Activate() override;
107 // OWizardPage overridables
108 virtual void initializePage() override;
109 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
110 virtual bool canAdvance() const override;
112 DECL_LINK( OnTableDoubleClicked, weld::TreeView&, bool );
113 DECL_LINK( OnTableSelected, weld::TreeView&, void );
116 class OContentFieldSelection final : public OLCPage
118 std::unique_ptr<weld::TreeView> m_xSelectTableField;
119 std::unique_ptr<weld::Entry> m_xDisplayedField;
120 std::unique_ptr<weld::Label> m_xInfo;
122 public:
123 explicit OContentFieldSelection(weld::Container* pPage, OListComboWizard* pWizard);
124 virtual ~OContentFieldSelection() override;
126 private:
127 DECL_LINK( OnFieldSelected, weld::TreeView&, void );
128 DECL_LINK( OnTableDoubleClicked, weld::TreeView&, bool );
130 // OWizardPage overridables
131 virtual void initializePage() override;
132 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
133 virtual bool canAdvance() const override;
136 class OLinkFieldsPage final : public OLCPage
138 std::unique_ptr<weld::ComboBox> m_xValueListField;
139 std::unique_ptr<weld::ComboBox> m_xTableField;
141 public:
142 explicit OLinkFieldsPage(weld::Container* pPage, OListComboWizard* pWizard);
143 virtual ~OLinkFieldsPage() override;
145 private:
146 // BuilderPage overridables
147 virtual void Activate() override;
149 // OWizardPage overridables
150 virtual void initializePage() override;
151 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
152 virtual bool canAdvance() const override;
154 void implCheckFinish();
156 DECL_LINK(OnSelectionModified, weld::ComboBox&, void);
159 class OComboDBFieldPage : public ODBFieldPage
161 public:
162 explicit OComboDBFieldPage(weld::Container* pPage, OControlWizard* pWizard);
164 protected:
165 // BuilderPage overridables
166 virtual void Activate() override;
168 // OWizardPage overridables
169 virtual bool canAdvance() const override;
171 // ODBFieldPage overridables
172 virtual OUString& getDBFieldSetting() override;
176 } // namespace dbp
179 #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_LISTCOMBOWIZARD_HXX
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */