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