/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
Sequence<Type> OEditControl::_getTypes()
{ // my two base classes static Sequence<Type> const aTypes = concatSequences(OBoundControl::_getTypes(), OEditControl_BASE::getTypes()); return aTypes;
}
Any SAL_CALL OEditControl::queryAggregation(const Type& _rType)
{
Any aReturn = OBoundControl::queryAggregation(_rType); if (!aReturn.hasValue())
aReturn = OEditControl_BASE::queryInterface(_rType);
// Is the Control in a form with a submit URL?
Reference<XPropertySet> xSet(getModel(), UNO_QUERY); if( !xSet.is() ) return;
// Not for multiline edits
Any aTmp( xSet->getPropertyValue(PROPERTY_MULTILINE)); if ((aTmp.getValueType().equals(cppu::UnoType<bool>::get())) && getBOOL(aTmp)) return;
if (hasProperty(PROPERTY_CLASSID, xFCSet) &&
getINT16(xFCSet->getPropertyValue(PROPERTY_CLASSID)) == FormComponentType::TEXTFIELD)
{ // Found another Edit -> then do not submit! if (xFCSet != xSet) return;
}
}
}
// Because we're still in the header, trigger submit asynchronously if( m_nKeyEvent )
Application::RemoveUserEvent( m_nKeyEvent );
m_nKeyEvent = Application::PostUserEvent( LINK(this, OEditControl, OnKeyPressed) );
}
// Note that most of the properties are not clone from the original object: // Things as the format key, it's type, and such, depend on the field being part of a loaded form // (they're initialized in onConnectedDbColumn). Even if the original object _is_ part of such a form, we ourself // certainly aren't, so these members are defaulted. If we're inserted into a form which is already loaded, // they will be set to new values, anyway...
}
OEditModel::~OEditModel()
{ if (!OComponentHelper::rBHelper.bDisposed)
{
acquire();
dispose();
}
// our aggregate is a rich text model, which also derives from OControlModel, as // do we, so we need to remove some duplicate properties
RemoveProperty( _rAggregateProps, PROPERTY_TABINDEX );
RemoveProperty( _rAggregateProps, PROPERTY_CLASSID );
RemoveProperty( _rAggregateProps, PROPERTY_NAME );
RemoveProperty( _rAggregateProps, PROPERTY_TAG );
RemoveProperty( _rAggregateProps, PROPERTY_NATIVE_LOOK );
RemoveProperty( _rAggregateProps, PROPERTY_STANDARD_THEME );
try
{
_rxDest->setPropertyValue( sourceprop.Name, _rxSource->getPropertyValue( sourceprop.Name ) );
} catch(const IllegalArgumentException&)
{
TOOLS_WARN_EXCEPTION( "forms.component", "could not transfer the property named '"
<< sourceprop.Name
<< "'" );
}
}
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("forms.component");
}
}
}
void OEditModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutStream ) const
{ // we need to fake the writing of our aggregate. Since #i24387#, we have another aggregate, // but for compatibility, we need to use an "old" aggregate for writing and reading
Reference< XPropertySet > xFakedAggregate(
getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
UNO_QUERY
);
OSL_ENSURE( xFakedAggregate.is(), "OEditModel::writeAggregate: could not create an old EditControlModel!" ); if ( !xFakedAggregate.is() ) return;
void OEditModel::readAggregate( const Reference< XObjectInputStream >& _rxInStream )
{ // we need to fake the reading of our aggregate. Since #i24387#, we have another aggregate, // but for compatibility, we need to use an "old" aggregate for writing and reading
Reference< XPropertySet > xFakedAggregate(
getContext()->getServiceManager()->createInstanceWithContext( VCL_CONTROLMODEL_EDIT, getContext() ),
UNO_QUERY
);
Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY );
OSL_ENSURE( xFakedPersist.is(), "OEditModel::readAggregate: no XPersistObject, or no faked aggregate at all!" ); if ( xFakedPersist.is() )
{
xFakedPersist->read( _rxInStream );
lcl_transferProperties( xFakedAggregate, m_xAggregateSet );
}
}
void OEditModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
{
Any aCurrentText;
sal_Int16 nOldTextLen = 0; // Am I loaded at the moment and did I switch MaxTextLen temporarily? if ( m_bMaxTextLenModified )
{ // -> for the duration of saving, make my aggregated model believe the old TextLen
// before doing this we have to save the current text value of the aggregate, as this may be affected by resetting the text len
aCurrentText = m_xAggregateSet->getPropertyValue(PROPERTY_TEXT);
if ( m_bMaxTextLenModified )
{ // Reset again
m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(nOldTextLen)); // and reset the text // First we set it to an empty string : Without this the second setPropertyValue would not do anything as it thinks // we aren't changing the prop (it didn't notify the - implicit - change of the text prop while setting the max text len) // This seems to be a bug with in toolkit's EditControl-implementation.
m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, Any(OUString()));
m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, aCurrentText);
}
}
// Some versions (5.1 'til about 552) wrote a wrong DefaultControl-property value which is unknown // to older versions (5.0). // correct this ... if (m_xAggregateSet.is())
{
Any aDefaultControl = m_xAggregateSet->getPropertyValue(PROPERTY_DEFAULTCONTROL); if ( (aDefaultControl.getValueTypeClass() == TypeClass_STRING)
&& (getString(aDefaultControl) == STARDIV_ONE_FORM_CONTROL_TEXTFIELD )
)
{
m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, Any( STARDIV_ONE_FORM_CONTROL_EDIT ) ); // Older as well as current versions should understand this : the former knew only the STARDIV_ONE_FORM_CONTROL_EDIT, // the latter are registered for both STARDIV_ONE_FORM_CONTROL_EDIT and STARDIV_ONE_FORM_CONTROL_TEXTFIELD.
}
}
}
if ( hasField() && m_bMaxTextLenModified )
{
Any aVal;
aVal <<= sal_Int16(0); // Only if it was 0, I switched it in onConnectedDbColumn
m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal);
m_bMaxTextLenModified = false;
}
}
bool OEditModel::approveDbColumnType( sal_Int32 _nColumnType )
{ // if we act as rich text currently, we do not allow binding to a database column if ( implActsAsRichText() ) returnfalse;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.