Files
libreoffice/forms/source/component/FormattedField.cxx

1045 lines
43 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by Christian Lippka impress212: #i113063# patch: dubios self assign in svx/source/dialog/framelink.cxx http://svn.apache.org/viewvc?view=revision&revision=1167619 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation http://svn.apache.org/viewvc?view=revision&revision=1172343 cws mba34issues01: #i117719#: use correct resource ID http://svn.apache.org/viewvc?view=revision&revision=1172351 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Armin Le-Grand #118804# corrected GraphicExporter behaviour on shortcut when pixel graphic is requested http://svn.apache.org/viewvc?view=revision&revision=1240195 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 13f79535-47bb-0310-9956-ffa450edef68 Patch contributed by Regina Henschel linecap: Reintegrating finished LineCap feature http://svn.apache.org/viewvc?view=revision&revision=1232507 Patch contributed by Wang Lei (leiw) #i118760# split the first table cell vertically, then undo&redo, the Presentation app will crash http://svn.apache.org/viewvc?view=revision&revision=1301361 cleanup globlmn hacks, undo dependent fixmes.
2012-11-21 22:06:52 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 15:33:13 +00:00
#include "FormattedField.hxx"
#include "services.hxx"
#include "property.hrc"
#include "property.hxx"
#include "frm_resource.hxx"
#include "frm_resource.hrc"
#include "propertybaghelper.hxx"
2000-10-19 10:52:20 +00:00
#include <comphelper/sequence.hxx>
#include <comphelper/numbers.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbconversion.hxx>
#include <svl/zforlist.hxx>
#include <svl/numuno.hxx>
2000-09-18 15:33:13 +00:00
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
2000-09-18 15:33:13 +00:00
#include <tools/debug.hxx>
2010-11-23 18:41:04 +01:00
#include <tools/wintypes.hxx>
#include <i18nlangtag/languagetag.hxx>
2000-09-18 15:33:13 +00:00
#include <rtl/textenc.h>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/util/NumberFormat.hpp>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/Time.hpp>
2000-09-18 15:33:13 +00:00
#include <com/sun/star/awt/MouseEvent.hpp>
#include <com/sun/star/form/XSubmit.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/XKeyListener.hpp>
#include <com/sun/star/form/FormComponentType.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#include <com/sun/star/form/XForm.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <osl/mutex.hxx>
// needed as long as we use the SolarMutex
#include <comphelper/streamsection.hxx>
#include <cppuhelper/weakref.hxx>
#include <unotools/desktopterminationobserver.hxx>
#include <list>
#include <algorithm>
2000-11-23 07:48:15 +00:00
using namespace dbtools;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::form::binding;
namespace
{
typedef com::sun::star::util::Date UNODate;
typedef com::sun::star::util::Time UNOTime;
typedef com::sun::star::util::DateTime UNODateTime;
}
2000-09-18 15:33:13 +00:00
namespace frm
{
class StandardFormatsSupplier : protected SvNumberFormatsSupplierObj, public ::utl::ITerminationListener
2000-09-18 15:33:13 +00:00
{
protected:
SvNumberFormatter* m_pMyPrivateFormatter;
static WeakReference< XNumberFormatsSupplier > s_xDefaultFormatsSupplier;
2000-09-18 15:33:13 +00:00
public:
static Reference< XNumberFormatsSupplier > get( const Reference< XComponentContext >& _rxORB );
using SvNumberFormatsSupplierObj::operator new;
using SvNumberFormatsSupplierObj::operator delete;
2000-09-18 15:33:13 +00:00
protected:
StandardFormatsSupplier(const Reference< XComponentContext >& _rxFactory,LanguageType _eSysLanguage);
~StandardFormatsSupplier();
protected:
virtual bool queryTermination() const;
virtual void notifyTermination();
2000-09-18 15:33:13 +00:00
};
WeakReference< XNumberFormatsSupplier > StandardFormatsSupplier::s_xDefaultFormatsSupplier;
StandardFormatsSupplier::StandardFormatsSupplier(const Reference< XComponentContext > & _rxContext,LanguageType _eSysLanguage)
2000-09-18 15:33:13 +00:00
:SvNumberFormatsSupplierObj()
,m_pMyPrivateFormatter(new SvNumberFormatter(_rxContext, _eSysLanguage))
2000-09-18 15:33:13 +00:00
{
SetNumberFormatter(m_pMyPrivateFormatter);
2011-02-13 17:35:58 +01:00
// #i29147#
::utl::DesktopTerminationObserver::registerTerminationListener( this );
}
StandardFormatsSupplier::~StandardFormatsSupplier()
{
::utl::DesktopTerminationObserver::revokeTerminationListener( this );
DELETEZ( m_pMyPrivateFormatter );
}
Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Reference< XComponentContext >& _rxORB )
{
LanguageType eSysLanguage = LANGUAGE_SYSTEM;
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier;
if ( xSupplier.is() )
return xSupplier;
// get the Office's locale
eSysLanguage = SvtSysLocale().GetLanguageTag().getLanguageType( false);
}
StandardFormatsSupplier* pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage );
Reference< XNumberFormatsSupplier > xNewlyCreatedSupplier( pSupplier );
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier;
if ( xSupplier.is() )
// somebody used the small time frame where the mutex was not locked to create and set
// the supplier
return xSupplier;
s_xDefaultFormatsSupplier = xNewlyCreatedSupplier;
}
return xNewlyCreatedSupplier;
2000-09-18 15:33:13 +00:00
}
bool StandardFormatsSupplier::queryTermination() const
2000-09-18 15:33:13 +00:00
{
return true;
2000-09-18 15:33:13 +00:00
}
void StandardFormatsSupplier::notifyTermination()
{
Reference< XNumberFormatsSupplier > xKeepAlive = this;
// when the application is terminating, release our static reference so that we are cleared/destructed
// earlier than upon unloading the library
2011-02-13 17:35:58 +01:00
// #i29147#
s_xDefaultFormatsSupplier = WeakReference< XNumberFormatsSupplier >( );
SetNumberFormatter( NULL );
DELETEZ( m_pMyPrivateFormatter );
}
2000-11-23 07:48:15 +00:00
InterfaceRef SAL_CALL OFormattedControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
2000-09-18 15:33:13 +00:00
{
return *(new OFormattedControl( comphelper::getComponentContext(_rxFactory) ));
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
Sequence<Type> OFormattedControl::_getTypes()
2000-09-18 15:33:13 +00:00
{
return ::comphelper::concatSequences(
OFormattedControl_BASE::getTypes(),
OBoundControl::_getTypes()
);
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
Any SAL_CALL OFormattedControl::queryAggregation(const Type& _rType) throw (RuntimeException)
2000-09-18 15:33:13 +00:00
{
2000-11-23 07:48:15 +00:00
Any aReturn = OBoundControl::queryAggregation(_rType);
2000-09-18 15:33:13 +00:00
if (!aReturn.hasValue())
2000-11-23 07:48:15 +00:00
aReturn = OFormattedControl_BASE::queryInterface(_rType);
2000-09-18 15:33:13 +00:00
return aReturn;
}
OFormattedControl::OFormattedControl(const Reference<XComponentContext>& _rxFactory)
2000-09-18 15:33:13 +00:00
:OBoundControl(_rxFactory, VCL_CONTROL_FORMATTEDFIELD)
,m_nKeyEvent(0)
{
increment(m_refCount);
{
2001-05-18 13:44:30 +00:00
Reference<XWindow> xComp;
2000-09-18 15:33:13 +00:00
if (query_aggregation(m_xAggregate, xComp))
{
xComp->addKeyListener(this);
}
}
decrement(m_refCount);
2000-09-18 15:33:13 +00:00
}
OFormattedControl::~OFormattedControl()
{
if( m_nKeyEvent )
Application::RemoveUserEvent( m_nKeyEvent );
if (!OComponentHelper::rBHelper.bDisposed)
{
acquire();
dispose();
}
}
2000-11-23 07:48:15 +00:00
// XKeyListener
void OFormattedControl::disposing(const EventObject& _rSource) throw(RuntimeException)
2000-09-18 15:33:13 +00:00
{
OBoundControl::disposing(_rSource);
}
2002-07-23 10:05:38 +00:00
void OFormattedControl::keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
return;
// Steht das Control in einem Formular mit einer Submit-URL?
2000-11-23 07:48:15 +00:00
Reference<com::sun::star::beans::XPropertySet> xSet(getModel(), UNO_QUERY);
2000-09-18 15:33:13 +00:00
if( !xSet.is() )
return;
2000-11-23 07:48:15 +00:00
Reference<XFormComponent> xFComp(xSet, UNO_QUERY);
2000-09-18 15:33:13 +00:00
InterfaceRef xParent = xFComp->getParent();
if( !xParent.is() )
return;
2000-11-23 07:48:15 +00:00
Reference<com::sun::star::beans::XPropertySet> xFormSet(xParent, UNO_QUERY);
2000-09-18 15:33:13 +00:00
if( !xFormSet.is() )
return;
2000-11-23 07:48:15 +00:00
Any aTmp(xFormSet->getPropertyValue( PROPERTY_TARGET_URL ));
if (!isA(aTmp, static_cast< OUString* >(NULL)) ||
getString(aTmp).isEmpty() )
2000-09-18 15:33:13 +00:00
return;
2000-11-23 07:48:15 +00:00
Reference<XIndexAccess> xElements(xParent, UNO_QUERY);
2000-09-18 15:33:13 +00:00
sal_Int32 nCount = xElements->getCount();
if( nCount > 1 )
{
2000-11-23 07:48:15 +00:00
Reference<com::sun::star::beans::XPropertySet> xFCSet;
2000-09-18 15:33:13 +00:00
for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
{
2000-11-23 07:48:15 +00:00
// Any aElement(xElements->getByIndex(nIndex));
xElements->getByIndex(nIndex) >>= xFCSet;
2000-09-18 15:33:13 +00:00
if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
2000-11-23 07:48:15 +00:00
getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == FormComponentType::TEXTFIELD)
2000-09-18 15:33:13 +00:00
{
// Noch ein weiteres Edit gefunden ==> dann nicht submitten
if (xFCSet != xSet)
return;
}
}
}
// Da wir noch im Haender stehen, submit asynchron ausloesen
if( m_nKeyEvent )
Application::RemoveUserEvent( m_nKeyEvent );
m_nKeyEvent = Application::PostUserEvent( LINK(this, OFormattedControl,
OnKeyPressed) );
}
void OFormattedControl::keyReleased(const ::com::sun::star::awt::KeyEvent& /*e*/) throw ( ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
}
IMPL_LINK(OFormattedControl, OnKeyPressed, void*, /*EMPTYARG*/)
2000-09-18 15:33:13 +00:00
{
m_nKeyEvent = 0;
2001-04-26 11:36:28 +00:00
Reference<XFormComponent> xFComp(getModel(), UNO_QUERY);
2000-09-18 15:33:13 +00:00
InterfaceRef xParent = xFComp->getParent();
2001-04-26 11:36:28 +00:00
Reference<XSubmit> xSubmit(xParent, UNO_QUERY);
2000-09-18 15:33:13 +00:00
if (xSubmit.is())
xSubmit->submit( Reference<XControl> (), ::com::sun::star::awt::MouseEvent() );
2000-09-18 15:33:13 +00:00
return 0L;
}
StringSequence OFormattedControl::getSupportedServiceNames() throw()
{
StringSequence aSupported = OBoundControl::getSupportedServiceNames();
aSupported.realloc(aSupported.getLength() + 1);
OUString*pArray = aSupported.getArray();
2000-09-18 15:33:13 +00:00
pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_FORMATTEDFIELD;
return aSupported;
}
2001-09-12 15:21:50 +00:00
void OFormattedControl::setDesignMode(sal_Bool bOn) throw ( ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
OBoundControl::setDesignMode(bOn);
}
void OFormattedModel::implConstruct()
2000-09-18 15:33:13 +00:00
{
// members
m_bOriginalNumeric = sal_False;
m_bNumeric = sal_False;
m_xOriginalFormatter = NULL;
m_nKeyType = NumberFormat::UNDEFINED;
m_aNullDate = DBTypeConversion::getStandardDate();
m_nFieldType = DataType::OTHER;
// default our formats supplier
2000-09-18 15:33:13 +00:00
increment(m_refCount);
setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
decrement(m_refCount);
startAggregatePropertyListening( PROPERTY_FORMATKEY );
startAggregatePropertyListening( PROPERTY_FORMATSSUPPLIER );
}
OFormattedModel::OFormattedModel(const Reference<XComponentContext>& _rxFactory)
:OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_FORMATTEDFIELD, FRM_SUN_CONTROL_FORMATTEDFIELD, sal_True, sal_True )
// use the old control name for compytibility reasons
,OErrorBroadcaster( OComponentHelper::rBHelper )
{
implConstruct();
m_nClassId = FormComponentType::TEXTFIELD;
initValueProperty( PROPERTY_EFFECTIVE_VALUE, PROPERTY_ID_EFFECTIVE_VALUE );
}
OFormattedModel::OFormattedModel( const OFormattedModel* _pOriginal, const Reference< XComponentContext >& _rxFactory )
:OEditBaseModel( _pOriginal, _rxFactory )
,OErrorBroadcaster( OComponentHelper::rBHelper )
{
implConstruct();
}
OFormattedModel::~OFormattedModel()
{
}
// XCloneable
IMPLEMENT_DEFAULT_CLONING( OFormattedModel )
void SAL_CALL OFormattedModel::disposing()
{
OErrorBroadcaster::disposing();
OEditBaseModel::disposing();
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
// XServiceInfo
2000-09-18 15:33:13 +00:00
StringSequence OFormattedModel::getSupportedServiceNames() throw()
{
StringSequence aSupported = OEditBaseModel::getSupportedServiceNames();
sal_Int32 nOldLen = aSupported.getLength();
aSupported.realloc( nOldLen + 8 );
OUString* pStoreTo = aSupported.getArray() + nOldLen;
*pStoreTo++ = BINDABLE_CONTROL_MODEL;
*pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
*pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
*pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
*pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
*pStoreTo++ = FRM_SUN_COMPONENT_FORMATTEDFIELD;
*pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD;
*pStoreTo++ = BINDABLE_DATABASE_FORMATTED_FIELD;
2000-09-18 15:33:13 +00:00
return aSupported;
}
// XAggregation
Any SAL_CALL OFormattedModel::queryAggregation(const Type& _rType) throw(RuntimeException)
{
Any aReturn = OEditBaseModel::queryAggregation( _rType );
return aReturn.hasValue() ? aReturn : OErrorBroadcaster::queryInterface( _rType );
}
// XTypeProvider
Sequence< Type > OFormattedModel::_getTypes()
{
return ::comphelper::concatSequences(
OEditBaseModel::_getTypes(),
OErrorBroadcaster::getTypes()
);
}
2000-11-23 07:48:15 +00:00
// XPersistObject
OUString SAL_CALL OFormattedModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
return OUString(FRM_COMPONENT_EDIT);
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
// XPropertySet
void OFormattedModel::describeFixedProperties( Sequence< Property >& _rProps ) const
2000-09-18 15:33:13 +00:00
{
BEGIN_DESCRIBE_PROPERTIES( 3, OEditBaseModel )
DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
DECL_PROP1(TABINDEX, sal_Int16, BOUND);
DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT);
END_DESCRIBE_PROPERTIES();
2000-09-18 15:33:13 +00:00
}
void OFormattedModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::describeAggregateProperties( _rAggregateProps );
// TreatAsNumeric nicht transient : wir wollen es an der UI anbinden (ist noetig, um dem EffectiveDefault
// - der kann Text oder Zahl sein - einen Sinn zu geben)
ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TREATASNUMERIC, 0, PropertyAttribute::TRANSIENT);
// same for FormatKey
// (though the paragraph above for the TreatAsNumeric does not hold anymore - we do not have an UI for this.
// But we have for the format key ...)
ModifyPropertyAttributes(_rAggregateProps, PROPERTY_FORMATKEY, 0, PropertyAttribute::TRANSIENT);
RemoveProperty(_rAggregateProps, PROPERTY_STRICTFORMAT);
// no strict format property for formatted fields: it does not make sense, 'cause
// there is no general way to decide which characters/sub strings are allowed during the input of an
// arbitraryly formatted control
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
void OFormattedModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::getFastPropertyValue(rValue, nHandle);
}
2001-09-12 15:21:50 +00:00
void OFormattedModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) throw ( ::com::sun::star::uno::Exception)
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
}
2000-11-23 07:48:15 +00:00
sal_Bool OFormattedModel::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue)
throw( IllegalArgumentException )
2000-09-18 15:33:13 +00:00
{
return OEditBaseModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
}
void OFormattedModel::setPropertyToDefaultByHandle(sal_Int32 nHandle)
{
if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
{
2001-05-18 13:44:30 +00:00
Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier();
2000-09-18 15:33:13 +00:00
DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::setPropertyToDefaultByHandle(FORMATSSUPPLIER) : have no aggregate !");
if (m_xAggregateSet.is())
2000-11-23 07:48:15 +00:00
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
2000-09-18 15:33:13 +00:00
}
else
OEditBaseModel::setPropertyToDefaultByHandle(nHandle);
}
void OFormattedModel::setPropertyToDefault(const OUString& aPropertyName) throw( com::sun::star::beans::UnknownPropertyException, RuntimeException )
2000-09-18 15:33:13 +00:00
{
OPropertyArrayAggregationHelper& rPH = m_aPropertyBagHelper.getInfoHelper();
2000-09-18 15:33:13 +00:00
sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
setPropertyToDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
else
OEditBaseModel::setPropertyToDefault(aPropertyName);
}
2000-11-23 07:48:15 +00:00
Any OFormattedModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
2000-09-18 15:33:13 +00:00
{
if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
{
Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier();
2000-11-23 07:48:15 +00:00
return makeAny(xSupplier);
2000-09-18 15:33:13 +00:00
}
else
return OEditBaseModel::getPropertyDefaultByHandle(nHandle);
}
Any SAL_CALL OFormattedModel::getPropertyDefault( const OUString& aPropertyName ) throw( com::sun::star::beans::UnknownPropertyException, RuntimeException )
2000-09-18 15:33:13 +00:00
{
OPropertyArrayAggregationHelper& rPH = m_aPropertyBagHelper.getInfoHelper();
2000-09-18 15:33:13 +00:00
sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
if (nHandle == PROPERTY_ID_FORMATSSUPPLIER)
return getPropertyDefaultByHandle(PROPERTY_ID_FORMATSSUPPLIER);
else
return OEditBaseModel::getPropertyDefault(aPropertyName);
}
2000-11-23 07:48:15 +00:00
void OFormattedModel::_propertyChanged( const com::sun::star::beans::PropertyChangeEvent& evt ) throw(RuntimeException)
2000-09-18 15:33:13 +00:00
{
// TODO: check how this works with external bindings
OSL_ENSURE( evt.Source == m_xAggregateSet, "OFormattedModel::_propertyChanged: where did this come from?" );
if ( evt.Source == m_xAggregateSet )
2000-09-18 15:33:13 +00:00
{
Reference< XPropertySet > xSourceSet( evt.Source, UNO_QUERY );
if ( evt.PropertyName.equals( PROPERTY_FORMATKEY ) )
2000-09-18 15:33:13 +00:00
{
if ( evt.NewValue.getValueType().getTypeClass() == TypeClass_LONG )
2000-09-18 15:33:13 +00:00
{
try
{
::osl::MutexGuard aGuard( m_aMutex );
Reference<XNumberFormatsSupplier> xSupplier( calcFormatsSupplier() );
m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32( evt.NewValue ) );
// as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have
// to recalc it, which is done by translateDbColumnToControlValue
if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast())
2000-09-18 15:33:13 +00:00
{
setControlValue( translateDbColumnToControlValue(), eOther );
2000-09-18 15:33:13 +00:00
}
// if we're connected to an external value binding, then re-calculate the type
// used to exchange the value - it depends on the format, too
if ( hasExternalValueBinding() )
{
calculateExternalValueType();
}
2000-09-18 15:33:13 +00:00
}
2011-12-11 18:51:50 +09:00
catch(const Exception&)
2000-09-18 15:33:13 +00:00
{
}
}
return;
2000-09-18 15:33:13 +00:00
}
if ( evt.PropertyName.equals( PROPERTY_FORMATSSUPPLIER ) )
{
updateFormatterNullDate();
return;
}
OBoundControlModel::_propertyChanged( evt );
2000-09-18 15:33:13 +00:00
}
}
void OFormattedModel::updateFormatterNullDate()
{
// calc the current NULL date
Reference< XNumberFormatsSupplier > xSupplier( calcFormatsSupplier() );
if ( xSupplier.is() )
xSupplier->getNumberFormatSettings()->getPropertyValue("NullDate") >>= m_aNullDate;
}
Reference< XNumberFormatsSupplier > OFormattedModel::calcFormatsSupplier() const
2000-09-18 15:33:13 +00:00
{
2000-11-23 07:48:15 +00:00
Reference<XNumberFormatsSupplier> xSupplier;
2000-09-18 15:33:13 +00:00
DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::calcFormatsSupplier : have no aggregate !");
// hat mein aggregiertes Model einen FormatSupplier ?
2000-11-23 07:48:15 +00:00
if( m_xAggregateSet.is() )
m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xSupplier;
2000-09-18 15:33:13 +00:00
if (!xSupplier.is())
// check if my parent form has a supplier
2000-09-18 15:33:13 +00:00
xSupplier = calcFormFormatsSupplier();
if (!xSupplier.is())
xSupplier = calcDefaultFormatsSupplier();
DBG_ASSERT(xSupplier.is(), "OFormattedModel::calcFormatsSupplier : no supplier !");
// jetzt sollte aber einer da sein
return xSupplier;
}
2000-11-23 07:48:15 +00:00
Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const
2000-09-18 15:33:13 +00:00
{
2000-11-23 07:48:15 +00:00
Reference<XChild> xMe;
query_interface(static_cast<XWeak*>(const_cast<OFormattedModel*>(this)), xMe);
2000-09-18 15:33:13 +00:00
// damit stellen wir sicher, dass wir auch fuer den Fall der Aggregation das richtige
// Objekt bekommen
DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !");
// jetzt durchhangeln nach oben, bis wir auf eine starform treffen (angefangen mit meinem eigenen Parent)
2000-11-23 07:48:15 +00:00
Reference<XChild> xParent(xMe->getParent(), UNO_QUERY);
Reference<XForm> xNextParentForm(xParent, UNO_QUERY);
2000-09-18 15:33:13 +00:00
while (!xNextParentForm.is() && xParent.is())
{
xParent = xParent.query( xParent->getParent() );
xNextParentForm = xNextParentForm.query( xParent );
2000-09-18 15:33:13 +00:00
}
if (!xNextParentForm.is())
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("OFormattedModel::calcFormFormatsSupplier : have no ancestor which is a form !");
2000-09-18 15:33:13 +00:00
return NULL;
}
// den FormatSupplier von meinem Vorfahren (falls der einen hat)
Reference< XRowSet > xRowSet( xNextParentForm, UNO_QUERY );
Reference< XNumberFormatsSupplier > xSupplier;
2000-09-18 15:33:13 +00:00
if (xRowSet.is())
xSupplier = getNumberFormats( getConnection(xRowSet), sal_True, getContext() );
2000-09-18 15:33:13 +00:00
return xSupplier;
}
Reference< XNumberFormatsSupplier > OFormattedModel::calcDefaultFormatsSupplier() const
2000-09-18 15:33:13 +00:00
{
return StandardFormatsSupplier::get( getContext() );
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
// XBoundComponent
2001-09-12 15:21:50 +00:00
void OFormattedModel::loaded(const EventObject& rEvent) throw ( ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
// HACK : our onConnectedDbColumn accesses our NumberFormatter which locks the solar mutex (as it doesn't have
2000-09-18 15:33:13 +00:00
// an own one). To prevent deadlocks with other threads which may request a property from us in an
// UI-triggered action (e.g. an tooltip) we lock the solar mutex _here_ before our base class locks
// it's own muext (which is used for property requests)
// alternative a): we use two mutexes, one which is passed to the OPropertysetHelper and used for
// property requests and one for our own code. This would need a lot of code rewriting
// alternative b): The NumberFormatter has to be really threadsafe (with an own mutex), which is
// the only "clean" solution for me.
SolarMutexGuard aGuard;
2000-09-18 15:33:13 +00:00
OEditBaseModel::loaded(rEvent);
}
void OFormattedModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
2000-09-18 15:33:13 +00:00
{
m_xOriginalFormatter = NULL;
// get some properties of the field
m_nFieldType = DataType::OTHER;
Reference<XPropertySet> xField = getField();
if ( xField.is() )
xField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= m_nFieldType;
sal_Int32 nFormatKey = 0;
DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::onConnectedDbColumn : have no aggregate !");
2000-09-18 15:33:13 +00:00
if (m_xAggregateSet.is())
{ // all the following doesn't make any sense if we have no aggregate ...
2000-11-23 07:48:15 +00:00
Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
DBG_ASSERT( aSupplier.hasValue(), "OFormattedModel::onConnectedDbColumn : invalid property value !" );
2000-11-23 07:48:15 +00:00
// das sollte im Constructor oder im read auf was richtiges gesetzt worden sein
Any aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
if ( !(aFmtKey >>= nFormatKey ) )
{ // nobody gave us a format to use. So we examine the field we're bound to for a
// format key, and use it ourself, too
2000-11-23 07:48:15 +00:00
sal_Int32 nType = DataType::VARCHAR;
if (xField.is())
2000-09-18 15:33:13 +00:00
{
aFmtKey = xField->getPropertyValue(PROPERTY_FORMATKEY);
xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType ;
2000-09-18 15:33:13 +00:00
}
2000-11-23 07:48:15 +00:00
Reference<XNumberFormatsSupplier> xSupplier = calcFormFormatsSupplier();
DBG_ASSERT(xSupplier.is(), "OFormattedModel::onConnectedDbColumn : bound to a field but no parent with a formatter ? how this ?");
2000-09-18 15:33:13 +00:00
if (xSupplier.is())
{
m_bOriginalNumeric = getBOOL(getPropertyValue(PROPERTY_TREATASNUMERIC));
2000-09-18 15:33:13 +00:00
if (!aFmtKey.hasValue())
{ // we aren't bound to a field (or this field's format is invalid)
// -> determine the standard text (or numeric) format of the supplier
Reference<XNumberFormatTypes> xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
2000-09-18 15:33:13 +00:00
if (xTypes.is())
{
Locale aApplicationLocale = Application::GetSettings().GetUILanguageTag().getLocale();
if (m_bOriginalNumeric)
aFmtKey <<= (sal_Int32)xTypes->getStandardFormat(NumberFormat::NUMBER, aApplicationLocale);
else
aFmtKey <<= (sal_Int32)xTypes->getStandardFormat(NumberFormat::TEXT, aApplicationLocale);
2000-09-18 15:33:13 +00:00
}
}
aSupplier >>= m_xOriginalFormatter;
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
2000-09-18 15:33:13 +00:00
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, aFmtKey);
// das Numeric-Flag an mein gebundenes Feld anpassen
if (xField.is())
2000-09-18 15:33:13 +00:00
{
m_bNumeric = sal_False;
switch (nType)
{
case DataType::BIT:
case DataType::BOOLEAN:
case DataType::TINYINT:
case DataType::SMALLINT:
case DataType::INTEGER:
case DataType::BIGINT:
case DataType::FLOAT:
case DataType::REAL:
case DataType::DOUBLE:
case DataType::NUMERIC:
case DataType::DECIMAL:
case DataType::DATE:
case DataType::TIME:
case DataType::TIMESTAMP:
m_bNumeric = sal_True;
break;
}
2000-09-18 15:33:13 +00:00
}
else
m_bNumeric = m_bOriginalNumeric;
2000-11-23 07:48:15 +00:00
setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny((sal_Bool)m_bNumeric));
OSL_VERIFY( aFmtKey >>= nFormatKey );
2000-09-18 15:33:13 +00:00
}
}
}
Reference<XNumberFormatsSupplier> xSupplier = calcFormatsSupplier();
m_bNumeric = getBOOL( getPropertyValue( PROPERTY_TREATASNUMERIC ) );
m_nKeyType = getNumberFormatType( xSupplier->getNumberFormats(), nFormatKey );
xSupplier->getNumberFormatSettings()->getPropertyValue("NullDate") >>= m_aNullDate;
OEditBaseModel::onConnectedDbColumn( _rxForm );
2000-09-18 15:33:13 +00:00
}
void OFormattedModel::onDisconnectedDbColumn()
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::onDisconnectedDbColumn();
2000-09-18 15:33:13 +00:00
if (m_xOriginalFormatter.is())
{ // unser aggregiertes Model hatte keinerlei Format-Informationen
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(m_xOriginalFormatter));
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, Any());
setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny((sal_Bool)m_bOriginalNumeric));
2000-09-18 15:33:13 +00:00
m_xOriginalFormatter = NULL;
}
m_nFieldType = DataType::OTHER;
2000-11-23 07:48:15 +00:00
m_nKeyType = NumberFormat::UNDEFINED;
2000-12-06 09:24:23 +00:00
m_aNullDate = DBTypeConversion::getStandardDate();
2000-09-18 15:33:13 +00:00
}
2001-09-12 15:21:50 +00:00
void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::write(_rxOutStream);
_rxOutStream->writeShort(0x0003);
DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::write : have no aggregate !");
// mein Format (evtl. void) in ein persistentes Format bringen (der Supplier zusammen mit dem Key ist es zwar auch,
// aber deswegen muessen wir ja nicht gleich den ganzen Supplier speichern, das waere ein klein wenig Overhead ;)
2000-11-23 07:48:15 +00:00
Reference<XNumberFormatsSupplier> xSupplier;
Any aFmtKey;
2000-09-18 15:33:13 +00:00
sal_Bool bVoidKey = sal_True;
if (m_xAggregateSet.is())
{
Any aSupplier = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATSSUPPLIER);
if (aSupplier.getValueType().getTypeClass() != TypeClass_VOID)
2000-09-18 15:33:13 +00:00
{
OSL_VERIFY( aSupplier >>= xSupplier );
2000-09-18 15:33:13 +00:00
}
aFmtKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
bVoidKey = (!xSupplier.is() || !aFmtKey.hasValue()) || (isLoaded() && m_xOriginalFormatter.is());
2000-09-18 15:33:13 +00:00
// (kein Fomatter und/oder Key) oder (loaded und faked Formatter)
}
_rxOutStream->writeBoolean(!bVoidKey);
if (!bVoidKey)
{
// aus dem FormatKey und dem Formatter persistente Angaben basteln
2001-05-18 13:44:30 +00:00
Any aKey = m_xAggregateSet->getPropertyValue(PROPERTY_FORMATKEY);
2000-09-18 15:33:13 +00:00
sal_Int32 nKey = aKey.hasValue() ? getINT32(aKey) : 0;
2001-05-18 13:44:30 +00:00
Reference<XNumberFormats> xFormats = xSupplier->getNumberFormats();
OUString sFormatDescription;
2000-09-18 15:33:13 +00:00
LanguageType eFormatLanguage = LANGUAGE_DONTKNOW;
static const OUString s_aLocaleProp ("Locale");
2001-05-18 13:44:30 +00:00
Reference<com::sun::star::beans::XPropertySet> xFormat = xFormats->getByKey(nKey);
2000-09-18 15:33:13 +00:00
if (hasProperty(s_aLocaleProp, xFormat))
{
2001-05-18 13:44:30 +00:00
Any aLocale = xFormat->getPropertyValue(s_aLocaleProp);
DBG_ASSERT(isA(aLocale, static_cast<Locale*>(NULL)), "OFormattedModel::write : invalid language property !");
if (isA(aLocale, static_cast<Locale*>(NULL)))
2000-09-18 15:33:13 +00:00
{
2001-05-18 13:44:30 +00:00
Locale* pLocale = (Locale*)aLocale.getValue();
eFormatLanguage = LanguageTag::convertToLanguageType( *pLocale, false);
2000-09-18 15:33:13 +00:00
}
}
static const OUString s_aFormatStringProp ("FormatString");
2000-09-18 15:33:13 +00:00
if (hasProperty(s_aFormatStringProp, xFormat))
xFormat->getPropertyValue(s_aFormatStringProp) >>= sFormatDescription;
_rxOutStream->writeUTF(sFormatDescription);
_rxOutStream->writeLong((sal_Int32)eFormatLanguage);
}
// version 2 : write the properties common to all OEditBaseModels
writeCommonEditProperties(_rxOutStream);
// version 3 : write the effective value property of the aggregate
// Due to a bug within the UnoControlFormattedFieldModel implementation (our default aggregate) this props value isn't correctly read
// and this can't be corrected without being incompatible.
// so we have our own handling.
// and to be a little bit more compatible we make the following section skippable
{
OStreamSection aDownCompat(_rxOutStream);
2000-09-18 15:33:13 +00:00
// a sub version within the skippable block
_rxOutStream->writeShort(0x0000);
// version 0: the effective value of the aggregate
2000-11-23 07:48:15 +00:00
Any aEffectiveValue;
2000-09-18 15:33:13 +00:00
if (m_xAggregateSet.is())
{
2011-12-11 18:51:50 +09:00
try { aEffectiveValue = m_xAggregateSet->getPropertyValue(PROPERTY_EFFECTIVE_VALUE); } catch(const Exception&) { }
2000-09-18 15:33:13 +00:00
}
{
OStreamSection aDownCompat2(_rxOutStream);
2000-09-18 15:33:13 +00:00
switch (aEffectiveValue.getValueType().getTypeClass())
{
2000-11-23 07:48:15 +00:00
case TypeClass_STRING:
2000-09-18 15:33:13 +00:00
_rxOutStream->writeShort(0x0000);
2000-10-19 10:52:20 +00:00
_rxOutStream->writeUTF(::comphelper::getString(aEffectiveValue));
2000-09-18 15:33:13 +00:00
break;
2000-11-23 07:48:15 +00:00
case TypeClass_DOUBLE:
2000-09-18 15:33:13 +00:00
_rxOutStream->writeShort(0x0001);
2000-10-19 10:52:20 +00:00
_rxOutStream->writeDouble(::comphelper::getDouble(aEffectiveValue));
2000-09-18 15:33:13 +00:00
break;
default: // void and all unknown states
DBG_ASSERT(!aEffectiveValue.hasValue(), "FmXFormattedModel::write : unknown property value type !");
_rxOutStream->writeShort(0x0002);
break;
}
}
}
}
2001-09-12 15:21:50 +00:00
void OFormattedModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
2000-09-18 15:33:13 +00:00
{
OEditBaseModel::read(_rxInStream);
sal_uInt16 nVersion = _rxInStream->readShort();
2001-05-18 13:44:30 +00:00
Reference<XNumberFormatsSupplier> xSupplier;
2000-09-18 15:33:13 +00:00
sal_Int32 nKey = -1;
switch (nVersion)
{
case 0x0001 :
case 0x0002 :
case 0x0003 :
{
sal_Bool bNonVoidKey = _rxInStream->readBoolean();
if (bNonVoidKey)
{
// read string and language...
OUString sFormatDescription = _rxInStream->readUTF();
2000-09-18 15:33:13 +00:00
LanguageType eDescriptionLanguage = (LanguageType)_rxInStream->readLong();
// and let a formatter roll dice based on that to create a key...
2000-09-18 15:33:13 +00:00
xSupplier = calcFormatsSupplier();
// calcFormatsSupplier first takes the one from the model, then one from the starform, then a new one...
2001-05-18 13:44:30 +00:00
Reference<XNumberFormats> xFormats = xSupplier->getNumberFormats();
2000-09-18 15:33:13 +00:00
if (xFormats.is())
{
Locale aDescriptionLanguage( LanguageTag::convertToLocale(eDescriptionLanguage));
2000-09-18 15:33:13 +00:00
nKey = xFormats->queryKey(sFormatDescription, aDescriptionLanguage, sal_False);
if (nKey == (sal_Int32)-1)
{ // does not yet exist in my formatter...
2000-09-18 15:33:13 +00:00
nKey = xFormats->addNew(sFormatDescription, aDescriptionLanguage);
}
}
}
if ((nVersion == 0x0002) || (nVersion == 0x0003))
readCommonEditProperties(_rxInStream);
if (nVersion == 0x0003)
{ // since version 3 there is a "skippable" block at this position
OStreamSection aDownCompat(_rxInStream);
2000-09-18 15:33:13 +00:00
sal_Int16 nSubVersion = _rxInStream->readShort();
(void)nSubVersion;
2000-09-18 15:33:13 +00:00
// version 0 and higher : the "effective value" property
Any aEffectiveValue;
2000-09-18 15:33:13 +00:00
{
OStreamSection aDownCompat2(_rxInStream);
2000-09-18 15:33:13 +00:00
switch (_rxInStream->readShort())
{
case 0: // String
aEffectiveValue <<= _rxInStream->readUTF();
break;
case 1: // double
aEffectiveValue <<= (double)_rxInStream->readDouble();
break;
case 2:
break;
case 3:
2011-03-01 17:55:09 +01:00
OSL_FAIL("FmXFormattedModel::read : unknown effective value type !");
2000-09-18 15:33:13 +00:00
}
}
// this property is only to be set if we have no control source : in all other cases the base class did a
// reset after it's read and this set the effective value to a default value
if ( m_xAggregateSet.is() && getControlSource().isEmpty() )
2000-09-18 15:33:13 +00:00
{
try
{
m_xAggregateSet->setPropertyValue(PROPERTY_EFFECTIVE_VALUE, aEffectiveValue);
}
2011-12-11 18:51:50 +09:00
catch(const Exception&)
2000-09-18 15:33:13 +00:00
{
}
}
}
}
break;
default :
2011-03-01 17:55:09 +01:00
OSL_FAIL("OFormattedModel::read : unknown version !");
// then the format of the aggregated set stay like it was during creation: void
2000-09-18 15:33:13 +00:00
defaultCommonEditProperties();
break;
}
if ((nKey != -1) && m_xAggregateSet.is())
{
2000-11-23 07:48:15 +00:00
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier));
m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, makeAny((sal_Int32)nKey));
2000-09-18 15:33:13 +00:00
}
else
{
setPropertyToDefault(PROPERTY_FORMATSSUPPLIER);
setPropertyToDefault(PROPERTY_FORMATKEY);
}
}
sal_uInt16 OFormattedModel::getPersistenceFlags() const
2000-09-18 15:33:13 +00:00
{
return (OEditBaseModel::getPersistenceFlags() & ~PF_HANDLE_COMMON_PROPS);
// a) we do our own call to writeCommonEditProperties
}
sal_Bool OFormattedModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
2000-09-18 15:33:13 +00:00
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
if ( aControlValue != m_aSaveValue )
2000-09-18 15:33:13 +00:00
{
// empty string + EmptyIsNull = void
if ( !aControlValue.hasValue()
|| ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING )
&& getString( aControlValue ).isEmpty()
2001-02-21 10:10:53 +00:00
&& m_bEmptyIsNull
)
)
2000-09-18 15:33:13 +00:00
m_xColumnUpdate->updateNull();
else
{
try
{
2011-01-03 13:58:05 +01:00
double f = 0.0;
if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323
2000-09-18 15:33:13 +00:00
{
DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType );
2000-09-18 15:33:13 +00:00
}
else
{
DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalud value type !" );
m_xColumnUpdate->updateString( getString( aControlValue ) );
2000-09-18 15:33:13 +00:00
}
}
2011-12-11 18:51:50 +09:00
catch(const Exception&)
2000-09-18 15:33:13 +00:00
{
return sal_False;
}
}
m_aSaveValue = aControlValue;
2000-09-18 15:33:13 +00:00
}
return sal_True;
}
void OFormattedModel::onConnectedExternalValue( )
{
OEditBaseModel::onConnectedExternalValue();
updateFormatterNullDate();
}
Any OFormattedModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const
{
Any aControlValue;
switch( _rExternalValue.getValueTypeClass() )
{
case TypeClass_VOID:
break;
case TypeClass_STRING:
aControlValue = _rExternalValue;
break;
case TypeClass_BOOLEAN:
{
sal_Bool bExternalValue = sal_False;
_rExternalValue >>= bExternalValue;
aControlValue <<= (double)( bExternalValue ? 1 : 0 );
}
break;
default:
{
if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNODate* >( NULL ) ) ) )
{
UNODate aDate;
_rExternalValue >>= aDate;
aControlValue <<= DBTypeConversion::toDouble( aDate, m_aNullDate );
}
else if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNOTime* >( NULL ) ) ) )
{
UNOTime aTime;
_rExternalValue >>= aTime;
aControlValue <<= DBTypeConversion::toDouble( aTime );
}
else if ( _rExternalValue.getValueType().equals( ::getCppuType( static_cast< UNODateTime* >( NULL ) ) ) )
{
UNODateTime aDateTime;
_rExternalValue >>= aDateTime;
aControlValue <<= DBTypeConversion::toDouble( aDateTime, m_aNullDate );
}
else
{
OSL_ENSURE( _rExternalValue.getValueTypeClass() == TypeClass_DOUBLE,
"OFormattedModel::translateExternalValueToControlValue: don't know how to translate this type!" );
double fValue = 0;
OSL_VERIFY( _rExternalValue >>= fValue );
aControlValue <<= fValue;
}
}
}
return aControlValue;
}
Any OFormattedModel::translateControlValueToExternalValue( ) const
{
OSL_PRECOND( hasExternalValueBinding(),
"OFormattedModel::translateControlValueToExternalValue: precondition not met!" );
Any aControlValue( getControlValue() );
if ( !aControlValue.hasValue() )
return aControlValue;
Any aExternalValue;
// translate into the external value type
Type aExternalValueType( getExternalValueType() );
switch ( aExternalValueType.getTypeClass() )
{
case TypeClass_STRING:
{
OUString sString;
if ( aControlValue >>= sString )
{
aExternalValue <<= sString;
break;
}
}
// NO break here!
case TypeClass_BOOLEAN:
{
double fValue = 0;
OSL_VERIFY( aControlValue >>= fValue );
// if this asserts ... well, the somebody set the TreatAsNumeric property to false,
// and the control value is a string. This implies some weird misconfiguration
// of the FormattedModel, so we won't care for it for the moment.
aExternalValue <<= (sal_Bool)( fValue ? sal_True : sal_False );
}
break;
default:
{
double fValue = 0;
OSL_VERIFY( aControlValue >>= fValue );
// if this asserts ... well, the somebody set the TreatAsNumeric property to false,
// and the control value is a string. This implies some weird misconfiguration
// of the FormattedModel, so we won't care for it for the moment.
if ( aExternalValueType.equals( ::getCppuType( static_cast< UNODate* >( NULL ) ) ) )
{
aExternalValue <<= DBTypeConversion::toDate( fValue, m_aNullDate );
}
else if ( aExternalValueType.equals( ::getCppuType( static_cast< UNOTime* >( NULL ) ) ) )
{
aExternalValue <<= DBTypeConversion::toTime( fValue );
}
else if ( aExternalValueType.equals( ::getCppuType( static_cast< UNODateTime* >( NULL ) ) ) )
{
aExternalValue <<= DBTypeConversion::toDateTime( fValue, m_aNullDate );
}
else
{
OSL_ENSURE( aExternalValueType.equals( ::getCppuType( static_cast< double* >( NULL ) ) ),
"OFormattedModel::translateControlValueToExternalValue: don't know how to translate this type!" );
aExternalValue <<= fValue;
}
}
break;
}
return aExternalValue;
}
Any OFormattedModel::translateDbColumnToControlValue()
2000-09-18 15:33:13 +00:00
{
if ( m_bNumeric )
m_aSaveValue <<= DBTypeConversion::getValue( m_xColumn, m_aNullDate ); // #100056# OJ
2000-09-18 15:33:13 +00:00
else
m_aSaveValue <<= m_xColumn->getString();
if ( m_xColumn->wasNull() )
2000-09-18 15:33:13 +00:00
m_aSaveValue.clear();
return m_aSaveValue;
2000-09-18 15:33:13 +00:00
}
Sequence< Type > OFormattedModel::getSupportedBindingTypes()
2000-09-18 15:33:13 +00:00
{
::std::list< Type > aTypes;
aTypes.push_back( ::getCppuType( static_cast< double* >( NULL ) ) );
switch ( m_nKeyType & ~NumberFormat::DEFINED )
{
case NumberFormat::DATE:
aTypes.push_front(::getCppuType( static_cast< UNODate* >( NULL ) ) );
break;
case NumberFormat::TIME:
aTypes.push_front(::getCppuType( static_cast< UNOTime* >( NULL ) ) );
break;
case NumberFormat::DATETIME:
aTypes.push_front(::getCppuType( static_cast< UNODateTime* >( NULL ) ) );
break;
case NumberFormat::TEXT:
aTypes.push_front(::getCppuType( static_cast< OUString* >( NULL ) ) );
break;
case NumberFormat::LOGICAL:
aTypes.push_front(::getCppuType( static_cast< sal_Bool* >( NULL ) ) );
break;
}
Sequence< Type > aTypesRet( aTypes.size() );
::std::copy( aTypes.begin(), aTypes.end(), aTypesRet.getArray() );
return aTypesRet;
}
Any OFormattedModel::getDefaultForReset() const
{
return m_xAggregateSet->getPropertyValue( PROPERTY_EFFECTIVE_DEFAULT );
2000-09-18 15:33:13 +00:00
}
CWS-TOOLING: integrate CWS dba32j 2009-11-26 09:30:10 +0100 msc r277648 : #100000 fix urgent testscript error 2009-11-25 10:27:56 +0100 msc r277625 : #i100000 fix urgent testscript error 2009-11-17 22:16:46 +0100 fs r277544 : CWS-TOOLING: rebase CWS dba32j to branches/OOO320@277531 (milestone: OOO320:m5) 2009-11-17 14:26:47 +0100 fs r277535 : ooops, didn't mean to commit this uncommented line 2009-11-14 20:50:29 +0100 fs r277505 : add a --disable-pango switch to SM's configure options, and add a patch which makes certain code respect it (well, respect it better than currently, by not using some pango_x_* functions, which are not always available, even when pango itself is present) 2009-11-14 20:47:41 +0100 fs r277504 : spelling 2009-11-13 14:04:00 +0100 fs r277502 : #i100764# (commit approved by ab@openoffice.org): getModelFromBasic: do not start with the parent's parent when looking for ThisComponent, but walk up the anchestor chain, starting with the immediate parent 2009-11-13 11:04:15 +0100 fs r277496 : #i100764# better heuristics for determining whether or not to participate in the ThisComponent game 2009-11-13 11:02:30 +0100 fs r277495 : #i100764# set the WB_EXT_DOCUMENT style at the backing component's container window, when creating it without the TaskCreator (which would normally do this) 2009-11-11 13:49:11 +0100 fs r277452 : #i106816# 2009-11-11 13:48:53 +0100 fs r277451 : fix the CREATETARBAL target, which is expected to create the zips used as prebuilts. The *inc.zip missed the NSS files in case NSS was built externally 2009-11-11 12:15:34 +0100 fs r277449 : update ignore list 2009-11-11 12:09:23 +0100 fs r277448 : add a link to the Mozilla build tools download location 2009-11-11 12:07:16 +0100 fs r277447 : add a link to the Mozilla build tools download location 2009-11-06 16:23:12 +0100 fs r277393 : #i106643# 2009-11-03 23:20:29 +0100 fs r277328 : #i106574# reverted the recent fix for issue #i105235#, and implemented a better one. 2009-11-02 12:59:48 +0100 fs r277294 : #i106550# errorOccured: also display the error when we're not in a nested form action - form actions are allowed to be triggered by other instances as well
2009-12-01 09:53:35 +00:00
void OFormattedModel::resetNoBroadcast()
{
OEditBaseModel::resetNoBroadcast();
m_aSaveValue.clear();
}
2000-09-18 15:33:13 +00:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */