Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / forms / source / component / Edit.cxx
blob580e4f3a9f0e45be01217bd1e45471913904ddc5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "Edit.hxx"
22 #include <property.hxx>
23 #include <services.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/form/FormComponentType.hpp>
27 #include <com/sun/star/uno/Type.hxx>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <com/sun/star/container/XIndexAccess.hpp>
30 #include <com/sun/star/form/XSubmit.hpp>
31 #include <com/sun/star/util/NumberFormat.hpp>
33 #include <vcl/svapp.hxx>
34 #include <vcl/keycodes.hxx>
36 #include <connectivity/formattedcolumnvalue.hxx>
38 #include <comphelper/property.hxx>
39 #include <comphelper/types.hxx>
40 #include <tools/debug.hxx>
41 #include <comphelper/diagnose_ex.hxx>
42 #include <sal/log.hxx>
44 using namespace dbtools;
46 namespace frm
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::sdb;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::beans;
52 using namespace ::com::sun::star::container;
53 using namespace ::com::sun::star::form;
54 using namespace ::com::sun::star::awt;
55 using namespace ::com::sun::star::io;
56 using namespace ::com::sun::star::lang;
57 using namespace ::com::sun::star::util;
58 using namespace ::com::sun::star::form::binding;
61 Sequence<Type> OEditControl::_getTypes()
63 // my two base classes
64 static Sequence<Type> const aTypes = concatSequences(OBoundControl::_getTypes(), OEditControl_BASE::getTypes());
65 return aTypes;
69 Any SAL_CALL OEditControl::queryAggregation(const Type& _rType)
71 Any aReturn = OBoundControl::queryAggregation(_rType);
72 if (!aReturn.hasValue())
73 aReturn = OEditControl_BASE::queryInterface(_rType);
75 return aReturn;
79 OEditControl::OEditControl(const Reference<XComponentContext>& _rxFactory)
80 :OBoundControl( _rxFactory, FRM_SUN_CONTROL_RICHTEXTCONTROL )
81 ,m_aChangeListeners(m_aMutex)
82 ,m_nKeyEvent( nullptr )
85 osl_atomic_increment(&m_refCount);
87 Reference<XWindow> xComp;
88 if (query_aggregation(m_xAggregate, xComp))
90 xComp->addFocusListener(this);
91 xComp->addKeyListener(this);
94 osl_atomic_decrement(&m_refCount);
98 OEditControl::~OEditControl()
100 if( m_nKeyEvent )
101 Application::RemoveUserEvent( m_nKeyEvent );
103 if (!OComponentHelper::rBHelper.bDisposed)
105 acquire();
106 dispose();
111 // XChangeBroadcaster
113 void OEditControl::addChangeListener(const Reference<XChangeListener>& l)
115 m_aChangeListeners.addInterface( l );
119 void OEditControl::removeChangeListener(const Reference<XChangeListener>& l)
121 m_aChangeListeners.removeInterface( l );
124 // OComponentHelper
126 void OEditControl::disposing()
128 OBoundControl::disposing();
130 EventObject aEvt(static_cast<XWeak*>(this));
131 m_aChangeListeners.disposeAndClear(aEvt);
134 // XServiceInfo
136 css::uno::Sequence<OUString> OEditControl::getSupportedServiceNames()
138 css::uno::Sequence<OUString> aSupported = OBoundControl::getSupportedServiceNames();
139 aSupported.realloc(aSupported.getLength() + 3);
141 OUString*pArray = aSupported.getArray();
142 pArray[aSupported.getLength()-3] = FRM_SUN_CONTROL_TEXTFIELD;
143 pArray[aSupported.getLength()-2] = STARDIV_ONE_FORM_CONTROL_EDIT;
144 pArray[aSupported.getLength()-1] = STARDIV_ONE_FORM_CONTROL_TEXTFIELD;
145 return aSupported;
148 // XEventListener
150 void OEditControl::disposing(const EventObject& Source)
152 OBoundControl::disposing(Source);
155 // XFocusListener
157 void OEditControl::focusGained( const FocusEvent& /*e*/ )
159 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
160 if (xSet.is())
161 xSet->getPropertyValue( PROPERTY_TEXT ) >>= m_aHtmlChangeValue;
165 void OEditControl::focusLost( const FocusEvent& /*e*/ )
167 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
168 if (xSet.is())
170 OUString sNewHtmlChangeValue;
171 xSet->getPropertyValue( PROPERTY_TEXT ) >>= sNewHtmlChangeValue;
172 if( sNewHtmlChangeValue != m_aHtmlChangeValue )
174 EventObject aEvt( *this );
175 m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvt );
180 // XKeyListener
182 void OEditControl::keyPressed(const css::awt::KeyEvent& e)
184 if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
185 return;
187 // Is the Control in a form with a submit URL?
188 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
189 if( !xSet.is() )
190 return;
192 // Not for multiline edits
193 Any aTmp( xSet->getPropertyValue(PROPERTY_MULTILINE));
194 if ((aTmp.getValueType().equals(cppu::UnoType<bool>::get())) && getBOOL(aTmp))
195 return;
197 Reference<XFormComponent> xFComp(xSet, UNO_QUERY);
198 css::uno::Reference<css::uno::XInterface> xParent = xFComp->getParent();
199 if( !xParent.is() )
200 return;
202 Reference<XPropertySet> xFormSet(xParent, UNO_QUERY);
203 if( !xFormSet.is() )
204 return;
206 aTmp = xFormSet->getPropertyValue( PROPERTY_TARGET_URL );
207 if (!aTmp.getValueType().equals(cppu::UnoType<OUString>::get()) ||
208 getString(aTmp).isEmpty() )
209 return;
211 Reference<XIndexAccess> xElements(xParent, UNO_QUERY);
212 sal_Int32 nCount = xElements->getCount();
213 if( nCount > 1 )
215 Reference<XPropertySet> xFCSet;
216 for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
218 // Any aElement(xElements->getByIndex(nIndex));
219 xElements->getByIndex(nIndex) >>= xFCSet;
220 OSL_ENSURE(xFCSet.is(),"OEditControl::keyPressed: No XPropertySet!");
222 if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
223 getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == FormComponentType::TEXTFIELD)
225 // Found another Edit -> then do not submit!
226 if (xFCSet != xSet)
227 return;
232 // Because we're still in the header, trigger submit asynchronously
233 if( m_nKeyEvent )
234 Application::RemoveUserEvent( m_nKeyEvent );
235 m_nKeyEvent = Application::PostUserEvent( LINK(this, OEditControl, OnKeyPressed) );
239 void OEditControl::keyReleased(const css::awt::KeyEvent& /*e*/)
244 IMPL_LINK_NOARG(OEditControl, OnKeyPressed, void*, void)
246 m_nKeyEvent = nullptr;
248 Reference<XFormComponent> xFComp(getModel(), UNO_QUERY);
249 css::uno::Reference<css::uno::XInterface> xParent = xFComp->getParent();
250 Reference<XSubmit> xSubmit(xParent, UNO_QUERY);
251 if (xSubmit.is())
252 xSubmit->submit( Reference<XControl>(), css::awt::MouseEvent() );
257 OEditModel::OEditModel(const Reference<XComponentContext>& _rxFactory)
258 :OEditBaseModel( _rxFactory, FRM_SUN_COMPONENT_RICHTEXTCONTROL, FRM_SUN_CONTROL_TEXTFIELD, true, true )
259 ,m_bMaxTextLenModified(false)
260 ,m_bWritingFormattedFake(false)
263 m_nClassId = FormComponentType::TEXTFIELD;
264 initValueProperty( PROPERTY_TEXT, PROPERTY_ID_TEXT );
268 OEditModel::OEditModel( const OEditModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
269 :OEditBaseModel( _pOriginal, _rxFactory )
270 ,m_bMaxTextLenModified(false)
271 ,m_bWritingFormattedFake(false)
274 // Note that most of the properties are not clone from the original object:
275 // Things as the format key, it's type, and such, depend on the field being part of a loaded form
276 // (they're initialized in onConnectedDbColumn). Even if the original object _is_ part of such a form, we ourself
277 // certainly aren't, so these members are defaulted. If we're inserted into a form which is already loaded,
278 // they will be set to new values, anyway...
282 OEditModel::~OEditModel()
284 if (!OComponentHelper::rBHelper.bDisposed)
286 acquire();
287 dispose();
293 css::uno::Reference< css::util::XCloneable > SAL_CALL OEditModel::createClone()
295 rtl::Reference<OEditModel> pClone = new OEditModel(this, getContext());
296 pClone->clonedFrom(this);
297 return pClone;
301 void OEditModel::disposing()
303 OEditBaseModel::disposing();
304 m_pValueFormatter.reset();
307 // XPersistObject
309 OUString SAL_CALL OEditModel::getServiceName()
311 return FRM_COMPONENT_EDIT; // old (non-sun) name for compatibility !
314 // XServiceInfo
316 css::uno::Sequence<OUString> SAL_CALL OEditModel::getSupportedServiceNames()
318 css::uno::Sequence<OUString> aSupported = OBoundControlModel::getSupportedServiceNames();
320 sal_Int32 nOldLen = aSupported.getLength();
321 aSupported.realloc( nOldLen + 9 );
322 OUString* pStoreTo = aSupported.getArray() + nOldLen;
324 *pStoreTo++ = BINDABLE_CONTROL_MODEL;
325 *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
326 *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
328 *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
329 *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
331 *pStoreTo++ = FRM_SUN_COMPONENT_TEXTFIELD;
332 *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_TEXTFIELD;
333 *pStoreTo++ = BINDABLE_DATABASE_TEXT_FIELD;
335 *pStoreTo++ = FRM_COMPONENT_TEXTFIELD;
337 return aSupported;
340 // XPropertySet
341 void SAL_CALL OEditModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
343 if ( PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH == nHandle )
345 if ( m_bMaxTextLenModified )
346 rValue <<= sal_Int16(0);
347 else if ( m_xAggregateSet.is() )
348 rValue = m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN);
350 else
352 OEditBaseModel::getFastPropertyValue(rValue, nHandle );
357 void OEditModel::describeFixedProperties( Sequence< Property >& _rProps ) const
359 OEditBaseModel::describeFixedProperties( _rProps );
360 sal_Int32 nOldCount = _rProps.getLength();
361 _rProps.realloc( nOldCount + 5);
362 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
363 *pProperties++ = css::beans::Property(PROPERTY_PERSISTENCE_MAXTEXTLENGTH, PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT);
364 *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT);
365 *pProperties++ = css::beans::Property(PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL, cppu::UnoType<bool>::get(),
366 css::beans::PropertyAttribute::BOUND);
367 *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND);
368 *pProperties++ = css::beans::Property(PROPERTY_FILTERPROPOSAL, PROPERTY_ID_FILTERPROPOSAL, cppu::UnoType<bool>::get(),
369 css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT);
370 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
374 void OEditModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
376 OEditBaseModel::describeAggregateProperties( _rAggregateProps );
378 // our aggregate is a rich text model, which also derives from OControlModel, as
379 // do we, so we need to remove some duplicate properties
380 RemoveProperty( _rAggregateProps, PROPERTY_TABINDEX );
381 RemoveProperty( _rAggregateProps, PROPERTY_CLASSID );
382 RemoveProperty( _rAggregateProps, PROPERTY_NAME );
383 RemoveProperty( _rAggregateProps, PROPERTY_TAG );
384 RemoveProperty( _rAggregateProps, PROPERTY_NATIVE_LOOK );
385 RemoveProperty( _rAggregateProps, PROPERTY_STANDARD_THEME );
390 bool OEditModel::implActsAsRichText( ) const
392 bool bActAsRichText = false;
393 if ( m_xAggregateSet.is() )
395 OSL_VERIFY( m_xAggregateSet->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActAsRichText );
397 return bActAsRichText;
401 void SAL_CALL OEditModel::reset( )
403 // no reset if we currently act as rich text control
404 if ( implActsAsRichText() )
405 return;
407 OEditBaseModel::reset();
411 namespace
413 void lcl_transferProperties( const Reference< XPropertySet >& _rxSource, const Reference< XPropertySet >& _rxDest )
417 Reference< XPropertySetInfo > xSourceInfo;
418 if ( _rxSource.is() )
419 xSourceInfo = _rxSource->getPropertySetInfo();
421 Reference< XPropertySetInfo > xDestInfo;
422 if ( _rxDest.is() )
423 xDestInfo = _rxDest->getPropertySetInfo();
425 if ( !xSourceInfo.is() || !xDestInfo.is() )
427 OSL_FAIL( "lcl_transferProperties: invalid property set(s)!" );
428 return;
431 const Sequence< Property > aSourceProps( xSourceInfo->getProperties() );
432 for ( auto const & sourceprop : aSourceProps )
434 if ( !xDestInfo->hasPropertyByName( sourceprop.Name ) )
436 continue;
439 Property aDestProp( xDestInfo->getPropertyByName( sourceprop.Name ) );
440 if ( 0 != ( aDestProp.Attributes & PropertyAttribute::READONLY ) )
442 continue;
447 _rxDest->setPropertyValue( sourceprop.Name, _rxSource->getPropertyValue( sourceprop.Name ) );
449 catch(const IllegalArgumentException&)
451 TOOLS_WARN_EXCEPTION( "forms.component", "could not transfer the property named '"
452 << sourceprop.Name
453 << "'" );
457 catch( const Exception& )
459 DBG_UNHANDLED_EXCEPTION("forms.component");
465 void OEditModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutStream ) const
467 // we need to fake the writing of our aggregate. Since #i24387#, we have another aggregate,
468 // but for compatibility, we need to use an "old" aggregate for writing and reading
470 Reference< XPropertySet > xFakedAggregate(
471 getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
472 UNO_QUERY
474 OSL_ENSURE( xFakedAggregate.is(), "OEditModel::writeAggregate: could not create an old EditControlModel!" );
475 if ( !xFakedAggregate.is() )
476 return;
478 lcl_transferProperties( m_xAggregateSet, xFakedAggregate );
480 Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY );
481 OSL_ENSURE( xFakedPersist.is(), "OEditModel::writeAggregate: no XPersistObject!" );
482 if ( xFakedPersist.is() )
483 xFakedPersist->write( _rxOutStream );
487 void OEditModel::readAggregate( const Reference< XObjectInputStream >& _rxInStream )
489 // we need to fake the reading of our aggregate. Since #i24387#, we have another aggregate,
490 // but for compatibility, we need to use an "old" aggregate for writing and reading
492 Reference< XPropertySet > xFakedAggregate(
493 getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
494 UNO_QUERY
496 Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY );
497 OSL_ENSURE( xFakedPersist.is(), "OEditModel::readAggregate: no XPersistObject, or no faked aggregate at all!" );
498 if ( xFakedPersist.is() )
500 xFakedPersist->read( _rxInStream );
501 lcl_transferProperties( xFakedAggregate, m_xAggregateSet );
506 void OEditModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
508 Any aCurrentText;
509 sal_Int16 nOldTextLen = 0;
510 // Am I loaded at the moment and did I switch MaxTextLen temporarily?
511 if ( m_bMaxTextLenModified )
512 { // -> for the duration of saving, make my aggregated model believe the old TextLen
514 // before doing this we have to save the current text value of the aggregate, as this may be affected by resetting the text len
515 aCurrentText = m_xAggregateSet->getPropertyValue(PROPERTY_TEXT);
517 m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN) >>= nOldTextLen;
518 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(sal_Int16(0)));
521 OEditBaseModel::write(_rxOutStream);
523 if ( m_bMaxTextLenModified )
524 { // Reset again
525 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(nOldTextLen));
526 // and reset the text
527 // First we set it to an empty string : Without this the second setPropertyValue would not do anything as it thinks
528 // we aren't changing the prop (it didn't notify the - implicit - change of the text prop while setting the max text len)
529 // This seems to be a bug with in toolkit's EditControl-implementation.
530 m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, Any(OUString()));
531 m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, aCurrentText);
536 void OEditModel::read(const Reference<XObjectInputStream>& _rxInStream)
538 OEditBaseModel::read(_rxInStream);
540 // Some versions (5.1 'til about 552) wrote a wrong DefaultControl-property value which is unknown
541 // to older versions (5.0).
542 // correct this ...
543 if (m_xAggregateSet.is())
545 Any aDefaultControl = m_xAggregateSet->getPropertyValue(PROPERTY_DEFAULTCONTROL);
546 if ( (aDefaultControl.getValueType().getTypeClass() == TypeClass_STRING)
547 && (getString(aDefaultControl) == STARDIV_ONE_FORM_CONTROL_TEXTFIELD )
550 m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, Any( OUString(STARDIV_ONE_FORM_CONTROL_EDIT) ) );
551 // Older as well as current versions should understand this : the former knew only the STARDIV_ONE_FORM_CONTROL_EDIT,
552 // the latter are registered for both STARDIV_ONE_FORM_CONTROL_EDIT and STARDIV_ONE_FORM_CONTROL_TEXTFIELD.
558 sal_uInt16 OEditModel::getPersistenceFlags() const
560 sal_uInt16 nFlags = OEditBaseModel::getPersistenceFlags();
562 if (m_bWritingFormattedFake)
563 nFlags |= PF_FAKE_FORMATTED_FIELD;
565 return nFlags;
569 void OEditModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
571 Reference< XPropertySet > xField = getField();
572 if ( !xField.is() )
573 return;
575 m_pValueFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) );
577 if ( m_pValueFormatter->getKeyType() == NumberFormat::SCIENTIFIC )
578 return;
580 m_bMaxTextLenModified = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)) != 0;
581 if ( !m_bMaxTextLenModified )
583 sal_Int32 nFieldLen = 0;
584 xField->getPropertyValue("Precision") >>= nFieldLen;
586 if (nFieldLen > 0 && nFieldLen <= SAL_MAX_INT16)
588 Any aVal;
589 aVal <<= static_cast<sal_Int16>(nFieldLen);
590 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
592 m_bMaxTextLenModified = true;
595 else
596 m_bMaxTextLenModified = false; // to get sure that the text len won't be set in unloaded
600 void OEditModel::onDisconnectedDbColumn()
602 OEditBaseModel::onDisconnectedDbColumn();
604 m_pValueFormatter.reset();
606 if ( hasField() && m_bMaxTextLenModified )
608 Any aVal;
609 aVal <<= sal_Int16(0); // Only if it was 0, I switched it in onConnectedDbColumn
610 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
611 m_bMaxTextLenModified = false;
616 bool OEditModel::approveDbColumnType( sal_Int32 _nColumnType )
618 // if we act as rich text currently, we do not allow binding to a database column
619 if ( implActsAsRichText() )
620 return false;
622 return OEditBaseModel::approveDbColumnType( _nColumnType );
626 bool OEditModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
628 Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
630 OUString sNewValue;
631 aNewValue >>= sNewValue;
633 if ( !aNewValue.hasValue()
634 || ( sNewValue.isEmpty() // an empty string
635 && m_bEmptyIsNull // which should be interpreted as NULL
639 m_xColumnUpdate->updateNull();
641 else
643 OSL_PRECOND(m_pValueFormatter,
644 "OEditModel::commitControlValueToDbColumn: no value formatter!");
647 if (m_pValueFormatter)
649 if ( !m_pValueFormatter->setFormattedValue( sNewValue ) )
650 return false;
652 else
653 m_xColumnUpdate->updateString( sNewValue );
655 catch ( const Exception& )
657 return false;
661 return true;
665 Any OEditModel::translateDbColumnToControlValue()
667 OSL_PRECOND(m_pValueFormatter,
668 "OEditModel::translateDbColumnToControlValue: no value formatter!");
669 Any aRet;
670 if (m_pValueFormatter)
672 OUString sValue( m_pValueFormatter->getFormattedValue() );
673 if ( sValue.isEmpty()
674 && m_pValueFormatter->getColumn().is()
675 && m_pValueFormatter->getColumn()->wasNull()
679 else
681 // #i2817# OJ
682 sal_uInt16 nMaxTextLen = getINT16( m_xAggregateSet->getPropertyValue( PROPERTY_MAXTEXTLEN ) );
683 if ( nMaxTextLen && sValue.getLength() > nMaxTextLen )
685 sal_Int32 nDiff = sValue.getLength() - nMaxTextLen;
686 sValue = sValue.replaceAt( nMaxTextLen, nDiff, u"" );
689 aRet <<= sValue;
693 return aRet.hasValue() ? aRet : Any( OUString() );
697 Any OEditModel::getDefaultForReset() const
699 return Any( m_aDefaultText );
704 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
705 com_sun_star_form_OEditModel_get_implementation(css::uno::XComponentContext* component,
706 css::uno::Sequence<css::uno::Any> const &)
708 return cppu::acquire(new frm::OEditModel(component));
711 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
712 com_sun_star_form_OEditControl_get_implementation(css::uno::XComponentContext* component,
713 css::uno::Sequence<css::uno::Any> const &)
715 return cppu::acquire(new frm::OEditControl(component));
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */