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 DBAUI_FIELDDESCRIPTIONCONTROL_HXX
20 : #define DBAUI_FIELDDESCRIPTIONCONTROL_HXX
21 :
22 : #include <vcl/tabpage.hxx>
23 : #include "QEnumTypes.hxx"
24 : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
25 : #include <com/sun/star/util/XNumberFormatter.hpp>
26 : #include "TypeInfo.hxx"
27 :
28 : // field description columns of a table
29 : #define FIELD_NAME 1
30 : #define FIELD_TYPE 2
31 : #define HELP_TEXT 3
32 : #define COLUMN_DESCRIPTION 4
33 :
34 : #define FIELD_FIRST_VIRTUAL_COLUMN 5
35 :
36 : #define FIELD_PROPERTY_REQUIRED 5
37 : #define FIELD_PROPERTY_NUMTYPE 6
38 : #define FIELD_PROPERTY_AUTOINC 7
39 : #define FIELD_PROPERTY_DEFAULT 8
40 : #define FIELD_PROPERTY_TEXTLEN 9
41 : #define FIELD_PROPERTY_LENGTH 10
42 : #define FIELD_PROPERTY_SCALE 11
43 : #define FIELD_PROPERTY_BOOL_DEFAULT 12
44 : #define FIELD_PROPERTY_FORMAT 13
45 : #define FIELD_PRPOERTY_COLUMNNAME 14
46 : #define FIELD_PRPOERTY_TYPE 15
47 : #define FIELD_PRPOERTY_AUTOINCREMENT 16
48 :
49 : class FixedText;
50 : class PushButton;
51 : class ScrollBar;
52 : class Button;
53 : class ListBox;
54 : class Control;
55 :
56 : namespace dbaui
57 : {
58 : class OTableDesignHelpBar;
59 : class OPropListBoxCtrl;
60 : class OPropEditCtrl;
61 : class OPropNumericEditCtrl;
62 : class OFieldDescription;
63 : class OPropColumnEditCtrl;
64 :
65 : class OFieldDescControl : public TabPage
66 : {
67 : private:
68 : OTableDesignHelpBar* pHelp;
69 : Window* pLastFocusWindow;
70 : Window* m_pActFocusWindow;
71 :
72 : FixedText* pDefaultText;
73 : FixedText* pRequiredText;
74 : FixedText* pAutoIncrementText;
75 : FixedText* pTextLenText;
76 : FixedText* pNumTypeText;
77 : FixedText* pLengthText;
78 : FixedText* pScaleText;
79 : FixedText* pFormatText;
80 : FixedText* pBoolDefaultText;
81 : FixedText* m_pColumnNameText;
82 : FixedText* m_pTypeText;
83 : FixedText* m_pAutoIncrementValueText;
84 :
85 : OPropListBoxCtrl* pRequired;
86 : OPropListBoxCtrl* pNumType;
87 : OPropListBoxCtrl* pAutoIncrement;
88 : OPropEditCtrl* pDefault;
89 : OPropNumericEditCtrl* pTextLen;
90 : OPropNumericEditCtrl* pLength;
91 : OPropNumericEditCtrl* pScale;
92 : OPropEditCtrl* pFormatSample;
93 : OPropListBoxCtrl* pBoolDefault;
94 : OPropColumnEditCtrl* m_pColumnName;
95 : OPropListBoxCtrl* m_pType;
96 : OPropEditCtrl* m_pAutoIncrementValue;
97 :
98 : PushButton* pFormat;
99 :
100 : ScrollBar* m_pVertScroll;
101 : ScrollBar* m_pHorzScroll;
102 :
103 : TOTypeInfoSP m_pPreviousType;
104 : short m_nPos;
105 : XubString aYes;
106 : XubString aNo;
107 :
108 : long m_nOldVThumb;
109 : long m_nOldHThumb;
110 : sal_Int32 m_nWidth;
111 :
112 : sal_Bool m_bAdded;
113 : bool m_bRightAligned;
114 :
115 : OFieldDescription* pActFieldDescr;
116 :
117 : DECL_LINK( OnScroll, ScrollBar*);
118 :
119 : DECL_LINK( FormatClickHdl, Button * );
120 : DECL_LINK( ChangeHdl, ListBox * );
121 :
122 : // used by ActivatePropertyField
123 : DECL_LINK( OnControlFocusLost, Control* );
124 : DECL_LINK( OnControlFocusGot, Control* );
125 :
126 : void UpdateFormatSample(OFieldDescription* pFieldDescr);
127 : void ArrangeAggregates();
128 :
129 : void SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol );
130 :
131 : void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY);
132 : void ScrollAllAggregates();
133 :
134 : sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
135 : void Contruct();
136 : OPropNumericEditCtrl* CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId);
137 : FixedText* CreateText(sal_uInt16 _nTextRes);
138 : void InitializeControl(Control* _pControl,const rtl::OString& _sHelpId,bool _bAddChangeHandler);
139 :
140 : protected:
141 0 : inline void setRightAligned() { m_bRightAligned = true; }
142 0 : inline bool isRightAligned() const { return m_bRightAligned; }
143 :
144 0 : inline void saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
145 0 : inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; }
146 0 : inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; }
147 :
148 : sal_uInt16 CountActiveAggregates() const;
149 : sal_Int32 GetMaxControlHeight() const;
150 :
151 : virtual void ActivateAggregate( EControlType eType );
152 : virtual void DeactivateAggregate( EControlType eType );
153 0 : virtual sal_Bool IsReadOnly() { return sal_False; };
154 :
155 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const = 0;
156 :
157 : virtual ::com::sun::star::lang::Locale GetLocale() const = 0;
158 :
159 : virtual void CellModified(long nRow, sal_uInt16 nColId ) = 0;
160 : virtual void SetModified(sal_Bool bModified); // base implementation is empty
161 :
162 : virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) = 0;
163 : virtual const OTypeInfoMap* getTypeInfo() const = 0;
164 :
165 : virtual sal_Bool isAutoIncrementValueEnabled() const = 0;
166 : virtual ::rtl::OUString getAutoIncrementValue() const = 0;
167 :
168 : String BoolStringPersistent(const String& rUIString) const;
169 : String BoolStringUI(const String& rPersistentString) const;
170 :
171 0 : const OPropColumnEditCtrl* getColumnCtrl() const { return m_pColumnName; }
172 :
173 : void implFocusLost(Window* _pWhich);
174 :
175 : public:
176 : OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
177 : OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
178 : virtual ~OFieldDescControl();
179 :
180 : void DisplayData(OFieldDescription* pFieldDescr );
181 :
182 : void SaveData( OFieldDescription* pFieldDescr );
183 :
184 : void SetControlText( sal_uInt16 nControlId, const String& rText );
185 : String GetControlText( sal_uInt16 nControlId );
186 : void SetReadOnly( sal_Bool bReadOnly );
187 :
188 : // when resize is called
189 : void CheckScrollBars();
190 : sal_Bool isCutAllowed();
191 : sal_Bool isCopyAllowed();
192 : sal_Bool isPasteAllowed();
193 :
194 : void cut();
195 : void copy();
196 : void paste();
197 :
198 : virtual void Init();
199 : virtual void GetFocus();
200 : virtual void LoseFocus();
201 : virtual void Resize();
202 :
203 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0;
204 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() = 0;
205 :
206 : String getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck = sal_True) const;
207 :
208 0 : inline void setEditWidth(sal_Int32 _nWidth) { m_nWidth = _nWidth; }
209 : };
210 : }
211 : #endif
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|