LibreOffice Module forms (master) 1
Edit.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include "Edit.hxx"
22#include <property.hxx>
23#include <services.hxx>
24
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>
32
33#include <vcl/svapp.hxx>
34#include <vcl/keycodes.hxx>
35
37
39#include <comphelper/types.hxx>
40#include <tools/debug.hxx>
42#include <sal/log.hxx>
43
44using namespace dbtools;
45
46namespace frm
47{
48using namespace ::com::sun::star::uno;
49using namespace ::com::sun::star::sdb;
50using namespace ::com::sun::star::sdbc;
51using namespace ::com::sun::star::beans;
52using namespace ::com::sun::star::container;
53using namespace ::com::sun::star::form;
54using namespace ::com::sun::star::awt;
55using namespace ::com::sun::star::io;
56using namespace ::com::sun::star::lang;
57using namespace ::com::sun::star::util;
58using namespace ::com::sun::star::form::binding;
59
60
62{
63 // my two base classes
65 return aTypes;
66}
67
68
70{
71 Any aReturn = OBoundControl::queryAggregation(_rType);
72 if (!aReturn.hasValue())
73 aReturn = OEditControl_BASE::queryInterface(_rType);
74
75 return aReturn;
76}
77
78
79OEditControl::OEditControl(const Reference<XComponentContext>& _rxFactory)
81 ,m_aChangeListeners(m_aMutex)
82 ,m_nKeyEvent( nullptr )
83{
84
85 osl_atomic_increment(&m_refCount);
86 {
87 Reference<XWindow> xComp;
89 {
90 xComp->addFocusListener(this);
91 xComp->addKeyListener(this);
92 }
93 }
94 osl_atomic_decrement(&m_refCount);
95}
96
97
99{
100 if( m_nKeyEvent )
102
103 if (!OComponentHelper::rBHelper.bDisposed)
104 {
105 acquire();
106 dispose();
107 }
108
109}
110
111// XChangeBroadcaster
112
113void OEditControl::addChangeListener(const Reference<XChangeListener>& l)
114{
116}
117
118
119void OEditControl::removeChangeListener(const Reference<XChangeListener>& l)
120{
122}
123
124// OComponentHelper
125
127{
129
130 EventObject aEvt(static_cast<XWeak*>(this));
132}
133
134// XServiceInfo
135
136css::uno::Sequence<OUString> OEditControl::getSupportedServiceNames()
137{
138 css::uno::Sequence<OUString> aSupported = OBoundControl::getSupportedServiceNames();
139 aSupported.realloc(aSupported.getLength() + 3);
140
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;
146}
147
148// XEventListener
149
150void OEditControl::disposing(const EventObject& Source)
151{
153}
154
155// XFocusListener
156
157void OEditControl::focusGained( const FocusEvent& /*e*/ )
158{
159 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
160 if (xSet.is())
161 xSet->getPropertyValue( PROPERTY_TEXT ) >>= m_aHtmlChangeValue;
162}
163
164
165void OEditControl::focusLost( const FocusEvent& /*e*/ )
166{
167 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
168 if (xSet.is())
169 {
170 OUString sNewHtmlChangeValue;
171 xSet->getPropertyValue( PROPERTY_TEXT ) >>= sNewHtmlChangeValue;
172 if( sNewHtmlChangeValue != m_aHtmlChangeValue )
173 {
174 EventObject aEvt( *this );
175 m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvt );
176 }
177 }
178}
179
180// XKeyListener
181
182void OEditControl::keyPressed(const css::awt::KeyEvent& e)
183{
184 if( e.KeyCode != KEY_RETURN || e.Modifiers != 0 )
185 return;
186
187 // Is the Control in a form with a submit URL?
188 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
189 if( !xSet.is() )
190 return;
191
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;
196
197 Reference<XFormComponent> xFComp(xSet, UNO_QUERY);
198 css::uno::Reference<css::uno::XInterface> xParent = xFComp->getParent();
199 if( !xParent.is() )
200 return;
201
202 Reference<XPropertySet> xFormSet(xParent, UNO_QUERY);
203 if( !xFormSet.is() )
204 return;
205
206 aTmp = xFormSet->getPropertyValue( PROPERTY_TARGET_URL );
207 if (!aTmp.getValueType().equals(cppu::UnoType<OUString>::get()) ||
208 getString(aTmp).isEmpty() )
209 return;
210
211 Reference<XIndexAccess> xElements(xParent, UNO_QUERY);
212 sal_Int32 nCount = xElements->getCount();
213 if( nCount > 1 )
214 {
215 Reference<XPropertySet> xFCSet;
216 for( sal_Int32 nIndex=0; nIndex < nCount; nIndex++ )
217 {
218 // Any aElement(xElements->getByIndex(nIndex));
219 xElements->getByIndex(nIndex) >>= xFCSet;
220 OSL_ENSURE(xFCSet.is(),"OEditControl::keyPressed: No XPropertySet!");
221
222 if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
223 getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == FormComponentType::TEXTFIELD)
224 {
225 // Found another Edit -> then do not submit!
226 if (xFCSet != xSet)
227 return;
228 }
229 }
230 }
231
232 // Because we're still in the header, trigger submit asynchronously
233 if( m_nKeyEvent )
236}
237
238
239void OEditControl::keyReleased(const css::awt::KeyEvent& /*e*/)
240{
241}
242
243
244IMPL_LINK_NOARG(OEditControl, OnKeyPressed, void*, void)
245{
246 m_nKeyEvent = nullptr;
247
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() );
253}
254
255
256
257OEditModel::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)
261{
262
263 m_nClassId = FormComponentType::TEXTFIELD;
264 initValueProperty( PROPERTY_TEXT, PROPERTY_ID_TEXT );
265}
266
267
268OEditModel::OEditModel( const OEditModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
269 :OEditBaseModel( _pOriginal, _rxFactory )
270 ,m_bMaxTextLenModified(false)
271 ,m_bWritingFormattedFake(false)
272{
273
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...
279}
280
281
282OEditModel::~OEditModel()
283{
284 if (!OComponentHelper::rBHelper.bDisposed)
285 {
286 acquire();
287 dispose();
288 }
289
290}
291
292
293css::uno::Reference< css::util::XCloneable > SAL_CALL OEditModel::createClone()
294{
295 rtl::Reference<OEditModel> pClone = new OEditModel(this, getContext());
296 pClone->clonedFrom(this);
297 return pClone;
298}
299
300
301void OEditModel::disposing()
302{
303 OEditBaseModel::disposing();
304 m_pValueFormatter.reset();
305}
306
307// XPersistObject
308
309OUString SAL_CALL OEditModel::getServiceName()
310{
311 return FRM_COMPONENT_EDIT; // old (non-sun) name for compatibility !
312}
313
314// XServiceInfo
315
316css::uno::Sequence<OUString> SAL_CALL OEditModel::getSupportedServiceNames()
317{
318 css::uno::Sequence<OUString> aSupported = OBoundControlModel::getSupportedServiceNames();
319
320 sal_Int32 nOldLen = aSupported.getLength();
321 aSupported.realloc( nOldLen + 9 );
322 OUString* pStoreTo = aSupported.getArray() + nOldLen;
323
324 *pStoreTo++ = BINDABLE_CONTROL_MODEL;
325 *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
326 *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
327
330
331 *pStoreTo++ = FRM_SUN_COMPONENT_TEXTFIELD;
333 *pStoreTo++ = BINDABLE_DATABASE_TEXT_FIELD;
334
335 *pStoreTo++ = FRM_COMPONENT_TEXTFIELD;
336
337 return aSupported;
338}
339
340// XPropertySet
341void SAL_CALL OEditModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
342{
344 {
345 if ( m_bMaxTextLenModified )
346 rValue <<= sal_Int16(0);
347 else if ( m_xAggregateSet.is() )
348 rValue = m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN);
349 }
350 else
351 {
352 OEditBaseModel::getFastPropertyValue(rValue, nHandle );
353 }
354}
355
356
357void OEditModel::describeFixedProperties( Sequence< Property >& _rProps ) const
358{
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 ?");
371}
372
373
374void OEditModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
375{
376 OEditBaseModel::describeAggregateProperties( _rAggregateProps );
377
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 );
386
387}
388
389
390bool OEditModel::implActsAsRichText( ) const
391{
392 bool bActAsRichText = false;
393 if ( m_xAggregateSet.is() )
394 {
395 OSL_VERIFY( m_xAggregateSet->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActAsRichText );
396 }
397 return bActAsRichText;
398}
399
400
401void SAL_CALL OEditModel::reset( )
402{
403 // no reset if we currently act as rich text control
404 if ( implActsAsRichText() )
405 return;
406
407 OEditBaseModel::reset();
408}
409
410
411namespace
412{
413 void lcl_transferProperties( const Reference< XPropertySet >& _rxSource, const Reference< XPropertySet >& _rxDest )
414 {
415 try
416 {
417 Reference< XPropertySetInfo > xSourceInfo;
418 if ( _rxSource.is() )
419 xSourceInfo = _rxSource->getPropertySetInfo();
420
421 Reference< XPropertySetInfo > xDestInfo;
422 if ( _rxDest.is() )
423 xDestInfo = _rxDest->getPropertySetInfo();
424
425 if ( !xSourceInfo.is() || !xDestInfo.is() )
426 {
427 OSL_FAIL( "lcl_transferProperties: invalid property set(s)!" );
428 return;
429 }
430
431 const Sequence< Property > aSourceProps( xSourceInfo->getProperties() );
432 for ( auto const & sourceprop : aSourceProps )
433 {
434 if ( !xDestInfo->hasPropertyByName( sourceprop.Name ) )
435 {
436 continue;
437 }
438
439 Property aDestProp( xDestInfo->getPropertyByName( sourceprop.Name ) );
440 if ( 0 != ( aDestProp.Attributes & PropertyAttribute::READONLY ) )
441 {
442 continue;
443 }
444
445 try
446 {
447 _rxDest->setPropertyValue( sourceprop.Name, _rxSource->getPropertyValue( sourceprop.Name ) );
448 }
449 catch(const IllegalArgumentException&)
450 {
451 TOOLS_WARN_EXCEPTION( "forms.component", "could not transfer the property named '"
452 << sourceprop.Name
453 << "'" );
454 }
455 }
456 }
457 catch( const Exception& )
458 {
459 DBG_UNHANDLED_EXCEPTION("forms.component");
460 }
461 }
462}
463
464
465void OEditModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutStream ) const
466{
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
469
470 Reference< XPropertySet > xFakedAggregate(
471 getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
472 UNO_QUERY
473 );
474 OSL_ENSURE( xFakedAggregate.is(), "OEditModel::writeAggregate: could not create an old EditControlModel!" );
475 if ( !xFakedAggregate.is() )
476 return;
477
478 lcl_transferProperties( m_xAggregateSet, xFakedAggregate );
479
480 Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY );
481 OSL_ENSURE( xFakedPersist.is(), "OEditModel::writeAggregate: no XPersistObject!" );
482 if ( xFakedPersist.is() )
483 xFakedPersist->write( _rxOutStream );
484}
485
486
487void OEditModel::readAggregate( const Reference< XObjectInputStream >& _rxInStream )
488{
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
491
492 Reference< XPropertySet > xFakedAggregate(
493 getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
494 UNO_QUERY
495 );
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() )
499 {
500 xFakedPersist->read( _rxInStream );
501 lcl_transferProperties( xFakedAggregate, m_xAggregateSet );
502 }
503}
504
505
506void OEditModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
507{
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
513
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);
516
517 m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN) >>= nOldTextLen;
518 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(sal_Int16(0)));
519 }
520
521 OEditBaseModel::write(_rxOutStream);
522
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);
532 }
533}
534
535
536void OEditModel::read(const Reference<XObjectInputStream>& _rxInStream)
537{
538 OEditBaseModel::read(_rxInStream);
539
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())
544 {
545 Any aDefaultControl = m_xAggregateSet->getPropertyValue(PROPERTY_DEFAULTCONTROL);
546 if ( (aDefaultControl.getValueType().getTypeClass() == TypeClass_STRING)
547 && (getString(aDefaultControl) == STARDIV_ONE_FORM_CONTROL_TEXTFIELD )
548 )
549 {
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.
553 }
554 }
555}
556
557
558sal_uInt16 OEditModel::getPersistenceFlags() const
559{
560 sal_uInt16 nFlags = OEditBaseModel::getPersistenceFlags();
561
562 if (m_bWritingFormattedFake)
563 nFlags |= PF_FAKE_FORMATTED_FIELD;
564
565 return nFlags;
566}
567
568
569void OEditModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
570{
571 Reference< XPropertySet > xField = getField();
572 if ( !xField.is() )
573 return;
574
575 m_pValueFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) );
576
577 if ( m_pValueFormatter->getKeyType() == NumberFormat::SCIENTIFIC )
578 return;
579
580 m_bMaxTextLenModified = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)) != 0;
581 if ( !m_bMaxTextLenModified )
582 {
583 sal_Int32 nFieldLen = 0;
584 xField->getPropertyValue("Precision") >>= nFieldLen;
585
586 if (nFieldLen > 0 && nFieldLen <= SAL_MAX_INT16)
587 {
588 Any aVal;
589 aVal <<= static_cast<sal_Int16>(nFieldLen);
590 m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
591
592 m_bMaxTextLenModified = true;
593 }
594 }
595 else
596 m_bMaxTextLenModified = false; // to get sure that the text len won't be set in unloaded
597}
598
599
600void OEditModel::onDisconnectedDbColumn()
601{
602 OEditBaseModel::onDisconnectedDbColumn();
603
604 m_pValueFormatter.reset();
605
606 if ( hasField() && m_bMaxTextLenModified )
607 {
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;
612 }
613}
614
615
616bool OEditModel::approveDbColumnType( sal_Int32 _nColumnType )
617{
618 // if we act as rich text currently, we do not allow binding to a database column
619 if ( implActsAsRichText() )
620 return false;
621
622 return OEditBaseModel::approveDbColumnType( _nColumnType );
623}
624
625
626bool OEditModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
627{
628 Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
629
630 OUString sNewValue;
631 aNewValue >>= sNewValue;
632
633 if ( !aNewValue.hasValue()
634 || ( sNewValue.isEmpty() // an empty string
635 && m_bEmptyIsNull // which should be interpreted as NULL
636 )
637 )
638 {
639 m_xColumnUpdate->updateNull();
640 }
641 else
642 {
643 OSL_PRECOND(m_pValueFormatter,
644 "OEditModel::commitControlValueToDbColumn: no value formatter!");
645 try
646 {
647 if (m_pValueFormatter)
648 {
649 if ( !m_pValueFormatter->setFormattedValue( sNewValue ) )
650 return false;
651 }
652 else
653 m_xColumnUpdate->updateString( sNewValue );
654 }
655 catch ( const Exception& )
656 {
657 return false;
658 }
659 }
660
661 return true;
662}
663
664
665Any OEditModel::translateDbColumnToControlValue()
666{
667 OSL_PRECOND(m_pValueFormatter,
668 "OEditModel::translateDbColumnToControlValue: no value formatter!");
669 Any aRet;
670 if (m_pValueFormatter)
671 {
672 OUString sValue( m_pValueFormatter->getFormattedValue() );
673 if ( sValue.isEmpty()
674 && m_pValueFormatter->getColumn().is()
675 && m_pValueFormatter->getColumn()->wasNull()
676 )
677 {
678 }
679 else
680 {
681 // #i2817# OJ
682 sal_uInt16 nMaxTextLen = getINT16( m_xAggregateSet->getPropertyValue( PROPERTY_MAXTEXTLEN ) );
683 if ( nMaxTextLen && sValue.getLength() > nMaxTextLen )
684 {
685 sal_Int32 nDiff = sValue.getLength() - nMaxTextLen;
686 sValue = sValue.replaceAt( nMaxTextLen, nDiff, u"" );
687 }
688
689 aRet <<= sValue;
690 }
691 }
692
693 return aRet.hasValue() ? aRet : Any( OUString() );
694}
695
696
697Any OEditModel::getDefaultForReset() const
698{
699 return Any( m_aDefaultText );
700}
701
702}
703
704extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
705com_sun_star_form_OEditModel_get_implementation(css::uno::XComponentContext* component,
706 css::uno::Sequence<css::uno::Any> const &)
707{
708 return cppu::acquire(new frm::OEditModel(component));
709}
710
711extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
712com_sun_star_form_OEditControl_get_implementation(css::uno::XComponentContext* component,
713 css::uno::Sequence<css::uno::Any> const &)
714{
715 return cppu::acquire(new frm::OEditControl(component));
716}
717
718/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define PF_FAKE_FORMATTED_FIELD
Definition: EditBase.hxx:29
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OEditModel_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
Definition: Edit.cxx:705
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OEditControl_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
Definition: Edit.cxx:712
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
oslInterlockedCount m_refCount
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
css::uno::Reference< css::uno::XAggregation > m_xAggregate
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
virtual void SAL_CALL dispose() override
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: Edit.cxx:157
::comphelper::OInterfaceContainerHelper3< css::form::XChangeListener > m_aChangeListeners
Definition: Edit.hxx:131
virtual void SAL_CALL addChangeListener(const css::uno::Reference< css::form::XChangeListener > &_rxListener) override
Definition: Edit.cxx:113
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
Definition: Edit.cxx:69
OUString m_aHtmlChangeValue
Definition: Edit.hxx:133
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &e) override
Definition: Edit.cxx:239
virtual ~OEditControl() override
Definition: Edit.cxx:98
OEditControl(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual void SAL_CALL removeChangeListener(const css::uno::Reference< css::form::XChangeListener > &_rxListener) override
Definition: Edit.cxx:119
virtual void SAL_CALL disposing() override
Definition: Edit.cxx:126
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
Definition: Edit.cxx:61
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: Edit.cxx:136
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: Edit.cxx:165
ImplSVEvent * m_nKeyEvent
Definition: Edit.hxx:134
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &e) override
Definition: Edit.cxx:182
OEditModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
float u
constexpr OUStringLiteral PROPERTY_TABINDEX
Definition: frm_strings.hxx:26
constexpr OUStringLiteral PROPERTY_DEFAULTCONTROL
Definition: frm_strings.hxx:51
constexpr OUStringLiteral PROPERTY_NAME
Definition: frm_strings.hxx:28
constexpr OUStringLiteral PROPERTY_FILTERPROPOSAL
constexpr OUStringLiteral PROPERTY_DEFAULT_TEXT
Definition: frm_strings.hxx:64
constexpr OUStringLiteral PROPERTY_TARGET_URL
Definition: frm_strings.hxx:49
constexpr OUStringLiteral PROPERTY_NATIVE_LOOK
constexpr OUStringLiteral PROPERTY_TEXT
Definition: frm_strings.hxx:33
constexpr OUStringLiteral PROPERTY_STANDARD_THEME
constexpr OUStringLiteral PROPERTY_EMPTY_IS_NULL
Definition: frm_strings.hxx:75
constexpr OUStringLiteral PROPERTY_MAXTEXTLEN
Definition: frm_strings.hxx:52
constexpr OUStringLiteral PROPERTY_CLASSID
Definition: frm_strings.hxx:30
constexpr OUStringLiteral PROPERTY_TAG
Definition: frm_strings.hxx:27
constexpr OUStringLiteral PROPERTY_PERSISTENCE_MAXTEXTLENGTH
constexpr OUStringLiteral PROPERTY_RICH_TEXT
constexpr OUStringLiteral PROPERTY_MULTILINE
Definition: frm_strings.hxx:48
std::mutex m_aMutex
sal_Int32 nIndex
constexpr sal_uInt16 KEY_RETURN
@ Exception
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
bool getBOOL(const Any &_rAny)
bool query_aggregation(const css::uno::Reference< css::uno::XAggregation > &_rxAggregate, css::uno::Reference< iface > &_rxOut)
sal_Int16 getINT16(const Any &_rAny)
OUString getString(const Any &_rAny)
void RemoveProperty(Sequence< Property > &_rProps, const OUString &_rPropName)
Type
const ColumnProperty * getField(guint n)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
IMPL_LINK_NOARG(OButtonControl, OnClick, void *, void)
Definition: Button.cxx:440
void dispose()
#define PROPERTY_ID_FILTERPROPOSAL
Definition: property.hxx:197
#define PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH
Definition: property.hxx:249
#define PROPERTY_ID_EMPTY_IS_NULL
Definition: property.hxx:161
#define PROPERTY_ID_DEFAULT_TEXT
Definition: property.hxx:106
#define PROPERTY_ID_TEXT
Definition: property.hxx:83
#define PROPERTY_ID_TABINDEX
Definition: property.hxx:41
sal_Int32 nHandle
constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_TEXTFIELD
Definition: services.hxx:143
constexpr OUStringLiteral VALIDATABLE_BINDABLE_CONTROL_MODEL
Definition: services.hxx:184
constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_EDIT
Definition: services.hxx:92
constexpr OUStringLiteral VCL_CONTROLMODEL_EDIT
Definition: services.hxx:39
constexpr OUStringLiteral BINDABLE_DATA_AWARE_CONTROL_MODEL
Definition: services.hxx:181
constexpr OUStringLiteral FRM_SUN_CONTROL_RICHTEXTCONTROL
Definition: services.hxx:166
constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_TEXTFIELD
Definition: services.hxx:96
constexpr OUStringLiteral DATA_AWARE_CONTROL_MODEL
Definition: services.hxx:182
constexpr OUStringLiteral FRM_SUN_CONTROL_TEXTFIELD
Definition: services.hxx:150
constexpr OUStringLiteral VALIDATABLE_CONTROL_MODEL
Definition: services.hxx:183
constexpr OUStringLiteral FRM_SUN_COMPONENT_RICHTEXTCONTROL
Definition: services.hxx:133
constexpr OUStringLiteral FRM_SUN_COMPONENT_TEXTFIELD
Definition: services.hxx:113
constexpr OUStringLiteral FRM_COMPONENT_EDIT
Definition: services.hxx:65
constexpr OUStringLiteral BINDABLE_CONTROL_MODEL
Definition: services.hxx:179
constexpr OUStringLiteral FRM_COMPONENT_TEXTFIELD
Definition: services.hxx:66
constexpr OUStringLiteral BINDABLE_DATABASE_TEXT_FIELD
Definition: services.hxx:175
#define SAL_MAX_INT16
const SvXMLTokenMapEntry aTypes[]