Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
21 :
22 : #include "FieldDescControl.hxx"
23 : #include "TypeInfo.hxx"
24 : #include "WTabPage.hxx"
25 :
26 : #include <vcl/button.hxx>
27 : #include <vcl/field.hxx>
28 : #include <vcl/fixed.hxx>
29 : #include <vcl/lstbox.hxx>
30 :
31 : class SvStream;
32 : class SvParser;
33 : namespace dbaui
34 : {
35 : class OTableDesignHelpBar;
36 : // OWizTypeSelectControl
37 : class OWizTypeSelectControl : public OFieldDescControl
38 : {
39 : protected:
40 : VclPtr<vcl::Window> m_pParentTabPage;
41 : virtual void ActivateAggregate( EControlType eType ) SAL_OVERRIDE;
42 : virtual void DeactivateAggregate( EControlType eType ) SAL_OVERRIDE;
43 :
44 : virtual void CellModified(long nRow, sal_uInt16 nColId ) SAL_OVERRIDE;
45 :
46 : virtual ::com::sun::star::lang::Locale GetLocale() const SAL_OVERRIDE;
47 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const SAL_OVERRIDE;
48 : virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) SAL_OVERRIDE;
49 : virtual const OTypeInfoMap* getTypeInfo() const SAL_OVERRIDE;
50 : virtual bool isAutoIncrementValueEnabled() const SAL_OVERRIDE;
51 : virtual OUString getAutoIncrementValue() const SAL_OVERRIDE;
52 :
53 : public:
54 : OWizTypeSelectControl(vcl::Window* pParent, vcl::Window* pParentTabPage, OTableDesignHelpBar* pHelpBar=NULL);
55 : virtual ~OWizTypeSelectControl();
56 : virtual void dispose() SAL_OVERRIDE;
57 :
58 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() SAL_OVERRIDE;
59 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() SAL_OVERRIDE;
60 : };
61 :
62 : // Wizard Page: OWizTypeSelectList
63 : // just defines the ::com::sun::star::ucb::Command for the Contextmenu
64 : class OWizTypeSelectList : public MultiListBox
65 : {
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 ) SAL_OVERRIDE;
73 : VclPtr<vcl::Window> m_pParentTabPage;
74 : public:
75 0 : OWizTypeSelectList( vcl::Window* pParent, WinBits nStyle = WB_BORDER )
76 : : MultiListBox(pParent,nStyle)
77 : , m_bPKey(false)
78 0 : , m_pParentTabPage(NULL)
79 0 : {}
80 : virtual ~OWizTypeSelectList();
81 : virtual void dispose() SAL_OVERRIDE;
82 0 : void SetPKey(bool bPKey) { m_bPKey = bPKey; }
83 0 : void SetParentTabPage(vcl::Window* pParentTabPage) { m_pParentTabPage = pParentTabPage; }
84 : };
85 :
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
90 : {
91 : friend class OWizTypeSelectControl;
92 : friend class OWizTypeSelectList;
93 :
94 : DECL_LINK( ColumnSelectHdl, MultiListBox* );
95 : DECL_LINK( ButtonClickHdl, Button * );
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;
104 :
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;
111 :
112 : void fillColumnList(sal_uInt32 nRows);
113 : virtual SvParser* createReader(sal_Int32 _nRows) = 0;
114 :
115 : void EnableAuto(bool bEnable);
116 : public:
117 : virtual void Reset ( ) SAL_OVERRIDE;
118 : virtual void ActivatePage( ) SAL_OVERRIDE;
119 : virtual bool LeavePage() SAL_OVERRIDE;
120 : virtual OUString GetTitle() const SAL_OVERRIDE;
121 :
122 : OWizTypeSelect(vcl::Window* pParent, SvStream* _pStream = NULL );
123 : virtual ~OWizTypeSelect();
124 : virtual void dispose() SAL_OVERRIDE;
125 :
126 0 : inline void setDisplayRow(sal_Int32 _nRow) { m_nDisplayRow = _nRow - 1; }
127 0 : inline void setDuplicateName(bool _bDuplicateName) { m_bDuplicateName = _bDuplicateName; }
128 : };
129 :
130 : typedef VclPtr<OWizTypeSelect> (*TypeSelectionPageFactory)( vcl::Window*, SvStream& );
131 : }
132 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|