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_COMMONPAGESDBP_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_COMMONPAGESDBP_HXX
23 #include "controlwizard.hxx"
24 #include <vcl/fixed.hxx>
25 #include <vcl/lstbox.hxx>
26 #include <com/sun/star/sdb/XDatabaseContext.hpp>
32 class OTableSelectionPage final
: public OControlWizardPage
34 VclPtr
<FixedText
> m_pDatasourceLabel
;
35 VclPtr
<ListBox
> m_pDatasource
;
36 VclPtr
<PushButton
> m_pSearchDatabase
;
37 VclPtr
<ListBox
> m_pTable
;
39 css::uno::Reference
< css::sdb::XDatabaseContext
>
43 explicit OTableSelectionPage(OControlWizard
* _pParent
);
44 virtual ~OTableSelectionPage() override
;
45 virtual void dispose() override
;
48 // TabPage overridables
49 void ActivatePage() override
;
51 // OWizardPage overridables
52 virtual void initializePage() override
;
53 virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason
) override
;
55 DECL_LINK( OnListboxSelection
, ListBox
&, void );
56 DECL_LINK( OnListboxDoubleClicked
, ListBox
&, void );
57 DECL_LINK( OnSearchClicked
, Button
*, void );
59 void implFillTables(const css::uno::Reference
< css::sdbc::XConnection
>&
60 _rxConn
= css::uno::Reference
< css::sdbc::XConnection
>());
62 // OControlWizardPage overridables
63 virtual bool canAdvance() const override
;
66 class OMaybeListSelectionPage
: public OControlWizardPage
68 VclPtr
<RadioButton
> m_pYes
;
69 VclPtr
<RadioButton
> m_pNo
;
70 VclPtr
<ListBox
> m_pList
;
73 OMaybeListSelectionPage( OControlWizard
* _pParent
, const OString
& _rID
, const OUString
& _rUIXMLDescription
);
74 virtual ~OMaybeListSelectionPage() override
;
75 virtual void dispose() override
;
78 DECL_LINK( OnRadioSelected
, Button
*, void );
80 // TabPage overridables
81 void ActivatePage() override
;
84 void announceControls(
85 RadioButton
& _rYesButton
,
86 RadioButton
& _rNoButton
,
87 ListBox
& _rSelection
);
89 void implEnableWindows();
91 void implInitialize(const OUString
& _rSelection
);
92 void implCommit(OUString
& _rSelection
);
95 class ODBFieldPage
: public OMaybeListSelectionPage
98 VclPtr
<FixedText
> m_pDescription
;
99 VclPtr
<RadioButton
> m_pStoreYes
;
100 VclPtr
<RadioButton
> m_pStoreNo
;
101 VclPtr
<ListBox
> m_pStoreWhere
;
104 explicit ODBFieldPage( OControlWizard
* _pParent
);
105 virtual ~ODBFieldPage() override
;
106 virtual void dispose() override
;
109 void setDescriptionText(const OUString
& rDesc
)
111 m_pDescription
->set_width_request(-1);
112 m_pDescription
->set_height_request(-1);
114 auto nWidthAvail
= GetParent()->GetSizePixel().Width();
116 m_pDescription
->SetText(rDesc
);
118 //tdf#122307 wrap based on current wizard width
119 Size
aPrefSize(m_pDescription
->get_preferred_size());
120 Size
aSize(m_pDescription
->CalcMinimumSize(nWidthAvail
));
121 if (aSize
.Height() > aPrefSize
.Height())
123 m_pDescription
->set_width_request(aSize
.Width());
124 m_pDescription
->set_height_request(aSize
.Height());
128 // OWizardPage overridables
129 virtual void initializePage() override
;
130 virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason
) override
;
133 virtual OUString
& getDBFieldSetting() = 0;
140 #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_COMMONPAGESDBP_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */