xref: /AOO41X/main/svtools/source/uno/unoiface.cxx (revision 5900e8ec128faec89519683efce668ccd8cc6084)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SVT_UNOIFACE_CXX
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <svtools/svmedit.hxx>
31cdf0e10cSrcweir #include <unoiface.hxx>
32cdf0e10cSrcweir #include <svtools/filedlg.hxx>
33cdf0e10cSrcweir #include <svtools/filectrl.hxx>
34cdf0e10cSrcweir #include <svtools/roadmap.hxx>
35cdf0e10cSrcweir #include <svtools/fixedhyper.hxx>
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/LineEndFormat.hpp>
39cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
40cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
41cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
42cdf0e10cSrcweir #include <svtools/fmtfield.hxx>
43cdf0e10cSrcweir #include <svl/numuno.hxx>
44cdf0e10cSrcweir #include <svtools/calendar.hxx>
45cdf0e10cSrcweir #include <svtools/prgsbar.hxx>
46cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
47cdf0e10cSrcweir #include "treecontrolpeer.hxx"
48cdf0e10cSrcweir #include "svtxgridcontrol.hxx"
49cdf0e10cSrcweir #include <svtools/table/tablecontrol.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace
52cdf0e10cSrcweir {
lcl_setWinBits(Window * _pWindow,WinBits _nBits,sal_Bool _bSet)53cdf0e10cSrcweir     static void lcl_setWinBits( Window* _pWindow, WinBits _nBits, sal_Bool _bSet )
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         WinBits nStyle = _pWindow->GetStyle();
56cdf0e10cSrcweir         if ( _bSet )
57cdf0e10cSrcweir             nStyle |= _nBits;
58cdf0e10cSrcweir         else
59cdf0e10cSrcweir             nStyle &= ~_nBits;
60cdf0e10cSrcweir         _pWindow->SetStyle( nStyle );
61cdf0e10cSrcweir     }
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //	----------------------------------------------------
65cdf0e10cSrcweir //	help function for the toolkit...
66cdf0e10cSrcweir //	----------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir extern "C" {
69cdf0e10cSrcweir 
CreateWindow(VCLXWindow ** ppNewComp,const::com::sun::star::awt::WindowDescriptor * pDescriptor,Window * pParent,WinBits nWinBits)70cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, Window* pParent, WinBits nWinBits )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	Window* pWindow = NULL;
73cdf0e10cSrcweir 	String aServiceName( pDescriptor->WindowServiceName );
74cdf0e10cSrcweir 	if ( aServiceName.EqualsIgnoreCaseAscii( "MultiLineEdit" ) )
75cdf0e10cSrcweir 	{
76cdf0e10cSrcweir 		if ( pParent )
77cdf0e10cSrcweir 		{
78cdf0e10cSrcweir 			pWindow = new MultiLineEdit( pParent, nWinBits|WB_IGNORETAB);
79cdf0e10cSrcweir             static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus();
80cdf0e10cSrcweir 			*ppNewComp = new VCLXMultiLineEdit;
81cdf0e10cSrcweir 		}
82cdf0e10cSrcweir 		else
83cdf0e10cSrcweir 		{
84cdf0e10cSrcweir 			*ppNewComp = NULL;
85cdf0e10cSrcweir 			return NULL;
86cdf0e10cSrcweir 		}
87cdf0e10cSrcweir 	}
88cdf0e10cSrcweir 	else if ( aServiceName.EqualsIgnoreCaseAscii( "FileControl" ) )
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 		if ( pParent )
91cdf0e10cSrcweir 		{
92cdf0e10cSrcweir 			pWindow = new FileControl( pParent, nWinBits );
93cdf0e10cSrcweir 			*ppNewComp = new VCLXFileControl;
94cdf0e10cSrcweir 		}
95cdf0e10cSrcweir 		else
96cdf0e10cSrcweir 		{
97cdf0e10cSrcweir 			*ppNewComp = NULL;
98cdf0e10cSrcweir 			return NULL;
99cdf0e10cSrcweir 		}
100cdf0e10cSrcweir 	}
101cdf0e10cSrcweir 	else if (aServiceName.EqualsIgnoreCaseAscii("FormattedField") )
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		pWindow = new FormattedField( pParent, nWinBits );
104cdf0e10cSrcweir 		*ppNewComp = new SVTXFormattedField;
105cdf0e10cSrcweir 	}
106cdf0e10cSrcweir 	else if (aServiceName.EqualsIgnoreCaseAscii("NumericField") )
107cdf0e10cSrcweir 	{
108cdf0e10cSrcweir 		pWindow = new DoubleNumericField( pParent, nWinBits );
109cdf0e10cSrcweir 		*ppNewComp = new SVTXNumericField;
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	else if (aServiceName.EqualsIgnoreCaseAscii("LongCurrencyField") )
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		pWindow = new DoubleCurrencyField( pParent, nWinBits );
114cdf0e10cSrcweir 		*ppNewComp = new SVTXCurrencyField;
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir 	else if (aServiceName.EqualsIgnoreCaseAscii("datefield") )
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		pWindow = new CalendarField( pParent, nWinBits);
119cdf0e10cSrcweir 		static_cast<CalendarField*>(pWindow)->EnableToday();
120cdf0e10cSrcweir 		static_cast<CalendarField*>(pWindow)->EnableNone();
121cdf0e10cSrcweir 		static_cast<CalendarField*>(pWindow)->EnableEmptyFieldValue( sal_True );
122cdf0e10cSrcweir 		*ppNewComp = new SVTXDateField;
123cdf0e10cSrcweir 		((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pWindow );
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir 	else if (aServiceName.EqualsIgnoreCaseAscii("roadmap") )
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir         pWindow = new ::svt::ORoadmap( pParent, WB_TABSTOP );
128cdf0e10cSrcweir 		*ppNewComp = new SVTXRoadmap;
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir     else if ( aServiceName.EqualsIgnoreCaseAscii( "ProgressBar" ) )
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir 		if ( pParent )
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir 			pWindow = new ProgressBar( pParent, nWinBits );
135cdf0e10cSrcweir 			*ppNewComp = new VCLXProgressBar;
136cdf0e10cSrcweir 		}
137cdf0e10cSrcweir 		else
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			*ppNewComp = NULL;
140cdf0e10cSrcweir 			return NULL;
141cdf0e10cSrcweir 		}
142cdf0e10cSrcweir 	}
143cdf0e10cSrcweir 	else if ( aServiceName.EqualsIgnoreCaseAscii( "Tree" ) )
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		TreeControlPeer* pPeer = new TreeControlPeer;
146cdf0e10cSrcweir 		*ppNewComp = pPeer;
147cdf0e10cSrcweir 		pWindow = pPeer->createVclControl( pParent, nWinBits );
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir     else if ( aServiceName.EqualsIgnoreCaseAscii( "FixedHyperlink" ) )
150cdf0e10cSrcweir     {
151cdf0e10cSrcweir         if ( pParent )
152cdf0e10cSrcweir         {
153cdf0e10cSrcweir             pWindow = new ::svt::FixedHyperlink( pParent, nWinBits );
154cdf0e10cSrcweir             *ppNewComp = new VCLXFixedHyperlink;
155cdf0e10cSrcweir         }
156cdf0e10cSrcweir         else
157cdf0e10cSrcweir         {
158cdf0e10cSrcweir             *ppNewComp = NULL;
159cdf0e10cSrcweir             return NULL;
160cdf0e10cSrcweir         }
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 	else if ( aServiceName.EqualsIgnoreCaseAscii( "Grid" ) )
163cdf0e10cSrcweir 	{
164cdf0e10cSrcweir 		if ( pParent )
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 			pWindow = new ::svt::table::TableControl(pParent, nWinBits);
167cdf0e10cSrcweir 			*ppNewComp = new SVTXGridControl;
168cdf0e10cSrcweir 		}
169cdf0e10cSrcweir 		else
170cdf0e10cSrcweir 		{
171cdf0e10cSrcweir 			*ppNewComp = NULL;
172cdf0e10cSrcweir 			return NULL;
173cdf0e10cSrcweir 		}
174cdf0e10cSrcweir 	}
175cdf0e10cSrcweir 	return pWindow;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir }	// extern "C"
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //	----------------------------------------------------
181cdf0e10cSrcweir //	class VCLXMultiLineEdit
182cdf0e10cSrcweir //	----------------------------------------------------
VCLXMultiLineEdit()183cdf0e10cSrcweir VCLXMultiLineEdit::VCLXMultiLineEdit()
184cdf0e10cSrcweir     :maTextListeners( *this )
185cdf0e10cSrcweir     ,meLineEndType( LINEEND_LF )    // default behavior before introducing this property: LF (unix-like)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
~VCLXMultiLineEdit()189cdf0e10cSrcweir VCLXMultiLineEdit::~VCLXMultiLineEdit()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
queryInterface(const::com::sun::star::uno::Type & rType)193cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMultiLineEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
196cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ),
197cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextArea*, this ),
198cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ),
199cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
200cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
204cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXMultiLineEdit )
205cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
206cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextArea>* ) NULL ),
207cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
208cdf0e10cSrcweir 	VCLXWindow::getTypes()
209cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
210cdf0e10cSrcweir 
211cdf0e10cSrcweir void VCLXMultiLineEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	maTextListeners.addInterface( l );
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
removeTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)216cdf0e10cSrcweir void VCLXMultiLineEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	maTextListeners.removeInterface( l );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
setText(const::rtl::OUString & aText)221cdf0e10cSrcweir void VCLXMultiLineEdit::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
226cdf0e10cSrcweir 	if ( pEdit )
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		pEdit->SetText( aText );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir         // #107218# Call same listeners like VCL would do after user interaction
231cdf0e10cSrcweir         SetSynthesizingVCLEvent( sal_True );
232cdf0e10cSrcweir         pEdit->SetModifyFlag();
233cdf0e10cSrcweir         pEdit->Modify();
234cdf0e10cSrcweir         SetSynthesizingVCLEvent( sal_False );
235cdf0e10cSrcweir 	}
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
insertText(const::com::sun::star::awt::Selection & rSel,const::rtl::OUString & aText)238cdf0e10cSrcweir void VCLXMultiLineEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
243cdf0e10cSrcweir 	if ( pEdit )
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		setSelection( rSel );
246cdf0e10cSrcweir 		pEdit->ReplaceSelected( aText );
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir }
249cdf0e10cSrcweir 
getText()250cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getText() throw(::com::sun::star::uno::RuntimeException)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	::rtl::OUString aText;
255cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
256cdf0e10cSrcweir 	if ( pEdit )
257cdf0e10cSrcweir 		aText = pEdit->GetText( meLineEndType );
258cdf0e10cSrcweir 	return aText;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
getSelectedText()261cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	::rtl::OUString aText;
266cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
267cdf0e10cSrcweir 	if ( pMultiLineEdit)
268cdf0e10cSrcweir 		aText = pMultiLineEdit->GetSelected( meLineEndType );
269cdf0e10cSrcweir 	return aText;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
setSelection(const::com::sun::star::awt::Selection & aSelection)273cdf0e10cSrcweir void VCLXMultiLineEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
278cdf0e10cSrcweir 	if ( pMultiLineEdit )
279cdf0e10cSrcweir 	{
280cdf0e10cSrcweir 		pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
getSelection()284cdf0e10cSrcweir ::com::sun::star::awt::Selection VCLXMultiLineEdit::getSelection() throw(::com::sun::star::uno::RuntimeException)
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	::com::sun::star::awt::Selection aSel;
289cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
290cdf0e10cSrcweir 	if ( pMultiLineEdit )
291cdf0e10cSrcweir 	{
292cdf0e10cSrcweir 		aSel.Min = pMultiLineEdit->GetSelection().Min();
293cdf0e10cSrcweir 		aSel.Max = pMultiLineEdit->GetSelection().Max();
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir 	return aSel;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
isEditable()298cdf0e10cSrcweir sal_Bool VCLXMultiLineEdit::isEditable() throw(::com::sun::star::uno::RuntimeException)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
303cdf0e10cSrcweir 	return ( pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled() ) ? sal_True : sal_False;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
setEditable(sal_Bool bEditable)306cdf0e10cSrcweir void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
311cdf0e10cSrcweir 	if ( pMultiLineEdit )
312cdf0e10cSrcweir 		pMultiLineEdit->SetReadOnly( !bEditable );
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
setMaxTextLen(sal_Int16 nLen)315cdf0e10cSrcweir void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
320cdf0e10cSrcweir 	if ( pMultiLineEdit )
321cdf0e10cSrcweir 		pMultiLineEdit->SetMaxTextLen( nLen );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
getMaxTextLen()324cdf0e10cSrcweir sal_Int16 VCLXMultiLineEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
329cdf0e10cSrcweir 	return pMultiLineEdit ? (sal_Int16)pMultiLineEdit->GetMaxTextLen() : (sal_Int16)0;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
getTextLines()332cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getTextLines() throw(::com::sun::star::uno::RuntimeException)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	::rtl::OUString aText;
337cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
338cdf0e10cSrcweir 	if ( pEdit )
339cdf0e10cSrcweir 		aText = pEdit->GetTextLines( meLineEndType );
340cdf0e10cSrcweir 	return aText;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
getMinimumSize()343cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz;
348cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
349cdf0e10cSrcweir 	if ( pEdit )
350cdf0e10cSrcweir 		aSz = AWTSize(pEdit->CalcMinimumSize());
351cdf0e10cSrcweir 	return aSz;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
getPreferredSize()354cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getPreferredSize() throw(::com::sun::star::uno::RuntimeException)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir 	return getMinimumSize();
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)359cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz = rNewSize;
364cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
365cdf0e10cSrcweir 	if ( pEdit )
366cdf0e10cSrcweir 		aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
367cdf0e10cSrcweir 	return aSz;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)370cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz;
375cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
376cdf0e10cSrcweir 	if ( pEdit )
377cdf0e10cSrcweir 		aSz = AWTSize(pEdit->CalcSize( nCols, nLines ));
378cdf0e10cSrcweir 	return aSz;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)381cdf0e10cSrcweir void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	nCols = nLines = 0;
386cdf0e10cSrcweir 	MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
387cdf0e10cSrcweir 	if ( pEdit )
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		sal_uInt16 nC, nL;
390cdf0e10cSrcweir 		pEdit->GetMaxVisColumnsAndLines( nC, nL );
391cdf0e10cSrcweir 		nCols = nC;
392cdf0e10cSrcweir 		nLines = nL;
393cdf0e10cSrcweir 	}
394cdf0e10cSrcweir }
395cdf0e10cSrcweir 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)396cdf0e10cSrcweir void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir 	switch ( rVclWindowEvent.GetId() )
399cdf0e10cSrcweir 	{
400cdf0e10cSrcweir 		case VCLEVENT_EDIT_MODIFY:
401cdf0e10cSrcweir         {
402cdf0e10cSrcweir 		    if ( maTextListeners.getLength() )
403cdf0e10cSrcweir 		    {
404cdf0e10cSrcweir 	            ::com::sun::star::awt::TextEvent aEvent;
405cdf0e10cSrcweir 	            aEvent.Source = (::cppu::OWeakObject*)this;
406cdf0e10cSrcweir 	            maTextListeners.textChanged( aEvent );
407cdf0e10cSrcweir 		    }
408cdf0e10cSrcweir         }
409cdf0e10cSrcweir         break;
410cdf0e10cSrcweir 		default:
411cdf0e10cSrcweir         {
412cdf0e10cSrcweir 			VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
413cdf0e10cSrcweir         }
414cdf0e10cSrcweir 		break;
415cdf0e10cSrcweir 	}
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)418cdf0e10cSrcweir void VCLXMultiLineEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow();
423cdf0e10cSrcweir 	if ( pMultiLineEdit )
424cdf0e10cSrcweir 	{
425cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
426cdf0e10cSrcweir 		switch ( nPropType )
427cdf0e10cSrcweir 		{
428cdf0e10cSrcweir             case BASEPROPERTY_LINE_END_FORMAT:
429cdf0e10cSrcweir             {
430cdf0e10cSrcweir                 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
431cdf0e10cSrcweir                 OSL_VERIFY( Value >>= nLineEndType );
432cdf0e10cSrcweir                 switch ( nLineEndType )
433cdf0e10cSrcweir                 {
434cdf0e10cSrcweir                 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN:           meLineEndType = LINEEND_CR; break;
435cdf0e10cSrcweir                 case ::com::sun::star::awt::LineEndFormat::LINE_FEED:                 meLineEndType = LINEEND_LF; break;
436cdf0e10cSrcweir                 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
437cdf0e10cSrcweir                 default: DBG_ERROR( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break;
438cdf0e10cSrcweir                 }
439cdf0e10cSrcweir             }
440cdf0e10cSrcweir             break;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 			case BASEPROPERTY_READONLY:
443cdf0e10cSrcweir 			{
444cdf0e10cSrcweir 				sal_Bool b = sal_Bool();
445cdf0e10cSrcweir 				if ( Value >>= b )
446cdf0e10cSrcweir 					pMultiLineEdit->SetReadOnly( b );
447cdf0e10cSrcweir 			}
448cdf0e10cSrcweir 			break;
449cdf0e10cSrcweir 			case BASEPROPERTY_MAXTEXTLEN:
450cdf0e10cSrcweir 			{
451cdf0e10cSrcweir 				sal_Int16 n = sal_Int16();
452cdf0e10cSrcweir 				if ( Value >>= n )
453cdf0e10cSrcweir 					pMultiLineEdit->SetMaxTextLen( n );
454cdf0e10cSrcweir 			}
455cdf0e10cSrcweir 			break;
456cdf0e10cSrcweir 			case BASEPROPERTY_HIDEINACTIVESELECTION:
457cdf0e10cSrcweir 			{
458cdf0e10cSrcweir 				sal_Bool b = sal_Bool();
459cdf0e10cSrcweir 				if ( Value >>= b )
460cdf0e10cSrcweir                 {
461cdf0e10cSrcweir 					pMultiLineEdit->EnableFocusSelectionHide( b );
462cdf0e10cSrcweir                     lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
463cdf0e10cSrcweir                 }
464cdf0e10cSrcweir 			}
465cdf0e10cSrcweir 			break;
466cdf0e10cSrcweir 			default:
467cdf0e10cSrcweir 			{
468cdf0e10cSrcweir 				VCLXWindow::setProperty( PropertyName, Value );
469cdf0e10cSrcweir 			}
470cdf0e10cSrcweir 		}
471cdf0e10cSrcweir 	}
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
getProperty(const::rtl::OUString & PropertyName)474cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMultiLineEdit::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	::com::sun::star::uno::Any aProp;
479cdf0e10cSrcweir 	MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow();
480cdf0e10cSrcweir 	if ( pMultiLineEdit )
481cdf0e10cSrcweir 	{
482cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
483cdf0e10cSrcweir 		switch ( nPropType )
484cdf0e10cSrcweir 		{
485cdf0e10cSrcweir             case BASEPROPERTY_LINE_END_FORMAT:
486cdf0e10cSrcweir             {
487cdf0e10cSrcweir                 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
488cdf0e10cSrcweir                 switch ( meLineEndType )
489cdf0e10cSrcweir                 {
490cdf0e10cSrcweir                 case LINEEND_CR:   nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN; break;
491cdf0e10cSrcweir                 case LINEEND_LF:   nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; break;
492cdf0e10cSrcweir                 case LINEEND_CRLF: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
493cdf0e10cSrcweir                 default: DBG_ERROR( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break;
494cdf0e10cSrcweir                 }
495cdf0e10cSrcweir                 aProp <<= nLineEndType;
496cdf0e10cSrcweir             }
497cdf0e10cSrcweir             break;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 			case BASEPROPERTY_READONLY:
500cdf0e10cSrcweir 			{
501cdf0e10cSrcweir 				aProp <<= pMultiLineEdit->IsReadOnly();
502cdf0e10cSrcweir 			}
503cdf0e10cSrcweir 			break;
504cdf0e10cSrcweir 			case BASEPROPERTY_MAXTEXTLEN:
505cdf0e10cSrcweir 			{
506cdf0e10cSrcweir 				aProp <<= (sal_Int16) pMultiLineEdit->GetMaxTextLen();
507cdf0e10cSrcweir 			}
508cdf0e10cSrcweir 			break;
509cdf0e10cSrcweir 			default:
510cdf0e10cSrcweir 			{
511cdf0e10cSrcweir 				aProp <<= VCLXWindow::getProperty( PropertyName );
512cdf0e10cSrcweir 			}
513cdf0e10cSrcweir 		}
514cdf0e10cSrcweir 	}
515cdf0e10cSrcweir 	return aProp;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
setFocus()518cdf0e10cSrcweir void SAL_CALL VCLXMultiLineEdit::setFocus(  ) throw(::com::sun::star::uno::RuntimeException)
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     // don't grab the focus if we already have it. Reason is that the only thing which the edit
523cdf0e10cSrcweir     // does is forwarding the focus to it's text window. This text window then does a "select all".
524cdf0e10cSrcweir     // So if the text window already has the focus, and we give the focus to the multi line
525cdf0e10cSrcweir     // edit, then all which happens is that everything is selected.
526cdf0e10cSrcweir     // #i27072# - 2004-04-25 - fs@openoffice.org
527cdf0e10cSrcweir     if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
528cdf0e10cSrcweir 		GetWindow()->GrabFocus();
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)531cdf0e10cSrcweir void VCLXMultiLineEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     PushPropertyIds( rIds,
534cdf0e10cSrcweir                      // FIXME: elide duplication ?
535cdf0e10cSrcweir                      BASEPROPERTY_LINE_END_FORMAT,
536cdf0e10cSrcweir                      BASEPROPERTY_READONLY,
537cdf0e10cSrcweir                      BASEPROPERTY_MAXTEXTLEN,
538cdf0e10cSrcweir                      BASEPROPERTY_HIDEINACTIVESELECTION,
539cdf0e10cSrcweir                      0);
540cdf0e10cSrcweir     VCLXWindow::ImplGetPropertyIds( rIds, true );
541cdf0e10cSrcweir 
542cdf0e10cSrcweir }
543cdf0e10cSrcweir //	----------------------------------------------------
544cdf0e10cSrcweir //	class VCLXFileControl
545cdf0e10cSrcweir //	----------------------------------------------------
VCLXFileControl()546cdf0e10cSrcweir VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir }
549cdf0e10cSrcweir 
~VCLXFileControl()550cdf0e10cSrcweir VCLXFileControl::~VCLXFileControl()
551cdf0e10cSrcweir {
552cdf0e10cSrcweir 	FileControl* pControl = (FileControl*) GetWindow();
553cdf0e10cSrcweir 	if ( pControl )
554cdf0e10cSrcweir 		pControl->GetEdit().SetModifyHdl( Link() );
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
queryInterface(const::com::sun::star::uno::Type & rType)557cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFileControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
560cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ),
561cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ),
562cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
563cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
567cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXFileControl )
568cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
569cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
570cdf0e10cSrcweir 	VCLXWindow::getTypes()
571cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
572cdf0e10cSrcweir 
573cdf0e10cSrcweir void SAL_CALL VCLXFileControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 	FileControl* pControl = (FileControl*)GetWindow();
578cdf0e10cSrcweir 	if ( pControl )
579cdf0e10cSrcweir 	{
580cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
581cdf0e10cSrcweir 		switch ( nPropType )
582cdf0e10cSrcweir 		{
583cdf0e10cSrcweir         case BASEPROPERTY_HIDEINACTIVESELECTION:
584cdf0e10cSrcweir         {
585cdf0e10cSrcweir             sal_Bool bValue( sal_False );
586cdf0e10cSrcweir             OSL_VERIFY( Value >>= bValue );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir             lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
589cdf0e10cSrcweir             lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
590cdf0e10cSrcweir         }
591cdf0e10cSrcweir         break;
592cdf0e10cSrcweir 
593cdf0e10cSrcweir         default:
594cdf0e10cSrcweir             VCLXWindow::setProperty( PropertyName, Value );
595cdf0e10cSrcweir             break;
596cdf0e10cSrcweir         }
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
SetWindow(Window * pWindow)600cdf0e10cSrcweir void VCLXFileControl::SetWindow( Window* pWindow )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir 	FileControl* pPrevFileControl = dynamic_cast<FileControl*>( GetWindow() );
603cdf0e10cSrcweir 	if ( pPrevFileControl )
604cdf0e10cSrcweir 		pPrevFileControl->GetEdit().SetModifyHdl( Link() );
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow );
607cdf0e10cSrcweir 	if ( pNewFileControl )
608cdf0e10cSrcweir 		pNewFileControl->GetEdit().SetModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) );
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	VCLXWindow::SetWindow( pWindow );
611cdf0e10cSrcweir }
612cdf0e10cSrcweir 
addTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)613cdf0e10cSrcweir void VCLXFileControl::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
614cdf0e10cSrcweir {
615cdf0e10cSrcweir 	maTextListeners.addInterface( l );
616cdf0e10cSrcweir }
617cdf0e10cSrcweir 
removeTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)618cdf0e10cSrcweir void VCLXFileControl::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir 	maTextListeners.removeInterface( l );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
setText(const::rtl::OUString & aText)623cdf0e10cSrcweir void VCLXFileControl::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
624cdf0e10cSrcweir {
625cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	Window* pWindow = GetWindow();
628cdf0e10cSrcweir 	if ( pWindow )
629cdf0e10cSrcweir 	{
630cdf0e10cSrcweir 		pWindow->SetText( aText );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 		// In JAVA wird auch ein textChanged ausgeloest, in VCL nicht.
633cdf0e10cSrcweir 		// ::com::sun::star::awt::Toolkit soll JAVA-komform sein...
634cdf0e10cSrcweir 		ModifyHdl( NULL );
635cdf0e10cSrcweir 	}
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
insertText(const::com::sun::star::awt::Selection & rSel,const::rtl::OUString & aText)638cdf0e10cSrcweir void VCLXFileControl::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
643cdf0e10cSrcweir 	if ( pFileControl )
644cdf0e10cSrcweir 	{
645cdf0e10cSrcweir 		pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
646cdf0e10cSrcweir 		pFileControl->GetEdit().ReplaceSelected( aText );
647cdf0e10cSrcweir 	}
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
getText()650cdf0e10cSrcweir ::rtl::OUString VCLXFileControl::getText() throw(::com::sun::star::uno::RuntimeException)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	::rtl::OUString aText;
655cdf0e10cSrcweir 	Window* pWindow = GetWindow();
656cdf0e10cSrcweir 	if ( pWindow )
657cdf0e10cSrcweir 		aText = pWindow->GetText();
658cdf0e10cSrcweir 	return aText;
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
getSelectedText()661cdf0e10cSrcweir ::rtl::OUString VCLXFileControl::getSelectedText() throw(::com::sun::star::uno::RuntimeException)
662cdf0e10cSrcweir {
663cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 	::rtl::OUString aText;
666cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
667cdf0e10cSrcweir 	if ( pFileControl)
668cdf0e10cSrcweir 		aText = pFileControl->GetEdit().GetSelected();
669cdf0e10cSrcweir 	return aText;
670cdf0e10cSrcweir 
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
setSelection(const::com::sun::star::awt::Selection & aSelection)673cdf0e10cSrcweir void VCLXFileControl::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException)
674cdf0e10cSrcweir {
675cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
678cdf0e10cSrcweir 	if ( pFileControl )
679cdf0e10cSrcweir 		pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
getSelection()682cdf0e10cSrcweir ::com::sun::star::awt::Selection VCLXFileControl::getSelection() throw(::com::sun::star::uno::RuntimeException)
683cdf0e10cSrcweir {
684cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 	::com::sun::star::awt::Selection aSel;
687cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
688cdf0e10cSrcweir 	if ( pFileControl )
689cdf0e10cSrcweir 	{
690cdf0e10cSrcweir 		aSel.Min = pFileControl->GetEdit().GetSelection().Min();
691cdf0e10cSrcweir 		aSel.Max = pFileControl->GetEdit().GetSelection().Max();
692cdf0e10cSrcweir 	}
693cdf0e10cSrcweir 	return aSel;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
isEditable()696cdf0e10cSrcweir sal_Bool VCLXFileControl::isEditable() throw(::com::sun::star::uno::RuntimeException)
697cdf0e10cSrcweir {
698cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
701cdf0e10cSrcweir 	return ( pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled() ) ? sal_True : sal_False;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
setEditable(sal_Bool bEditable)704cdf0e10cSrcweir void VCLXFileControl::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException)
705cdf0e10cSrcweir {
706cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
709cdf0e10cSrcweir 	if ( pFileControl )
710cdf0e10cSrcweir 		pFileControl->GetEdit().SetReadOnly( !bEditable );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
setMaxTextLen(sal_Int16 nLen)713cdf0e10cSrcweir void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException)
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
718cdf0e10cSrcweir 	if ( pFileControl )
719cdf0e10cSrcweir 		pFileControl->GetEdit().SetMaxTextLen( nLen );
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
getMaxTextLen()722cdf0e10cSrcweir sal_Int16 VCLXFileControl::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException)
723cdf0e10cSrcweir {
724cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	FileControl* pFileControl = (FileControl*) GetWindow();
727cdf0e10cSrcweir 	return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 
IMPL_LINK(VCLXFileControl,ModifyHdl,Edit *,EMPTYARG)731cdf0e10cSrcweir IMPL_LINK( VCLXFileControl, ModifyHdl, Edit*, EMPTYARG )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir 	::com::sun::star::awt::TextEvent aEvent;
734cdf0e10cSrcweir 	aEvent.Source = (::cppu::OWeakObject*)this;
735cdf0e10cSrcweir 	maTextListeners.textChanged( aEvent );
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 	return 1;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
getMinimumSize()740cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz;
745cdf0e10cSrcweir 	FileControl* pControl = (FileControl*) GetWindow();
746cdf0e10cSrcweir 	if ( pControl )
747cdf0e10cSrcweir 	{
748cdf0e10cSrcweir 		Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
749cdf0e10cSrcweir 		aTmpSize.Width() += pControl->GetButton().CalcMinimumSize().Width();
750cdf0e10cSrcweir 		aSz = AWTSize(pControl->CalcWindowSize( aTmpSize ));
751cdf0e10cSrcweir 	}
752cdf0e10cSrcweir 	return aSz;
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
getPreferredSize()755cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getPreferredSize() throw(::com::sun::star::uno::RuntimeException)
756cdf0e10cSrcweir {
757cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz = getMinimumSize();
758cdf0e10cSrcweir 	aSz.Height += 4;
759cdf0e10cSrcweir 	return aSz;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)762cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
763cdf0e10cSrcweir {
764cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz =rNewSize;
767cdf0e10cSrcweir 	FileControl* pControl = (FileControl*) GetWindow();
768cdf0e10cSrcweir 	if ( pControl )
769cdf0e10cSrcweir 	{
770cdf0e10cSrcweir 		::com::sun::star::awt::Size aMinSz = getMinimumSize();
771cdf0e10cSrcweir 		if ( aSz.Height != aMinSz.Height )
772cdf0e10cSrcweir 			aSz.Height = aMinSz.Height;
773cdf0e10cSrcweir 	}
774cdf0e10cSrcweir 	return aSz;
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
getMinimumSize(sal_Int16 nCols,sal_Int16)777cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 	::com::sun::star::awt::Size aSz;
782cdf0e10cSrcweir 	FileControl* pControl = (FileControl*) GetWindow();
783cdf0e10cSrcweir 	if ( pControl )
784cdf0e10cSrcweir 	{
785cdf0e10cSrcweir 		aSz = AWTSize(pControl->GetEdit().CalcSize( nCols ));
786cdf0e10cSrcweir 		aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
787cdf0e10cSrcweir 	}
788cdf0e10cSrcweir 	return aSz;
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)791cdf0e10cSrcweir void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
792cdf0e10cSrcweir {
793cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 	nCols = 0;
796cdf0e10cSrcweir 	nLines = 1;
797cdf0e10cSrcweir 	FileControl* pControl = (FileControl*) GetWindow();
798cdf0e10cSrcweir 	if ( pControl )
799cdf0e10cSrcweir 		nCols = (sal_Int16) pControl->GetEdit().GetMaxVisChars();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)802cdf0e10cSrcweir void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
803cdf0e10cSrcweir {
804cdf0e10cSrcweir     PushPropertyIds( rIds,
805cdf0e10cSrcweir                      // FIXME: elide duplication ?
806cdf0e10cSrcweir                      BASEPROPERTY_HIDEINACTIVESELECTION,
807cdf0e10cSrcweir                      0);
808cdf0e10cSrcweir     VCLXWindow::ImplGetPropertyIds( rIds, true );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir 
812cdf0e10cSrcweir //	----------------------------------------------------
813cdf0e10cSrcweir //	class SVTXFormattedField
814cdf0e10cSrcweir //	----------------------------------------------------
815cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SVTXFormattedField()816cdf0e10cSrcweir SVTXFormattedField::SVTXFormattedField()
817cdf0e10cSrcweir 	:m_pCurrentSupplier(NULL)
818cdf0e10cSrcweir 	,bIsStandardSupplier(sal_True)
819cdf0e10cSrcweir 	,nKeyToSetDelayed(-1)
820cdf0e10cSrcweir {
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823cdf0e10cSrcweir // --------------------------------------------------------------------------------------
~SVTXFormattedField()824cdf0e10cSrcweir SVTXFormattedField::~SVTXFormattedField()
825cdf0e10cSrcweir {
826cdf0e10cSrcweir 	if (m_pCurrentSupplier)
827cdf0e10cSrcweir 	{
828cdf0e10cSrcweir 		m_pCurrentSupplier->release();
829cdf0e10cSrcweir 		m_pCurrentSupplier = NULL;
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetWindow(Window * _pWindow)834cdf0e10cSrcweir void SVTXFormattedField::SetWindow( Window* _pWindow )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir 	VCLXSpinField::SetWindow(_pWindow);
837cdf0e10cSrcweir 	if (GetFormattedField())
838cdf0e10cSrcweir 		GetFormattedField()->SetAutoColor(sal_True);
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
841cdf0e10cSrcweir // --------------------------------------------------------------------------------------
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)842cdf0e10cSrcweir void SVTXFormattedField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
843cdf0e10cSrcweir {
844cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
847cdf0e10cSrcweir 	if ( pField )
848cdf0e10cSrcweir 	{
849cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
850cdf0e10cSrcweir 		switch (nPropType)
851cdf0e10cSrcweir 		{
852cdf0e10cSrcweir             case BASEPROPERTY_ENFORCE_FORMAT:
853cdf0e10cSrcweir             {
854cdf0e10cSrcweir                 sal_Bool bEnable( sal_True );
855cdf0e10cSrcweir                 if ( Value >>= bEnable )
856cdf0e10cSrcweir                     pField->EnableNotANumber( !bEnable );
857cdf0e10cSrcweir             }
858cdf0e10cSrcweir             break;
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_MIN:
861cdf0e10cSrcweir 			case BASEPROPERTY_VALUEMIN_DOUBLE:
862cdf0e10cSrcweir 				SetMinValue(Value);
863cdf0e10cSrcweir 				break;
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_MAX:
866cdf0e10cSrcweir 			case BASEPROPERTY_VALUEMAX_DOUBLE:
867cdf0e10cSrcweir 				SetMaxValue(Value);
868cdf0e10cSrcweir 				break;
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_DEFAULT:
871cdf0e10cSrcweir 				SetDefaultValue(Value);
872cdf0e10cSrcweir 				break;
873cdf0e10cSrcweir 
874cdf0e10cSrcweir             case BASEPROPERTY_TREATASNUMBER:
875cdf0e10cSrcweir             {
876cdf0e10cSrcweir                 sal_Bool b = sal_Bool();
877cdf0e10cSrcweir                 if ( Value >>= b )
878cdf0e10cSrcweir                     SetTreatAsNumber(b);
879cdf0e10cSrcweir             }
880cdf0e10cSrcweir             break;
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 			case BASEPROPERTY_FORMATSSUPPLIER:
883cdf0e10cSrcweir 				if (!Value.hasValue())
884cdf0e10cSrcweir 					setFormatsSupplier(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > (NULL));
885cdf0e10cSrcweir 				else
886cdf0e10cSrcweir 				{
887cdf0e10cSrcweir 					::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS;
888cdf0e10cSrcweir 					if ( Value >>= xNFS )
889cdf0e10cSrcweir 						setFormatsSupplier(xNFS);
890cdf0e10cSrcweir 				}
891cdf0e10cSrcweir 				break;
892cdf0e10cSrcweir 			case BASEPROPERTY_FORMATKEY:
893cdf0e10cSrcweir 				if (!Value.hasValue())
894cdf0e10cSrcweir 					setFormatKey(0);
895cdf0e10cSrcweir 				else
896cdf0e10cSrcweir 				{
897cdf0e10cSrcweir 					sal_Int32 n = 0;
898cdf0e10cSrcweir 					if ( Value >>= n )
899cdf0e10cSrcweir 						setFormatKey(n);
900cdf0e10cSrcweir 				}
901cdf0e10cSrcweir 				break;
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_VALUE:
904cdf0e10cSrcweir 			case BASEPROPERTY_VALUE_DOUBLE:
905cdf0e10cSrcweir 			{
906cdf0e10cSrcweir 				const ::com::sun::star::uno::TypeClass rTC = Value.getValueType().getTypeClass();
907cdf0e10cSrcweir 				if (rTC != ::com::sun::star::uno::TypeClass_STRING)
908cdf0e10cSrcweir 					// no string
909cdf0e10cSrcweir 					if (rTC != ::com::sun::star::uno::TypeClass_DOUBLE)
910cdf0e10cSrcweir 						// no double
911cdf0e10cSrcweir 						if (Value.hasValue())
912cdf0e10cSrcweir 						{	// but a value
913cdf0e10cSrcweir 							// try if it is something converitble
914cdf0e10cSrcweir 							sal_Int32 nValue = 0;
915cdf0e10cSrcweir 							if (!(Value >>= nValue))
916cdf0e10cSrcweir 								throw ::com::sun::star::lang::IllegalArgumentException();
917cdf0e10cSrcweir 							SetValue(::com::sun::star::uno::makeAny((double)nValue));
918cdf0e10cSrcweir 							break;
919cdf0e10cSrcweir 						}
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 				SetValue(Value);
922cdf0e10cSrcweir 			}
923cdf0e10cSrcweir 			break;
924cdf0e10cSrcweir 			case BASEPROPERTY_VALUESTEP_DOUBLE:
925cdf0e10cSrcweir 			{
926cdf0e10cSrcweir 				double d = 0.0;
927cdf0e10cSrcweir 				if ( Value >>= d )
928cdf0e10cSrcweir 		 			pField->SetSpinSize( d );
929cdf0e10cSrcweir 				else
930cdf0e10cSrcweir 				{
931cdf0e10cSrcweir 					sal_Int32 n = 0;
932cdf0e10cSrcweir 					if ( Value >>= n )
933cdf0e10cSrcweir 		 				pField->SetSpinSize( n );
934cdf0e10cSrcweir 				}
935cdf0e10cSrcweir 			}
936cdf0e10cSrcweir 			break;
937cdf0e10cSrcweir 			case BASEPROPERTY_DECIMALACCURACY:
938cdf0e10cSrcweir 			{
939cdf0e10cSrcweir 				sal_Int32 n = 0;
940cdf0e10cSrcweir 				if ( Value >>= n )
941cdf0e10cSrcweir 			 		pField->SetDecimalDigits( (sal_uInt16)n );
942cdf0e10cSrcweir 			}
943cdf0e10cSrcweir 			break;
944cdf0e10cSrcweir 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
945cdf0e10cSrcweir 			{
946cdf0e10cSrcweir 					sal_Bool b = sal_Bool();
947cdf0e10cSrcweir 					if ( Value >>= b )
948cdf0e10cSrcweir 			 		pField->SetThousandsSep( b );
949cdf0e10cSrcweir 			}
950cdf0e10cSrcweir 			break;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 			default:
953cdf0e10cSrcweir 				VCLXSpinField::setProperty( PropertyName, Value );
954cdf0e10cSrcweir 		}
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 		if (BASEPROPERTY_TEXTCOLOR == nPropType)
957cdf0e10cSrcweir 		{	// after setting a new text color, think again about the AutoColor flag of the control
958cdf0e10cSrcweir 			// 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
959cdf0e10cSrcweir 			pField->SetAutoColor(!Value.hasValue());
960cdf0e10cSrcweir 		}
961cdf0e10cSrcweir 	}
962cdf0e10cSrcweir 	else
963cdf0e10cSrcweir 		VCLXSpinField::setProperty( PropertyName, Value );
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir // --------------------------------------------------------------------------------------
getProperty(const::rtl::OUString & PropertyName)967cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
970cdf0e10cSrcweir 
971cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
974cdf0e10cSrcweir 	if ( pField )
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
977cdf0e10cSrcweir 		switch (nPropType)
978cdf0e10cSrcweir 		{
979cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_MIN:
980cdf0e10cSrcweir 			case BASEPROPERTY_VALUEMIN_DOUBLE:
981cdf0e10cSrcweir 				aReturn <<= GetMinValue();
982cdf0e10cSrcweir 				break;
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_MAX:
985cdf0e10cSrcweir 			case BASEPROPERTY_VALUEMAX_DOUBLE:
986cdf0e10cSrcweir 				aReturn <<= GetMaxValue();
987cdf0e10cSrcweir 				break;
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_DEFAULT:
990cdf0e10cSrcweir 				aReturn <<= GetDefaultValue();
991cdf0e10cSrcweir 				break;
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 			case BASEPROPERTY_TREATASNUMBER:
994cdf0e10cSrcweir 				aReturn <<= GetTreatAsNumber();
995cdf0e10cSrcweir 				break;
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 			case BASEPROPERTY_EFFECTIVE_VALUE:
998cdf0e10cSrcweir 			case BASEPROPERTY_VALUE_DOUBLE:
999cdf0e10cSrcweir 				aReturn <<= GetValue();
1000cdf0e10cSrcweir 				break;
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 			case BASEPROPERTY_VALUESTEP_DOUBLE:
1003cdf0e10cSrcweir 				aReturn <<= pField->GetSpinSize();
1004cdf0e10cSrcweir 				break;
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 			case BASEPROPERTY_DECIMALACCURACY:
1007cdf0e10cSrcweir 				aReturn <<= pField->GetDecimalDigits();
1008cdf0e10cSrcweir 				break;
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 			case BASEPROPERTY_FORMATSSUPPLIER:
1011cdf0e10cSrcweir 			{
1012cdf0e10cSrcweir 				if (!bIsStandardSupplier)
1013cdf0e10cSrcweir 				{	// ansonsten void
1014cdf0e10cSrcweir 					::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >  xSupplier = getFormatsSupplier();
1015cdf0e10cSrcweir 					aReturn <<= xSupplier;
1016cdf0e10cSrcweir 				}
1017cdf0e10cSrcweir 			}
1018cdf0e10cSrcweir 			break;
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 			case BASEPROPERTY_FORMATKEY:
1021cdf0e10cSrcweir 			{
1022cdf0e10cSrcweir 				if (!bIsStandardSupplier)
1023cdf0e10cSrcweir 					aReturn <<= getFormatKey();
1024cdf0e10cSrcweir 			}
1025cdf0e10cSrcweir 			break;
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 			default:
1028cdf0e10cSrcweir 				aReturn <<= VCLXSpinField::getProperty(PropertyName);
1029cdf0e10cSrcweir 		}
1030cdf0e10cSrcweir 	}
1031cdf0e10cSrcweir 	return aReturn;
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir // --------------------------------------------------------------------------------------
convertEffectiveValue(const::com::sun::star::uno::Any & rValue)1035cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::convertEffectiveValue(const ::com::sun::star::uno::Any& rValue)
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1040cdf0e10cSrcweir 	if (!pField)
1041cdf0e10cSrcweir 		return aReturn;
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 	switch (rValue.getValueType().getTypeClass())
1044cdf0e10cSrcweir 	{
1045cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_DOUBLE:
1046cdf0e10cSrcweir 			if (pField->TreatingAsNumber())
1047cdf0e10cSrcweir 			{
1048cdf0e10cSrcweir 				double d = 0.0;
1049cdf0e10cSrcweir 				rValue >>= d;
1050cdf0e10cSrcweir 				aReturn <<= d;
1051cdf0e10cSrcweir 			}
1052cdf0e10cSrcweir 			else
1053cdf0e10cSrcweir 			{
1054cdf0e10cSrcweir 				SvNumberFormatter* pFormatter = pField->GetFormatter();
1055cdf0e10cSrcweir 				if (!pFormatter)
1056cdf0e10cSrcweir 					pFormatter = pField->StandardFormatter();
1057cdf0e10cSrcweir 					// should never fail
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 				Color* pDum;
1060cdf0e10cSrcweir 				double d = 0.0;
1061cdf0e10cSrcweir 				rValue >>= d;
1062cdf0e10cSrcweir 				String sConverted;
1063cdf0e10cSrcweir 				pFormatter->GetOutputString(d, 0, sConverted, &pDum);
1064cdf0e10cSrcweir 				aReturn <<= ::rtl::OUString( sConverted );
1065cdf0e10cSrcweir 			}
1066cdf0e10cSrcweir 			break;
1067cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_STRING:
1068cdf0e10cSrcweir 		{
1069cdf0e10cSrcweir 			::rtl::OUString aStr;
1070cdf0e10cSrcweir 			rValue >>= aStr;
1071cdf0e10cSrcweir 			String sValue = aStr;
1072cdf0e10cSrcweir 			if (pField->TreatingAsNumber())
1073cdf0e10cSrcweir 			{
1074cdf0e10cSrcweir 				SvNumberFormatter* pFormatter = pField->GetFormatter();
1075cdf0e10cSrcweir 				if (!pFormatter)
1076cdf0e10cSrcweir 					pFormatter = pField->StandardFormatter();
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 				double dVal;
1079cdf0e10cSrcweir 				sal_uInt32 nTestFormat(0);
1080cdf0e10cSrcweir 				if (!pFormatter->IsNumberFormat(sValue, nTestFormat, dVal))
1081cdf0e10cSrcweir 					aReturn.clear();
1082cdf0e10cSrcweir 				aReturn <<=dVal;
1083cdf0e10cSrcweir 			}
1084cdf0e10cSrcweir 			else
1085cdf0e10cSrcweir 				aReturn <<= aStr;
1086cdf0e10cSrcweir 		}
1087cdf0e10cSrcweir 		break;
1088cdf0e10cSrcweir 		default:
1089cdf0e10cSrcweir 			aReturn.clear();
1090cdf0e10cSrcweir 			break;
1091cdf0e10cSrcweir 	}
1092cdf0e10cSrcweir 	return aReturn;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetMinValue(const::com::sun::star::uno::Any & rValue)1096cdf0e10cSrcweir void SVTXFormattedField::SetMinValue(const ::com::sun::star::uno::Any& rValue)
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1099cdf0e10cSrcweir 	if (!pField)
1100cdf0e10cSrcweir 		return;
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 	switch (rValue.getValueType().getTypeClass())
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 	{
1105cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_DOUBLE:
1106cdf0e10cSrcweir         {
1107cdf0e10cSrcweir 			double d = 0.0;
1108cdf0e10cSrcweir 			rValue >>= d;
1109cdf0e10cSrcweir 			pField->SetMinValue(d);
1110cdf0e10cSrcweir         }
1111cdf0e10cSrcweir 			break;
1112cdf0e10cSrcweir 		default:
1113cdf0e10cSrcweir 			DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
1114cdf0e10cSrcweir 			if ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID )
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 			{
1117cdf0e10cSrcweir 				throw ::com::sun::star::lang::IllegalArgumentException();
1118cdf0e10cSrcweir 			}
1119cdf0e10cSrcweir 			pField->ClearMinValue();
1120cdf0e10cSrcweir 			break;
1121cdf0e10cSrcweir 	}
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir // --------------------------------------------------------------------------------------
GetMinValue()1125cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetMinValue()
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1128cdf0e10cSrcweir 	if (!pField || !pField->HasMinValue())
1129cdf0e10cSrcweir 		return ::com::sun::star::uno::Any();
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1132cdf0e10cSrcweir 	aReturn <<= pField->GetMinValue();
1133cdf0e10cSrcweir 	return aReturn;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetMaxValue(const::com::sun::star::uno::Any & rValue)1137cdf0e10cSrcweir void SVTXFormattedField::SetMaxValue(const ::com::sun::star::uno::Any& rValue)
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1140cdf0e10cSrcweir 	if (!pField)
1141cdf0e10cSrcweir 		return;
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	switch (rValue.getValueType().getTypeClass())
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 	{
1146cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_DOUBLE:
1147cdf0e10cSrcweir         {
1148cdf0e10cSrcweir 			double d = 0.0;
1149cdf0e10cSrcweir 			rValue >>= d;
1150cdf0e10cSrcweir 			pField->SetMaxValue(d);
1151cdf0e10cSrcweir         }
1152cdf0e10cSrcweir 			break;
1153cdf0e10cSrcweir 		default:
1154cdf0e10cSrcweir 			if (rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID)
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir 			{
1157cdf0e10cSrcweir 				throw ::com::sun::star::lang::IllegalArgumentException();
1158cdf0e10cSrcweir 			}
1159cdf0e10cSrcweir 			pField->ClearMaxValue();
1160cdf0e10cSrcweir 			break;
1161cdf0e10cSrcweir 	}
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir // --------------------------------------------------------------------------------------
GetMaxValue()1165cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetMaxValue()
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1168cdf0e10cSrcweir 	if (!pField || !pField->HasMaxValue())
1169cdf0e10cSrcweir 		return ::com::sun::star::uno::Any();
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1172cdf0e10cSrcweir 	aReturn <<= pField->GetMaxValue();
1173cdf0e10cSrcweir 	return aReturn;
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetDefaultValue(const::com::sun::star::uno::Any & rValue)1177cdf0e10cSrcweir void SVTXFormattedField::SetDefaultValue(const ::com::sun::star::uno::Any& rValue)
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1180cdf0e10cSrcweir 	if (!pField)
1181cdf0e10cSrcweir 		return;
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 	::com::sun::star::uno::Any aConverted = convertEffectiveValue(rValue);
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir 	switch (aConverted.getValueType().getTypeClass())
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 	{
1188cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_DOUBLE:
1189cdf0e10cSrcweir 		{
1190cdf0e10cSrcweir 			double d = 0.0;
1191cdf0e10cSrcweir 			aConverted >>= d;
1192cdf0e10cSrcweir 			pField->SetDefaultValue(d);
1193cdf0e10cSrcweir 		}
1194cdf0e10cSrcweir 		break;
1195cdf0e10cSrcweir 		case ::com::sun::star::uno::TypeClass_STRING:
1196cdf0e10cSrcweir 		{
1197cdf0e10cSrcweir 			::rtl::OUString aStr;
1198cdf0e10cSrcweir 			aConverted >>= aStr;
1199cdf0e10cSrcweir 			pField->SetDefaultText( aStr );
1200cdf0e10cSrcweir 		}
1201cdf0e10cSrcweir 		break;
1202cdf0e10cSrcweir 		default:
1203cdf0e10cSrcweir 			pField->EnableEmptyField(sal_True);
1204cdf0e10cSrcweir 				// nur noch void erlaubt
1205cdf0e10cSrcweir 			break;
1206cdf0e10cSrcweir 	}
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir // --------------------------------------------------------------------------------------
GetDefaultValue()1210cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetDefaultValue()
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1213cdf0e10cSrcweir 	if (!pField || pField->IsEmptyFieldEnabled())
1214cdf0e10cSrcweir 		return ::com::sun::star::uno::Any();
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1217cdf0e10cSrcweir 	if (pField->TreatingAsNumber())
1218cdf0e10cSrcweir 		aReturn <<= pField->GetDefaultValue();
1219cdf0e10cSrcweir 	else
1220cdf0e10cSrcweir 		aReturn <<= ::rtl::OUString( pField->GetDefaultText() );
1221cdf0e10cSrcweir 	return aReturn;
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir // --------------------------------------------------------------------------------------
GetTreatAsNumber()1225cdf0e10cSrcweir sal_Bool SVTXFormattedField::GetTreatAsNumber()
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1228cdf0e10cSrcweir 	if (pField)
1229cdf0e10cSrcweir 		return pField->TreatingAsNumber();
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir 	return sal_True;
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetTreatAsNumber(sal_Bool bSet)1235cdf0e10cSrcweir void SVTXFormattedField::SetTreatAsNumber(sal_Bool bSet)
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1238cdf0e10cSrcweir 	if (pField)
1239cdf0e10cSrcweir 		pField->TreatAsNumber(bSet);
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir // --------------------------------------------------------------------------------------
GetValue()1243cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetValue()
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1246cdf0e10cSrcweir 	if (!pField)
1247cdf0e10cSrcweir 		return ::com::sun::star::uno::Any();
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1250cdf0e10cSrcweir 	if (!pField->TreatingAsNumber())
1251cdf0e10cSrcweir 	{
1252cdf0e10cSrcweir 		::rtl::OUString sText = pField->GetTextValue();
1253cdf0e10cSrcweir 		aReturn <<= sText;
1254cdf0e10cSrcweir 	}
1255cdf0e10cSrcweir 	else
1256cdf0e10cSrcweir 	{
1257cdf0e10cSrcweir 		if (pField->GetText().Len())	// empty wird erst mal standardmaessig als void nach draussen gereicht
1258cdf0e10cSrcweir 			aReturn <<= pField->GetValue();
1259cdf0e10cSrcweir 	}
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir 	return aReturn;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SetValue(const::com::sun::star::uno::Any & rValue)1265cdf0e10cSrcweir void SVTXFormattedField::SetValue(const ::com::sun::star::uno::Any& rValue)
1266cdf0e10cSrcweir {
1267cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1268cdf0e10cSrcweir 	if (!pField)
1269cdf0e10cSrcweir 		return;
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	if (!rValue.hasValue())
1272cdf0e10cSrcweir 	{
1273cdf0e10cSrcweir 		pField->SetText(String());
1274cdf0e10cSrcweir 	}
1275cdf0e10cSrcweir 	else
1276cdf0e10cSrcweir 	{
1277cdf0e10cSrcweir 		if (rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE )
1278cdf0e10cSrcweir 		{
1279cdf0e10cSrcweir 			double d = 0.0;
1280cdf0e10cSrcweir 			rValue >>= d;
1281cdf0e10cSrcweir 			pField->SetValue(d);
1282cdf0e10cSrcweir 		}
1283cdf0e10cSrcweir 		else
1284cdf0e10cSrcweir 		{
1285cdf0e10cSrcweir 			DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir 			::rtl::OUString sText;
1288cdf0e10cSrcweir 			rValue >>= sText;
1289cdf0e10cSrcweir 			String aStr( sText );
1290cdf0e10cSrcweir 			if (!pField->TreatingAsNumber())
1291cdf0e10cSrcweir 				pField->SetTextFormatted(aStr);
1292cdf0e10cSrcweir 			else
1293cdf0e10cSrcweir 				pField->SetTextValue(aStr);
1294cdf0e10cSrcweir 		}
1295cdf0e10cSrcweir 	}
1296cdf0e10cSrcweir //	NotifyTextListeners();
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir // --------------------------------------------------------------------------------------
getFormatsSupplier(void) const1300cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >  SVTXFormattedField::getFormatsSupplier(void) const
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir 	return ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > ((::com::sun::star::util::XNumberFormatsSupplier*)m_pCurrentSupplier);
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir // --------------------------------------------------------------------------------------
setFormatsSupplier(const::com::sun::star::uno::Reference<::com::sun::star::util::XNumberFormatsSupplier> & xSupplier)1306cdf0e10cSrcweir void SVTXFormattedField::setFormatsSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier)
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir 	SvNumberFormatsSupplierObj* pNew = NULL;
1311cdf0e10cSrcweir 	if (!xSupplier.is())
1312cdf0e10cSrcweir 	{
1313cdf0e10cSrcweir 		if (pField)
1314cdf0e10cSrcweir 		{
1315cdf0e10cSrcweir 			pNew = new SvNumberFormatsSupplierObj(pField->StandardFormatter());
1316cdf0e10cSrcweir 			bIsStandardSupplier = sal_True;
1317cdf0e10cSrcweir 		}
1318cdf0e10cSrcweir 	}
1319cdf0e10cSrcweir 	else
1320cdf0e10cSrcweir 	{
1321cdf0e10cSrcweir 		pNew = SvNumberFormatsSupplierObj::getImplementation(xSupplier);
1322cdf0e10cSrcweir 		bIsStandardSupplier = sal_False;
1323cdf0e10cSrcweir 	}
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 	if (!pNew)
1326cdf0e10cSrcweir 		return;		// TODO : wie das behandeln ?
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 	if (m_pCurrentSupplier)
1329cdf0e10cSrcweir 		m_pCurrentSupplier->release();
1330cdf0e10cSrcweir 	m_pCurrentSupplier = pNew;
1331cdf0e10cSrcweir 	m_pCurrentSupplier->acquire();
1332cdf0e10cSrcweir 	if (pField)
1333cdf0e10cSrcweir 	{
1334cdf0e10cSrcweir 		// den aktuellen Value mit hinueberretten
1335cdf0e10cSrcweir 		::com::sun::star::uno::Any aCurrent = GetValue();
1336cdf0e10cSrcweir 		pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), sal_False);
1337cdf0e10cSrcweir 		if (nKeyToSetDelayed != -1)
1338cdf0e10cSrcweir 		{
1339cdf0e10cSrcweir 			pField->SetFormatKey(nKeyToSetDelayed);
1340cdf0e10cSrcweir 			nKeyToSetDelayed = -1;
1341cdf0e10cSrcweir 		}
1342cdf0e10cSrcweir 		SetValue(aCurrent);
1343cdf0e10cSrcweir 		NotifyTextListeners();
1344cdf0e10cSrcweir 	}
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir // --------------------------------------------------------------------------------------
getFormatKey(void) const1348cdf0e10cSrcweir sal_Int32 SVTXFormattedField::getFormatKey(void) const
1349cdf0e10cSrcweir {
1350cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1351cdf0e10cSrcweir 	return pField ? pField->GetFormatKey() : 0;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir // --------------------------------------------------------------------------------------
setFormatKey(sal_Int32 nKey)1355cdf0e10cSrcweir void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
1356cdf0e10cSrcweir {
1357cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1358cdf0e10cSrcweir 	if (pField)
1359cdf0e10cSrcweir 	{
1360cdf0e10cSrcweir 		if (pField->GetFormatter())
1361cdf0e10cSrcweir 			pField->SetFormatKey(nKey);
1362cdf0e10cSrcweir 		else
1363cdf0e10cSrcweir 		{	// Wahrscheinlich bin ich gerade in einem Block, in dem erst der Key und dann der Formatter gesetzt
1364cdf0e10cSrcweir 			// wird, das passiert initial mit ziemlicher Sicherheit, da die Properties in alphabetischer Reihenfolge
1365cdf0e10cSrcweir 			// gesetzt werden, und der FormatsSupplier nun mal vor dem FormatKey kommt
1366cdf0e10cSrcweir 			nKeyToSetDelayed = nKey;
1367cdf0e10cSrcweir 		}
1368cdf0e10cSrcweir 		NotifyTextListeners();
1369cdf0e10cSrcweir 	}
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir // --------------------------------------------------------------------------------------
NotifyTextListeners()1373cdf0e10cSrcweir void SVTXFormattedField::NotifyTextListeners()
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir 	if ( GetTextListeners().getLength() )
1376cdf0e10cSrcweir 	{
1377cdf0e10cSrcweir 		::com::sun::star::awt::TextEvent aEvent;
1378cdf0e10cSrcweir 		aEvent.Source = (::cppu::OWeakObject*)this;
1379cdf0e10cSrcweir 		GetTextListeners().textChanged( aEvent );
1380cdf0e10cSrcweir 	}
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1383cdf0e10cSrcweir void SVTXFormattedField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1384cdf0e10cSrcweir {
1385cdf0e10cSrcweir     PushPropertyIds( rIds,
1386cdf0e10cSrcweir                      // FIXME: elide duplication ?
1387cdf0e10cSrcweir                      BASEPROPERTY_EFFECTIVE_MIN,
1388cdf0e10cSrcweir                      BASEPROPERTY_VALUEMIN_DOUBLE,
1389cdf0e10cSrcweir                      BASEPROPERTY_EFFECTIVE_MAX,
1390cdf0e10cSrcweir                      BASEPROPERTY_VALUEMAX_DOUBLE,
1391cdf0e10cSrcweir                      BASEPROPERTY_EFFECTIVE_DEFAULT,
1392cdf0e10cSrcweir                      BASEPROPERTY_TREATASNUMBER,
1393cdf0e10cSrcweir                      BASEPROPERTY_EFFECTIVE_VALUE,
1394cdf0e10cSrcweir                      BASEPROPERTY_VALUE_DOUBLE,
1395cdf0e10cSrcweir                      BASEPROPERTY_VALUESTEP_DOUBLE,
1396cdf0e10cSrcweir                      BASEPROPERTY_DECIMALACCURACY,
1397cdf0e10cSrcweir                      BASEPROPERTY_FORMATSSUPPLIER,
1398cdf0e10cSrcweir                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
1399cdf0e10cSrcweir                      BASEPROPERTY_FORMATKEY,
1400cdf0e10cSrcweir                      BASEPROPERTY_TREATASNUMBER,
1401cdf0e10cSrcweir                      BASEPROPERTY_ENFORCE_FORMAT,
1402cdf0e10cSrcweir                      0);
1403cdf0e10cSrcweir     VCLXWindow::ImplGetPropertyIds( rIds, true );
1404cdf0e10cSrcweir     VCLXSpinField::ImplGetPropertyIds( rIds );
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir //	----------------------------------------------------
1409cdf0e10cSrcweir //	class SVTXRoadmap
1410cdf0e10cSrcweir //	----------------------------------------------------
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir using namespace svt;
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir // --------------------------------------------------------------------------------------
SVTXRoadmap()1415cdf0e10cSrcweir SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this )
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir // --------------------------------------------------------------------------------------
~SVTXRoadmap()1420cdf0e10cSrcweir SVTXRoadmap::~SVTXRoadmap()
1421cdf0e10cSrcweir {
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1424cdf0e10cSrcweir void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir 	switch ( rVclWindowEvent.GetId() )
1427cdf0e10cSrcweir 	{
1428cdf0e10cSrcweir 		case VCLEVENT_ROADMAP_ITEMSELECTED:
1429cdf0e10cSrcweir         {
1430cdf0e10cSrcweir         	::vos::OGuard aGuard( GetMutex() );
1431cdf0e10cSrcweir             ::svt::ORoadmap* pField = GetRoadmap();
1432cdf0e10cSrcweir 	        if ( pField )
1433cdf0e10cSrcweir 	        {
1434cdf0e10cSrcweir                 sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID();
1435cdf0e10cSrcweir                 ::com::sun::star::awt::ItemEvent aEvent;
1436cdf0e10cSrcweir                 aEvent.Selected = CurItemID;
1437cdf0e10cSrcweir                 aEvent.Highlighted = CurItemID;
1438cdf0e10cSrcweir                 aEvent.ItemId = CurItemID;
1439cdf0e10cSrcweir                 maItemListeners.itemStateChanged( aEvent );
1440cdf0e10cSrcweir             }
1441cdf0e10cSrcweir         }
1442cdf0e10cSrcweir         break;
1443cdf0e10cSrcweir 		default:
1444cdf0e10cSrcweir             SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent );
1445cdf0e10cSrcweir 		    break;
1446cdf0e10cSrcweir 	}
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 
propertyChange(const::com::sun::star::beans::PropertyChangeEvent & evt)1450cdf0e10cSrcweir void SVTXRoadmap::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
1451cdf0e10cSrcweir {
1452cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1453cdf0e10cSrcweir     ::svt::ORoadmap* pField = GetRoadmap();
1454cdf0e10cSrcweir 	if ( pField )
1455cdf0e10cSrcweir 	{
1456cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1457cdf0e10cSrcweir         xRoadmapItem = evt.Source;
1458cdf0e10cSrcweir         sal_Int32 nID = 0;
1459cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1460cdf0e10cSrcweir         ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "ID" ));
1461cdf0e10cSrcweir         aValue >>= nID;
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir         ::com::sun::star::uno::Any rVal = evt.NewValue;
1464cdf0e10cSrcweir         evt.NewValue >>= rVal;
1465cdf0e10cSrcweir         ::rtl::OUString sPropertyName = evt.PropertyName;
1466cdf0e10cSrcweir         if ( sPropertyName.equals(::rtl::OUString::createFromAscii( "Enabled" ) ) )
1467cdf0e10cSrcweir         {
1468cdf0e10cSrcweir             sal_Bool bEnable = false;
1469cdf0e10cSrcweir             evt.NewValue >>= bEnable;
1470cdf0e10cSrcweir             pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable );
1471cdf0e10cSrcweir         }
1472cdf0e10cSrcweir         else if ( sPropertyName.equals(::rtl::OUString::createFromAscii( "Label" ) ) )
1473cdf0e10cSrcweir         {
1474cdf0e10cSrcweir             ::rtl::OUString sLabel;
1475cdf0e10cSrcweir             evt.NewValue >>= sLabel;
1476cdf0e10cSrcweir             pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel );
1477cdf0e10cSrcweir         }
1478cdf0e10cSrcweir         else if  ( sPropertyName.equals(::rtl::OUString::createFromAscii( "ID" ) ) )
1479cdf0e10cSrcweir         {
1480cdf0e10cSrcweir             sal_Int32 nNewID = 0;
1481cdf0e10cSrcweir             evt.NewValue >>= nNewID;
1482cdf0e10cSrcweir             evt.OldValue >>= nID;
1483cdf0e10cSrcweir             pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID );
1484cdf0e10cSrcweir         }
1485cdf0e10cSrcweir     //    else
1486cdf0e10cSrcweir             // Todo: handle Interactive appropriately
1487cdf0e10cSrcweir     }
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1491cdf0e10cSrcweir void SVTXRoadmap::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir     maItemListeners.addInterface( l );
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1496cdf0e10cSrcweir void SVTXRoadmap::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir     maItemListeners.removeInterface( l );
1499cdf0e10cSrcweir }
1500cdf0e10cSrcweir 
GetRMItemData(const::com::sun::star::container::ContainerEvent & _rEvent)1501cdf0e10cSrcweir RMItemData SVTXRoadmap::GetRMItemData( const ::com::sun::star::container::ContainerEvent& _rEvent )
1502cdf0e10cSrcweir {
1503cdf0e10cSrcweir     RMItemData aCurRMItemData;
1504cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1505cdf0e10cSrcweir 	_rEvent.Element >>= xRoadmapItem;
1506cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1507cdf0e10cSrcweir 	if ( xPropertySet.is() )
1508cdf0e10cSrcweir     {
1509cdf0e10cSrcweir         ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "Label" ));
1510cdf0e10cSrcweir         aValue >>= aCurRMItemData.Label;
1511cdf0e10cSrcweir         aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "ID" ));
1512cdf0e10cSrcweir         aValue >>= aCurRMItemData.n_ID;
1513cdf0e10cSrcweir         aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "Enabled" ));
1514cdf0e10cSrcweir         aValue >>= aCurRMItemData.b_Enabled;
1515cdf0e10cSrcweir     }
1516cdf0e10cSrcweir     return aCurRMItemData;;
1517cdf0e10cSrcweir }
1518cdf0e10cSrcweir 
elementInserted(const::com::sun::star::container::ContainerEvent & _rEvent)1519cdf0e10cSrcweir void SVTXRoadmap::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1522cdf0e10cSrcweir     ::svt::ORoadmap* pField = GetRoadmap();
1523cdf0e10cSrcweir 	if ( pField )
1524cdf0e10cSrcweir 	{
1525cdf0e10cSrcweir         RMItemData CurItemData = GetRMItemData(  _rEvent );
1526cdf0e10cSrcweir         sal_Int32 InsertIndex = 0;
1527cdf0e10cSrcweir         _rEvent.Accessor >>= InsertIndex;
1528cdf0e10cSrcweir         pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1529cdf0e10cSrcweir     }
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir 
elementRemoved(const::com::sun::star::container::ContainerEvent & _rEvent)1532cdf0e10cSrcweir void SVTXRoadmap::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1535cdf0e10cSrcweir     ::svt::ORoadmap* pField = GetRoadmap();
1536cdf0e10cSrcweir 	if ( pField )
1537cdf0e10cSrcweir 	{
1538cdf0e10cSrcweir         sal_Int32 DelIndex = 0;
1539cdf0e10cSrcweir         _rEvent.Accessor >>= DelIndex;
1540cdf0e10cSrcweir         pField->DeleteRoadmapItem(DelIndex);
1541cdf0e10cSrcweir //        pField->GetCurrentRoadmapItem()
1542cdf0e10cSrcweir //        setProperty(::rtl::OUString.createFromAscii( "CurrentItem" )aAny,
1543cdf0e10cSrcweir     }
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir 
elementReplaced(const::com::sun::star::container::ContainerEvent & _rEvent)1546cdf0e10cSrcweir void SVTXRoadmap::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1547cdf0e10cSrcweir {
1548cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1549cdf0e10cSrcweir     ::svt::ORoadmap* pField = GetRoadmap();
1550cdf0e10cSrcweir 	if ( pField )
1551cdf0e10cSrcweir 	{
1552cdf0e10cSrcweir         RMItemData CurItemData = GetRMItemData(  _rEvent );
1553cdf0e10cSrcweir         sal_Int32 ReplaceIndex = 0;
1554cdf0e10cSrcweir         _rEvent.Accessor >>= ReplaceIndex;
1555cdf0e10cSrcweir         pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1556cdf0e10cSrcweir     }
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir // --------------------------------------------------------------------------------------
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1562cdf0e10cSrcweir void SVTXRoadmap::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir     ::svt::ORoadmap* pField = GetRoadmap();
1567cdf0e10cSrcweir 	if ( pField )
1568cdf0e10cSrcweir 	{
1569cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1570cdf0e10cSrcweir 		switch (nPropType)
1571cdf0e10cSrcweir 		{
1572cdf0e10cSrcweir 			case BASEPROPERTY_COMPLETE:
1573cdf0e10cSrcweir             {
1574cdf0e10cSrcweir                 sal_Bool b = false;
1575cdf0e10cSrcweir 	    		Value >>= b;
1576cdf0e10cSrcweir                 pField->SetRoadmapComplete( b);
1577cdf0e10cSrcweir             }
1578cdf0e10cSrcweir             break;
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir 			case BASEPROPERTY_ACTIVATED:
1581cdf0e10cSrcweir             {
1582cdf0e10cSrcweir    		    	sal_Bool b = false;
1583cdf0e10cSrcweir 	    		Value >>= b;
1584cdf0e10cSrcweir                 pField->SetRoadmapInteractive( b);
1585cdf0e10cSrcweir             }
1586cdf0e10cSrcweir 			break;
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir             case BASEPROPERTY_CURRENTITEMID:
1589cdf0e10cSrcweir             {
1590cdf0e10cSrcweir    				sal_Int32 nId = 0;
1591cdf0e10cSrcweir 				Value >>= nId;
1592cdf0e10cSrcweir                 pField->SelectRoadmapItemByID( (RoadmapTypes::ItemId)nId );
1593cdf0e10cSrcweir             }
1594cdf0e10cSrcweir             break;
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir             case BASEPROPERTY_TEXT:
1597cdf0e10cSrcweir             {
1598cdf0e10cSrcweir    				::rtl::OUString aStr;
1599cdf0e10cSrcweir 				Value >>= aStr;
1600cdf0e10cSrcweir                 pField->SetText( aStr );
1601cdf0e10cSrcweir                 pField->Invalidate();
1602cdf0e10cSrcweir             }
1603cdf0e10cSrcweir             break;
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir             default:
1606cdf0e10cSrcweir 				SVTXRoadmap_Base::setProperty( PropertyName, Value );
1607cdf0e10cSrcweir                 break;
1608cdf0e10cSrcweir 		}
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir 	}
1611cdf0e10cSrcweir 	else
1612cdf0e10cSrcweir 		SVTXRoadmap_Base::setProperty( PropertyName, Value );
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir // --------------------------------------------------------------------------------------
getProperty(const::rtl::OUString & PropertyName)1617cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXRoadmap::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	::svt::ORoadmap* pField = GetRoadmap();
1624cdf0e10cSrcweir 	if ( pField )
1625cdf0e10cSrcweir 	{
1626cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1627cdf0e10cSrcweir 		switch (nPropType)
1628cdf0e10cSrcweir 		{
1629cdf0e10cSrcweir 			case BASEPROPERTY_COMPLETE:
1630cdf0e10cSrcweir                 aReturn <<= pField->IsRoadmapComplete();
1631cdf0e10cSrcweir                 break;
1632cdf0e10cSrcweir 			case BASEPROPERTY_ACTIVATED:
1633cdf0e10cSrcweir                 aReturn <<= pField->IsRoadmapInteractive();
1634cdf0e10cSrcweir 				break;
1635cdf0e10cSrcweir 			case BASEPROPERTY_CURRENTITEMID:
1636cdf0e10cSrcweir                 aReturn <<= pField->GetCurrentRoadmapItemID();
1637cdf0e10cSrcweir                 break;
1638cdf0e10cSrcweir             default:
1639cdf0e10cSrcweir 				aReturn = SVTXRoadmap_Base::getProperty(PropertyName);
1640cdf0e10cSrcweir                 break;
1641cdf0e10cSrcweir 		}
1642cdf0e10cSrcweir 	}
1643cdf0e10cSrcweir 	return aReturn;
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir 
ImplSetNewImage()1646cdf0e10cSrcweir void SVTXRoadmap::ImplSetNewImage()
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir     OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" );
1649cdf0e10cSrcweir 	::svt::ORoadmap* pButton = static_cast< ::svt::ORoadmap* >( GetWindow() );
1650cdf0e10cSrcweir 	pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() );
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1653cdf0e10cSrcweir void SVTXRoadmap::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir     PushPropertyIds( rIds,
1656cdf0e10cSrcweir                      BASEPROPERTY_COMPLETE,
1657cdf0e10cSrcweir                      BASEPROPERTY_ACTIVATED,
1658cdf0e10cSrcweir                      BASEPROPERTY_CURRENTITEMID,
1659cdf0e10cSrcweir                      BASEPROPERTY_TEXT,
1660cdf0e10cSrcweir                      0);
1661cdf0e10cSrcweir     VCLXWindow::ImplGetPropertyIds( rIds, true );
1662cdf0e10cSrcweir     VCLXGraphicControl::ImplGetPropertyIds( rIds );
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir //	----------------------------------------------------
1666cdf0e10cSrcweir //	class SVTXNumericField
1667cdf0e10cSrcweir //	----------------------------------------------------
SVTXNumericField()1668cdf0e10cSrcweir SVTXNumericField::SVTXNumericField()
1669cdf0e10cSrcweir {
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir 
~SVTXNumericField()1672cdf0e10cSrcweir SVTXNumericField::~SVTXNumericField()
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir }
1675cdf0e10cSrcweir 
queryInterface(const::com::sun::star::uno::Type & rType)1676cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1677cdf0e10cSrcweir {
1678cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1679cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ),
1680cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
1681cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
1685cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( SVTXNumericField )
1686cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
1687cdf0e10cSrcweir 	SVTXFormattedField::getTypes()
1688cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir void SVTXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1696cdf0e10cSrcweir 	if ( pField )
1697cdf0e10cSrcweir 		pField->SetValue( Value );
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir 
getValue()1700cdf0e10cSrcweir double SVTXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException)
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1705cdf0e10cSrcweir 	return pField ? pField->GetValue() : 0;
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir 
setMin(double Value)1708cdf0e10cSrcweir void SVTXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1713cdf0e10cSrcweir 	if ( pField )
1714cdf0e10cSrcweir 		pField->SetMinValue( Value );
1715cdf0e10cSrcweir }
1716cdf0e10cSrcweir 
getMin()1717cdf0e10cSrcweir double SVTXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException)
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1722cdf0e10cSrcweir 	return pField ? pField->GetMinValue() : 0;
1723cdf0e10cSrcweir }
1724cdf0e10cSrcweir 
setMax(double Value)1725cdf0e10cSrcweir void SVTXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1726cdf0e10cSrcweir {
1727cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1730cdf0e10cSrcweir 	if ( pField )
1731cdf0e10cSrcweir 		pField->SetMaxValue( Value );
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir 
getMax()1734cdf0e10cSrcweir double SVTXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException)
1735cdf0e10cSrcweir {
1736cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1739cdf0e10cSrcweir 	return pField ? pField->GetMaxValue() : 0;
1740cdf0e10cSrcweir }
1741cdf0e10cSrcweir 
setFirst(double Value)1742cdf0e10cSrcweir void SVTXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1747cdf0e10cSrcweir 	if ( pField )
1748cdf0e10cSrcweir 		pField->SetSpinFirst( Value );
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir 
getFirst()1751cdf0e10cSrcweir double SVTXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1752cdf0e10cSrcweir {
1753cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1756cdf0e10cSrcweir 	return pField ? pField->GetSpinFirst() : 0;
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir 
setLast(double Value)1759cdf0e10cSrcweir void SVTXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1760cdf0e10cSrcweir {
1761cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1764cdf0e10cSrcweir 	if ( pField )
1765cdf0e10cSrcweir 		pField->SetSpinLast( Value );
1766cdf0e10cSrcweir }
1767cdf0e10cSrcweir 
getLast()1768cdf0e10cSrcweir double SVTXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException)
1769cdf0e10cSrcweir {
1770cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1773cdf0e10cSrcweir 	return pField ? pField->GetSpinLast() : 0;
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir 
setSpinSize(double Value)1776cdf0e10cSrcweir void SVTXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1777cdf0e10cSrcweir {
1778cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1781cdf0e10cSrcweir 	if ( pField )
1782cdf0e10cSrcweir 		pField->SetSpinSize( Value );
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
getSpinSize()1785cdf0e10cSrcweir double SVTXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1786cdf0e10cSrcweir {
1787cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1790cdf0e10cSrcweir 	return pField ? pField->GetSpinSize() : 0;
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir 
setDecimalDigits(sal_Int16 Value)1793cdf0e10cSrcweir void SVTXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1798cdf0e10cSrcweir 	if ( pField )
1799cdf0e10cSrcweir 		pField->SetDecimalDigits( Value );
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir 
getDecimalDigits()1802cdf0e10cSrcweir sal_Int16 SVTXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1807cdf0e10cSrcweir 	return pField ? pField->GetDecimalDigits() : 0;
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir 
setStrictFormat(sal_Bool bStrict)1810cdf0e10cSrcweir void SVTXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1811cdf0e10cSrcweir {
1812cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1815cdf0e10cSrcweir 	if ( pField )
1816cdf0e10cSrcweir 		pField->SetStrictFormat( bStrict );
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir 
isStrictFormat()1819cdf0e10cSrcweir sal_Bool SVTXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1822cdf0e10cSrcweir 
1823cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1824cdf0e10cSrcweir 	return pField ? pField->IsStrictFormat() : sal_False;
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1827cdf0e10cSrcweir void SVTXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir     SVTXFormattedField::ImplGetPropertyIds( rIds );
1830cdf0e10cSrcweir }
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir //	----------------------------------------------------
1833cdf0e10cSrcweir //	class SVTXCurrencyField
1834cdf0e10cSrcweir //	----------------------------------------------------
SVTXCurrencyField()1835cdf0e10cSrcweir SVTXCurrencyField::SVTXCurrencyField()
1836cdf0e10cSrcweir {
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir 
~SVTXCurrencyField()1839cdf0e10cSrcweir SVTXCurrencyField::~SVTXCurrencyField()
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir }
1842cdf0e10cSrcweir 
queryInterface(const::com::sun::star::uno::Type & rType)1843cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1844cdf0e10cSrcweir {
1845cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1846cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ),
1847cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
1848cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1849cdf0e10cSrcweir }
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
1852cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( SVTXCurrencyField )
1853cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
1854cdf0e10cSrcweir 	SVTXFormattedField::getTypes()
1855cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
1856cdf0e10cSrcweir 
1857cdf0e10cSrcweir void SVTXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1858cdf0e10cSrcweir {
1859cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1862cdf0e10cSrcweir 	if ( pField )
1863cdf0e10cSrcweir 		pField->SetValue( Value );
1864cdf0e10cSrcweir }
1865cdf0e10cSrcweir 
getValue()1866cdf0e10cSrcweir double SVTXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException)
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1871cdf0e10cSrcweir 	return pField ? pField->GetValue() : 0;
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir 
setMin(double Value)1874cdf0e10cSrcweir void SVTXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1875cdf0e10cSrcweir {
1876cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1879cdf0e10cSrcweir 	if ( pField )
1880cdf0e10cSrcweir 		pField->SetMinValue( Value );
1881cdf0e10cSrcweir }
1882cdf0e10cSrcweir 
getMin()1883cdf0e10cSrcweir double SVTXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException)
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1888cdf0e10cSrcweir 	return pField ? pField->GetMinValue() : 0;
1889cdf0e10cSrcweir }
1890cdf0e10cSrcweir 
setMax(double Value)1891cdf0e10cSrcweir void SVTXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1892cdf0e10cSrcweir {
1893cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1896cdf0e10cSrcweir 	if ( pField )
1897cdf0e10cSrcweir 		pField->SetMaxValue( Value );
1898cdf0e10cSrcweir }
1899cdf0e10cSrcweir 
getMax()1900cdf0e10cSrcweir double SVTXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException)
1901cdf0e10cSrcweir {
1902cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1905cdf0e10cSrcweir 	return pField ? pField->GetMaxValue() : 0;
1906cdf0e10cSrcweir }
1907cdf0e10cSrcweir 
setFirst(double Value)1908cdf0e10cSrcweir void SVTXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1909cdf0e10cSrcweir {
1910cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1913cdf0e10cSrcweir 	if ( pField )
1914cdf0e10cSrcweir 		pField->SetSpinFirst( Value );
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir 
getFirst()1917cdf0e10cSrcweir double SVTXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1922cdf0e10cSrcweir 	return pField ? pField->GetSpinFirst() : 0;
1923cdf0e10cSrcweir }
1924cdf0e10cSrcweir 
setLast(double Value)1925cdf0e10cSrcweir void SVTXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1930cdf0e10cSrcweir 	if ( pField )
1931cdf0e10cSrcweir 		pField->SetSpinLast( Value );
1932cdf0e10cSrcweir }
1933cdf0e10cSrcweir 
getLast()1934cdf0e10cSrcweir double SVTXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException)
1935cdf0e10cSrcweir {
1936cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1939cdf0e10cSrcweir 	return pField ? pField->GetSpinLast() : 0;
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
setSpinSize(double Value)1942cdf0e10cSrcweir void SVTXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1945cdf0e10cSrcweir 
1946cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1947cdf0e10cSrcweir 	if ( pField )
1948cdf0e10cSrcweir 		pField->SetSpinSize( Value );
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir 
getSpinSize()1951cdf0e10cSrcweir double SVTXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1952cdf0e10cSrcweir {
1953cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1956cdf0e10cSrcweir 	return pField ? pField->GetSpinSize() : 0;
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir 
setDecimalDigits(sal_Int16 Value)1959cdf0e10cSrcweir void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1960cdf0e10cSrcweir {
1961cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1964cdf0e10cSrcweir 	if ( pField )
1965cdf0e10cSrcweir 		pField->SetDecimalDigits( Value );
1966cdf0e10cSrcweir }
1967cdf0e10cSrcweir 
getDecimalDigits()1968cdf0e10cSrcweir sal_Int16 SVTXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1969cdf0e10cSrcweir {
1970cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1973cdf0e10cSrcweir 	return pField ? pField->GetDecimalDigits() : 0;
1974cdf0e10cSrcweir }
1975cdf0e10cSrcweir 
setStrictFormat(sal_Bool bStrict)1976cdf0e10cSrcweir void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1977cdf0e10cSrcweir {
1978cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1979cdf0e10cSrcweir 
1980cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1981cdf0e10cSrcweir 	if ( pField )
1982cdf0e10cSrcweir 		pField->SetStrictFormat( bStrict );
1983cdf0e10cSrcweir }
1984cdf0e10cSrcweir 
isStrictFormat()1985cdf0e10cSrcweir sal_Bool SVTXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1986cdf0e10cSrcweir {
1987cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir 	FormattedField* pField = GetFormattedField();
1990cdf0e10cSrcweir 	return pField ? pField->IsStrictFormat() : sal_False;
1991cdf0e10cSrcweir }
1992cdf0e10cSrcweir 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1993cdf0e10cSrcweir void SVTXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1994cdf0e10cSrcweir {
1995cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir 	DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
2000cdf0e10cSrcweir 	if ( pField )
2001cdf0e10cSrcweir 	{
2002cdf0e10cSrcweir #ifdef DBG_UTIL
2003cdf0e10cSrcweir 		String sAssertion( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "SVTXCurrencyField::setProperty(" ) ) );
2004cdf0e10cSrcweir 		sAssertion += String( PropertyName );
2005cdf0e10cSrcweir 		sAssertion.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ") : invalid value !" ) );
2006cdf0e10cSrcweir #endif
2007cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2008cdf0e10cSrcweir 		switch (nPropType)
2009cdf0e10cSrcweir 		{
2010cdf0e10cSrcweir 			case BASEPROPERTY_CURRENCYSYMBOL:
2011cdf0e10cSrcweir 			{
2012cdf0e10cSrcweir 				::rtl::OUString aStr;
2013cdf0e10cSrcweir 				Value >>= aStr;
2014cdf0e10cSrcweir 				pField->setCurrencySymbol( aStr );
2015cdf0e10cSrcweir 			}
2016cdf0e10cSrcweir 			break;
2017cdf0e10cSrcweir 			case BASEPROPERTY_CURSYM_POSITION:
2018cdf0e10cSrcweir 			{
2019cdf0e10cSrcweir 				sal_Bool b = false;
2020cdf0e10cSrcweir 				Value >>= b;
2021cdf0e10cSrcweir 				pField->setPrependCurrSym(b);
2022cdf0e10cSrcweir 			}
2023cdf0e10cSrcweir 			break;
2024cdf0e10cSrcweir 
2025cdf0e10cSrcweir 			default:
2026cdf0e10cSrcweir 				SVTXFormattedField::setProperty(PropertyName, Value);
2027cdf0e10cSrcweir 		}
2028cdf0e10cSrcweir 	}
2029cdf0e10cSrcweir 	else
2030cdf0e10cSrcweir 		SVTXFormattedField::setProperty(PropertyName, Value);
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir 
getProperty(const::rtl::OUString & PropertyName)2033cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2034cdf0e10cSrcweir {
2035cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn;
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir 	DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
2040cdf0e10cSrcweir 	if ( pField )
2041cdf0e10cSrcweir 	{
2042cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2043cdf0e10cSrcweir 		switch (nPropType)
2044cdf0e10cSrcweir 		{
2045cdf0e10cSrcweir 			case BASEPROPERTY_CURRENCYSYMBOL:
2046cdf0e10cSrcweir 			{
2047cdf0e10cSrcweir 				aReturn <<= ::rtl::OUString( pField->getCurrencySymbol() );
2048cdf0e10cSrcweir 			}
2049cdf0e10cSrcweir 			break;
2050cdf0e10cSrcweir 			case BASEPROPERTY_CURSYM_POSITION:
2051cdf0e10cSrcweir 			{
2052cdf0e10cSrcweir 				aReturn <<= pField->getPrependCurrSym();
2053cdf0e10cSrcweir 			}
2054cdf0e10cSrcweir 			break;
2055cdf0e10cSrcweir 			default:
2056cdf0e10cSrcweir 				return SVTXFormattedField::getProperty(PropertyName);
2057cdf0e10cSrcweir 		}
2058cdf0e10cSrcweir 	}
2059cdf0e10cSrcweir 	return SVTXFormattedField::getProperty(PropertyName);
2060cdf0e10cSrcweir }
2061cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2062cdf0e10cSrcweir void SVTXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2063cdf0e10cSrcweir {
2064cdf0e10cSrcweir     PushPropertyIds( rIds,
2065cdf0e10cSrcweir                      BASEPROPERTY_CURRENCYSYMBOL,
2066cdf0e10cSrcweir                      BASEPROPERTY_CURSYM_POSITION,
2067cdf0e10cSrcweir                      0);
2068cdf0e10cSrcweir     SVTXFormattedField::ImplGetPropertyIds( rIds );
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir //	----------------------------------------------------
2073cdf0e10cSrcweir //	class VCLXProgressBar
2074cdf0e10cSrcweir //	----------------------------------------------------
2075cdf0e10cSrcweir 
VCLXProgressBar()2076cdf0e10cSrcweir VCLXProgressBar::VCLXProgressBar()
2077cdf0e10cSrcweir 			:m_nValue(0)
2078cdf0e10cSrcweir 			,m_nValueMin(0)
2079cdf0e10cSrcweir 			,m_nValueMax(100)
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir }
2082cdf0e10cSrcweir 
~VCLXProgressBar()2083cdf0e10cSrcweir VCLXProgressBar::~VCLXProgressBar()
2084cdf0e10cSrcweir {
2085cdf0e10cSrcweir }
2086cdf0e10cSrcweir 
ImplUpdateValue()2087cdf0e10cSrcweir void VCLXProgressBar::ImplUpdateValue()
2088cdf0e10cSrcweir {
2089cdf0e10cSrcweir 	ProgressBar* pProgressBar = (ProgressBar*) GetWindow();
2090cdf0e10cSrcweir 	if ( pProgressBar )
2091cdf0e10cSrcweir 	{
2092cdf0e10cSrcweir 		sal_Int32 nVal;
2093cdf0e10cSrcweir 		sal_Int32 nValMin;
2094cdf0e10cSrcweir 		sal_Int32 nValMax;
2095cdf0e10cSrcweir 
2096cdf0e10cSrcweir 		// check min and max
2097cdf0e10cSrcweir 		if (m_nValueMin < m_nValueMax)
2098cdf0e10cSrcweir 		{
2099cdf0e10cSrcweir 			nValMin = m_nValueMin;
2100cdf0e10cSrcweir 			nValMax = m_nValueMax;
2101cdf0e10cSrcweir 		}
2102cdf0e10cSrcweir 		else
2103cdf0e10cSrcweir 		{
2104cdf0e10cSrcweir 			nValMin = m_nValueMax;
2105cdf0e10cSrcweir 			nValMax = m_nValueMin;
2106cdf0e10cSrcweir 		}
2107cdf0e10cSrcweir 
2108cdf0e10cSrcweir 		// check value
2109cdf0e10cSrcweir 		if (m_nValue < nValMin)
2110cdf0e10cSrcweir 		{
2111cdf0e10cSrcweir 			nVal = nValMin;
2112cdf0e10cSrcweir 		}
2113cdf0e10cSrcweir 		else if (m_nValue > nValMax)
2114cdf0e10cSrcweir 		{
2115cdf0e10cSrcweir 			nVal = nValMax;
2116cdf0e10cSrcweir 		}
2117cdf0e10cSrcweir 		else
2118cdf0e10cSrcweir 		{
2119cdf0e10cSrcweir 			nVal = m_nValue;
2120cdf0e10cSrcweir 		}
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir 		// calculate percent
2123cdf0e10cSrcweir 		sal_Int32 nPercent;
2124cdf0e10cSrcweir 		if (nValMin != nValMax)
2125cdf0e10cSrcweir 		{
2126cdf0e10cSrcweir 			nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
2127cdf0e10cSrcweir 		}
2128cdf0e10cSrcweir 		else
2129cdf0e10cSrcweir 		{
2130cdf0e10cSrcweir 			nPercent = 0;
2131cdf0e10cSrcweir 		}
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir 		// set progressbar value
2134cdf0e10cSrcweir 		pProgressBar->SetValue( (sal_uInt16) nPercent );
2135cdf0e10cSrcweir 	}
2136cdf0e10cSrcweir }
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2139cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXProgressBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2142cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XProgressBar*, this ),
2143cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
2144cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
2148cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXProgressBar )
2149cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar>* ) NULL ),
2150cdf0e10cSrcweir 	VCLXWindow::getTypes()
2151cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir // ::com::sun::star::awt::XProgressBar
2154cdf0e10cSrcweir void VCLXProgressBar::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir 	Window* pWindow = GetWindow();
2159cdf0e10cSrcweir 	if ( pWindow )
2160cdf0e10cSrcweir 	{
2161cdf0e10cSrcweir 		Color aColor( nColor );
2162cdf0e10cSrcweir 		pWindow->SetControlForeground( aColor );
2163cdf0e10cSrcweir 	}
2164cdf0e10cSrcweir }
2165cdf0e10cSrcweir 
setBackgroundColor(sal_Int32 nColor)2166cdf0e10cSrcweir void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2167cdf0e10cSrcweir {
2168cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 	Window* pWindow = GetWindow();
2171cdf0e10cSrcweir 	if ( pWindow )
2172cdf0e10cSrcweir 	{
2173cdf0e10cSrcweir 		Color aColor( nColor );
2174cdf0e10cSrcweir 		pWindow->SetBackground( aColor );
2175cdf0e10cSrcweir 		pWindow->SetControlBackground( aColor );
2176cdf0e10cSrcweir 		pWindow->Invalidate();
2177cdf0e10cSrcweir 	}
2178cdf0e10cSrcweir }
2179cdf0e10cSrcweir 
setValue(sal_Int32 nValue)2180cdf0e10cSrcweir void VCLXProgressBar::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir 	m_nValue = nValue;
2185cdf0e10cSrcweir 	ImplUpdateValue();
2186cdf0e10cSrcweir }
2187cdf0e10cSrcweir 
setRange(sal_Int32 nMin,sal_Int32 nMax)2188cdf0e10cSrcweir void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
2189cdf0e10cSrcweir {
2190cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2191cdf0e10cSrcweir 
2192cdf0e10cSrcweir 	if ( nMin < nMax )
2193cdf0e10cSrcweir 	{
2194cdf0e10cSrcweir 		// take correct min and max
2195cdf0e10cSrcweir 		m_nValueMin = nMin;
2196cdf0e10cSrcweir 		m_nValueMax = nMax;
2197cdf0e10cSrcweir 	}
2198cdf0e10cSrcweir 	else
2199cdf0e10cSrcweir 	{
2200cdf0e10cSrcweir 		// change min and max
2201cdf0e10cSrcweir 		m_nValueMin = nMax;
2202cdf0e10cSrcweir 		m_nValueMax = nMin;
2203cdf0e10cSrcweir 	}
2204cdf0e10cSrcweir 
2205cdf0e10cSrcweir 	ImplUpdateValue();
2206cdf0e10cSrcweir }
2207cdf0e10cSrcweir 
getValue()2208cdf0e10cSrcweir sal_Int32 VCLXProgressBar::getValue() throw(::com::sun::star::uno::RuntimeException)
2209cdf0e10cSrcweir {
2210cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir 	return m_nValue;
2213cdf0e10cSrcweir }
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir // ::com::sun::star::awt::VclWindowPeer
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2216cdf0e10cSrcweir void VCLXProgressBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
2217cdf0e10cSrcweir {
2218cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir     ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2221cdf0e10cSrcweir     if ( pProgressBar )
2222cdf0e10cSrcweir 	{
2223cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2224cdf0e10cSrcweir 		switch ( nPropType )
2225cdf0e10cSrcweir 		{
2226cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE:
2227cdf0e10cSrcweir 			{
2228cdf0e10cSrcweir 				if ( Value >>= m_nValue )
2229cdf0e10cSrcweir 					ImplUpdateValue();
2230cdf0e10cSrcweir 			}
2231cdf0e10cSrcweir 			break;
2232cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE_MIN:
2233cdf0e10cSrcweir 			{
2234cdf0e10cSrcweir 				if ( Value >>= m_nValueMin )
2235cdf0e10cSrcweir 					ImplUpdateValue();
2236cdf0e10cSrcweir 			}
2237cdf0e10cSrcweir 			break;
2238cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE_MAX:
2239cdf0e10cSrcweir 			{
2240cdf0e10cSrcweir 				if ( Value >>= m_nValueMax )
2241cdf0e10cSrcweir 					ImplUpdateValue();
2242cdf0e10cSrcweir 			}
2243cdf0e10cSrcweir 			break;
2244cdf0e10cSrcweir 			case BASEPROPERTY_FILLCOLOR:
2245cdf0e10cSrcweir 			{
2246cdf0e10cSrcweir 				Window* pWindow = GetWindow();
2247cdf0e10cSrcweir 				if ( pWindow )
2248cdf0e10cSrcweir 				{
2249cdf0e10cSrcweir 					sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir 					if ( bVoid )
2252cdf0e10cSrcweir 					{
2253cdf0e10cSrcweir 						pWindow->SetControlForeground();
2254cdf0e10cSrcweir 					}
2255cdf0e10cSrcweir 					else
2256cdf0e10cSrcweir 					{
2257cdf0e10cSrcweir 						sal_Int32 nColor = 0;
2258cdf0e10cSrcweir 						if ( Value >>= nColor )
2259cdf0e10cSrcweir 						{
2260cdf0e10cSrcweir 							Color aColor( nColor );
2261cdf0e10cSrcweir 							pWindow->SetControlForeground( aColor );
2262cdf0e10cSrcweir 						}
2263cdf0e10cSrcweir 					}
2264cdf0e10cSrcweir 				}
2265cdf0e10cSrcweir 			}
2266cdf0e10cSrcweir 			break;
2267cdf0e10cSrcweir 			default:
2268cdf0e10cSrcweir 				VCLXWindow::setProperty( PropertyName, Value );
2269cdf0e10cSrcweir                 break;
2270cdf0e10cSrcweir 		}
2271cdf0e10cSrcweir 	}
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir 
getProperty(const::rtl::OUString & PropertyName)2274cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXProgressBar::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2275cdf0e10cSrcweir {
2276cdf0e10cSrcweir 	::vos::OGuard aGuard( GetMutex() );
2277cdf0e10cSrcweir 
2278cdf0e10cSrcweir 	::com::sun::star::uno::Any aProp;
2279cdf0e10cSrcweir     ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2280cdf0e10cSrcweir     if ( pProgressBar )
2281cdf0e10cSrcweir 	{
2282cdf0e10cSrcweir 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2283cdf0e10cSrcweir 		switch ( nPropType )
2284cdf0e10cSrcweir 		{
2285cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE:
2286cdf0e10cSrcweir 			{
2287cdf0e10cSrcweir  				aProp <<= m_nValue;
2288cdf0e10cSrcweir 			}
2289cdf0e10cSrcweir 			break;
2290cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE_MIN:
2291cdf0e10cSrcweir 			{
2292cdf0e10cSrcweir  				aProp <<= m_nValueMin;
2293cdf0e10cSrcweir 			}
2294cdf0e10cSrcweir 			break;
2295cdf0e10cSrcweir 			case BASEPROPERTY_PROGRESSVALUE_MAX:
2296cdf0e10cSrcweir 			{
2297cdf0e10cSrcweir  				aProp <<= m_nValueMax;
2298cdf0e10cSrcweir 			}
2299cdf0e10cSrcweir 			break;
2300cdf0e10cSrcweir             default:
2301cdf0e10cSrcweir 				aProp <<= VCLXWindow::getProperty( PropertyName );
2302cdf0e10cSrcweir                 break;
2303cdf0e10cSrcweir 		}
2304cdf0e10cSrcweir 	}
2305cdf0e10cSrcweir 	return aProp;
2306cdf0e10cSrcweir }
2307cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2308cdf0e10cSrcweir void VCLXProgressBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2309cdf0e10cSrcweir {
2310cdf0e10cSrcweir     PushPropertyIds( rIds,
2311cdf0e10cSrcweir                      BASEPROPERTY_PROGRESSVALUE,
2312cdf0e10cSrcweir                      BASEPROPERTY_PROGRESSVALUE_MIN,
2313cdf0e10cSrcweir                      BASEPROPERTY_PROGRESSVALUE_MAX,
2314cdf0e10cSrcweir                      BASEPROPERTY_FILLCOLOR,
2315cdf0e10cSrcweir                      0);
2316cdf0e10cSrcweir     VCLXWindow::ImplGetPropertyIds( rIds, true );
2317cdf0e10cSrcweir }
2318cdf0e10cSrcweir 
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir //	----------------------------------------------------
2321cdf0e10cSrcweir //	class SVTXDateField
2322cdf0e10cSrcweir //	----------------------------------------------------
SVTXDateField()2323cdf0e10cSrcweir SVTXDateField::SVTXDateField()
2324cdf0e10cSrcweir     :VCLXDateField()
2325cdf0e10cSrcweir {
2326cdf0e10cSrcweir }
2327cdf0e10cSrcweir 
~SVTXDateField()2328cdf0e10cSrcweir SVTXDateField::~SVTXDateField()
2329cdf0e10cSrcweir {
2330cdf0e10cSrcweir }
2331cdf0e10cSrcweir 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2332cdf0e10cSrcweir void SAL_CALL SVTXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException)
2333cdf0e10cSrcweir {
2334cdf0e10cSrcweir     VCLXDateField::setProperty( PropertyName, Value );
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir     // some properties need to be forwarded to the sub edit, too
2337cdf0e10cSrcweir     Edit* pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow() )->GetSubEdit() : NULL;
2338cdf0e10cSrcweir     if ( !pSubEdit )
2339cdf0e10cSrcweir         return;
2340cdf0e10cSrcweir 
2341cdf0e10cSrcweir     switch ( GetPropertyId( PropertyName ) )
2342cdf0e10cSrcweir     {
2343cdf0e10cSrcweir     case BASEPROPERTY_TEXTLINECOLOR:
2344cdf0e10cSrcweir         if ( !Value.hasValue() )
2345cdf0e10cSrcweir             pSubEdit->SetTextLineColor();
2346cdf0e10cSrcweir         else
2347cdf0e10cSrcweir         {
2348cdf0e10cSrcweir             sal_Int32 nColor = 0;
2349cdf0e10cSrcweir             if ( Value >>= nColor )
2350cdf0e10cSrcweir                 pSubEdit->SetTextLineColor( Color( nColor ) );
2351cdf0e10cSrcweir         }
2352cdf0e10cSrcweir         break;
2353cdf0e10cSrcweir     }
2354cdf0e10cSrcweir }
2355cdf0e10cSrcweir 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2356cdf0e10cSrcweir void SVTXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2357cdf0e10cSrcweir {
2358cdf0e10cSrcweir     PushPropertyIds( rIds,
2359cdf0e10cSrcweir                      BASEPROPERTY_TEXTLINECOLOR,
2360cdf0e10cSrcweir                      0);
2361cdf0e10cSrcweir     VCLXDateField::ImplGetPropertyIds( rIds );
2362cdf0e10cSrcweir }
2363