merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / FieldDescControl.hxx
blob36ba15ec8bd049c910533442de4ddeca36f74dd7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FieldDescControl.hxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
31 #define DBAUI_FIELDDESCRIPTIONCONTROL_HXX
33 #ifndef _SV_TABPAGE_HXX
34 #include <vcl/tabpage.hxx>
35 #endif
36 #ifndef DBAUI_ENUMTYPES_HXX
37 #include "QEnumTypes.hxx"
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
40 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
43 #include <com/sun/star/util/XNumberFormatter.hpp>
44 #endif
45 #ifndef DBAUI_TYPEINFO_HXX
46 #include "TypeInfo.hxx"
47 #endif
49 //------------------------------------------------------------------
50 // die Spalten einer Feld-Beschreibung einer Tabelle
51 #define FIELD_NAME 1
52 #define FIELD_TYPE 2
53 #define FIELD_DESCR 3
55 #define FIELD_FIRST_VIRTUAL_COLUMN 4
57 #define FIELD_PROPERTY_REQUIRED 4
58 #define FIELD_PROPERTY_NUMTYPE 5
59 #define FIELD_PROPERTY_AUTOINC 6
60 #define FIELD_PROPERTY_DEFAULT 7
61 #define FIELD_PROPERTY_TEXTLEN 8
62 #define FIELD_PROPERTY_LENGTH 9
63 #define FIELD_PROPERTY_SCALE 10
64 #define FIELD_PROPERTY_BOOL_DEFAULT 11
65 #define FIELD_PROPERTY_FORMAT 12
66 #define FIELD_PRPOERTY_COLUMNNAME 13
67 #define FIELD_PRPOERTY_TYPE 14
68 #define FIELD_PRPOERTY_AUTOINCREMENT 15
70 class FixedText;
71 class PushButton;
72 class SvxNumberFormatShell;
73 class ScrollBar;
74 class Button;
75 class ListBox;
76 class Control;
77 class SvNumberFormatter;
79 namespace dbaui
82 class OTableDesignHelpBar;
83 class OPropListBoxCtrl;
84 class OPropEditCtrl;
85 class OPropNumericEditCtrl;
86 class OFieldDescription;
87 class OTypeInfo;
88 class OPropColumnEditCtrl;
89 //==================================================================
90 class OFieldDescControl : public TabPage
92 private:
93 OTableDesignHelpBar* pHelp;
94 Window* pLastFocusWindow;
95 Window* m_pActFocusWindow;
97 FixedText* pDefaultText;
98 FixedText* pRequiredText;
99 FixedText* pAutoIncrementText;
100 FixedText* pTextLenText;
101 FixedText* pNumTypeText;
102 FixedText* pLengthText;
103 FixedText* pScaleText;
104 FixedText* pFormatText;
105 FixedText* pBoolDefaultText;
106 FixedText* m_pColumnNameText;
107 FixedText* m_pTypeText;
108 FixedText* m_pAutoIncrementValueText;
110 OPropListBoxCtrl* pRequired;
111 OPropListBoxCtrl* pNumType;
112 OPropListBoxCtrl* pAutoIncrement;
113 OPropEditCtrl* pDefault;
114 OPropNumericEditCtrl* pTextLen;
115 OPropNumericEditCtrl* pLength;
116 OPropNumericEditCtrl* pScale;
117 OPropEditCtrl* pFormatSample;
118 OPropListBoxCtrl* pBoolDefault;
119 OPropColumnEditCtrl* m_pColumnName;
120 OPropListBoxCtrl* m_pType;
121 OPropEditCtrl* m_pAutoIncrementValue;
123 PushButton* pFormat;
125 ScrollBar* m_pVertScroll;
126 ScrollBar* m_pHorzScroll;
128 TOTypeInfoSP m_pPreviousType;
129 USHORT nCurChildId;
130 short m_nPos;
131 XubString aYes;
132 XubString aNo;
134 long m_nOldVThumb;
135 long m_nOldHThumb;
136 sal_Int32 m_nWidth;
138 ULONG nDelayedGrabFocusEvent;
139 sal_Bool m_bAdded;
140 bool m_bRightAligned;
142 OFieldDescription* pActFieldDescr;
144 DECL_LINK( OnScroll, ScrollBar*);
146 DECL_LINK( FormatClickHdl, Button * );
147 DECL_LINK( ChangeHdl, ListBox * );
149 DECL_LINK( DelayedGrabFocus, Control** );
150 // von ActivatePropertyField benutzt
151 DECL_LINK( OnControlFocusLost, Control* );
152 DECL_LINK( OnControlFocusGot, Control* );
154 void UpdateFormatSample(OFieldDescription* pFieldDescr);
155 void ArrangeAggregates();
157 void SetPosSize( Control** ppControl, long nRow, USHORT nCol );
159 void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY);
160 void ScrollAllAggregates();
162 sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
163 void Contruct();
164 OPropNumericEditCtrl* CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId);
165 FixedText* CreateText(USHORT _nTextRes);
166 void InitializeControl(Control* _pControl,ULONG _nHelpId,bool _bAddChangeHandler);
168 protected:
169 inline void setRightAligned() { m_bRightAligned = true; }
170 inline bool isRightAligned() const { return m_bRightAligned; }
172 inline void saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
173 inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; }
174 inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; }
176 sal_uInt16 CountActiveAggregates() const;
177 sal_Int32 GetMaxControlHeight() const;
179 virtual void ActivateAggregate( EControlType eType );
180 virtual void DeactivateAggregate( EControlType eType );
181 virtual BOOL IsReadOnly() { return FALSE; };
183 // Sind von den abgeleiteten Klassen zu impl.
184 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const = 0;
186 virtual ::com::sun::star::lang::Locale GetLocale() const = 0;
188 virtual void CellModified(long nRow, USHORT nColId ) = 0;
189 virtual void SetModified(BOOL bModified); // base implementation is empty
191 virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) = 0;
192 virtual const OTypeInfoMap* getTypeInfo() const = 0;
194 virtual sal_Bool isAutoIncrementValueEnabled() const = 0;
195 virtual ::rtl::OUString getAutoIncrementValue() const = 0;
197 String BoolStringPersistent(const String& rUIString) const;
198 String BoolStringUI(const String& rPersistentString) const;
200 const OPropColumnEditCtrl* getColumnCtrl() const { return m_pColumnName; }
202 public:
203 OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
204 OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
205 virtual ~OFieldDescControl();
207 void DisplayData(OFieldDescription* pFieldDescr );
208 // void DisplayData(const OColumn* pColumn);
210 void SaveData( OFieldDescription* pFieldDescr );
211 // void SaveData( OColumn* pColumn);
213 void SetControlText( USHORT nControlId, const String& rText );
214 String GetControlText( USHORT nControlId );
215 void SetReadOnly( BOOL bReadOnly );
217 // Resize aufegrufen
218 void CheckScrollBars();
219 sal_Bool isCutAllowed();
220 sal_Bool isCopyAllowed();
221 sal_Bool isPasteAllowed();
223 void cut();
224 void copy();
225 void paste();
227 virtual void Init();
228 virtual void GetFocus();
229 virtual void LoseFocus();
230 virtual void Resize();
232 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0;
233 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() = 0;
235 String getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck = sal_True) const;
237 inline void setEditWidth(sal_Int32 _nWidth) { m_nWidth = _nWidth; }
238 protected:
239 void implFocusLost(Window* _pWhich);
242 #endif // DBAUI_FIELDDESCRIPTIONCONTROL_HXX