update dev300-m58
[ooovba.git] / forms / source / component / FormattedField.cxx
blob2a0d973ebaf09494730a291566fa3938c5abdc4f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FormattedField.cxx,v $
10 * $Revision: 1.46 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
34 #include "FormattedField.hxx"
35 #include "services.hxx"
36 #include "property.hrc"
37 #include "property.hxx"
38 #include "frm_resource.hxx"
39 #include "frm_resource.hrc"
40 #include "propertybaghelper.hxx"
41 #include <comphelper/sequence.hxx>
42 #include <comphelper/numbers.hxx>
43 #include <connectivity/dbtools.hxx>
44 #include <connectivity/dbconversion.hxx>
45 #include <svtools/zforlist.hxx>
46 #include <svtools/numuno.hxx>
47 #include <vcl/svapp.hxx>
48 #include <tools/debug.hxx>
49 #include <vcl/wintypes.hxx>
50 #include <i18npool/mslangid.hxx>
51 #include <rtl/textenc.h>
52 #include <com/sun/star/sdbc/DataType.hpp>
53 #include <com/sun/star/util/NumberFormat.hpp>
54 #include <com/sun/star/util/Date.hpp>
55 #include <com/sun/star/util/Time.hpp>
56 #include <com/sun/star/awt/MouseEvent.hpp>
57 #include <com/sun/star/form/XSubmit.hpp>
58 #include <com/sun/star/awt/XWindow.hpp>
59 #include <com/sun/star/awt/XKeyListener.hpp>
60 #include <com/sun/star/form/FormComponentType.hpp>
61 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
62 #include <com/sun/star/util/XNumberFormatTypes.hpp>
63 #include <com/sun/star/form/XForm.hpp>
64 #include <com/sun/star/container/XIndexAccess.hpp>
65 #include <vos/mutex.hxx>
66 // needed as long as we use the SolarMutex
67 #include <comphelper/streamsection.hxx>
68 #include <cppuhelper/weakref.hxx>
69 #include <unotools/desktopterminationobserver.hxx>
71 #include <list>
72 #include <algorithm>
74 using namespace dbtools;
75 using namespace ::com::sun::star::uno;
76 using namespace ::com::sun::star::sdb;
77 using namespace ::com::sun::star::sdbc;
78 using namespace ::com::sun::star::sdbcx;
79 using namespace ::com::sun::star::beans;
80 using namespace ::com::sun::star::container;
81 using namespace ::com::sun::star::form;
82 using namespace ::com::sun::star::awt;
83 using namespace ::com::sun::star::io;
84 using namespace ::com::sun::star::lang;
85 using namespace ::com::sun::star::util;
86 using namespace ::com::sun::star::form::binding;
88 namespace
90 typedef com::sun::star::util::Date UNODate;
91 typedef com::sun::star::util::Time UNOTime;
92 typedef com::sun::star::util::DateTime UNODateTime;
95 //.........................................................................
96 namespace frm
99 /*************************************************************************/
101 class StandardFormatsSupplier : protected SvNumberFormatsSupplierObj, public ::utl::ITerminationListener
103 protected:
104 SvNumberFormatter* m_pMyPrivateFormatter;
105 static WeakReference< XNumberFormatsSupplier > s_xDefaultFormatsSupplier;
107 public:
108 static Reference< XNumberFormatsSupplier > get( const Reference< XMultiServiceFactory >& _rxORB );
110 using SvNumberFormatsSupplierObj::operator new;
111 using SvNumberFormatsSupplierObj::operator delete;
113 protected:
114 StandardFormatsSupplier(const Reference<XMultiServiceFactory>& _rxFactory,LanguageType _eSysLanguage);
115 ~StandardFormatsSupplier();
117 protected:
118 virtual bool queryTermination() const;
119 virtual void notifyTermination();
122 //------------------------------------------------------------------
123 WeakReference< XNumberFormatsSupplier > StandardFormatsSupplier::s_xDefaultFormatsSupplier;
125 //------------------------------------------------------------------
126 StandardFormatsSupplier::StandardFormatsSupplier(const Reference< XMultiServiceFactory > & _rxFactory,LanguageType _eSysLanguage)
127 :SvNumberFormatsSupplierObj()
128 ,m_pMyPrivateFormatter(new SvNumberFormatter(_rxFactory, _eSysLanguage))
130 SetNumberFormatter(m_pMyPrivateFormatter);
132 // #i29147# - 2004-06-18 - fs@openoffice.org
133 ::utl::DesktopTerminationObserver::registerTerminationListener( this );
136 //------------------------------------------------------------------
137 StandardFormatsSupplier::~StandardFormatsSupplier()
139 ::utl::DesktopTerminationObserver::revokeTerminationListener( this );
141 DELETEZ( m_pMyPrivateFormatter );
144 //------------------------------------------------------------------
145 Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Reference< XMultiServiceFactory >& _rxORB )
147 LanguageType eSysLanguage = LANGUAGE_SYSTEM;
149 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
150 Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier;
151 if ( xSupplier.is() )
152 return xSupplier;
154 // get the Office's locale
155 const Locale& rSysLocale = SvtSysLocale().GetLocaleData().getLocale();
156 // translate
157 eSysLanguage = MsLangId::convertLocaleToLanguage( rSysLocale );
160 StandardFormatsSupplier* pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage );
161 Reference< XNumberFormatsSupplier > xNewlyCreatedSupplier( pSupplier );
164 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
165 Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier;
166 if ( xSupplier.is() )
167 // somebody used the small time frame where the mutex was not locked to create and set
168 // the supplier
169 return xSupplier;
171 s_xDefaultFormatsSupplier = xNewlyCreatedSupplier;
174 return xNewlyCreatedSupplier;
177 //------------------------------------------------------------------
178 bool StandardFormatsSupplier::queryTermination() const
180 return true;
183 //------------------------------------------------------------------
184 void StandardFormatsSupplier::notifyTermination()
186 Reference< XNumberFormatsSupplier > xKeepAlive = this;
187 // when the application is terminating, release our static reference so that we are cleared/destructed
188 // earlier than upon unloading the library
189 // #i29147# - 2004-06-18 - fs@openoffice.org
190 s_xDefaultFormatsSupplier = WeakReference< XNumberFormatsSupplier >( );
192 SetNumberFormatter( NULL );
193 DELETEZ( m_pMyPrivateFormatter );
196 /*************************************************************************/
197 //------------------------------------------------------------------
198 InterfaceRef SAL_CALL OFormattedControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
200 return *(new OFormattedControl(_rxFactory));
203 //------------------------------------------------------------------
204 Sequence<Type> OFormattedControl::_getTypes()
206 return ::comphelper::concatSequences(
207 OFormattedControl_BASE::getTypes(),
208 OBoundControl::_getTypes()
212 //------------------------------------------------------------------
213 Any SAL_CALL OFormattedControl::queryAggregation(const Type& _rType) throw (RuntimeException)
215 Any aReturn = OBoundControl::queryAggregation(_rType);
216 if (!aReturn.hasValue())
217 aReturn = OFormattedControl_BASE::queryInterface(_rType);
218 return aReturn;
222 DBG_NAME(OFormattedControl);
223 //------------------------------------------------------------------------------
224 OFormattedControl::OFormattedControl(const Reference<XMultiServiceFactory>& _rxFactory)
225 :OBoundControl(_rxFactory, VCL_CONTROL_FORMATTEDFIELD)
226 ,m_nKeyEvent(0)
228 DBG_CTOR(OFormattedControl,NULL);
230 increment(m_refCount);
232 Reference<XWindow> xComp;
233 if (query_aggregation(m_xAggregate, xComp))
235 xComp->addKeyListener(this);
238 decrement(m_refCount);
241 //------------------------------------------------------------------------------
242 OFormattedControl::~OFormattedControl()
244 if( m_nKeyEvent )
245 Application::RemoveUserEvent( m_nKeyEvent );
247 if (!OComponentHelper::rBHelper.bDisposed)
249 acquire();
250 dispose();
253 DBG_DTOR(OFormattedControl,NULL);
256 // XKeyListener
257 //------------------------------------------------------------------------------
258 void OFormattedControl::disposing(const EventObject& _rSource) throw(RuntimeException)
260 OBoundControl::disposing(_rSource);
263 //------------------------------------------------------------------------------
264 void OFormattedControl::keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException)
266 if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
267 return;
269 // Steht das Control in einem Formular mit einer Submit-URL?
270 Reference<com::sun::star::beans::XPropertySet> xSet(getModel(), UNO_QUERY);
271 if( !xSet.is() )
272 return;
274 Reference<XFormComponent> xFComp(xSet, UNO_QUERY);
275 InterfaceRef xParent = xFComp->getParent();
276 if( !xParent.is() )
277 return;
279 Reference<com::sun::star::beans::XPropertySet> xFormSet(xParent, UNO_QUERY);
280 if( !xFormSet.is() )
281 return;
283 Any aTmp(xFormSet->getPropertyValue( PROPERTY_TARGET_URL ));
284 if (!isA(aTmp, static_cast< ::rtl::OUString* >(NULL)) ||
285 !getString(aTmp).getLength() )
286 return;
288 Reference<XIndexAccess> xElements(xParent, UNO_QUERY);
289 sal_Int32 nCount = xElements->getCount();
290 if( nCount > 1 )
293 Reference<com::sun::star::beans::XPropertySet> xFCSet;
294 for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
296 // Any aElement(xElements->getByIndex(nIndex));
297 xElements->getByIndex(nIndex) >>= xFCSet;
299 if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
300 getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == FormComponentType::TEXTFIELD)
302 // Noch ein weiteres Edit gefunden ==> dann nicht submitten
303 if (xFCSet != xSet)
304 return;
309 // Da wir noch im Haender stehen, submit asynchron ausloesen
310 if( m_nKeyEvent )
311 Application::RemoveUserEvent( m_nKeyEvent );
312 m_nKeyEvent = Application::PostUserEvent( LINK(this, OFormattedControl,
313 OnKeyPressed) );
316 //------------------------------------------------------------------------------
317 void OFormattedControl::keyReleased(const ::com::sun::star::awt::KeyEvent& /*e*/) throw ( ::com::sun::star::uno::RuntimeException)
321 //------------------------------------------------------------------------------
322 IMPL_LINK(OFormattedControl, OnKeyPressed, void*, /*EMPTYARG*/)
324 m_nKeyEvent = 0;
326 Reference<XFormComponent> xFComp(getModel(), UNO_QUERY);
327 InterfaceRef xParent = xFComp->getParent();
328 Reference<XSubmit> xSubmit(xParent, UNO_QUERY);
329 if (xSubmit.is())
330 xSubmit->submit( Reference<XControl> (), ::com::sun::star::awt::MouseEvent() );
331 return 0L;
334 //------------------------------------------------------------------------------
335 StringSequence OFormattedControl::getSupportedServiceNames() throw()
337 StringSequence aSupported = OBoundControl::getSupportedServiceNames();
338 aSupported.realloc(aSupported.getLength() + 1);
340 ::rtl::OUString*pArray = aSupported.getArray();
341 pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_FORMATTEDFIELD;
342 return aSupported;
345 //------------------------------------------------------------------------------
346 void OFormattedControl::setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException)
348 OBoundControl::setDesignMode(bOn);
351 /*************************************************************************/
352 DBG_NAME(OFormattedModel)
353 //------------------------------------------------------------------
354 void OFormattedModel::implConstruct()
356 // members
357 m_bOriginalNumeric = sal_False;
358 m_bNumeric = sal_False;
359 m_xOriginalFormatter = NULL;
360 m_nKeyType = NumberFormat::UNDEFINED;
361 m_aNullDate = DBTypeConversion::getStandardDate();
362 m_nFieldType = DataType::OTHER;
364 // default our formats supplier
365 increment(m_refCount);
366 setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
367 decrement(m_refCount);
369 startAggregatePropertyListening( PROPERTY_FORMATKEY );
370 startAggregatePropertyListening( PROPERTY_FORMATSSUPPLIER );
373 //------------------------------------------------------------------
374 OFormattedModel::OFormattedModel(const Reference<XMultiServiceFactory>& _rxFactory)
375 :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_FORMATTEDFIELD, FRM_SUN_CONTROL_FORMATTEDFIELD, sal_True, sal_True )
376 // use the old control name for compytibility reasons
377 ,OErrorBroadcaster( OComponentHelper::rBHelper )
379 DBG_CTOR(OFormattedModel, NULL);
381 implConstruct();
383 m_nClassId = FormComponentType::TEXTFIELD;
384 initValueProperty( PROPERTY_EFFECTIVE_VALUE, PROPERTY_ID_EFFECTIVE_VALUE );
387 //------------------------------------------------------------------
388 OFormattedModel::OFormattedModel( const OFormattedModel* _pOriginal, const Reference< XMultiServiceFactory >& _rxFactory )
389 :OEditBaseModel( _pOriginal, _rxFactory )
390 ,OErrorBroadcaster( OComponentHelper::rBHelper )
392 DBG_CTOR(OFormattedModel, NULL);
394 implConstruct();
397 //------------------------------------------------------------------------------
398 OFormattedModel::~OFormattedModel()
400 DBG_DTOR(OFormattedModel, NULL);
403 // XCloneable
404 //------------------------------------------------------------------------------
405 IMPLEMENT_DEFAULT_CLONING( OFormattedModel )
407 //------------------------------------------------------------------------------
408 void SAL_CALL OFormattedModel::disposing()
410 OErrorBroadcaster::disposing();
411 OEditBaseModel::disposing();
414 // XServiceInfo
415 //------------------------------------------------------------------------------
416 StringSequence OFormattedModel::getSupportedServiceNames() throw()
418 StringSequence aSupported = OEditBaseModel::getSupportedServiceNames();
420 sal_Int32 nOldLen = aSupported.getLength();
421 aSupported.realloc( nOldLen + 8 );
422 ::rtl::OUString* pStoreTo = aSupported.getArray() + nOldLen;
424 *pStoreTo++ = BINDABLE_CONTROL_MODEL;
425 *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
426 *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
428 *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
429 *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
431 *pStoreTo++ = FRM_SUN_COMPONENT_FORMATTEDFIELD;
432 *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD;
433 *pStoreTo++ = BINDABLE_DATABASE_FORMATTED_FIELD;
435 return aSupported;
438 // XAggregation
439 //------------------------------------------------------------------------------
440 Any SAL_CALL OFormattedModel::queryAggregation(const Type& _rType) throw(RuntimeException)
442 Any aReturn = OEditBaseModel::queryAggregation( _rType );
443 return aReturn.hasValue() ? aReturn : OErrorBroadcaster::queryInterface( _rType );
446 // XTypeProvider
447 //------------------------------------------------------------------------------
448 Sequence< Type > OFormattedModel::_getTypes()
450 return ::comphelper::concatSequences(
451 OEditBaseModel::_getTypes(),
452 OErrorBroadcaster::getTypes()
456 // XPersistObject
457 //------------------------------------------------------------------------------
458 ::rtl::OUString SAL_CALL OFormattedModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
460 return ::rtl::OUString(FRM_COMPONENT_EDIT);
463 // XPropertySet
464 //------------------------------------------------------------------------------
465 void OFormattedModel::describeFixedProperties( Sequence< Property >& _rProps ) const
467 BEGIN_DESCRIBE_PROPERTIES( 3, OEditBaseModel )
468 DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
469 DECL_PROP1(TABINDEX, sal_Int16, BOUND);
470 DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT);
471 END_DESCRIBE_PROPERTIES();
474 //------------------------------------------------------------------------------
475 void OFormattedModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
477 OEditBaseModel::describeAggregateProperties( _rAggregateProps );
479 // TreatAsNumeric nicht transient : wir wollen es an der UI anbinden (ist noetig, um dem EffectiveDefault
480 // - der kann Text oder Zahl sein - einen Sinn zu geben)
481 ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TREATASNUMERIC, 0, PropertyAttribute::TRANSIENT);
482 // same for FormatKey
483 // (though the paragraph above for the TreatAsNumeric does not hold anymore - we do not have an UI for this.
484 // But we have for the format key ...)
485 // 25.06.2001 - 87862 - frank.schoenheit@sun.com
486 ModifyPropertyAttributes(_rAggregateProps, PROPERTY_FORMATKEY, 0, PropertyAttribute::TRANSIENT);
488 RemoveProperty(_rAggregateProps, PROPERTY_STRICTFORMAT);
489 // no strict format property for formatted fields: it does not make sense, 'cause
490 // there is no general way to decide which characters/sub strings are allowed during the input of an
491 // arbitraryly formatted control
492 // 81441 - 12/07/00 - FS
495 //------------------------------------------------------------------------------
496 void OFormattedModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const
498 OEditBaseModel::getFastPropertyValue(rValue, nHandle);
501 //------------------------------------------------------------------------------
502 void OFormattedModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) throw ( ::com::sun::star::uno::Exception)
504 OEditBaseModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
507 //------------------------------------------------------------------------------
508 sal_Bool OFormattedModel::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue)
509 throw( IllegalArgumentException )
511 return OEditBaseModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
514 //------------------------------------------------------------------------------
515 void OFormattedModel::setPropertyToDefaultByHandle(sal_Int32 nHandle)
517 if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
519 Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier();
520 DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::setPropertyToDefaultByHandle(FORMATSSUPPLIER) : have no aggregate !");
521 if (m_xAggregateSet.is())
522 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
524 else
525 OEditBaseModel::setPropertyToDefaultByHandle(nHandle);
528 //------------------------------------------------------------------------------
529 void OFormattedModel::setPropertyToDefault(const ::rtl::OUString& aPropertyName) throw( com::sun::star::beans::UnknownPropertyException, RuntimeException )
531 OPropertyArrayAggregationHelper& rPH = m_aPropertyBagHelper.getInfoHelper();
532 sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
534 if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
535 setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
536 else
537 OEditBaseModel::setPropertyToDefault(aPropertyName);
540 //------------------------------------------------------------------------------
541 Any OFormattedModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
543 if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
545 Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier();
546 return makeAny(xSupplier);
548 else
549 return OEditBaseModel::getPropertyDefaultByHandle(nHandle);
552 //------------------------------------------------------------------------------
553 Any SAL_CALL OFormattedModel::getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw( com::sun::star::beans::UnknownPropertyException, RuntimeException )
555 OPropertyArrayAggregationHelper& rPH = m_aPropertyBagHelper.getInfoHelper();
556 sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
558 if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
559 return getPropertyDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
560 else
561 return OEditBaseModel::getPropertyDefault(aPropertyName);
564 //------------------------------------------------------------------------------
565 void OFormattedModel::_propertyChanged( const com::sun::star::beans::PropertyChangeEvent& evt ) throw(RuntimeException)
567 // TODO: check how this works with external bindings
569 OSL_ENSURE( evt.Source == m_xAggregateSet, "OFormattedModel::_propertyChanged: where did this come from?" );
570 if ( evt.Source == m_xAggregateSet )
572 Reference< XPropertySet > xSourceSet( evt.Source, UNO_QUERY );
573 if ( evt.PropertyName.equals( PROPERTY_FORMATKEY ) )
575 if ( evt.NewValue.getValueType().getTypeClass() == TypeClass_LONG )
579 ::osl::MutexGuard aGuard( m_aMutex );
581 Reference<XNumberFormatsSupplier> xSupplier( calcFormatsSupplier() );
582 m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32( evt.NewValue ) );
584 // as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have
585 // to recalc it, which is done by translateDbColumnToControlValue
586 if ( m_xColumn.is() && m_xAggregateFastSet.is() )
588 setControlValue( translateDbColumnToControlValue(), eOther );
591 // if we're connected to an external value binding, then re-calculate the type
592 // used to exchange the value - it depends on the format, too
593 if ( hasExternalValueBinding() )
595 calculateExternalValueType();
598 catch(Exception&)
602 return;
605 if ( evt.PropertyName.equals( PROPERTY_FORMATSSUPPLIER ) )
607 updateFormatterNullDate();
608 return;
611 OBoundControlModel::_propertyChanged( evt );
615 //------------------------------------------------------------------------------
616 void OFormattedModel::updateFormatterNullDate()
618 // calc the current NULL date
619 Reference< XNumberFormatsSupplier > xSupplier( calcFormatsSupplier() );
620 if ( xSupplier.is() )
621 xSupplier->getNumberFormatSettings()->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NullDate" ) ) ) >>= m_aNullDate;
624 //------------------------------------------------------------------------------
625 Reference< XNumberFormatsSupplier > OFormattedModel::calcFormatsSupplier() const
627 Reference<XNumberFormatsSupplier> xSupplier;
629 DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::calcFormatsSupplier : have no aggregate !");
630 // hat mein aggregiertes Model einen FormatSupplier ?
631 if( m_xAggregateSet.is() )
632 m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xSupplier;
634 if (!xSupplier.is())
635 // check if my parent form has a supplier
636 xSupplier = calcFormFormatsSupplier();
638 if (!xSupplier.is())
639 xSupplier = calcDefaultFormatsSupplier();
641 DBG_ASSERT(xSupplier.is(), "OFormattedModel::calcFormatsSupplier : no supplier !");
642 // jetzt sollte aber einer da sein
643 return xSupplier;
646 //------------------------------------------------------------------------------
647 Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const
649 Reference<XChild> xMe;
650 query_interface(static_cast<XWeak*>(const_cast<OFormattedModel*>(this)), xMe);
651 // damit stellen wir sicher, dass wir auch fuer den Fall der Aggregation das richtige
652 // Objekt bekommen
653 DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !");
655 // jetzt durchhangeln nach oben, bis wir auf eine starform treffen (angefangen mit meinem eigenen Parent)
656 Reference<XChild> xParent(xMe->getParent(), UNO_QUERY);
657 Reference<XForm> xNextParentForm(xParent, UNO_QUERY);
658 while (!xNextParentForm.is() && xParent.is())
660 xParent = xParent.query( xParent->getParent() );
661 xNextParentForm = xNextParentForm.query( xParent );
664 if (!xNextParentForm.is())
666 DBG_ERROR("OFormattedModel::calcFormFormatsSupplier : have no ancestor which is a form !");
667 return NULL;
670 // den FormatSupplier von meinem Vorfahren (falls der einen hat)
671 Reference< XRowSet > xRowSet( xNextParentForm, UNO_QUERY );
672 Reference< XNumberFormatsSupplier > xSupplier;
673 if (xRowSet.is())
674 xSupplier = getNumberFormats( getConnection(xRowSet), sal_True, getContext().getLegacyServiceFactory() );
675 return xSupplier;
678 //------------------------------------------------------------------------------
679 Reference< XNumberFormatsSupplier > OFormattedModel::calcDefaultFormatsSupplier() const
681 return StandardFormatsSupplier::get( getContext().getLegacyServiceFactory() );
684 // XBoundComponent
685 //------------------------------------------------------------------------------
686 void OFormattedModel::loaded(const EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException)
688 // HACK : our onConnectedDbColumn accesses our NumberFormatter which locks the solar mutex (as it doesn't have
689 // an own one). To prevent deadlocks with other threads which may request a property from us in an
690 // UI-triggered action (e.g. an tooltip) we lock the solar mutex _here_ before our base class locks
691 // it's own muext (which is used for property requests)
692 // alternative a): we use two mutexes, one which is passed to the OPropertysetHelper and used for
693 // property requests and one for our own code. This would need a lot of code rewriting
694 // alternative b): The NumberFormatter has to be really threadsafe (with an own mutex), which is
695 // the only "clean" solution for me.
696 // FS - 69603 - 02.11.99
698 ::vos::OGuard aGuard(Application::GetSolarMutex());
699 OEditBaseModel::loaded(rEvent);
702 //------------------------------------------------------------------------------
703 void OFormattedModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
705 m_xOriginalFormatter = NULL;
707 // get some properties of the field
708 m_nFieldType = DataType::OTHER;
709 Reference<XPropertySet> xField = getField();
710 if ( xField.is() )
711 xField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= m_nFieldType;
713 sal_Int32 nFormatKey = 0;
715 DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::onConnectedDbColumn : have no aggregate !");
716 if (m_xAggregateSet.is())
717 { // all the following doesn't make any sense if we have no aggregate ...
718 Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
719 DBG_ASSERT( aSupplier.hasValue(), "OFormattedModel::onConnectedDbColumn : invalid property value !" );
720 // das sollte im Constructor oder im read auf was richtiges gesetzt worden sein
722 Any aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
723 if ( !(aFmtKey >>= nFormatKey ) )
724 { // nobody gave us a format to use. So we examine the field we're bound to for a
725 // format key, and use it ourself, too
726 sal_Int32 nType = DataType::VARCHAR;
727 if (xField.is())
729 aFmtKey = xField->getPropertyValue(PROPERTY_FORMATKEY);
730 xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType ;
733 Reference<XNumberFormatsSupplier> xSupplier = calcFormFormatsSupplier();
734 DBG_ASSERT(xSupplier.is(), "OFormattedModel::onConnectedDbColumn : bound to a field but no parent with a formatter ? how this ?");
735 if (xSupplier.is())
737 m_bOriginalNumeric = getBOOL(getPropertyValue(PROPERTY_TREATASNUMERIC));
739 if (!aFmtKey.hasValue())
740 { // we aren't bound to a field (or this field's format is invalid)
741 // -> determine the standard text (or numeric) format of the supplier
742 Reference<XNumberFormatTypes> xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
743 if (xTypes.is())
745 Locale aApplicationLocale = Application::GetSettings().GetUILocale();
747 if (m_bOriginalNumeric)
748 aFmtKey <<= (sal_Int32)xTypes->getStandardFormat(NumberFormat::NUMBER, aApplicationLocale);
749 else
750 aFmtKey <<= (sal_Int32)xTypes->getStandardFormat(NumberFormat::TEXT, aApplicationLocale);
754 aSupplier >>= m_xOriginalFormatter;
755 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
756 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, aFmtKey);
758 // das Numeric-Flag an mein gebundenes Feld anpassen
759 if (xField.is())
761 m_bNumeric = sal_False;
762 switch (nType)
764 case DataType::BIT:
765 case DataType::BOOLEAN:
766 case DataType::TINYINT:
767 case DataType::SMALLINT:
768 case DataType::INTEGER:
769 case DataType::BIGINT:
770 case DataType::FLOAT:
771 case DataType::REAL:
772 case DataType::DOUBLE:
773 case DataType::NUMERIC:
774 case DataType::DECIMAL:
775 case DataType::DATE:
776 case DataType::TIME:
777 case DataType::TIMESTAMP:
778 m_bNumeric = sal_True;
779 break;
782 else
783 m_bNumeric = m_bOriginalNumeric;
785 setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny((sal_Bool)m_bNumeric));
787 OSL_VERIFY( aFmtKey >>= nFormatKey );
792 Reference<XNumberFormatsSupplier> xSupplier = calcFormatsSupplier();
793 m_bNumeric = getBOOL( getPropertyValue( PROPERTY_TREATASNUMERIC ) );
794 m_nKeyType = getNumberFormatType( xSupplier->getNumberFormats(), nFormatKey );
795 xSupplier->getNumberFormatSettings()->getPropertyValue( ::rtl::OUString::createFromAscii("NullDate") ) >>= m_aNullDate;
797 OEditBaseModel::onConnectedDbColumn( _rxForm );
800 //------------------------------------------------------------------------------
801 void OFormattedModel::onDisconnectedDbColumn()
803 OEditBaseModel::onDisconnectedDbColumn();
804 if (m_xOriginalFormatter.is())
805 { // unser aggregiertes Model hatte keinerlei Format-Informationen
806 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(m_xOriginalFormatter));
807 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, Any());
808 setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny((sal_Bool)m_bOriginalNumeric));
809 m_xOriginalFormatter = NULL;
812 m_nFieldType = DataType::OTHER;
813 m_nKeyType = NumberFormat::UNDEFINED;
814 m_aNullDate = DBTypeConversion::getStandardDate();
817 //------------------------------------------------------------------------------
818 void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
820 OEditBaseModel::write(_rxOutStream);
821 _rxOutStream->writeShort(0x0003);
823 DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::write : have no aggregate !");
825 // mein Format (evtl. void) in ein persistentes Format bringen (der Supplier zusammen mit dem Key ist es zwar auch,
826 // aber deswegen muessen wir ja nicht gleich den ganzen Supplier speichern, das waere ein klein wenig Overhead ;)
828 Reference<XNumberFormatsSupplier> xSupplier;
829 Any aFmtKey;
830 sal_Bool bVoidKey = sal_True;
831 if (m_xAggregateSet.is())
833 Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
834 if (aSupplier.getValueType().getTypeClass() != TypeClass_VOID)
836 OSL_VERIFY( aSupplier >>= xSupplier );
839 aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
840 bVoidKey = (!xSupplier.is() || !aFmtKey.hasValue()) || (isLoaded() && m_xOriginalFormatter.is());
841 // (kein Fomatter und/oder Key) oder (loaded und faked Formatter)
844 _rxOutStream->writeBoolean(!bVoidKey);
845 if (!bVoidKey)
847 // aus dem FormatKey und dem Formatter persistente Angaben basteln
849 Any aKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
850 sal_Int32 nKey = aKey.hasValue() ? getINT32(aKey) : 0;
852 Reference<XNumberFormats> xFormats = xSupplier->getNumberFormats();
854 ::rtl::OUString sFormatDescription;
855 LanguageType eFormatLanguage = LANGUAGE_DONTKNOW;
857 static const ::rtl::OUString s_aLocaleProp = ::rtl::OUString::createFromAscii("Locale");
858 Reference<com::sun::star::beans::XPropertySet> xFormat = xFormats->getByKey(nKey);
859 if (hasProperty(s_aLocaleProp, xFormat))
861 Any aLocale = xFormat->getPropertyValue(s_aLocaleProp);
862 DBG_ASSERT(isA(aLocale, static_cast<Locale*>(NULL)), "OFormattedModel::write : invalid language property !");
863 if (isA(aLocale, static_cast<Locale*>(NULL)))
865 Locale* pLocale = (Locale*)aLocale.getValue();
866 eFormatLanguage = MsLangId::convertLocaleToLanguage( *pLocale );
870 static const ::rtl::OUString s_aFormatStringProp = ::rtl::OUString::createFromAscii("FormatString");
871 if (hasProperty(s_aFormatStringProp, xFormat))
872 xFormat->getPropertyValue(s_aFormatStringProp) >>= sFormatDescription;
874 _rxOutStream->writeUTF(sFormatDescription);
875 _rxOutStream->writeLong((sal_Int32)eFormatLanguage);
878 // version 2 : write the properties common to all OEditBaseModels
879 writeCommonEditProperties(_rxOutStream);
881 // version 3 : write the effective value property of the aggregate
882 // Due to a bug within the UnoControlFormattedFieldModel implementation (our default aggregate) this props value isn't correctly read
883 // and this can't be corrected without being incompatible.
884 // so we have our own handling.
886 // and to be a little bit more compatible we make the following section skippable
888 Reference< XDataOutputStream > xOut(_rxOutStream, UNO_QUERY);
889 OStreamSection aDownCompat(xOut);
891 // a sub version within the skippable block
892 _rxOutStream->writeShort(0x0000);
894 // version 0: the effective value of the aggregate
895 Any aEffectiveValue;
896 if (m_xAggregateSet.is())
898 try { aEffectiveValue = m_xAggregateSet->getPropertyValue(PROPERTY_EFFECTIVE_VALUE); } catch(Exception&) { }
902 OStreamSection aDownCompat2(xOut);
903 switch (aEffectiveValue.getValueType().getTypeClass())
905 case TypeClass_STRING:
906 _rxOutStream->writeShort(0x0000);
907 _rxOutStream->writeUTF(::comphelper::getString(aEffectiveValue));
908 break;
909 case TypeClass_DOUBLE:
910 _rxOutStream->writeShort(0x0001);
911 _rxOutStream->writeDouble(::comphelper::getDouble(aEffectiveValue));
912 break;
913 default: // void and all unknown states
914 DBG_ASSERT(!aEffectiveValue.hasValue(), "FmXFormattedModel::write : unknown property value type !");
915 _rxOutStream->writeShort(0x0002);
916 break;
922 //------------------------------------------------------------------------------
923 void OFormattedModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
925 OEditBaseModel::read(_rxInStream);
926 sal_uInt16 nVersion = _rxInStream->readShort();
928 Reference<XNumberFormatsSupplier> xSupplier;
929 sal_Int32 nKey = -1;
930 switch (nVersion)
932 case 0x0001 :
933 case 0x0002 :
934 case 0x0003 :
936 sal_Bool bNonVoidKey = _rxInStream->readBoolean();
937 if (bNonVoidKey)
939 // den String und die Language lesen ....
940 ::rtl::OUString sFormatDescription = _rxInStream->readUTF();
941 LanguageType eDescriptionLanguage = (LanguageType)_rxInStream->readLong();
943 // und daraus von einem Formatter zu einem Key zusammenwuerfeln lassen ...
944 xSupplier = calcFormatsSupplier();
945 // calcFormatsSupplier nimmt erst den vom Model, dann einen von der starform, dann einen ganz neuen ....
946 Reference<XNumberFormats> xFormats = xSupplier->getNumberFormats();
948 if (xFormats.is())
950 Locale aDescriptionLanguage( MsLangId::convertLanguageToLocale(eDescriptionLanguage));
952 nKey = xFormats->queryKey(sFormatDescription, aDescriptionLanguage, sal_False);
953 if (nKey == (sal_Int32)-1)
954 { // noch nicht vorhanden in meinem Formatter ...
955 nKey = xFormats->addNew(sFormatDescription, aDescriptionLanguage);
959 if ((nVersion == 0x0002) || (nVersion == 0x0003))
960 readCommonEditProperties(_rxInStream);
962 if (nVersion == 0x0003)
963 { // since version 3 there is a "skippable" block at this position
964 Reference< XDataInputStream > xIn(_rxInStream, UNO_QUERY);
965 OStreamSection aDownCompat(xIn);
967 sal_Int16 nSubVersion = _rxInStream->readShort();
968 (void)nSubVersion;
970 // version 0 and higher : the "effective value" property
971 Any aEffectiveValue;
973 OStreamSection aDownCompat2(xIn);
974 switch (_rxInStream->readShort())
976 case 0: // String
977 aEffectiveValue <<= _rxInStream->readUTF();
978 break;
979 case 1: // double
980 aEffectiveValue <<= (double)_rxInStream->readDouble();
981 break;
982 case 2:
983 break;
984 case 3:
985 DBG_ERROR("FmXFormattedModel::read : unknown effective value type !");
989 // this property is only to be set if we have no control source : in all other cases the base class did a
990 // reset after it's read and this set the effective value to a default value
991 if ( m_xAggregateSet.is() && ( getControlSource().getLength() == 0 ) )
995 m_xAggregateSet->setPropertyValue(PROPERTY_EFFECTIVE_VALUE, aEffectiveValue);
997 catch(Exception&)
1003 break;
1004 default :
1005 DBG_ERROR("OFormattedModel::read : unknown version !");
1006 // dann bleibt das Format des aggregierten Sets, wie es bei der Erzeugung ist : void
1007 defaultCommonEditProperties();
1008 break;
1011 if ((nKey != -1) && m_xAggregateSet.is())
1013 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
1014 m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, makeAny((sal_Int32)nKey));
1016 else
1018 setPropertyToDefault(PROPERTY_FORMATSSUPPLIER);
1019 setPropertyToDefault(PROPERTY_FORMATKEY);
1023 //------------------------------------------------------------------------------
1024 sal_uInt16 OFormattedModel::getPersistenceFlags() const
1026 return (OEditBaseModel::getPersistenceFlags() & ~PF_HANDLE_COMMON_PROPS);
1027 // a) we do our own call to writeCommonEditProperties
1030 //------------------------------------------------------------------------------
1031 sal_Bool OFormattedModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
1033 Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
1034 if ( aControlValue != m_aSaveValue )
1036 // Leerstring + EmptyIsNull = void
1037 if ( !aControlValue.hasValue()
1038 || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING )
1039 && ( getString( aControlValue ).getLength() == 0 )
1040 && m_bEmptyIsNull
1043 m_xColumnUpdate->updateNull();
1044 else
1046 // als Value koennen nur double, string oder void auftreten
1049 if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE )
1051 DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType );
1053 else
1055 DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalud value type !" );
1056 m_xColumnUpdate->updateString( getString( aControlValue ) );
1059 catch(Exception&)
1061 return sal_False;
1064 m_aSaveValue = aControlValue;
1066 return sal_True;
1069 //------------------------------------------------------------------------------
1070 void OFormattedModel::onConnectedExternalValue( )
1072 OEditBaseModel::onConnectedExternalValue();
1073 updateFormatterNullDate();
1076 //------------------------------------------------------------------------------
1077 Any OFormattedModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const
1079 Any aControlValue;
1080 switch( _rExternalValue.getValueTypeClass() )
1082 case TypeClass_VOID:
1083 break;
1085 case TypeClass_STRING:
1086 aControlValue = _rExternalValue;
1087 break;
1089 case TypeClass_BOOLEAN:
1091 sal_Bool bExternalValue = sal_False;
1092 _rExternalValue >>= bExternalValue;
1093 aControlValue <<= (double)( bExternalValue ? 1 : 0 );
1095 break;
1097 default:
1099 if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNODate* >( NULL ) ) ) )
1101 UNODate aDate;
1102 _rExternalValue >>= aDate;
1103 aControlValue <<= DBTypeConversion::toDouble( aDate, m_aNullDate );
1105 else if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNOTime* >( NULL ) ) ) )
1107 UNOTime aTime;
1108 _rExternalValue >>= aTime;
1109 aControlValue <<= DBTypeConversion::toDouble( aTime );
1111 else if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNODateTime* >( NULL ) ) ) )
1113 UNODateTime aDateTime;
1114 _rExternalValue >>= aDateTime;
1115 aControlValue <<= DBTypeConversion::toDouble( aDateTime, m_aNullDate );
1117 else
1119 OSL_ENSURE( _rExternalValue.getValueTypeClass() == TypeClass_DOUBLE,
1120 "OFormattedModel::translateExternalValueToControlValue: don't know how to translate this type!" );
1121 double fValue = 0;
1122 OSL_VERIFY( _rExternalValue >>= fValue );
1123 aControlValue <<= fValue;
1128 return aControlValue;
1131 //------------------------------------------------------------------------------
1132 Any OFormattedModel::translateControlValueToExternalValue( ) const
1134 OSL_PRECOND( hasExternalValueBinding(),
1135 "OFormattedModel::translateControlValueToExternalValue: precondition not met!" );
1137 Any aControlValue( getControlValue() );
1138 if ( !aControlValue.hasValue() )
1139 return aControlValue;
1141 Any aExternalValue;
1143 // translate into the the external value type
1144 Type aExternalValueType( getExternalValueType() );
1145 switch ( aExternalValueType.getTypeClass() )
1147 case TypeClass_STRING:
1149 ::rtl::OUString sString;
1150 if ( aControlValue >>= sString )
1152 aExternalValue <<= sString;
1153 break;
1156 // NO break here!
1158 case TypeClass_BOOLEAN:
1160 double fValue = 0;
1161 OSL_VERIFY( aControlValue >>= fValue );
1162 // if this asserts ... well, the somebody set the TreatAsNumeric property to false,
1163 // and the control value is a string. This implies some weird misconfiguration
1164 // of the FormattedModel, so we won't care for it for the moment.
1165 aExternalValue <<= (sal_Bool)( fValue ? sal_True : sal_False );
1167 break;
1169 default:
1171 double fValue = 0;
1172 OSL_VERIFY( aControlValue >>= fValue );
1173 // if this asserts ... well, the somebody set the TreatAsNumeric property to false,
1174 // and the control value is a string. This implies some weird misconfiguration
1175 // of the FormattedModel, so we won't care for it for the moment.
1177 if ( aExternalValueType.equals( ::getCppuType( static_cast< UNODate* >( NULL ) ) ) )
1179 aExternalValue <<= DBTypeConversion::toDate( fValue, m_aNullDate );
1181 else if ( aExternalValueType.equals( ::getCppuType( static_cast< UNOTime* >( NULL ) ) ) )
1183 aExternalValue <<= DBTypeConversion::toTime( fValue );
1185 else if ( aExternalValueType.equals( ::getCppuType( static_cast< UNODateTime* >( NULL ) ) ) )
1187 aExternalValue <<= DBTypeConversion::toDateTime( fValue, m_aNullDate );
1189 else
1191 OSL_ENSURE( aExternalValueType.equals( ::getCppuType( static_cast< double* >( NULL ) ) ),
1192 "OFormattedModel::translateControlValueToExternalValue: don't know how to translate this type!" );
1193 aExternalValue <<= fValue;
1196 break;
1198 return aExternalValue;
1201 //------------------------------------------------------------------------------
1202 Any OFormattedModel::translateDbColumnToControlValue()
1204 if ( m_bNumeric )
1205 m_aSaveValue <<= DBTypeConversion::getValue( m_xColumn, m_aNullDate, m_nKeyType ); // #100056# OJ
1206 else
1207 m_aSaveValue <<= m_xColumn->getString();
1209 if ( m_xColumn->wasNull() )
1210 m_aSaveValue.clear();
1212 return m_aSaveValue;
1215 // -----------------------------------------------------------------------------
1216 Sequence< Type > OFormattedModel::getSupportedBindingTypes()
1218 ::std::list< Type > aTypes;
1219 aTypes.push_back( ::getCppuType( static_cast< double* >( NULL ) ) );
1221 switch ( m_nKeyType & ~NumberFormat::DEFINED )
1223 case NumberFormat::DATE:
1224 aTypes.push_front(::getCppuType( static_cast< UNODate* >( NULL ) ) );
1225 break;
1226 case NumberFormat::TIME:
1227 aTypes.push_front(::getCppuType( static_cast< UNOTime* >( NULL ) ) );
1228 break;
1229 case NumberFormat::DATETIME:
1230 aTypes.push_front(::getCppuType( static_cast< UNODateTime* >( NULL ) ) );
1231 break;
1232 case NumberFormat::TEXT:
1233 aTypes.push_front(::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) );
1234 break;
1235 case NumberFormat::LOGICAL:
1236 aTypes.push_front(::getCppuType( static_cast< sal_Bool* >( NULL ) ) );
1237 break;
1240 Sequence< Type > aTypesRet( aTypes.size() );
1241 ::std::copy( aTypes.begin(), aTypes.end(), aTypesRet.getArray() );
1242 return aTypesRet;
1245 //------------------------------------------------------------------------------
1246 Any OFormattedModel::getDefaultForReset() const
1248 return m_xAggregateSet->getPropertyValue( PROPERTY_EFFECTIVE_DEFAULT );
1251 //.........................................................................
1253 //.........................................................................