Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / ui / inc / WTypeSelect.hxx
blob54324110623be76d6fc8954bc16a250c86cb4fd0
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
22 #include "FieldDescControl.hxx"
23 #include "TypeInfo.hxx"
24 #include "WTabPage.hxx"
26 #include <vcl/button.hxx>
27 #include <vcl/field.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/lstbox.hxx>
31 class SvStream;
32 class SvParser;
33 namespace dbaui
35 class OTableDesignHelpBar;
36 // OWizTypeSelectControl
37 class OWizTypeSelectControl : public OFieldDescControl
39 protected:
40 VclPtr<vcl::Window> m_pParentTabPage;
41 virtual void ActivateAggregate( EControlType eType ) override;
42 virtual void DeactivateAggregate( EControlType eType ) override;
44 virtual void CellModified(long nRow, sal_uInt16 nColId ) override;
46 virtual css::lang::Locale GetLocale() const override;
47 virtual css::uno::Reference< css::util::XNumberFormatter > GetFormatter() const override;
48 virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) override;
49 virtual const OTypeInfoMap* getTypeInfo() const override;
50 virtual bool isAutoIncrementValueEnabled() const override;
51 virtual OUString getAutoIncrementValue() const override;
53 public:
54 OWizTypeSelectControl(vcl::Window* pParent, vcl::Window* pParentTabPage, OTableDesignHelpBar* pHelpBar=nullptr);
55 virtual ~OWizTypeSelectControl();
56 virtual void dispose() override;
58 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() override;
59 virtual css::uno::Reference< css::sdbc::XConnection> getConnection() override;
62 // Wizard Page: OWizTypeSelectList
63 // just defines the css::ucb::Command for the Contextmenu
64 class OWizTypeSelectList : public MultiListBox
66 bool m_bPKey;
67 bool IsPrimaryKeyAllowed() const;
68 void setPrimaryKey( OFieldDescription* _pFieldDescr,
69 sal_uInt16 _nPos,
70 bool _bSet = false);
71 protected:
72 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
73 VclPtr<vcl::Window> m_pParentTabPage;
74 public:
75 OWizTypeSelectList( vcl::Window* pParent, WinBits nStyle = WB_BORDER | WB_SIMPLEMODE )
76 : MultiListBox(pParent,nStyle)
77 , m_bPKey(false)
78 , m_pParentTabPage(nullptr)
80 virtual ~OWizTypeSelectList();
81 virtual void dispose() override;
82 void SetPKey(bool bPKey) { m_bPKey = bPKey; }
83 void SetParentTabPage(vcl::Window* pParentTabPage) { m_pParentTabPage = pParentTabPage; }
86 // Wizard Page: OWizTypeSelect
87 // Serves as base class for different copy properties.
88 // Calls FillColumnList, when button AUTO is triggered
89 class OWizTypeSelect : public OWizardPage
91 friend class OWizTypeSelectControl;
92 friend class OWizTypeSelectList;
94 DECL_LINK_TYPED( ColumnSelectHdl, ListBox&, void );
95 DECL_LINK_TYPED( ButtonClickHdl, Button *, void );
96 protected:
97 VclPtr<OWizTypeSelectList> m_pColumnNames;
98 VclPtr<FixedText> m_pColumns;
99 VclPtr<OWizTypeSelectControl> m_pTypeControl;
100 VclPtr<FixedText> m_pAutoType;
101 VclPtr<FixedText> m_pAutoFt;
102 VclPtr<NumericField> m_pAutoEt;
103 VclPtr<PushButton> m_pAutoPb;
105 Image m_imgPKey;
106 SvStream* m_pParserStream; // stream to read the tokens from or NULL
107 OUString m_sAutoIncrementValue;
108 sal_Int32 m_nDisplayRow;
109 bool m_bAutoIncrementEnabled;
110 bool m_bDuplicateName;
112 void fillColumnList(sal_uInt32 nRows);
113 virtual SvParser* createReader(sal_Int32 _nRows) = 0;
115 void EnableAuto(bool bEnable);
116 public:
117 virtual void Reset ( ) override;
118 virtual void ActivatePage( ) override;
119 virtual bool LeavePage() override;
120 virtual OUString GetTitle() const override;
122 OWizTypeSelect(vcl::Window* pParent, SvStream* _pStream = nullptr );
123 virtual ~OWizTypeSelect();
124 virtual void dispose() override;
126 inline void setDisplayRow(sal_Int32 _nRow) { m_nDisplayRow = _nRow - 1; }
127 inline void setDuplicateName(bool _bDuplicateName) { m_bDuplicateName = _bDuplicateName; }
130 typedef VclPtr<OWizTypeSelect> (*TypeSelectionPageFactory)( vcl::Window*, SvStream& );
132 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */