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 .
21 #include "FieldDescControl.hxx"
22 #include "TypeInfo.hxx"
23 #include "WTabPage.hxx"
30 class OTableDesignHelpBar
;
31 // OWizTypeSelectControl
32 class OWizTypeSelectControl final
: public OFieldDescControl
34 OWizTypeSelect
* m_pParentTabPage
;
35 virtual void ActivateAggregate( EControlType eType
) override
;
36 virtual void DeactivateAggregate( EControlType eType
) override
;
38 virtual void CellModified(sal_Int32 nRow
, sal_uInt16 nColId
) override
;
40 virtual css::lang::Locale
GetLocale() const override
;
41 virtual css::uno::Reference
< css::util::XNumberFormatter
> GetFormatter() const override
;
42 virtual TOTypeInfoSP
getTypeInfo(sal_Int32 _nPos
) override
;
43 virtual const OTypeInfoMap
* getTypeInfo() const override
;
44 virtual bool isAutoIncrementValueEnabled() const override
;
45 virtual OUString
getAutoIncrementValue() const override
;
48 OWizTypeSelectControl(weld::Container
* pPage
, OWizTypeSelect
* pParentTabPage
);
49 virtual ~OWizTypeSelectControl() override
;
51 virtual css::uno::Reference
< css::sdbc::XDatabaseMetaData
> getMetaData() override
;
52 virtual css::uno::Reference
< css::sdbc::XConnection
> getConnection() override
;
55 // Wizard Page: OWizTypeSelectList
56 // just defines the css::ucb::Command for the Contextmenu
57 class OWizTypeSelectList
59 std::unique_ptr
<weld::TreeView
> m_xControl
;
61 bool IsPrimaryKeyAllowed() const;
62 void setPrimaryKey( OFieldDescription
* _pFieldDescr
,
66 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
68 Link
<weld::TreeView
&, void> m_aChangeHdl
;
71 OWizTypeSelectList(std::unique_ptr
<weld::TreeView
> xControl
);
72 void SetPKey(bool bPKey
) { m_bPKey
= bPKey
; }
73 weld::TreeView
* GetWidget() { return m_xControl
.get(); }
74 OUString
get_selected_id() const { return m_xControl
->get_selected_id(); }
75 void clear() { m_xControl
->clear(); }
76 void append(const OUString
& rId
, const OUString
& rStr
)
78 m_xControl
->append(rId
, rStr
);
80 void set_image(int nRow
, const OUString
& rImage
)
82 m_xControl
->set_image(nRow
, rImage
);
84 void set_selection_mode(SelectionMode eMode
) { m_xControl
->set_selection_mode(eMode
); }
85 int count_selected_rows() const { return m_xControl
->count_selected_rows(); }
86 void select(int pos
) { m_xControl
->select(pos
); }
87 void connect_changed(const Link
<weld::TreeView
&, void>& rLink
)
90 m_xControl
->connect_selection_changed(rLink
);
94 // Wizard Page: OWizTypeSelect
95 // Serves as base class for different copy properties.
96 // Calls FillColumnList, when button AUTO is triggered
97 class OWizTypeSelect
: public OWizardPage
99 friend class OWizTypeSelectControl
;
100 friend class OWizTypeSelectList
;
102 DECL_LINK( ColumnSelectHdl
, weld::TreeView
&, void );
103 DECL_LINK( ButtonClickHdl
, weld::Button
&, void );
105 std::unique_ptr
<OWizTypeSelectList
> m_xColumnNames
;
106 std::unique_ptr
<weld::Container
> m_xControlContainer
;
107 std::unique_ptr
<OWizTypeSelectControl
> m_xTypeControl
;
108 std::unique_ptr
<weld::Label
> m_xAutoType
;
109 std::unique_ptr
<weld::Label
> m_xAutoFt
;
110 std::unique_ptr
<weld::SpinButton
> m_xAutoEt
;
111 std::unique_ptr
<weld::Button
> m_xAutoPb
;
113 SvStream
* m_pParserStream
; // stream to read the tokens from or NULL
114 OUString m_sAutoIncrementValue
;
115 sal_Int32 m_nDisplayRow
;
116 bool m_bAutoIncrementEnabled
;
117 bool m_bDuplicateName
;
119 virtual void createReaderAndCallParser(sal_Int32 _nRows
) = 0;
121 void EnableAuto(bool bEnable
);
123 virtual void Reset ( ) override
;
124 virtual void Activate( ) override
;
125 virtual bool LeavePage() override
;
126 virtual OUString
GetTitle() const override
;
128 OWizTypeSelect(weld::Container
* pParent
, OCopyTableWizard
* pWizard
, SvStream
* pStream
= nullptr);
129 virtual ~OWizTypeSelect() override
;
131 void setDisplayRow(sal_Int32 _nRow
) { m_nDisplayRow
= _nRow
- 1; }
132 void setDuplicateName(bool _bDuplicateName
) { m_bDuplicateName
= _bDuplicateName
; }
135 typedef std::unique_ptr
<OWizTypeSelect
> (*TypeSelectionPageFactory
)(weld::Container
*, OCopyTableWizard
*, SvStream
&);
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */