Branch data 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 : : sal_uInt16 nCurChildId;
105 : : short m_nPos;
106 : : XubString aYes;
107 : : XubString aNo;
108 : :
109 : : long m_nOldVThumb;
110 : : long m_nOldHThumb;
111 : : sal_Int32 m_nWidth;
112 : :
113 : : sal_Bool m_bAdded;
114 : : bool m_bRightAligned;
115 : :
116 : : OFieldDescription* pActFieldDescr;
117 : :
118 : : DECL_LINK( OnScroll, ScrollBar*);
119 : :
120 : : DECL_LINK( FormatClickHdl, Button * );
121 : : DECL_LINK( ChangeHdl, ListBox * );
122 : :
123 : : // used by ActivatePropertyField
124 : : DECL_LINK( OnControlFocusLost, Control* );
125 : : DECL_LINK( OnControlFocusGot, Control* );
126 : :
127 : : void UpdateFormatSample(OFieldDescription* pFieldDescr);
128 : : void ArrangeAggregates();
129 : :
130 : : void SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol );
131 : :
132 : : void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY);
133 : : void ScrollAllAggregates();
134 : :
135 : : sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
136 : : void Contruct();
137 : : OPropNumericEditCtrl* CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId);
138 : : FixedText* CreateText(sal_uInt16 _nTextRes);
139 : : void InitializeControl(Control* _pControl,const rtl::OString& _sHelpId,bool _bAddChangeHandler);
140 : :
141 : : protected:
142 : 0 : inline void setRightAligned() { m_bRightAligned = true; }
143 : 0 : inline bool isRightAligned() const { return m_bRightAligned; }
144 : :
145 : 0 : inline void saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
146 : 0 : inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; }
147 : 0 : inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; }
148 : :
149 : : sal_uInt16 CountActiveAggregates() const;
150 : : sal_Int32 GetMaxControlHeight() const;
151 : :
152 : : virtual void ActivateAggregate( EControlType eType );
153 : : virtual void DeactivateAggregate( EControlType eType );
154 : 0 : virtual sal_Bool IsReadOnly() { return sal_False; };
155 : :
156 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const = 0;
157 : :
158 : : virtual ::com::sun::star::lang::Locale GetLocale() const = 0;
159 : :
160 : : virtual void CellModified(long nRow, sal_uInt16 nColId ) = 0;
161 : : virtual void SetModified(sal_Bool bModified); // base implementation is empty
162 : :
163 : : virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) = 0;
164 : : virtual const OTypeInfoMap* getTypeInfo() const = 0;
165 : :
166 : : virtual sal_Bool isAutoIncrementValueEnabled() const = 0;
167 : : virtual ::rtl::OUString getAutoIncrementValue() const = 0;
168 : :
169 : : String BoolStringPersistent(const String& rUIString) const;
170 : : String BoolStringUI(const String& rPersistentString) const;
171 : :
172 : 0 : const OPropColumnEditCtrl* getColumnCtrl() const { return m_pColumnName; }
173 : :
174 : : void implFocusLost(Window* _pWhich);
175 : :
176 : : public:
177 : : OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
178 : : OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
179 : : virtual ~OFieldDescControl();
180 : :
181 : : void DisplayData(OFieldDescription* pFieldDescr );
182 : :
183 : : void SaveData( OFieldDescription* pFieldDescr );
184 : :
185 : : void SetControlText( sal_uInt16 nControlId, const String& rText );
186 : : String GetControlText( sal_uInt16 nControlId );
187 : : void SetReadOnly( sal_Bool bReadOnly );
188 : :
189 : : // when resize is called
190 : : void CheckScrollBars();
191 : : sal_Bool isCutAllowed();
192 : : sal_Bool isCopyAllowed();
193 : : sal_Bool isPasteAllowed();
194 : :
195 : : void cut();
196 : : void copy();
197 : : void paste();
198 : :
199 : : virtual void Init();
200 : : virtual void GetFocus();
201 : : virtual void LoseFocus();
202 : : virtual void Resize();
203 : :
204 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0;
205 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() = 0;
206 : :
207 : : String getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck = sal_True) const;
208 : :
209 : 0 : inline void setEditWidth(sal_Int32 _nWidth) { m_nWidth = _nWidth; }
210 : : };
211 : : }
212 : : #endif
213 : :
214 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|