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