1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define ITEMID_HORJUSTIFY		SID_ATTR_ALIGN_HOR_JUSTIFY
28cdf0e10cSrcweir #define ITEMID_VERJUSTIFY		SID_ATTR_ALIGN_VER_JUSTIFY
29cdf0e10cSrcweir //#define ITEMID_ORIENTATION     SID_ATTR_ALIGN_ORIENTATION
30cdf0e10cSrcweir #define ITEMID_LINEBREAK		SID_ATTR_ALIGN_LINEBREAK
31cdf0e10cSrcweir #define ITEMID_MARGIN			SID_ATTR_ALIGN_MARGIN
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "FieldDescControl.hxx"
34cdf0e10cSrcweir #include "FieldControls.hxx"
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir #include <tools/diagnose_ex.h>
37cdf0e10cSrcweir #include "TableDesignHelpBar.hxx"
38cdf0e10cSrcweir #include <vcl/scrbar.hxx>
39cdf0e10cSrcweir #include <vcl/button.hxx>
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <vcl/fixed.hxx>
42cdf0e10cSrcweir #include <vcl/msgbox.hxx>
43cdf0e10cSrcweir #include <vector>
44cdf0e10cSrcweir #include "FieldDescriptions.hxx"
45cdf0e10cSrcweir #include "dlgattr.hxx"
46cdf0e10cSrcweir #include <svx/numfmtsh.hxx>
47cdf0e10cSrcweir #include <svx/svxids.hrc>
48cdf0e10cSrcweir #include <svx/algitem.hxx>
49cdf0e10cSrcweir #include <svl/itempool.hxx>
50cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE		// ohne das bekomme ich einen Compiler-Fehler in <svl/zforlist.hxx>
51cdf0e10cSrcweir #include <svl/zforlist.hxx>
52cdf0e10cSrcweir #include <svl/rngitem.hxx>
53cdf0e10cSrcweir #include <svl/intitem.hxx>
54cdf0e10cSrcweir #include <svl/numuno.hxx>
55cdf0e10cSrcweir #include <svtools/transfer.hxx>
56cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
57cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp>
58cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatPreviewer.hpp>
59cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp>
60cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
61cdf0e10cSrcweir #include "QEnumTypes.hxx"
62cdf0e10cSrcweir #include "dbaccess_helpid.hrc"
63cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
64cdf0e10cSrcweir #include <connectivity/dbconversion.hxx>
65cdf0e10cSrcweir #include <comphelper/numbers.hxx>
66cdf0e10cSrcweir #include "UITools.hxx"
67cdf0e10cSrcweir #include <memory>
68cdf0e10cSrcweir #include "dbu_control.hrc"
69cdf0e10cSrcweir #include "dbu_tbl.hrc"
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir using namespace dbaui;
73cdf0e10cSrcweir using namespace dbtools;
74cdf0e10cSrcweir using namespace ::com::sun::star::uno;
75cdf0e10cSrcweir using namespace ::com::sun::star::beans;
76cdf0e10cSrcweir using namespace ::com::sun::star::lang;
77cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
78cdf0e10cSrcweir using namespace ::com::sun::star::util;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //==================================================================
81cdf0e10cSrcweir 
82cdf0e10cSrcweir // fuer die Controls auf der OFieldDescGenPage
83cdf0e10cSrcweir #define CONTROL_SPACING_X	18	// 6
84cdf0e10cSrcweir #define	CONTROL_SPACING_Y	4
85cdf0e10cSrcweir #define CONTROL_WIDTH_1		160	// 100
86cdf0e10cSrcweir #define CONTROL_WIDTH_2		100 // 60
87cdf0e10cSrcweir #define CONTROL_WIDTH_3		250
88cdf0e10cSrcweir #define CONTROL_WIDTH_4		(CONTROL_WIDTH_3 - 20 - 5)
89cdf0e10cSrcweir 
90cdf0e10cSrcweir #define SBA_DEF_RANGEFORMAT			(100 + 143) // RangeItem
91cdf0e10cSrcweir #define SBA_DEF_FMTVALUE			(100 + 144) // SfxULONG, Format
92cdf0e10cSrcweir #define SBA_ATTR_ALIGN_HOR_JUSTIFY	(100 + 145) //  SvxHorJustifyItem
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define HSCROLL_STEP		20
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 
97cdf0e10cSrcweir namespace
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference<::com::sun::star::util::XNumberFormatter> & _xNumberFormatter)100cdf0e10cSrcweir 	double checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference< ::com::sun::star::util::XNumberFormatter>& _xNumberFormatter)
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		double nValue = _nValue;
103cdf0e10cSrcweir 		sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(_xNumberFormatter,_nFormatKey);
104cdf0e10cSrcweir 		if(		(nNumberFormat & ::com::sun::star::util::NumberFormat::DATE)	== ::com::sun::star::util::NumberFormat::DATE
105cdf0e10cSrcweir 			|| (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
106cdf0e10cSrcweir 		{
107cdf0e10cSrcweir 			nValue = DBTypeConversion::toStandardDbDate(DBTypeConversion::getNULLDate(_xNumberFormatter->getNumberFormatsSupplier()),nValue);
108cdf0e10cSrcweir 		}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		return nValue;
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
lcl_HideAndDeleteControl(short & _nPos,T1 ** _pControl,T2 ** _pControlText)113cdf0e10cSrcweir     template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText)
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         if ( *_pControl )
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir             --_nPos;
118cdf0e10cSrcweir 	        (*_pControl)->Hide();
119cdf0e10cSrcweir 	        (*_pControlText)->Hide();
120cdf0e10cSrcweir 	        delete *_pControl;
121cdf0e10cSrcweir 	        delete *_pControlText;
122cdf0e10cSrcweir             (*_pControl) = NULL;
123cdf0e10cSrcweir             (*_pControlText) = NULL;
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir //==================================================================
130cdf0e10cSrcweir // class OFieldDescControl
131cdf0e10cSrcweir //==================================================================
132cdf0e10cSrcweir 
DBG_NAME(OFieldDescControl)133cdf0e10cSrcweir DBG_NAME(OFieldDescControl)
134cdf0e10cSrcweir 
135cdf0e10cSrcweir //==================================================================
136cdf0e10cSrcweir OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar)
137cdf0e10cSrcweir 	:TabPage( pParent, rResId )
138cdf0e10cSrcweir 	,pHelp( pHelpBar )
139cdf0e10cSrcweir 	,pLastFocusWindow(NULL)
140cdf0e10cSrcweir 	,m_pActFocusWindow(NULL)
141cdf0e10cSrcweir 	,pDefaultText(NULL)
142cdf0e10cSrcweir 	,pRequiredText(NULL)
143cdf0e10cSrcweir 	,pAutoIncrementText(NULL)
144cdf0e10cSrcweir 	,pTextLenText(NULL)
145cdf0e10cSrcweir 	,pNumTypeText(NULL)
146cdf0e10cSrcweir 	,pLengthText(NULL)
147cdf0e10cSrcweir 	,pScaleText(NULL)
148cdf0e10cSrcweir 	,pFormatText(NULL)
149cdf0e10cSrcweir 	,pBoolDefaultText(NULL)
150cdf0e10cSrcweir 	,m_pColumnNameText(NULL)
151cdf0e10cSrcweir 	,m_pTypeText(NULL)
152cdf0e10cSrcweir 	,m_pAutoIncrementValueText(NULL)
153cdf0e10cSrcweir 	,pRequired(NULL)
154cdf0e10cSrcweir 	,pNumType(NULL)
155cdf0e10cSrcweir 	,pAutoIncrement(NULL)
156cdf0e10cSrcweir 	,pDefault(NULL)
157cdf0e10cSrcweir 	,pTextLen(NULL)
158cdf0e10cSrcweir 	,pLength(NULL)
159cdf0e10cSrcweir 	,pScale(NULL)
160cdf0e10cSrcweir 	,pFormatSample(NULL)
161cdf0e10cSrcweir 	,pBoolDefault(NULL)
162cdf0e10cSrcweir 	,m_pColumnName(NULL)
163cdf0e10cSrcweir 	,m_pType(NULL)
164cdf0e10cSrcweir 	,m_pAutoIncrementValue(NULL)
165cdf0e10cSrcweir 	,pFormat(NULL)
166cdf0e10cSrcweir     ,m_pVertScroll( NULL )
167cdf0e10cSrcweir     ,m_pHorzScroll( NULL )
168cdf0e10cSrcweir     ,m_pPreviousType()
169cdf0e10cSrcweir 	,nCurChildId(1)
170cdf0e10cSrcweir 	,m_nPos(-1)
171cdf0e10cSrcweir     ,aYes(ModuleRes(STR_VALUE_YES))
172cdf0e10cSrcweir 	,aNo(ModuleRes(STR_VALUE_NO))
173cdf0e10cSrcweir     ,m_nOldVThumb( 0 )
174cdf0e10cSrcweir     ,m_nOldHThumb( 0 )
175cdf0e10cSrcweir 	,m_nWidth(50)
176cdf0e10cSrcweir     ,nDelayedGrabFocusEvent(0)
177cdf0e10cSrcweir     ,m_bAdded(sal_False)
178cdf0e10cSrcweir 	,m_bRightAligned(false)
179cdf0e10cSrcweir     ,pActFieldDescr(NULL)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	DBG_CTOR(OFieldDescControl,NULL);
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 	Contruct();
184cdf0e10cSrcweir }
185cdf0e10cSrcweir //------------------------------------------------------------------------------
OFieldDescControl(Window * pParent,OTableDesignHelpBar * pHelpBar)186cdf0e10cSrcweir OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar )
187cdf0e10cSrcweir 	:TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL )
188cdf0e10cSrcweir 	,pHelp( pHelpBar )
189cdf0e10cSrcweir 	,pLastFocusWindow(NULL)
190cdf0e10cSrcweir 	,m_pActFocusWindow(NULL)
191cdf0e10cSrcweir 	,pDefaultText(NULL)
192cdf0e10cSrcweir 	,pRequiredText(NULL)
193cdf0e10cSrcweir 	,pAutoIncrementText(NULL)
194cdf0e10cSrcweir 	,pTextLenText(NULL)
195cdf0e10cSrcweir 	,pNumTypeText(NULL)
196cdf0e10cSrcweir 	,pLengthText(NULL)
197cdf0e10cSrcweir 	,pScaleText(NULL)
198cdf0e10cSrcweir 	,pFormatText(NULL)
199cdf0e10cSrcweir 	,pBoolDefaultText(NULL)
200cdf0e10cSrcweir 	,m_pColumnNameText(NULL)
201cdf0e10cSrcweir 	,m_pTypeText(NULL)
202cdf0e10cSrcweir 	,m_pAutoIncrementValueText(NULL)
203cdf0e10cSrcweir 	,pRequired(NULL)
204cdf0e10cSrcweir 	,pNumType(NULL)
205cdf0e10cSrcweir 	,pAutoIncrement(NULL)
206cdf0e10cSrcweir 	,pDefault(NULL)
207cdf0e10cSrcweir 	,pTextLen(NULL)
208cdf0e10cSrcweir 	,pLength(NULL)
209cdf0e10cSrcweir 	,pScale(NULL)
210cdf0e10cSrcweir 	,pFormatSample(NULL)
211cdf0e10cSrcweir 	,pBoolDefault(NULL)
212cdf0e10cSrcweir 	,m_pColumnName(NULL)
213cdf0e10cSrcweir 	,m_pType(NULL)
214cdf0e10cSrcweir 	,m_pAutoIncrementValue(NULL)
215cdf0e10cSrcweir 	,pFormat(NULL)
216cdf0e10cSrcweir     ,m_pVertScroll( NULL )
217cdf0e10cSrcweir     ,m_pHorzScroll( NULL )
218cdf0e10cSrcweir     ,m_pPreviousType()
219cdf0e10cSrcweir 	,nCurChildId(1)
220cdf0e10cSrcweir 	,m_nPos(-1)
221cdf0e10cSrcweir     ,aYes(ModuleRes(STR_VALUE_YES))
222cdf0e10cSrcweir 	,aNo(ModuleRes(STR_VALUE_NO))
223cdf0e10cSrcweir     ,m_nOldVThumb( 0 )
224cdf0e10cSrcweir     ,m_nOldHThumb( 0 )
225cdf0e10cSrcweir 	,m_nWidth(50)
226cdf0e10cSrcweir     ,nDelayedGrabFocusEvent(0)
227cdf0e10cSrcweir     ,m_bAdded(sal_False)
228cdf0e10cSrcweir 	,m_bRightAligned(false)
229cdf0e10cSrcweir     ,pActFieldDescr(NULL)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	DBG_CTOR(OFieldDescControl,NULL);
232cdf0e10cSrcweir     Contruct();
233cdf0e10cSrcweir }
234cdf0e10cSrcweir // -----------------------------------------------------------------------------
Contruct()235cdf0e10cSrcweir void OFieldDescControl::Contruct()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG);
238cdf0e10cSrcweir 	m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG);
239cdf0e10cSrcweir 	m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
240cdf0e10cSrcweir 	m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
241cdf0e10cSrcweir 	m_pVertScroll->Show();
242cdf0e10cSrcweir 	m_pHorzScroll->Show();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	m_pVertScroll->EnableClipSiblings();
245cdf0e10cSrcweir 	m_pHorzScroll->EnableClipSiblings();
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	m_pVertScroll->SetLineSize(1);
248cdf0e10cSrcweir 	m_pVertScroll->SetPageSize(1);
249cdf0e10cSrcweir 	m_pHorzScroll->SetLineSize(1);
250cdf0e10cSrcweir 	m_pHorzScroll->SetPageSize(1);
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	m_nOldVThumb = m_nOldHThumb = 0;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //------------------------------------------------------------------------------
~OFieldDescControl()256cdf0e10cSrcweir OFieldDescControl::~OFieldDescControl()
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	DBG_DTOR(OFieldDescControl,NULL);
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	{
261cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pVertScroll);
262cdf0e10cSrcweir 		m_pVertScroll	 = NULL;
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pHorzScroll);
266cdf0e10cSrcweir 		m_pHorzScroll	 = NULL;
267cdf0e10cSrcweir 	}
268cdf0e10cSrcweir     if ( m_bAdded )
269cdf0e10cSrcweir         ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
270cdf0e10cSrcweir 	pLastFocusWindow = NULL;
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
273cdf0e10cSrcweir 	// Childs zerstoeren
274cdf0e10cSrcweir 	DeactivateAggregate( tpDefault );
275cdf0e10cSrcweir 	DeactivateAggregate( tpRequired );
276cdf0e10cSrcweir 	DeactivateAggregate( tpTextLen );
277cdf0e10cSrcweir 	DeactivateAggregate( tpNumType );
278cdf0e10cSrcweir 	DeactivateAggregate( tpScale );
279cdf0e10cSrcweir 	DeactivateAggregate( tpLength );
280cdf0e10cSrcweir 	DeactivateAggregate( tpFormat );
281cdf0e10cSrcweir 	DeactivateAggregate( tpAutoIncrement );
282cdf0e10cSrcweir 	DeactivateAggregate( tpBoolDefault );
283cdf0e10cSrcweir 	DeactivateAggregate( tpColumnName );
284cdf0e10cSrcweir 	DeactivateAggregate( tpType );
285cdf0e10cSrcweir 	DeactivateAggregate( tpAutoIncrementValue );
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 	if(nDelayedGrabFocusEvent)
288cdf0e10cSrcweir 		Application::RemoveUserEvent(nDelayedGrabFocusEvent);
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir //------------------------------------------------------------------------------
BoolStringPersistent(const String & rUIString) const292cdf0e10cSrcweir String OFieldDescControl::BoolStringPersistent(const String& rUIString) const
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	static String aZero('0');
295cdf0e10cSrcweir 	static String aOne('1');
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	if (rUIString == aNo)
298cdf0e10cSrcweir 		return aZero;
299cdf0e10cSrcweir 	if (rUIString == aYes)
300cdf0e10cSrcweir 		return aOne;
301cdf0e10cSrcweir 	return String();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir //------------------------------------------------------------------------------
BoolStringUI(const String & rPersistentString) const305cdf0e10cSrcweir String OFieldDescControl::BoolStringUI(const String& rPersistentString) const
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	static String aZero('0');
308cdf0e10cSrcweir 	static String aOne('1');
309cdf0e10cSrcweir 	static String aNone(ModuleRes(STR_VALUE_NONE));
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	// FS - 66161 - 14.05.1999 - aeltere Versionen haben eventuell einen sprachabhaengigen String als Default gespeichert
312cdf0e10cSrcweir 	if (rPersistentString.Equals(aYes) || rPersistentString.Equals(aNo))
313cdf0e10cSrcweir 		return rPersistentString;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	if (rPersistentString == aZero)
316cdf0e10cSrcweir 		return aNo;
317cdf0e10cSrcweir 	if (rPersistentString == aOne)
318cdf0e10cSrcweir 		return aYes;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	return aNone;
321cdf0e10cSrcweir }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir //------------------------------------------------------------------------------
Init()324cdf0e10cSrcweir void OFieldDescControl::Init()
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	Reference< ::com::sun::star::util::XNumberFormatter > xFormatter = GetFormatter();
327cdf0e10cSrcweir 	::dbaui::setEvalDateFormatForFormatter(xFormatter);
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir //------------------------------------------------------------------------------
331cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnScroll, ScrollBar*, /*pBar*/)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	ScrollAllAggregates();
334cdf0e10cSrcweir 	return 0;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir // -----------------------------------------------------------------------------
337cdf0e10cSrcweir namespace
338cdf0e10cSrcweir {
getMaxXPosition(Window * _pWindow,long & _rnMaxXPosition)339cdf0e10cSrcweir 	void getMaxXPosition(Window* _pWindow,long& _rnMaxXPosition)
340cdf0e10cSrcweir 	{
341cdf0e10cSrcweir 		if (_pWindow)
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			long nTemp = _pWindow->GetSizePixel().Width() + _pWindow->GetPosPixel().X();
344cdf0e10cSrcweir 			_rnMaxXPosition = ::std::max(_rnMaxXPosition, nTemp);
345cdf0e10cSrcweir 		}
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir }
348cdf0e10cSrcweir //------------------------------------------------------------------------------
CheckScrollBars()349cdf0e10cSrcweir void OFieldDescControl::CheckScrollBars()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	// ein paar Berechnungen zur neuen Position der ScrollBars
352cdf0e10cSrcweir 	Size szOverallSize = GetSizePixel();
353cdf0e10cSrcweir 	long nHScrollHeight = m_pHorzScroll->GetSizePixel().Height();
354cdf0e10cSrcweir 	long nVScrollWidth = m_pVertScroll->GetSizePixel().Width();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	long nNewHWidth = szOverallSize.Width() - nVScrollWidth;
357cdf0e10cSrcweir 	long nNewVHeight = szOverallSize.Height() - nHScrollHeight;
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	sal_Bool bNeedHScrollBar(sal_False), bNeedVScrollBar(sal_False);
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	// die Bereiche anpassen
362cdf0e10cSrcweir 	// brauche ich ScrollBars eigentlich ?
363cdf0e10cSrcweir 	// horizontal :
364cdf0e10cSrcweir 	long lMaxXPosition = 0;
365cdf0e10cSrcweir 	Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
366cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
367cdf0e10cSrcweir 		getMaxXPosition(ppAggregates[i],lMaxXPosition);
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	if (m_pHorzScroll)
370cdf0e10cSrcweir 		lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	long lMaxXAvailable = szOverallSize.Width();
373cdf0e10cSrcweir 	bNeedHScrollBar = lMaxXPosition > lMaxXAvailable;
374cdf0e10cSrcweir 		// aendert sich vielleicht noch
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	// vertikal
377cdf0e10cSrcweir 	// wieviel Controls habe ich
378cdf0e10cSrcweir 	sal_uInt16 nActive = CountActiveAggregates();
379cdf0e10cSrcweir 	// welches ist das letzte, was ganz drauf passt ?
380cdf0e10cSrcweir 	sal_uInt16 nLastVisible;
381cdf0e10cSrcweir     const sal_Int32 nControlHeight = GetMaxControlHeight();
382cdf0e10cSrcweir     const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
383cdf0e10cSrcweir 	if (bNeedHScrollBar)
384cdf0e10cSrcweir 		nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
385cdf0e10cSrcweir 	else
386cdf0e10cSrcweir 		nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y) / (nControl_Spacing_y + nControlHeight));
387cdf0e10cSrcweir 	bNeedVScrollBar = nActive>nLastVisible;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	if (bNeedVScrollBar)
390cdf0e10cSrcweir 	{
391cdf0e10cSrcweir 		// in die urspruengliche Berechnung von lMaxXAvailable ist nicht mit eingegangen, dass ich eine VScrollBar habe, also muss ich
392cdf0e10cSrcweir 		// das nachholen
393cdf0e10cSrcweir 		lMaxXAvailable -= nVScrollWidth;
394cdf0e10cSrcweir 		if (!bNeedHScrollBar && (lMaxXPosition > lMaxXAvailable))
395cdf0e10cSrcweir 		{
396cdf0e10cSrcweir 			// durch die vertikale brauche ich jetzt ploetzlich doch eine horizontale
397cdf0e10cSrcweir 			bNeedHScrollBar = sal_True;
398cdf0e10cSrcweir 			// nLastVisible anpassen
399cdf0e10cSrcweir 			nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
400cdf0e10cSrcweir 				// bNeedVScrollBar aendert sich nicht : es ist schon auf sal_True und nLastVisible wird hoechstens kleiner
401cdf0e10cSrcweir 		}
402cdf0e10cSrcweir 	}
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	// jetzt kann ich sie wirklich positionieren und ihre Parameter setzen
405cdf0e10cSrcweir 	if (bNeedVScrollBar)
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		m_pVertScroll->Show();
408cdf0e10cSrcweir 		m_pVertScroll->SetRangeMax(nActive - nLastVisible);
409cdf0e10cSrcweir //		m_pVertScroll->SetThumbPos(0);
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 		m_pVertScroll->SetPosSizePixel( Point(nNewHWidth, 0), Size(nVScrollWidth, szOverallSize.Height()) );
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 	else
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir 		m_pVertScroll->Hide();
416cdf0e10cSrcweir 		m_pVertScroll->SetRangeMax(0);
417cdf0e10cSrcweir 		m_pVertScroll->SetThumbPos(0);
418cdf0e10cSrcweir 	}
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 	if (bNeedHScrollBar)
421cdf0e10cSrcweir 	{
422cdf0e10cSrcweir 		m_pHorzScroll->Show();
423cdf0e10cSrcweir 		m_pHorzScroll->SetRangeMax((lMaxXPosition - lMaxXAvailable + HSCROLL_STEP - 1 )/HSCROLL_STEP);
424cdf0e10cSrcweir //		m_pHorzScroll->SetThumbPos(0);
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		m_pHorzScroll->SetPosSizePixel( Point(0, nNewVHeight), Size(bNeedVScrollBar ? nNewHWidth : szOverallSize.Width(), nHScrollHeight) );
427cdf0e10cSrcweir 	}
428cdf0e10cSrcweir 	else
429cdf0e10cSrcweir 	{
430cdf0e10cSrcweir 		m_pHorzScroll->Hide();
431cdf0e10cSrcweir 		m_pHorzScroll->SetRangeMax(0);
432cdf0e10cSrcweir 		m_pHorzScroll->SetThumbPos(0);
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()437cdf0e10cSrcweir void OFieldDescControl::Resize()
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	CheckScrollBars();
440cdf0e10cSrcweir 	ScrollAllAggregates();
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir //------------------------------------------------------------------------------
ScrollAggregate(Control * pText,Control * pInput,Control * pButton,long nDeltaX,long nDeltaY)444cdf0e10cSrcweir inline void OFieldDescControl::ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY)
445cdf0e10cSrcweir {
446cdf0e10cSrcweir 	if  (!pText)
447cdf0e10cSrcweir 		return;
448cdf0e10cSrcweir 	pText->SetPosPixel(pText->GetPosPixel() + Point(nDeltaX, nDeltaY));
449cdf0e10cSrcweir 	pInput->SetPosPixel(pInput->GetPosPixel() + Point(nDeltaX, nDeltaY));
450cdf0e10cSrcweir 	if (pButton)
451cdf0e10cSrcweir 		pButton->SetPosPixel(pButton->GetPosPixel() + Point(nDeltaX, nDeltaY));
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir //------------------------------------------------------------------------------
ScrollAllAggregates()455cdf0e10cSrcweir void OFieldDescControl::ScrollAllAggregates()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir 	long nDeltaX = 0, nDeltaY = 0;
458cdf0e10cSrcweir 	if (m_nOldHThumb != m_pHorzScroll->GetThumbPos())
459cdf0e10cSrcweir 	{
460cdf0e10cSrcweir 		nDeltaX = (m_nOldHThumb - m_pHorzScroll->GetThumbPos()) * HSCROLL_STEP;
461cdf0e10cSrcweir 		m_nOldHThumb = m_pHorzScroll->GetThumbPos();
462cdf0e10cSrcweir 	}
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 	if (m_nOldVThumb != m_pVertScroll->GetThumbPos())
465cdf0e10cSrcweir 	{
466cdf0e10cSrcweir         const sal_Int32 nControlHeight = GetMaxControlHeight();
467cdf0e10cSrcweir         const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
468cdf0e10cSrcweir 		nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (nControl_Spacing_y + nControlHeight);
469cdf0e10cSrcweir 		m_nOldVThumb = m_pVertScroll->GetThumbPos();
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 	if (nDeltaX || nDeltaY)
473cdf0e10cSrcweir 	{
474cdf0e10cSrcweir 		Control* ppAggregates[]		= {	  pRequired, pNumType
475cdf0e10cSrcweir 										, pAutoIncrement, pDefault
476cdf0e10cSrcweir 										, pTextLen, pLength
477cdf0e10cSrcweir 										, pScale, m_pColumnName
478cdf0e10cSrcweir 										, m_pType, m_pAutoIncrementValue};
479cdf0e10cSrcweir 		Control* ppAggregatesText[]	= {	  pRequiredText, pNumTypeText
480cdf0e10cSrcweir 										, pAutoIncrementText, pDefaultText
481cdf0e10cSrcweir 										, pTextLenText, pLengthText
482cdf0e10cSrcweir 										, pScaleText, m_pColumnNameText
483cdf0e10cSrcweir 										, m_pTypeText, m_pAutoIncrementValueText};
484cdf0e10cSrcweir 		OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 		for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
487cdf0e10cSrcweir 			ScrollAggregate(ppAggregatesText[i],ppAggregates[i],NULL,nDeltaX, nDeltaY);
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 		ScrollAggregate(pFormatText,pFormatSample,pFormat,nDeltaX, nDeltaY);
490cdf0e10cSrcweir 	}
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir //------------------------------------------------------------------------------
CountActiveAggregates() const494cdf0e10cSrcweir sal_uInt16 OFieldDescControl::CountActiveAggregates() const
495cdf0e10cSrcweir {
496cdf0e10cSrcweir 	Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
497cdf0e10cSrcweir 	sal_uInt16 nVisibleAggregates = 0;
498cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
499cdf0e10cSrcweir 		if (ppAggregates[i])
500cdf0e10cSrcweir 			++nVisibleAggregates;
501cdf0e10cSrcweir 	return nVisibleAggregates;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir //------------------------------------------------------------------------------
GetMaxControlHeight() const504cdf0e10cSrcweir sal_Int32 OFieldDescControl::GetMaxControlHeight() const
505cdf0e10cSrcweir {
506cdf0e10cSrcweir     Size aHeight;
507cdf0e10cSrcweir     Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
508cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir 		if ( ppAggregates[i] )
511cdf0e10cSrcweir         {
512cdf0e10cSrcweir             const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
513cdf0e10cSrcweir             if ( aTemp.Height() > aHeight.Height() )
514cdf0e10cSrcweir                 aHeight.Height() = aTemp.Height();
515cdf0e10cSrcweir         } // if ( ppAggregates[i] )
516cdf0e10cSrcweir     }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     return aHeight.Height();
519cdf0e10cSrcweir }
520cdf0e10cSrcweir //------------------------------------------------------------------------------
SetReadOnly(sal_Bool bReadOnly)521cdf0e10cSrcweir void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
524cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
525cdf0e10cSrcweir 	// Controls enablen/disablen
526cdf0e10cSrcweir 	Control* ppAggregates[]		= {	  pRequired, pNumType
527cdf0e10cSrcweir 										, pAutoIncrement, pDefault
528cdf0e10cSrcweir 										, pTextLen, pLength
529cdf0e10cSrcweir 										, pScale, m_pColumnName
530cdf0e10cSrcweir 										, m_pType, m_pAutoIncrementValue
531cdf0e10cSrcweir 										, pFormat};
532cdf0e10cSrcweir 	Control* ppAggregatesText[]	= {	  pRequiredText, pNumTypeText
533cdf0e10cSrcweir 										, pAutoIncrementText, pDefaultText
534cdf0e10cSrcweir 										, pTextLenText, pLengthText
535cdf0e10cSrcweir 										, pScaleText, m_pColumnNameText
536cdf0e10cSrcweir 										, m_pTypeText, m_pAutoIncrementValueText
537cdf0e10cSrcweir 										, pFormatText};
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 	OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
542cdf0e10cSrcweir 	{
543cdf0e10cSrcweir 		if ( ppAggregatesText[i] )
544cdf0e10cSrcweir 			ppAggregatesText[i]->Enable( !bReadOnly );
545cdf0e10cSrcweir 		if ( ppAggregates[i] )
546cdf0e10cSrcweir 			ppAggregates[i]->Enable( !bReadOnly );
547cdf0e10cSrcweir 	}
548cdf0e10cSrcweir }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir //------------------------------------------------------------------------------
GetControlText(sal_uInt16 nControlId)551cdf0e10cSrcweir String OFieldDescControl::GetControlText( sal_uInt16 nControlId )
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
554cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
555cdf0e10cSrcweir 	// Texte der Controls auslesen
556cdf0e10cSrcweir 	switch( nControlId )
557cdf0e10cSrcweir 	{
558cdf0e10cSrcweir 		case FIELD_PROPERTY_BOOL_DEFAULT:
559cdf0e10cSrcweir 			if (pBoolDefault)
560cdf0e10cSrcweir 				return pBoolDefault->GetSelectEntry();
561cdf0e10cSrcweir 			break;
562cdf0e10cSrcweir 		case FIELD_PROPERTY_DEFAULT:
563cdf0e10cSrcweir 			if (pDefault)
564cdf0e10cSrcweir 				return pDefault->GetText();
565cdf0e10cSrcweir 			break;
566cdf0e10cSrcweir 		case FIELD_PROPERTY_REQUIRED:
567cdf0e10cSrcweir 			if (pRequired)
568cdf0e10cSrcweir 				return pRequired->GetSelectEntry();
569cdf0e10cSrcweir 			break;
570cdf0e10cSrcweir 		case FIELD_PROPERTY_TEXTLEN:
571cdf0e10cSrcweir 			if (pTextLen)
572cdf0e10cSrcweir 				return String::CreateFromInt64(pTextLen->GetValue());
573cdf0e10cSrcweir 		case FIELD_PROPERTY_NUMTYPE:
574cdf0e10cSrcweir 			if (pNumType)
575cdf0e10cSrcweir 				return pNumType->GetSelectEntry();
576cdf0e10cSrcweir 			break;
577cdf0e10cSrcweir 		case FIELD_PROPERTY_AUTOINC:
578cdf0e10cSrcweir 			if (pAutoIncrement)
579cdf0e10cSrcweir 				return pAutoIncrement->GetSelectEntry();
580cdf0e10cSrcweir 			break;
581cdf0e10cSrcweir 		case FIELD_PROPERTY_LENGTH:
582cdf0e10cSrcweir 			if (pLength)
583cdf0e10cSrcweir 				return pLength->GetText();
584cdf0e10cSrcweir 			break;
585cdf0e10cSrcweir 		case FIELD_PROPERTY_SCALE:
586cdf0e10cSrcweir 			if (pScale)
587cdf0e10cSrcweir 				return pScale->GetText();
588cdf0e10cSrcweir 			break;
589cdf0e10cSrcweir 		case FIELD_PROPERTY_FORMAT:
590cdf0e10cSrcweir 			if (pFormatSample)
591cdf0e10cSrcweir 				return pFormatSample->GetText();
592cdf0e10cSrcweir 			break;
593cdf0e10cSrcweir 		case FIELD_PRPOERTY_COLUMNNAME:
594cdf0e10cSrcweir 			if(m_pColumnName)
595cdf0e10cSrcweir 				return m_pColumnName->GetText();
596cdf0e10cSrcweir 		case FIELD_PRPOERTY_TYPE:
597cdf0e10cSrcweir 			if(m_pType)
598cdf0e10cSrcweir 				return m_pType->GetSelectEntry();
599cdf0e10cSrcweir 			break;
600cdf0e10cSrcweir 		case FIELD_PRPOERTY_AUTOINCREMENT:
601cdf0e10cSrcweir 			if(m_pAutoIncrementValue)
602cdf0e10cSrcweir 				return m_pAutoIncrementValue->GetText();
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	return String();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir //------------------------------------------------------------------------------
SetControlText(sal_uInt16 nControlId,const String & rText)609cdf0e10cSrcweir void OFieldDescControl::SetControlText( sal_uInt16 nControlId, const String& rText )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
612cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
613cdf0e10cSrcweir 	// Texte der Controls setzen
614cdf0e10cSrcweir 	switch( nControlId )
615cdf0e10cSrcweir 	{
616cdf0e10cSrcweir 		case FIELD_PROPERTY_BOOL_DEFAULT:
617cdf0e10cSrcweir 			if (pBoolDefault)
618cdf0e10cSrcweir 			{
619cdf0e10cSrcweir 				String sOld = pBoolDefault->GetSelectEntry();
620cdf0e10cSrcweir 				pBoolDefault->SelectEntry(rText);
621cdf0e10cSrcweir 				if (!sOld.Equals(rText))
622cdf0e10cSrcweir 					LINK(this, OFieldDescControl, ChangeHdl).Call(pBoolDefault);
623cdf0e10cSrcweir 			}
624cdf0e10cSrcweir 			break;
625cdf0e10cSrcweir 		case FIELD_PROPERTY_DEFAULT:
626cdf0e10cSrcweir 			if (pDefault)
627cdf0e10cSrcweir 			{
628cdf0e10cSrcweir 				pDefault->SetText(rText);
629cdf0e10cSrcweir 				UpdateFormatSample(pActFieldDescr);
630cdf0e10cSrcweir 			}
631cdf0e10cSrcweir 			break;
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 		case FIELD_PROPERTY_REQUIRED:
634cdf0e10cSrcweir 			if (pRequired)
635cdf0e10cSrcweir 				pRequired->SelectEntry(rText);
636cdf0e10cSrcweir 			break;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 		case FIELD_PROPERTY_TEXTLEN:
640cdf0e10cSrcweir 			if (pTextLen)
641cdf0e10cSrcweir 				pTextLen->SetText(rText);
642cdf0e10cSrcweir 			break;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 		case FIELD_PROPERTY_NUMTYPE:
645cdf0e10cSrcweir 			if (pNumType)
646cdf0e10cSrcweir 				pNumType->SelectEntry(rText);
647cdf0e10cSrcweir 			break;
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 		case FIELD_PROPERTY_AUTOINC:
650cdf0e10cSrcweir 			if (pAutoIncrement)
651cdf0e10cSrcweir 			{
652cdf0e10cSrcweir 				String sOld = pAutoIncrement->GetSelectEntry();
653cdf0e10cSrcweir 				pAutoIncrement->SelectEntry(rText);
654cdf0e10cSrcweir 				if (!sOld.Equals(rText))
655cdf0e10cSrcweir 					LINK(this, OFieldDescControl, ChangeHdl).Call(pAutoIncrement);
656cdf0e10cSrcweir 			}
657cdf0e10cSrcweir 			break;
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 		case FIELD_PROPERTY_LENGTH:
660cdf0e10cSrcweir 			if (pLength)
661cdf0e10cSrcweir 				pLength->SetText(rText);
662cdf0e10cSrcweir 			break;
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		case FIELD_PROPERTY_SCALE:
665cdf0e10cSrcweir 			if (pScale)
666cdf0e10cSrcweir 				pScale->SetText(rText);
667cdf0e10cSrcweir 			break;
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 		case FIELD_PROPERTY_FORMAT:
670cdf0e10cSrcweir 			if (pActFieldDescr)
671cdf0e10cSrcweir 				UpdateFormatSample(pActFieldDescr);
672cdf0e10cSrcweir 			break;
673cdf0e10cSrcweir 		case FIELD_PRPOERTY_COLUMNNAME:
674cdf0e10cSrcweir 			if(m_pColumnName)
675cdf0e10cSrcweir 				m_pColumnName->SetText(rText);
676cdf0e10cSrcweir 			break;
677cdf0e10cSrcweir 		case FIELD_PRPOERTY_TYPE:
678cdf0e10cSrcweir 			if(m_pType)
679cdf0e10cSrcweir 				m_pType->SelectEntry(rText);
680cdf0e10cSrcweir 			break;
681cdf0e10cSrcweir 		case FIELD_PRPOERTY_AUTOINCREMENT:
682cdf0e10cSrcweir 			if(m_pAutoIncrementValue)
683cdf0e10cSrcweir 				m_pAutoIncrementValue->SetText(rText);
684cdf0e10cSrcweir 			break;
685cdf0e10cSrcweir 	}
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir //------------------------------------------------------------------------
689cdf0e10cSrcweir IMPL_LINK( OFieldDescControl, FormatClickHdl, Button *, /*pButton*/ )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
692cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
693cdf0e10cSrcweir 	// Temporaere Column erzeugen, mit der Datenaustausch mit Dialog erfolgt
694cdf0e10cSrcweir 	if( !pActFieldDescr )
695cdf0e10cSrcweir 		return 0;
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 	sal_Int32 nOldFormatKey(pActFieldDescr->GetFormatKey());
698cdf0e10cSrcweir 	SvxCellHorJustify rOldJustify = pActFieldDescr->GetHorJustify();
699cdf0e10cSrcweir 	Reference< XNumberFormatsSupplier >  xSupplier = GetFormatter()->getNumberFormatsSupplier();
700cdf0e10cSrcweir     SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 	SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
703cdf0e10cSrcweir 	sal_uInt16 nFlags;
704cdf0e10cSrcweir 	if(::dbaui::callColumnFormatDialog(this,pFormatter,pActFieldDescr->GetType(),nOldFormatKey,rOldJustify,nFlags,sal_True))
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir 		sal_Bool bModified = sal_False;
707cdf0e10cSrcweir 		if(nOldFormatKey != pActFieldDescr->GetFormatKey())
708cdf0e10cSrcweir 		{
709cdf0e10cSrcweir 			pActFieldDescr->SetFormatKey( nOldFormatKey );
710cdf0e10cSrcweir 			bModified = sal_True;
711cdf0e10cSrcweir 		}
712cdf0e10cSrcweir 		if(rOldJustify != pActFieldDescr->GetHorJustify())
713cdf0e10cSrcweir 		{
714cdf0e10cSrcweir 			pActFieldDescr->SetHorJustify( rOldJustify );
715cdf0e10cSrcweir 			bModified = sal_True;
716cdf0e10cSrcweir 		}
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 		if(bModified)
719cdf0e10cSrcweir 		{
720cdf0e10cSrcweir 			SetModified(sal_True);
721cdf0e10cSrcweir 			UpdateFormatSample(pActFieldDescr);
722cdf0e10cSrcweir 		}
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 	return 0;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir // -----------------------------------------------------------------------
SetModified(sal_Bool)728cdf0e10cSrcweir void OFieldDescControl::SetModified(sal_Bool /*bModified*/)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir }
731cdf0e10cSrcweir //------------------------------------------------------------------------
IMPL_LINK(OFieldDescControl,ChangeHdl,ListBox *,pListBox)732cdf0e10cSrcweir IMPL_LINK( OFieldDescControl, ChangeHdl, ListBox *, pListBox )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
735cdf0e10cSrcweir 	if ( !pActFieldDescr )
736cdf0e10cSrcweir 		return 0;
737cdf0e10cSrcweir 
738cdf0e10cSrcweir     if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
739cdf0e10cSrcweir 	    SetModified(sal_True);
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 	// Sonderbehandlund f"ur Bool Felder
742cdf0e10cSrcweir 	if(pListBox == pRequired && pBoolDefault )
743cdf0e10cSrcweir 	{
744cdf0e10cSrcweir 		// wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
745cdf0e10cSrcweir 		String sDef = BoolStringUI(::comphelper::getString(pActFieldDescr->GetControlDefault()));
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 		if(pRequired->GetSelectEntryPos() == 0) // JA
748cdf0e10cSrcweir 		{
749cdf0e10cSrcweir 			pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
750cdf0e10cSrcweir 			if (!sDef.Equals(aYes) && !sDef.Equals(aNo))
751cdf0e10cSrcweir 				pBoolDefault->SelectEntryPos(1);  // nein als Default
752cdf0e10cSrcweir 			else
753cdf0e10cSrcweir 				pBoolDefault->SelectEntry(sDef);
754cdf0e10cSrcweir 		}
755cdf0e10cSrcweir 		else if(pBoolDefault->GetEntryCount() < 3)
756cdf0e10cSrcweir 		{
757cdf0e10cSrcweir 			pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
758cdf0e10cSrcweir 			pBoolDefault->SelectEntry(sDef);
759cdf0e10cSrcweir 		}
760cdf0e10cSrcweir 	}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 	// nur fuer AutoIncrement eine Sonderbehandlung
763cdf0e10cSrcweir 	if (pListBox == pAutoIncrement)
764cdf0e10cSrcweir 	{
765cdf0e10cSrcweir 		if(pListBox->GetSelectEntryPos() == 1)
766cdf0e10cSrcweir 		{ // no
767cdf0e10cSrcweir 			DeactivateAggregate( tpAutoIncrementValue );
768cdf0e10cSrcweir 			if(pActFieldDescr->IsPrimaryKey())
769cdf0e10cSrcweir 				DeactivateAggregate( tpRequired );
770cdf0e10cSrcweir 			else if( pActFieldDescr->getTypeInfo()->bNullable )
771cdf0e10cSrcweir 			{
772cdf0e10cSrcweir 				ActivateAggregate( tpRequired );
773cdf0e10cSrcweir 				if(pRequired)
774cdf0e10cSrcweir 				{
775cdf0e10cSrcweir 					if( pActFieldDescr->IsNullable() )
776cdf0e10cSrcweir 						pRequired->SelectEntryPos( 1 ); // no
777cdf0e10cSrcweir 					else
778cdf0e10cSrcweir 						pRequired->SelectEntryPos( 0 ); // yes
779cdf0e10cSrcweir 				}
780cdf0e10cSrcweir 			}
781cdf0e10cSrcweir 			ActivateAggregate( tpDefault );
782cdf0e10cSrcweir 		}
783cdf0e10cSrcweir 		else
784cdf0e10cSrcweir 		{
785cdf0e10cSrcweir 			DeactivateAggregate( tpRequired );
786cdf0e10cSrcweir 			DeactivateAggregate( tpDefault );
787cdf0e10cSrcweir 			ActivateAggregate( tpAutoIncrementValue );
788cdf0e10cSrcweir 		}
789cdf0e10cSrcweir 		// und jetzt alle nach oben schieben
790cdf0e10cSrcweir 		ArrangeAggregates();
791cdf0e10cSrcweir 	}
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 	if(pListBox == m_pType)
794cdf0e10cSrcweir 	{
795cdf0e10cSrcweir 		TOTypeInfoSP pTypeInfo = getTypeInfo(m_pType->GetSelectEntryPos());
796cdf0e10cSrcweir 		pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False); // SetType(pTypeInfo);
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 		DisplayData(pActFieldDescr);
799cdf0e10cSrcweir 		CellModified(-1, m_pType->GetPos());
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	return 0;
803cdf0e10cSrcweir }
804cdf0e10cSrcweir //------------------------------------------------------------------------------
805cdf0e10cSrcweir // alle Control neu anordnen, so dass sie in fester Reihenfolge und wirklich
806cdf0e10cSrcweir // OBEN auf der DescriptionPage stehen
ArrangeAggregates()807cdf0e10cSrcweir void OFieldDescControl::ArrangeAggregates()
808cdf0e10cSrcweir {
809cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
810cdf0e10cSrcweir 	// die Beschreibung eines Controls
811cdf0e10cSrcweir 	struct AGGREGATE_DESCRIPTION
812cdf0e10cSrcweir 	{
813cdf0e10cSrcweir 		Control*	pctrlInputControl;	// das eigentliche Control zur Eingabe
814cdf0e10cSrcweir 		Control*	pctrlTextControl;	// das Label dazu
815cdf0e10cSrcweir 		sal_uInt16		nPosSizeArgument;	// das zweite Argument fuer SetPosSize
816cdf0e10cSrcweir 	};
817cdf0e10cSrcweir 	AGGREGATE_DESCRIPTION adAggregates[] = {
818cdf0e10cSrcweir 		{ m_pColumnName, m_pColumnNameText, 1},
819cdf0e10cSrcweir 		{ m_pType, m_pTypeText, 1},
820cdf0e10cSrcweir 		{ pAutoIncrement, pAutoIncrementText, 1 },
821cdf0e10cSrcweir 		{ m_pAutoIncrementValue, m_pAutoIncrementValueText, 3 },
822cdf0e10cSrcweir 		{ pNumType, pNumTypeText, 1 },
823cdf0e10cSrcweir 		{ pRequired, pRequiredText, 1 },
824cdf0e10cSrcweir 		{ pTextLen, pTextLenText, 1 },
825cdf0e10cSrcweir 		{ pLength, pLengthText, 1 },
826cdf0e10cSrcweir 		{ pScale, pScaleText, 1 },
827cdf0e10cSrcweir 		{ pDefault, pDefaultText, 3 },
828cdf0e10cSrcweir 		{ pFormatSample, pFormatText, 4 },
829cdf0e10cSrcweir 		{ pBoolDefault, pBoolDefaultText, 1 },
830cdf0e10cSrcweir 	};
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 	long nMaxWidth = 0;
833cdf0e10cSrcweir 	for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
834cdf0e10cSrcweir 	{
835cdf0e10cSrcweir 		if (adAggregates[i].pctrlTextControl)
836cdf0e10cSrcweir 		{
837cdf0e10cSrcweir 			nMaxWidth = ::std::max<long>(OutputDevice::GetTextWidth(adAggregates[i].pctrlTextControl->GetText()),nMaxWidth);
838cdf0e10cSrcweir 		}
839cdf0e10cSrcweir 	}
840cdf0e10cSrcweir 
841cdf0e10cSrcweir 	OSL_ENSURE(nMaxWidth != 0,"Invalid width!");
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	// und los ...
844cdf0e10cSrcweir 	int nCurrentControlPos = 0;
845cdf0e10cSrcweir 	Control* pZOrderPredecessor = NULL;
846cdf0e10cSrcweir 	for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
847cdf0e10cSrcweir 	{
848cdf0e10cSrcweir 		if (adAggregates[i].pctrlInputControl)
849cdf0e10cSrcweir 		{
850cdf0e10cSrcweir 			SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0);
851cdf0e10cSrcweir 			SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument);
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 			// die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie
854cdf0e10cSrcweir 			// hier angeordnet wurden
855cdf0e10cSrcweir             adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST);
856cdf0e10cSrcweir 			adAggregates[i].pctrlInputControl->SetZOrder(adAggregates[i].pctrlTextControl, WINDOW_ZORDER_BEHIND );
857cdf0e10cSrcweir 			pZOrderPredecessor = adAggregates[i].pctrlInputControl;
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 			if (adAggregates[i].pctrlInputControl == pFormatSample)
860cdf0e10cSrcweir 			{
861cdf0e10cSrcweir 				pFormat->SetZOrder(pZOrderPredecessor, WINDOW_ZORDER_BEHIND);
862cdf0e10cSrcweir 				pZOrderPredecessor = pFormat;
863cdf0e10cSrcweir 			}
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 			++nCurrentControlPos;
866cdf0e10cSrcweir 		}
867cdf0e10cSrcweir 	}
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 	// eine Sonderbehandlung fuer die Format-Controls
870cdf0e10cSrcweir 	if (pFormat)
871cdf0e10cSrcweir 	{
872cdf0e10cSrcweir 		Point ptSamplePos(pFormatSample->GetPosPixel());
873cdf0e10cSrcweir 		Size szSampleSize(pFormatSample->GetSizePixel());
874cdf0e10cSrcweir 		pFormat->SetPosPixel(Point(ptSamplePos.X() + szSampleSize.Width() + 5, ptSamplePos.Y()));
875cdf0e10cSrcweir 	}
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 	// als letztes noch die ScrollBars in der ZOrder ganz nach oben
878cdf0e10cSrcweir 	m_pVertScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
879cdf0e10cSrcweir 	m_pHorzScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
880cdf0e10cSrcweir }
881cdf0e10cSrcweir 
882cdf0e10cSrcweir //------------------------------------------------------------------------------
ActivateAggregate(EControlType eType)883cdf0e10cSrcweir void OFieldDescControl::ActivateAggregate( EControlType eType )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
886cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
887cdf0e10cSrcweir 	// Controls erzeugen
888cdf0e10cSrcweir 	switch( eType )
889cdf0e10cSrcweir 	{
890cdf0e10cSrcweir 	case tpDefault:
891cdf0e10cSrcweir 		if( pDefault )
892cdf0e10cSrcweir 			return;
893cdf0e10cSrcweir 		m_nPos++;
894cdf0e10cSrcweir         pDefaultText = CreateText(STR_DEFAULT_VALUE);
895cdf0e10cSrcweir 		pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER );
896cdf0e10cSrcweir         InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false);
897cdf0e10cSrcweir 		break;
898cdf0e10cSrcweir 	case tpAutoIncrementValue:
899cdf0e10cSrcweir 		if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() )
900cdf0e10cSrcweir 			return;
901cdf0e10cSrcweir 		m_nPos++;
902cdf0e10cSrcweir         m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE);
903cdf0e10cSrcweir 		m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER );
904cdf0e10cSrcweir 		m_pAutoIncrementValue->SetText( getAutoIncrementValue() );
905cdf0e10cSrcweir         InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false);
906cdf0e10cSrcweir 		break;
907cdf0e10cSrcweir 
908cdf0e10cSrcweir 	case tpRequired:
909cdf0e10cSrcweir 	{
910cdf0e10cSrcweir 		if( pRequired )
911cdf0e10cSrcweir 			return;
912cdf0e10cSrcweir 		Reference< XDatabaseMetaData> xMetaData = getMetaData();
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 		if(xMetaData.is() && xMetaData->supportsNonNullableColumns())
915cdf0e10cSrcweir 		{
916cdf0e10cSrcweir 			m_nPos++;
917cdf0e10cSrcweir             pRequiredText = CreateText(STR_FIELD_REQUIRED);
918cdf0e10cSrcweir 			pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN);
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 			pRequired->InsertEntry( aYes );
921cdf0e10cSrcweir 			pRequired->InsertEntry( aNo );
922cdf0e10cSrcweir 			pRequired->SelectEntryPos(1);
923cdf0e10cSrcweir 
924cdf0e10cSrcweir             InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true);
925cdf0e10cSrcweir 		}
926cdf0e10cSrcweir 	}
927cdf0e10cSrcweir 	break;
928cdf0e10cSrcweir 	case tpAutoIncrement:
929cdf0e10cSrcweir 	{
930cdf0e10cSrcweir 		if( pAutoIncrement )
931cdf0e10cSrcweir 			return;
932cdf0e10cSrcweir 		m_nPos++;
933cdf0e10cSrcweir         pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT);
934cdf0e10cSrcweir 		pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN );
935cdf0e10cSrcweir 		pAutoIncrement->InsertEntry( aYes );
936cdf0e10cSrcweir 		pAutoIncrement->InsertEntry( aNo );
937cdf0e10cSrcweir 		pAutoIncrement->SelectEntryPos(0);
938cdf0e10cSrcweir         InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true);
939cdf0e10cSrcweir 	}
940cdf0e10cSrcweir 	break;
941cdf0e10cSrcweir 	case tpTextLen:
942cdf0e10cSrcweir 		if( pTextLen )
943cdf0e10cSrcweir 			return;
944cdf0e10cSrcweir 		m_nPos++;
945cdf0e10cSrcweir         pTextLenText = CreateText(STR_TEXT_LENGTH);
946cdf0e10cSrcweir         pTextLen = CreateNumericControl(STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN,HID_TAB_ENT_TEXT_LEN);
947cdf0e10cSrcweir 		break;
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 	case tpType:
950cdf0e10cSrcweir 		if( m_pType)
951cdf0e10cSrcweir 			return;
952cdf0e10cSrcweir 		m_nPos++;
953cdf0e10cSrcweir         m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE);
954cdf0e10cSrcweir 		m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN );
955cdf0e10cSrcweir 		m_pType->SetDropDownLineCount(20);
956cdf0e10cSrcweir 		{
957cdf0e10cSrcweir 			const OTypeInfoMap* pTypeInfo = getTypeInfo();
958cdf0e10cSrcweir 			OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
959cdf0e10cSrcweir             OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
960cdf0e10cSrcweir 			for(;aIter != aEnd;++aIter)
961cdf0e10cSrcweir 				m_pType->InsertEntry( aIter->second->aUIName );
962cdf0e10cSrcweir 		}
963cdf0e10cSrcweir 		m_pType->SelectEntryPos(0);
964cdf0e10cSrcweir         InitializeControl(m_pType,HID_TAB_ENT_TYPE,true);
965cdf0e10cSrcweir 		break;
966cdf0e10cSrcweir 	case tpColumnName:
967cdf0e10cSrcweir 		if( m_pColumnName )
968cdf0e10cSrcweir 			return;
969cdf0e10cSrcweir 		m_nPos++;
970cdf0e10cSrcweir         {
971cdf0e10cSrcweir             sal_uInt32 nMax = EDIT_NOLIMIT;
972cdf0e10cSrcweir             ::rtl::OUString aTmpString;
973cdf0e10cSrcweir             try
974cdf0e10cSrcweir             {
975cdf0e10cSrcweir 			    Reference< XDatabaseMetaData> xMetaData = getMetaData();
976cdf0e10cSrcweir                 if ( xMetaData.is() )
977cdf0e10cSrcweir                 {
978cdf0e10cSrcweir 			        nMax =  xMetaData->getMaxColumnNameLength();
979cdf0e10cSrcweir                     aTmpString = xMetaData->getExtraNameCharacters();
980cdf0e10cSrcweir                 }
981cdf0e10cSrcweir             }
982cdf0e10cSrcweir             catch(Exception&)
983cdf0e10cSrcweir             {
984cdf0e10cSrcweir                 DBG_UNHANDLED_EXCEPTION();
985cdf0e10cSrcweir             }
986cdf0e10cSrcweir             m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME);
987cdf0e10cSrcweir 			m_pColumnName = new OPropColumnEditCtrl( this,
988cdf0e10cSrcweir 							                        aTmpString,
989cdf0e10cSrcweir 													STR_HELP_DEFAULT_VALUE,
990cdf0e10cSrcweir 													FIELD_PRPOERTY_COLUMNNAME,
991cdf0e10cSrcweir 													WB_BORDER );
992cdf0e10cSrcweir 			m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT));
993cdf0e10cSrcweir 			m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) );
994cdf0e10cSrcweir 		}
995cdf0e10cSrcweir 
996cdf0e10cSrcweir         InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false);
997cdf0e10cSrcweir 		break;
998cdf0e10cSrcweir 	case tpNumType:
999cdf0e10cSrcweir 		if( pNumType )
1000cdf0e10cSrcweir 			return;
1001cdf0e10cSrcweir 		m_nPos++;
1002cdf0e10cSrcweir         pNumTypeText = CreateText(STR_NUMERIC_TYPE);
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 		pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN );
1005cdf0e10cSrcweir 		pNumType->SetDropDownLineCount(5);
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 		pNumType->InsertEntry( String::CreateFromAscii("Byte") );
1008cdf0e10cSrcweir 		pNumType->InsertEntry( String::CreateFromAscii("SmallInt") );
1009cdf0e10cSrcweir 		pNumType->InsertEntry( String::CreateFromAscii("Integer") );
1010cdf0e10cSrcweir 		pNumType->InsertEntry( String::CreateFromAscii("Single") );
1011cdf0e10cSrcweir 		pNumType->InsertEntry( String::CreateFromAscii("Double") );
1012cdf0e10cSrcweir 		pNumType->SelectEntryPos(2);
1013cdf0e10cSrcweir         InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true);
1014cdf0e10cSrcweir 		break;
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 	case tpLength:
1017cdf0e10cSrcweir 		if( pLength )
1018cdf0e10cSrcweir 			return;
1019cdf0e10cSrcweir 		m_nPos++;
1020cdf0e10cSrcweir         pLengthText = CreateText(STR_LENGTH);
1021cdf0e10cSrcweir         pLength = CreateNumericControl(STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH,HID_TAB_ENT_LEN);
1022cdf0e10cSrcweir 		break;
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	case tpScale:
1025cdf0e10cSrcweir 		if( pScale )
1026cdf0e10cSrcweir 			return;
1027cdf0e10cSrcweir 		m_nPos++;
1028cdf0e10cSrcweir         pScaleText = CreateText(STR_SCALE);
1029cdf0e10cSrcweir         pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE);
1030cdf0e10cSrcweir 		break;
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 	case tpFormat:
1033cdf0e10cSrcweir 		if (!pFormat)
1034cdf0e10cSrcweir 		{
1035cdf0e10cSrcweir 			m_nPos++;
1036cdf0e10cSrcweir             pFormatText = CreateText(STR_FORMAT);
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 			pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER );
1039cdf0e10cSrcweir 			pFormatSample->SetReadOnly(sal_True);
1040cdf0e10cSrcweir 			pFormatSample->Enable(sal_False);
1041cdf0e10cSrcweir             InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false);
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 			pFormat = new PushButton( this, ModuleRes(PB_FORMAT) );
1044cdf0e10cSrcweir             const sal_Int32 nControlHeight = GetMaxControlHeight();
1045cdf0e10cSrcweir 			pFormat->SetSizePixel(Size(nControlHeight, nControlHeight));
1046cdf0e10cSrcweir 			pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) );
1047cdf0e10cSrcweir             InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false);
1048cdf0e10cSrcweir 		}
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 		UpdateFormatSample(pActFieldDescr);
1051cdf0e10cSrcweir 		break;
1052cdf0e10cSrcweir 	case tpBoolDefault:
1053cdf0e10cSrcweir 		if (pBoolDefault)
1054cdf0e10cSrcweir 			return;
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 		m_nPos++;
1057cdf0e10cSrcweir         pBoolDefaultText = CreateText(STR_DEFAULT_VALUE);
1058cdf0e10cSrcweir 		pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN );
1059cdf0e10cSrcweir 		pBoolDefault->SetDropDownLineCount(3);
1060cdf0e10cSrcweir 		pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
1061cdf0e10cSrcweir 		pBoolDefault->InsertEntry(aYes);
1062cdf0e10cSrcweir 		pBoolDefault->InsertEntry(aNo);
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir         InitializeControl(pBoolDefault,HID_TAB_ENT_BOOL_DEFAULT,false);
1065cdf0e10cSrcweir 		break;
1066cdf0e10cSrcweir 	}
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir // -----------------------------------------------------------------------------
InitializeControl(Control * _pControl,const::rtl::OString & _sHelpId,bool _bAddChangeHandler)1069cdf0e10cSrcweir void OFieldDescControl::InitializeControl(Control* _pControl,const ::rtl::OString& _sHelpId,bool _bAddChangeHandler)
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     _pControl->SetHelpId(_sHelpId);
1072cdf0e10cSrcweir     if ( _bAddChangeHandler )
1073cdf0e10cSrcweir 	    ((OPropListBoxCtrl*)_pControl)->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl));
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir 	_pControl->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot));
1076cdf0e10cSrcweir 	_pControl->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost));
1077cdf0e10cSrcweir 	_pControl->EnableClipSiblings();
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir // -----------------------------------------------------------------------------
CreateText(sal_uInt16 _nTextRes)1080cdf0e10cSrcweir FixedText* OFieldDescControl::CreateText(sal_uInt16 _nTextRes)
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir     FixedText* pFixedText = new FixedText( this );
1083cdf0e10cSrcweir 	pFixedText->SetText( ModuleRes(_nTextRes) );
1084cdf0e10cSrcweir     pFixedText->EnableClipSiblings();
1085cdf0e10cSrcweir     return pFixedText;
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir // -----------------------------------------------------------------------------
CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString & _sHelpId)1088cdf0e10cSrcweir OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId)
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir     OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER );
1091cdf0e10cSrcweir 	pControl->SetDecimalDigits(0);
1092cdf0e10cSrcweir 	pControl->SetMin(0);
1093cdf0e10cSrcweir 	pControl->SetMax(0x7FFFFFFF);	// soll draussen geaendert werden, wenn noetig
1094cdf0e10cSrcweir 	pControl->SetStrictFormat(sal_True);
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir     InitializeControl(pControl,_sHelpId,false);
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir     return pControl;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir //------------------------------------------------------------------------------
DeactivateAggregate(EControlType eType)1101cdf0e10cSrcweir void OFieldDescControl::DeactivateAggregate( EControlType eType )
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1104cdf0e10cSrcweir     pLastFocusWindow = NULL;
1105cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1106cdf0e10cSrcweir 	// Controls zerstoeren
1107cdf0e10cSrcweir 	switch( eType )
1108cdf0e10cSrcweir 	{
1109cdf0e10cSrcweir 	case tpDefault:
1110cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText);
1111cdf0e10cSrcweir 		break;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 	case tpAutoIncrementValue:
1114cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText);
1115cdf0e10cSrcweir 		break;
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 	case tpColumnName:
1118cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText);
1119cdf0e10cSrcweir 		break;
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir 	case tpType:
1122cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText);
1123cdf0e10cSrcweir 		break;
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir 	case tpAutoIncrement:
1126cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText);
1127cdf0e10cSrcweir 		break;
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 	case tpRequired:
1130cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText);
1131cdf0e10cSrcweir 		break;
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 	case tpTextLen:
1134cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText);
1135cdf0e10cSrcweir 		break;
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir 	case tpNumType:
1138cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText);
1139cdf0e10cSrcweir 		break;
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 	case tpLength:
1142cdf0e10cSrcweir 		lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText);
1143cdf0e10cSrcweir 		break;
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 	case tpScale:
1146cdf0e10cSrcweir 		lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText);
1147cdf0e10cSrcweir 		break;
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir 	case tpFormat:
1150cdf0e10cSrcweir         // TODO: we have to check if we have to increment m_nPos again
1151cdf0e10cSrcweir         lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText);
1152cdf0e10cSrcweir         if ( pFormatSample )
1153cdf0e10cSrcweir         {
1154cdf0e10cSrcweir 		    pFormatSample->Hide();
1155cdf0e10cSrcweir 		    delete pFormatSample;
1156cdf0e10cSrcweir 		    pFormatSample = NULL;
1157cdf0e10cSrcweir         }
1158cdf0e10cSrcweir 		break;
1159cdf0e10cSrcweir 	case tpBoolDefault:
1160cdf0e10cSrcweir 		lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText);
1161cdf0e10cSrcweir 		break;
1162cdf0e10cSrcweir 	}
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir //------------------------------------------------------------------------------
SetPosSize(Control ** ppControl,long nRow,sal_uInt16 nCol)1166cdf0e10cSrcweir void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol )
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1171cdf0e10cSrcweir 	// Groesse ermitteln
1172cdf0e10cSrcweir     const sal_Int32 nControlHeight = GetMaxControlHeight();
1173cdf0e10cSrcweir 	Size aSize(0,nControlHeight);
1174cdf0e10cSrcweir     if ( isRightAligned() && nCol )
1175cdf0e10cSrcweir         aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width();
1176cdf0e10cSrcweir     else
1177cdf0e10cSrcweir     {
1178cdf0e10cSrcweir 	    switch( nCol )
1179cdf0e10cSrcweir 	    {
1180cdf0e10cSrcweir 	    case 0:
1181cdf0e10cSrcweir         default:
1182cdf0e10cSrcweir 		    aSize.Width()  = CONTROL_WIDTH_1;
1183cdf0e10cSrcweir 		    break;
1184cdf0e10cSrcweir 	    case 1:
1185cdf0e10cSrcweir 			aSize.Width()  = CONTROL_WIDTH_2;
1186cdf0e10cSrcweir 		    break;
1187cdf0e10cSrcweir 	    case 3:
1188cdf0e10cSrcweir 			aSize.Width()  = CONTROL_WIDTH_3;
1189cdf0e10cSrcweir 		    break;
1190cdf0e10cSrcweir 	    case 4:
1191cdf0e10cSrcweir 			aSize.Width()  = CONTROL_WIDTH_4;
1192cdf0e10cSrcweir 		    break;
1193cdf0e10cSrcweir 	    } // switch( nCol )
1194cdf0e10cSrcweir     }
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1198cdf0e10cSrcweir 	// Position ermitteln
1199cdf0e10cSrcweir 	Point aPosition;
1200cdf0e10cSrcweir 	switch( nCol )
1201cdf0e10cSrcweir 	{
1202cdf0e10cSrcweir 	case 0:
1203cdf0e10cSrcweir 		aPosition.X() = 0;
1204cdf0e10cSrcweir 		aPosition.Y() = 1;
1205cdf0e10cSrcweir 		break;
1206cdf0e10cSrcweir 	case 1:
1207cdf0e10cSrcweir 	case 3:
1208cdf0e10cSrcweir 	case 4:
1209cdf0e10cSrcweir 		if ( isRightAligned() )
1210cdf0e10cSrcweir 		{
1211cdf0e10cSrcweir 			Size aOwnSize = GetSizePixel();
1212cdf0e10cSrcweir 			aPosition.X() = aOwnSize.Width() - aSize.Width();
1213cdf0e10cSrcweir 		}
1214cdf0e10cSrcweir 		else
1215cdf0e10cSrcweir 			aPosition.X() = CONTROL_WIDTH_1 + CONTROL_SPACING_X;
1216cdf0e10cSrcweir 		break;
1217cdf0e10cSrcweir 	default:
1218cdf0e10cSrcweir 		aPosition.X() = 0;
1219cdf0e10cSrcweir 	}
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir     (*ppControl)->SetSizePixel( aSize );
1222cdf0e10cSrcweir     aSize = (*ppControl)->GetSizePixel( );
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir     const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
1225cdf0e10cSrcweir 	aPosition.Y() += ((nRow+1)*nControl_Spacing_y) +
1226cdf0e10cSrcweir 					(nRow*nControlHeight);
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1229cdf0e10cSrcweir 	// Control anzeigen
1230cdf0e10cSrcweir 	(*ppControl)->SetPosSizePixel( aPosition, aSize );
1231cdf0e10cSrcweir     aSize = (*ppControl)->GetSizePixel();
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir 	(*ppControl)->Show();
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir //------------------------------------------------------------------------------
DisplayData(OFieldDescription * pFieldDescr)1236cdf0e10cSrcweir void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr )
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1239cdf0e10cSrcweir 	pActFieldDescr = pFieldDescr;
1240cdf0e10cSrcweir 	if(!pFieldDescr)
1241cdf0e10cSrcweir 	{
1242cdf0e10cSrcweir 		DeactivateAggregate( tpDefault );
1243cdf0e10cSrcweir 		DeactivateAggregate( tpRequired );
1244cdf0e10cSrcweir 		DeactivateAggregate( tpTextLen );
1245cdf0e10cSrcweir 		DeactivateAggregate( tpNumType );
1246cdf0e10cSrcweir 		DeactivateAggregate( tpScale );
1247cdf0e10cSrcweir 		DeactivateAggregate( tpLength );
1248cdf0e10cSrcweir 		DeactivateAggregate( tpFormat );
1249cdf0e10cSrcweir 		DeactivateAggregate( tpAutoIncrement );
1250cdf0e10cSrcweir 		DeactivateAggregate( tpBoolDefault );
1251cdf0e10cSrcweir 		DeactivateAggregate( tpColumnName );
1252cdf0e10cSrcweir 		DeactivateAggregate( tpType );
1253cdf0e10cSrcweir 		DeactivateAggregate( tpAutoIncrementValue );
1254cdf0e10cSrcweir 		m_pPreviousType = TOTypeInfoSP();
1255cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1256cdf0e10cSrcweir 		// Zeiger des gespeicherten Focus zuruecksetzen
1257cdf0e10cSrcweir 		pLastFocusWindow = NULL;
1258cdf0e10cSrcweir         if ( m_bAdded )
1259cdf0e10cSrcweir         {
1260cdf0e10cSrcweir 		    ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
1261cdf0e10cSrcweir             m_bAdded = sal_False;
1262cdf0e10cSrcweir         }
1263cdf0e10cSrcweir 		return;
1264cdf0e10cSrcweir 	}
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir     if ( !m_bAdded )
1267cdf0e10cSrcweir     {
1268cdf0e10cSrcweir 	    ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::AddWindow));
1269cdf0e10cSrcweir         m_bAdded = sal_True;
1270cdf0e10cSrcweir     }
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir 	TOTypeInfoSP pFieldType;
1273cdf0e10cSrcweir 	if( pFieldDescr )
1274cdf0e10cSrcweir 		pFieldType = pFieldDescr->getTypeInfo();
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir 	ActivateAggregate( tpColumnName );
1277cdf0e10cSrcweir 	ActivateAggregate( tpType );
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir 	OSL_ENSURE(pFieldType.get(),"We need a type information here!");
1280cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1281cdf0e10cSrcweir 	// Wenn sich der Typ geaendert hat, Controls austauschen
1282cdf0e10cSrcweir 	if( m_pPreviousType != pFieldType )
1283cdf0e10cSrcweir 	{
1284cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1285cdf0e10cSrcweir 		// Zeiger des gespeicherten Focus zuruecksetzen
1286cdf0e10cSrcweir 		pLastFocusWindow = NULL;
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1289cdf0e10cSrcweir 		// Controls, die nicht mehr angezeigt werden duerfen
1290cdf0e10cSrcweir 		DeactivateAggregate( tpNumType );
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1293cdf0e10cSrcweir 		// determine which controls we should show and which not
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 		// 1. the required control
1296cdf0e10cSrcweir 		if ( pFieldType->bNullable )
1297cdf0e10cSrcweir 			ActivateAggregate( tpRequired );
1298cdf0e10cSrcweir 		else
1299cdf0e10cSrcweir 			DeactivateAggregate( tpRequired );
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 		// 2. the autoincrement
1302cdf0e10cSrcweir 		if ( pFieldType->bAutoIncrement )
1303cdf0e10cSrcweir 		{
1304cdf0e10cSrcweir 			DeactivateAggregate( tpRequired );
1305cdf0e10cSrcweir 			DeactivateAggregate( tpDefault );
1306cdf0e10cSrcweir 			ActivateAggregate( tpAutoIncrement );
1307cdf0e10cSrcweir 			ActivateAggregate( tpAutoIncrementValue );
1308cdf0e10cSrcweir 		}
1309cdf0e10cSrcweir 		else
1310cdf0e10cSrcweir 		{
1311cdf0e10cSrcweir 			DeactivateAggregate( tpAutoIncrement );
1312cdf0e10cSrcweir 			DeactivateAggregate( tpAutoIncrementValue );
1313cdf0e10cSrcweir 			if(pFieldType->bNullable)
1314cdf0e10cSrcweir 				ActivateAggregate( tpRequired );
1315cdf0e10cSrcweir 			else
1316cdf0e10cSrcweir 				DeactivateAggregate( tpRequired );
1317cdf0e10cSrcweir 			ActivateAggregate( tpDefault );
1318cdf0e10cSrcweir 		}
1319cdf0e10cSrcweir 		// 3. the scale and precision
1320cdf0e10cSrcweir 		if (pFieldType->nPrecision)
1321cdf0e10cSrcweir 		{
1322cdf0e10cSrcweir 			ActivateAggregate( tpLength );
1323cdf0e10cSrcweir 			pLength->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
1324cdf0e10cSrcweir 			pLength->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
1325cdf0e10cSrcweir 		}
1326cdf0e10cSrcweir 		else
1327cdf0e10cSrcweir 			DeactivateAggregate( tpLength );
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 		if (pFieldType->nMaximumScale)
1330cdf0e10cSrcweir 		{
1331cdf0e10cSrcweir 			ActivateAggregate( tpScale );
1332cdf0e10cSrcweir 			pScale->SetMax(::std::max<sal_Int32>(pFieldType->nMaximumScale,pFieldDescr->GetScale()));
1333cdf0e10cSrcweir 			pScale->SetMin(pFieldType->nMinimumScale);
1334cdf0e10cSrcweir             static const ::rtl::OUString s_sPRECISION(RTL_CONSTASCII_USTRINGPARAM("PRECISION"));
1335cdf0e10cSrcweir 			pScale->SetSpecialReadOnly(pFieldType->aCreateParams.getLength() == 0 || pFieldType->aCreateParams == s_sPRECISION);
1336cdf0e10cSrcweir 		}
1337cdf0e10cSrcweir 		else
1338cdf0e10cSrcweir 			DeactivateAggregate( tpScale );
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir 		// and now look for type specific things
1341cdf0e10cSrcweir 		switch( pFieldType->nType )
1342cdf0e10cSrcweir 		{
1343cdf0e10cSrcweir 			case DataType::CHAR:
1344cdf0e10cSrcweir 			case DataType::VARCHAR:
1345cdf0e10cSrcweir 			case DataType::LONGVARCHAR:
1346cdf0e10cSrcweir 				DeactivateAggregate( tpLength );
1347cdf0e10cSrcweir 				DeactivateAggregate( tpBoolDefault );
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 				ActivateAggregate( tpDefault );
1350cdf0e10cSrcweir 				ActivateAggregate( tpFormat );
1351cdf0e10cSrcweir 				if (pFieldType->nPrecision)
1352cdf0e10cSrcweir 				{
1353cdf0e10cSrcweir 					ActivateAggregate( tpTextLen );
1354cdf0e10cSrcweir 					pTextLen->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
1355cdf0e10cSrcweir 					pTextLen->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
1356cdf0e10cSrcweir 				}
1357cdf0e10cSrcweir 				else
1358cdf0e10cSrcweir 					DeactivateAggregate( tpTextLen );
1359cdf0e10cSrcweir 				break;
1360cdf0e10cSrcweir 			case DataType::DATE:
1361cdf0e10cSrcweir 			case DataType::TIME:
1362cdf0e10cSrcweir 			case DataType::TIMESTAMP:
1363cdf0e10cSrcweir 				DeactivateAggregate( tpLength ); // we don't need a length for date types
1364cdf0e10cSrcweir 				DeactivateAggregate( tpTextLen );
1365cdf0e10cSrcweir 				DeactivateAggregate( tpBoolDefault );
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 				ActivateAggregate( tpDefault );
1368cdf0e10cSrcweir 				ActivateAggregate( tpFormat );
1369cdf0e10cSrcweir 				break;
1370cdf0e10cSrcweir 			case DataType::BIT:
1371cdf0e10cSrcweir 				if ( pFieldType->aCreateParams.getLength() )
1372cdf0e10cSrcweir 				{
1373cdf0e10cSrcweir 					DeactivateAggregate( tpFormat );
1374cdf0e10cSrcweir 					DeactivateAggregate( tpTextLen );
1375cdf0e10cSrcweir 					DeactivateAggregate( tpBoolDefault );
1376cdf0e10cSrcweir 					break;
1377cdf0e10cSrcweir 				}
1378cdf0e10cSrcweir 				// run through
1379cdf0e10cSrcweir 			case DataType::BOOLEAN:
1380cdf0e10cSrcweir 				DeactivateAggregate( tpTextLen );
1381cdf0e10cSrcweir 				DeactivateAggregate( tpFormat );
1382cdf0e10cSrcweir 				DeactivateAggregate( tpDefault );
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir 				ActivateAggregate( tpBoolDefault );
1385cdf0e10cSrcweir 				break;
1386cdf0e10cSrcweir 			case DataType::DECIMAL:
1387cdf0e10cSrcweir 			case DataType::NUMERIC:
1388cdf0e10cSrcweir 			case DataType::BIGINT:
1389cdf0e10cSrcweir 			case DataType::FLOAT:
1390cdf0e10cSrcweir 			case DataType::DOUBLE:
1391cdf0e10cSrcweir 			case DataType::TINYINT:
1392cdf0e10cSrcweir 			case DataType::SMALLINT:
1393cdf0e10cSrcweir 			case DataType::INTEGER:
1394cdf0e10cSrcweir 			case DataType::REAL:
1395cdf0e10cSrcweir 				DeactivateAggregate( tpTextLen );
1396cdf0e10cSrcweir 				DeactivateAggregate( tpBoolDefault );
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir 				ActivateAggregate( tpFormat );
1399cdf0e10cSrcweir 				break;
1400cdf0e10cSrcweir 			case DataType::BINARY:
1401cdf0e10cSrcweir 			case DataType::VARBINARY:
1402cdf0e10cSrcweir 				DeactivateAggregate( tpDefault );
1403cdf0e10cSrcweir 				DeactivateAggregate( tpRequired );
1404cdf0e10cSrcweir 				DeactivateAggregate( tpTextLen );
1405cdf0e10cSrcweir 				DeactivateAggregate( tpBoolDefault );
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 				ActivateAggregate( tpFormat );
1408cdf0e10cSrcweir 				break;
1409cdf0e10cSrcweir 			case DataType::LONGVARBINARY:
1410cdf0e10cSrcweir 			case DataType::SQLNULL:
1411cdf0e10cSrcweir 			case DataType::OBJECT:
1412cdf0e10cSrcweir 			case DataType::DISTINCT:
1413cdf0e10cSrcweir 			case DataType::STRUCT:
1414cdf0e10cSrcweir 			case DataType::ARRAY:
1415cdf0e10cSrcweir 			case DataType::BLOB:
1416cdf0e10cSrcweir 			case DataType::CLOB:
1417cdf0e10cSrcweir 			case DataType::REF:
1418cdf0e10cSrcweir 			case DataType::OTHER:
1419cdf0e10cSrcweir 				DeactivateAggregate( tpFormat );
1420cdf0e10cSrcweir 				DeactivateAggregate( tpTextLen );
1421cdf0e10cSrcweir 				DeactivateAggregate( tpBoolDefault );
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir 				break;
1424cdf0e10cSrcweir 			default:
1425cdf0e10cSrcweir 				OSL_ENSURE(0,"Unknown type");
1426cdf0e10cSrcweir 		}
1427cdf0e10cSrcweir 		m_pPreviousType = pFieldType;
1428cdf0e10cSrcweir 	}
1429cdf0e10cSrcweir 	if(pFieldDescr)
1430cdf0e10cSrcweir 	{
1431cdf0e10cSrcweir 		if(pFieldDescr->IsPrimaryKey())
1432cdf0e10cSrcweir 		{
1433cdf0e10cSrcweir 			DeactivateAggregate( tpRequired );
1434cdf0e10cSrcweir 		}
1435cdf0e10cSrcweir 		else if ( !pAutoIncrement && pFieldType.get() )
1436cdf0e10cSrcweir 		{
1437cdf0e10cSrcweir 			if ( pFieldType->bNullable )
1438cdf0e10cSrcweir 				ActivateAggregate( tpRequired );
1439cdf0e10cSrcweir 			else
1440cdf0e10cSrcweir 				DeactivateAggregate( tpRequired );
1441cdf0e10cSrcweir 		}
1442cdf0e10cSrcweir 	}
1443cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1444cdf0e10cSrcweir 	// Controls initialisieren
1445cdf0e10cSrcweir 	if( pAutoIncrement )
1446cdf0e10cSrcweir 	{
1447cdf0e10cSrcweir 		if ( pFieldDescr->IsAutoIncrement() )
1448cdf0e10cSrcweir 		{
1449cdf0e10cSrcweir 			pAutoIncrement->SelectEntryPos( 0 ); // yes
1450cdf0e10cSrcweir             ActivateAggregate( tpAutoIncrementValue );
1451cdf0e10cSrcweir 			if ( m_pAutoIncrementValue )
1452cdf0e10cSrcweir 				m_pAutoIncrementValue->SetText(pFieldDescr->GetAutoIncrementValue());
1453cdf0e10cSrcweir 			DeactivateAggregate( tpRequired );
1454cdf0e10cSrcweir 			DeactivateAggregate( tpDefault );
1455cdf0e10cSrcweir 		}
1456cdf0e10cSrcweir 		else
1457cdf0e10cSrcweir 		{
1458cdf0e10cSrcweir 			// disable autoincrement value because it should only be visible when autoincrement is to true
1459cdf0e10cSrcweir 			DeactivateAggregate( tpAutoIncrementValue );
1460cdf0e10cSrcweir 			pAutoIncrement->SelectEntryPos( 1 );		// no
1461cdf0e10cSrcweir 			ActivateAggregate( tpDefault );
1462cdf0e10cSrcweir 			// hat Auswirkungen auf pRequired
1463cdf0e10cSrcweir 			if(!pFieldDescr->IsPrimaryKey())
1464cdf0e10cSrcweir 				ActivateAggregate( tpRequired );
1465cdf0e10cSrcweir 		}
1466cdf0e10cSrcweir 	}
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir 	if( pDefault )
1469cdf0e10cSrcweir 	{
1470cdf0e10cSrcweir 		pDefault->SetText( getControlDefault(pFieldDescr) );
1471cdf0e10cSrcweir 		pDefault->ClearModifyFlag();
1472cdf0e10cSrcweir 	}
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 	if( pBoolDefault )
1475cdf0e10cSrcweir 	{
1476cdf0e10cSrcweir 		// wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
1477cdf0e10cSrcweir 		::rtl::OUString sValue;
1478cdf0e10cSrcweir 		pFieldDescr->GetControlDefault() >>= sValue;
1479cdf0e10cSrcweir 		String sDef = BoolStringUI(sValue);
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir 		// sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf
1482cdf0e10cSrcweir 		if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() )
1483cdf0e10cSrcweir 		{
1484cdf0e10cSrcweir 			pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // der Typ sagt das
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir 			pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
1487cdf0e10cSrcweir 			if ( !sDef.Equals(aYes) && !sDef.Equals(aNo) )
1488cdf0e10cSrcweir 				pBoolDefault->SelectEntryPos(1);  // nein als Default
1489cdf0e10cSrcweir 			else
1490cdf0e10cSrcweir 				pBoolDefault->SelectEntry(sDef);
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 			pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(BoolStringPersistent(pBoolDefault->GetSelectEntry()))));
1493cdf0e10cSrcweir 		}
1494cdf0e10cSrcweir 		else if(pBoolDefault->GetEntryCount() < 3)
1495cdf0e10cSrcweir 		{
1496cdf0e10cSrcweir 			pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
1497cdf0e10cSrcweir 			pBoolDefault->SelectEntry(sDef);
1498cdf0e10cSrcweir 		}
1499cdf0e10cSrcweir 		else
1500cdf0e10cSrcweir 			pBoolDefault->SelectEntry(sDef);
1501cdf0e10cSrcweir 	}
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir 	if( pRequired )
1504cdf0e10cSrcweir 	{
1505cdf0e10cSrcweir 		if( pFieldDescr->IsNullable() )
1506cdf0e10cSrcweir 			pRequired->SelectEntryPos( 1 );	// no
1507cdf0e10cSrcweir 		else
1508cdf0e10cSrcweir 			pRequired->SelectEntryPos( 0 );	// yes
1509cdf0e10cSrcweir 	}
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 	if( pTextLen )
1512cdf0e10cSrcweir 	{
1513cdf0e10cSrcweir 		pTextLen->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
1514cdf0e10cSrcweir 		pTextLen->ClearModifyFlag();
1515cdf0e10cSrcweir 	}
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir 	if( pNumType )
1518cdf0e10cSrcweir 	{
1519cdf0e10cSrcweir 		OSL_ENSURE(sal_False, "OFieldDescControl::DisplayData: invalid num type!");
1520cdf0e10cSrcweir 	}
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir 	if( pLength )
1523cdf0e10cSrcweir 		pLength->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 	if( pScale )
1526cdf0e10cSrcweir 		pScale->SetText( String::CreateFromInt32(pFieldDescr->GetScale()) );
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir 	if( pFormat )
1529cdf0e10cSrcweir 		UpdateFormatSample(pFieldDescr);
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir 	if(m_pColumnName)
1532cdf0e10cSrcweir 		m_pColumnName->SetText(pFieldDescr->GetName());
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 	if(m_pType)
1535cdf0e10cSrcweir 	{
1536cdf0e10cSrcweir 		sal_uInt16 nPos = pFieldType.get() ? m_pType->GetEntryPos(String(pFieldDescr->getTypeInfo()->aUIName)) : LISTBOX_ENTRY_NOTFOUND;
1537cdf0e10cSrcweir 		if(nPos == LISTBOX_ENTRY_NOTFOUND)
1538cdf0e10cSrcweir 		{
1539cdf0e10cSrcweir 			const OTypeInfoMap*	pMap = getTypeInfo();
1540cdf0e10cSrcweir 			OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType.get() ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType());
1541cdf0e10cSrcweir 			if(aIter == pMap->end() && !pMap->empty())
1542cdf0e10cSrcweir 			{
1543cdf0e10cSrcweir 				aIter = pMap->begin();
1544cdf0e10cSrcweir 				if(pFieldDescr->GetPrecision() > aIter->second->nPrecision)
1545cdf0e10cSrcweir 					pFieldDescr->SetPrecision(aIter->second->nPrecision);
1546cdf0e10cSrcweir 				if(pFieldDescr->GetScale() > aIter->second->nMaximumScale)
1547cdf0e10cSrcweir 					pFieldDescr->SetScale(0);
1548cdf0e10cSrcweir 				if(!aIter->second->bNullable && pFieldDescr->IsNullable())
1549cdf0e10cSrcweir 					pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
1550cdf0e10cSrcweir 				if(!aIter->second->bAutoIncrement && pFieldDescr->IsAutoIncrement())
1551cdf0e10cSrcweir 					pFieldDescr->SetAutoIncrement(sal_False);
1552cdf0e10cSrcweir 			}
1553cdf0e10cSrcweir 			if ( aIter != pMap->end() )
1554cdf0e10cSrcweir 			{
1555cdf0e10cSrcweir 				pFieldDescr->SetType(aIter->second);
1556cdf0e10cSrcweir 			}
1557cdf0e10cSrcweir 		}
1558cdf0e10cSrcweir 		m_pType->SelectEntry(pFieldDescr->getTypeInfo()->aUIName);
1559cdf0e10cSrcweir 	}
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1563cdf0e10cSrcweir 	// Controls Enablen/Disablen
1564cdf0e10cSrcweir 	sal_Bool bRead(IsReadOnly());
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 	ArrangeAggregates();
1568cdf0e10cSrcweir 	CheckScrollBars();
1569cdf0e10cSrcweir 	ScrollAllAggregates();
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir 	SetReadOnly( bRead );
1572cdf0e10cSrcweir }
1573cdf0e10cSrcweir //------------------------------------------------------------------------
IMPL_LINK(OFieldDescControl,DelayedGrabFocus,Control **,ppControl)1574cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, DelayedGrabFocus, Control**, ppControl)
1575cdf0e10cSrcweir {
1576cdf0e10cSrcweir 	nDelayedGrabFocusEvent = 0;
1577cdf0e10cSrcweir 	if (*ppControl)
1578cdf0e10cSrcweir 		(*ppControl)->GrabFocus();
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir 	return 0L;
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OFieldDescControl,OnControlFocusGot,Control *,pControl)1584cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl )
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir 	String strHelpText;
1587cdf0e10cSrcweir     OPropNumericEditCtrl* pNumeric = dynamic_cast< OPropNumericEditCtrl* >( pControl );
1588cdf0e10cSrcweir     if ( pNumeric )
1589cdf0e10cSrcweir 	{
1590cdf0e10cSrcweir 		pNumeric->SaveValue();
1591cdf0e10cSrcweir 		strHelpText = pNumeric->GetHelp();
1592cdf0e10cSrcweir 	}
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir     OPropColumnEditCtrl* pColumn = dynamic_cast< OPropColumnEditCtrl* >( pControl );
1595cdf0e10cSrcweir     if ( pColumn )
1596cdf0e10cSrcweir 	{
1597cdf0e10cSrcweir 		pColumn->SaveValue();
1598cdf0e10cSrcweir 		strHelpText = pColumn->GetHelp();
1599cdf0e10cSrcweir 	}
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     OPropEditCtrl* pEdit = dynamic_cast< OPropEditCtrl* >( pControl );
1602cdf0e10cSrcweir     if ( pEdit )
1603cdf0e10cSrcweir 	{
1604cdf0e10cSrcweir 		pEdit->SaveValue();
1605cdf0e10cSrcweir 		strHelpText = pEdit->GetHelp();
1606cdf0e10cSrcweir 	}
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir     OPropListBoxCtrl* pListBox = dynamic_cast< OPropListBoxCtrl* >( pControl );
1609cdf0e10cSrcweir     if ( pListBox )
1610cdf0e10cSrcweir 	{
1611cdf0e10cSrcweir 		pListBox->SaveValue();
1612cdf0e10cSrcweir 		strHelpText = pListBox->GetHelp();
1613cdf0e10cSrcweir 	}
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir     if (pControl == pFormat)
1616cdf0e10cSrcweir 		strHelpText  =String(ModuleRes(STR_HELP_FORMAT_BUTTON));
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir 	if (strHelpText.Len() && (pHelp != NULL))
1619cdf0e10cSrcweir 		pHelp->SetHelpText(strHelpText);
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir 	m_pActFocusWindow = pControl;
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	return 0L;
1624cdf0e10cSrcweir }
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OFieldDescControl,OnControlFocusLost,Control *,pControl)1627cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnControlFocusLost, Control*, pControl )
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir 	if ((pControl == pLength) || (pControl == pTextLen) || (pControl == pScale))
1630cdf0e10cSrcweir 	{
1631cdf0e10cSrcweir 		OPropNumericEditCtrl* pConverted = (OPropNumericEditCtrl*)pControl;
1632cdf0e10cSrcweir 		if (pConverted->IsModified())
1633cdf0e10cSrcweir 			CellModified(-1, pConverted->GetPos());
1634cdf0e10cSrcweir 	}
1635cdf0e10cSrcweir 	if(pControl == m_pColumnName)
1636cdf0e10cSrcweir 	{
1637cdf0e10cSrcweir 		OPropColumnEditCtrl* pConverted = (OPropColumnEditCtrl*)pControl;
1638cdf0e10cSrcweir 		if (pConverted->IsModified())
1639cdf0e10cSrcweir 			CellModified(-1, pConverted->GetPos());
1640cdf0e10cSrcweir 	}
1641cdf0e10cSrcweir 	else if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pAutoIncrementValue) )
1642cdf0e10cSrcweir 	{
1643cdf0e10cSrcweir 		OPropEditCtrl* pConverted = (OPropEditCtrl*)pControl;
1644cdf0e10cSrcweir 		if (pConverted->IsModified())
1645cdf0e10cSrcweir 			CellModified(-1, pConverted->GetPos());
1646cdf0e10cSrcweir 	}
1647cdf0e10cSrcweir 	else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType))
1648cdf0e10cSrcweir 	{
1649cdf0e10cSrcweir 		OPropListBoxCtrl* pConverted = (OPropListBoxCtrl*)pControl;
1650cdf0e10cSrcweir 		if (pConverted->IsModified())
1651cdf0e10cSrcweir 			CellModified(-1, pConverted->GetPos());
1652cdf0e10cSrcweir 	}
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir 	if (pControl == pDefault)
1655cdf0e10cSrcweir 		UpdateFormatSample(pActFieldDescr);
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir 	implFocusLost(pControl);
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir 	return 0L;
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir //------------------------------------------------------------------------------
SaveData(OFieldDescription * pFieldDescr)1662cdf0e10cSrcweir void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr )
1663cdf0e10cSrcweir {
1664cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1665cdf0e10cSrcweir 	if( !pFieldDescr )
1666cdf0e10cSrcweir 		return;
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1669cdf0e10cSrcweir 	// Controls auslesen
1670cdf0e10cSrcweir 	::rtl::OUString sDefault;
1671cdf0e10cSrcweir 	if (pDefault)
1672cdf0e10cSrcweir 	{
1673cdf0e10cSrcweir 		sDefault = pDefault->GetText();
1674cdf0e10cSrcweir 	}
1675cdf0e10cSrcweir 	else if (pBoolDefault)
1676cdf0e10cSrcweir 	{
1677cdf0e10cSrcweir 		sDefault = BoolStringPersistent(pBoolDefault->GetSelectEntry());
1678cdf0e10cSrcweir 	}
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir 	if ( sDefault.getLength() )
1681cdf0e10cSrcweir         pFieldDescr->SetControlDefault(makeAny(sDefault));
1682cdf0e10cSrcweir 	else
1683cdf0e10cSrcweir 		pFieldDescr->SetControlDefault(Any());
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir 	if((pRequired && pRequired->GetSelectEntryPos() == 0) || pFieldDescr->IsPrimaryKey() || (pBoolDefault && pBoolDefault->GetEntryCount() == 2))  // yes
1686cdf0e10cSrcweir 		pFieldDescr->SetIsNullable( ColumnValue::NO_NULLS );
1687cdf0e10cSrcweir 	else
1688cdf0e10cSrcweir 		pFieldDescr->SetIsNullable( ColumnValue::NULLABLE );
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 	if ( pAutoIncrement )
1691cdf0e10cSrcweir 		pFieldDescr->SetAutoIncrement( pAutoIncrement->GetSelectEntryPos() == 0 );
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir 	if( pTextLen )
1694cdf0e10cSrcweir 		pFieldDescr->SetPrecision( static_cast<sal_Int32>(pTextLen->GetValue()) );
1695cdf0e10cSrcweir 	else if( pLength )
1696cdf0e10cSrcweir 		pFieldDescr->SetPrecision( static_cast<sal_Int32>(pLength->GetValue()) );
1697cdf0e10cSrcweir 	if( pScale )
1698cdf0e10cSrcweir 		pFieldDescr->SetScale( static_cast<sal_Int32>(pScale->GetValue()) );
1699cdf0e10cSrcweir 
1700cdf0e10cSrcweir 	if(m_pColumnName)
1701cdf0e10cSrcweir 		pFieldDescr->SetName(m_pColumnName->GetText());
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 	if ( m_pAutoIncrementValue && isAutoIncrementValueEnabled() )
1704cdf0e10cSrcweir 		pFieldDescr->SetAutoIncrementValue(m_pAutoIncrementValue->GetText());
1705cdf0e10cSrcweir }
1706cdf0e10cSrcweir 
1707cdf0e10cSrcweir //------------------------------------------------------------------------------
UpdateFormatSample(OFieldDescription * pFieldDescr)1708cdf0e10cSrcweir void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr)
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir 	if ( pFieldDescr && pFormatSample )
1711cdf0e10cSrcweir 	    pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False));
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir //------------------------------------------------------------------------------
GetFocus()1715cdf0e10cSrcweir void OFieldDescControl::GetFocus()
1716cdf0e10cSrcweir {
1717cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1718cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1719cdf0e10cSrcweir 	// Setzt den Focus auf das zuletzt aktive Control
1720cdf0e10cSrcweir 	TabPage::GetFocus();
1721cdf0e10cSrcweir 	if( pLastFocusWindow )
1722cdf0e10cSrcweir 	{
1723cdf0e10cSrcweir 		pLastFocusWindow->GrabFocus();
1724cdf0e10cSrcweir 		pLastFocusWindow = NULL;
1725cdf0e10cSrcweir 	}
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir //------------------------------------------------------------------------------
implFocusLost(Window * _pWhich)1729cdf0e10cSrcweir void OFieldDescControl::implFocusLost(Window* _pWhich)
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1732cdf0e10cSrcweir 	DBG_ASSERT(!_pWhich || IsChild(_pWhich), "OFieldDescControl::implFocusLost : invalid window !");
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1735cdf0e10cSrcweir 	// Das aktive Control merken
1736cdf0e10cSrcweir 	if (!pLastFocusWindow)
1737cdf0e10cSrcweir 		pLastFocusWindow = _pWhich;
1738cdf0e10cSrcweir 
1739cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
1740cdf0e10cSrcweir 	// HelpText zuruecksetzen
1741cdf0e10cSrcweir 	if (pHelp && !pHelp->HasChildPathFocus())
1742cdf0e10cSrcweir 		pHelp->SetHelpText( String() );
1743cdf0e10cSrcweir }
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir //------------------------------------------------------------------------------
LoseFocus()1746cdf0e10cSrcweir void OFieldDescControl::LoseFocus()
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir 	DBG_CHKTHIS(OFieldDescControl,NULL);
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir 	implFocusLost(NULL);
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir 	TabPage::LoseFocus();
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir // -----------------------------------------------------------------------------
isCopyAllowed()1755cdf0e10cSrcweir sal_Bool OFieldDescControl::isCopyAllowed()
1756cdf0e10cSrcweir {
1757cdf0e10cSrcweir 	sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
1758cdf0e10cSrcweir 						(m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample	||
1759cdf0e10cSrcweir 						m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength			||
1760cdf0e10cSrcweir 						m_pActFocusWindow == pScale	 || m_pActFocusWindow == m_pColumnName		||
1761cdf0e10cSrcweir 						m_pActFocusWindow == m_pAutoIncrementValue) &&
1762cdf0e10cSrcweir 						static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir 	return bAllowed;
1765cdf0e10cSrcweir }
1766cdf0e10cSrcweir // -----------------------------------------------------------------------------
isCutAllowed()1767cdf0e10cSrcweir sal_Bool OFieldDescControl::isCutAllowed()
1768cdf0e10cSrcweir {
1769cdf0e10cSrcweir 	sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
1770cdf0e10cSrcweir 						(m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample	||
1771cdf0e10cSrcweir 						m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength			||
1772cdf0e10cSrcweir 						m_pActFocusWindow == pScale	 || m_pActFocusWindow == m_pColumnName		||
1773cdf0e10cSrcweir 						m_pActFocusWindow == m_pAutoIncrementValue) &&
1774cdf0e10cSrcweir 						static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
1775cdf0e10cSrcweir 	return bAllowed;
1776cdf0e10cSrcweir }
1777cdf0e10cSrcweir // -----------------------------------------------------------------------------
isPasteAllowed()1778cdf0e10cSrcweir sal_Bool OFieldDescControl::isPasteAllowed()
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir 	sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
1781cdf0e10cSrcweir 						(m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample	||
1782cdf0e10cSrcweir 						m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength			||
1783cdf0e10cSrcweir 						m_pActFocusWindow == pScale	 || m_pActFocusWindow == m_pColumnName		||
1784cdf0e10cSrcweir 						m_pActFocusWindow == m_pAutoIncrementValue);
1785cdf0e10cSrcweir 	if ( bAllowed )
1786cdf0e10cSrcweir 	{
1787cdf0e10cSrcweir 		TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
1788cdf0e10cSrcweir 		bAllowed = aTransferData.HasFormat(SOT_FORMAT_STRING);
1789cdf0e10cSrcweir 	}
1790cdf0e10cSrcweir 	return bAllowed;
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir // -----------------------------------------------------------------------------
cut()1793cdf0e10cSrcweir void OFieldDescControl::cut()
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir 	if(isCutAllowed())
1796cdf0e10cSrcweir 		static_cast<Edit*>(m_pActFocusWindow)->Cut();
1797cdf0e10cSrcweir }
1798cdf0e10cSrcweir // -----------------------------------------------------------------------------
copy()1799cdf0e10cSrcweir void OFieldDescControl::copy()
1800cdf0e10cSrcweir {
1801cdf0e10cSrcweir 	if(isCopyAllowed()) // this only checks if the focus window is valid
1802cdf0e10cSrcweir 		static_cast<Edit*>(m_pActFocusWindow)->Copy();
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir // -----------------------------------------------------------------------------
paste()1805cdf0e10cSrcweir void OFieldDescControl::paste()
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir 	if(m_pActFocusWindow) // this only checks if the focus window is valid
1808cdf0e10cSrcweir 		static_cast<Edit*>(m_pActFocusWindow)->Paste();
1809cdf0e10cSrcweir }
1810cdf0e10cSrcweir // -----------------------------------------------------------------------------
isTextFormat(const OFieldDescription * _pFieldDescr,sal_uInt32 & _nFormatKey) const1811cdf0e10cSrcweir sal_Bool OFieldDescControl::isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir 	_nFormatKey = _pFieldDescr->GetFormatKey();
1814cdf0e10cSrcweir 	sal_Bool bTextFormat = sal_True;
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 	try
1817cdf0e10cSrcweir 	{
1818cdf0e10cSrcweir 		if (!_nFormatKey)
1819cdf0e10cSrcweir 		{
1820cdf0e10cSrcweir 			Reference< ::com::sun::star::util::XNumberFormatTypes> xNumberTypes(GetFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY);
1821cdf0e10cSrcweir 			OSL_ENSURE(xNumberTypes.is(),"XNumberFormatTypes is null!");
1822cdf0e10cSrcweir 
1823cdf0e10cSrcweir 			_nFormatKey = ::dbtools::getDefaultNumberFormat( _pFieldDescr->GetType(),
1824cdf0e10cSrcweir 				_pFieldDescr->GetScale(),
1825cdf0e10cSrcweir 				_pFieldDescr->IsCurrency(),
1826cdf0e10cSrcweir 				xNumberTypes,
1827cdf0e10cSrcweir 				GetLocale());
1828cdf0e10cSrcweir 		}
1829cdf0e10cSrcweir 		sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(GetFormatter(),_nFormatKey);
1830cdf0e10cSrcweir 		bTextFormat = (nNumberFormat == ::com::sun::star::util::NumberFormat::TEXT);
1831cdf0e10cSrcweir 	}
1832cdf0e10cSrcweir 	catch(const Exception&)
1833cdf0e10cSrcweir 	{
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir 	}
1836cdf0e10cSrcweir 
1837cdf0e10cSrcweir 	return bTextFormat;
1838cdf0e10cSrcweir }
1839cdf0e10cSrcweir // -----------------------------------------------------------------------------
getControlDefault(const OFieldDescription * _pFieldDescr,sal_Bool _bCheck) const1840cdf0e10cSrcweir String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck) const
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir 	::rtl::OUString sDefault;
1843cdf0e10cSrcweir 	sal_Bool bCheck = !_bCheck || _pFieldDescr->GetControlDefault().hasValue();
1844cdf0e10cSrcweir 	if ( bCheck )
1845cdf0e10cSrcweir 	{
1846cdf0e10cSrcweir 		sal_uInt32 nFormatKey;
1847cdf0e10cSrcweir 		sal_Bool bTextFormat = sal_False;
1848cdf0e10cSrcweir 		double nValue = 0.0;
1849cdf0e10cSrcweir 
1850cdf0e10cSrcweir 		try
1851cdf0e10cSrcweir 		{
1852cdf0e10cSrcweir 			bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
1853cdf0e10cSrcweir 			if ( _pFieldDescr->GetControlDefault() >>= sDefault )
1854cdf0e10cSrcweir 			{
1855cdf0e10cSrcweir 				if ( !bTextFormat )
1856cdf0e10cSrcweir 				{
1857cdf0e10cSrcweir 					if ( sDefault.getLength() )
1858cdf0e10cSrcweir 					{
1859cdf0e10cSrcweir 						try
1860cdf0e10cSrcweir 						{
1861cdf0e10cSrcweir 							nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
1862cdf0e10cSrcweir 						}
1863cdf0e10cSrcweir 						catch(const Exception&)
1864cdf0e10cSrcweir 						{
1865cdf0e10cSrcweir 							return ::rtl::OUString(); // return empty string for format example
1866cdf0e10cSrcweir 						}
1867cdf0e10cSrcweir 					}
1868cdf0e10cSrcweir 				}
1869cdf0e10cSrcweir 			}
1870cdf0e10cSrcweir 			else
1871cdf0e10cSrcweir 				_pFieldDescr->GetControlDefault() >>= nValue;
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir 
1874cdf0e10cSrcweir 			Reference< ::com::sun::star::util::XNumberFormatter> xNumberFormatter = GetFormatter();
1875cdf0e10cSrcweir 			Reference<XPropertySet> xFormSet = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey);
1876cdf0e10cSrcweir 			OSL_ENSURE(xFormSet.is(),"XPropertySet is null!");
1877cdf0e10cSrcweir 			::rtl::OUString sFormat;
1878cdf0e10cSrcweir 			xFormSet->getPropertyValue(::rtl::OUString::createFromAscii("FormatString")) >>= sFormat;
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir 			if ( !bTextFormat )
1881cdf0e10cSrcweir 			{
1882cdf0e10cSrcweir 				Locale aLocale;
1883cdf0e10cSrcweir 				::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale;
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir 				sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(xNumberFormatter,nFormatKey);
1886cdf0e10cSrcweir 				if(		(nNumberFormat & ::com::sun::star::util::NumberFormat::DATE)	== ::com::sun::star::util::NumberFormat::DATE
1887cdf0e10cSrcweir 					|| (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
1888cdf0e10cSrcweir 				{
1889cdf0e10cSrcweir 					nValue = DBTypeConversion::toNullDate(DBTypeConversion::getNULLDate(xNumberFormatter->getNumberFormatsSupplier()),nValue);
1890cdf0e10cSrcweir 				}
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir 
1894cdf0e10cSrcweir 				Reference< ::com::sun::star::util::XNumberFormatPreviewer> xPreViewer(xNumberFormatter,UNO_QUERY);
1895cdf0e10cSrcweir 				OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!");
1896cdf0e10cSrcweir 				sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True);
1897cdf0e10cSrcweir 			}
1898cdf0e10cSrcweir 			else if ( !_bCheck || (sDefault.getLength() != 0) )
1899cdf0e10cSrcweir 				sDefault = xNumberFormatter->formatString(nFormatKey,(sDefault.getLength() != 0 )? sDefault : sFormat);
1900cdf0e10cSrcweir 		}
1901cdf0e10cSrcweir 		catch(const Exception&)
1902cdf0e10cSrcweir 		{
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir 		}
1905cdf0e10cSrcweir 	}
1906cdf0e10cSrcweir 
1907cdf0e10cSrcweir 	return sDefault;
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir // -----------------------------------------------------------------------------
1910