/* -*- 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 .
*/
void OElementExport::exportServiceNameAttribute()
{
Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY); if (!xPersistence.is())
{
OSL_FAIL("OElementExport::exportServiceNameAttribute: no XPersistObject!"); return;
}
OUString sServiceName = xPersistence->getServiceName(); // we don't want to write the old service name directly: it's a name used for compatibility reasons, but // as we start some kind of new file format here (with this xml export), we don't care about // compatibility ... // So we translate the old persistence service name into new ones, if possible
// now write this
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::ServiceName),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::ServiceName),
sToWriteServiceName);
}
void OElementExport::exportEvents()
{ if (!m_aEvents.hasElements()) // nothing to do return;
Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
m_rContext.getGlobalContext().GetEventExport().Export(xWrapper);
}
void OControlExport::exportOuterAttributes()
{ // the control id if (CCAFlags::Name & m_nIncludeCommon)
{
exportStringPropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Name),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Name),
PROPERTY_NAME
); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::Name; #endif
}
// the service name if (m_nIncludeCommon & CCAFlags::ServiceName)
{
exportServiceNameAttribute(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ServiceName; #endif
}
}
void OControlExport::exportInnerAttributes()
{ // the control id if (CCAFlags::ControlId & m_nIncludeCommon)
{
OSL_ENSURE(!m_sControlId.isEmpty(), "OControlExport::exportInnerAttributes: have no control id for the control!");
m_rContext.getGlobalContext().AddAttributeIdLegacy(
XML_NAMESPACE_FORM, m_sControlId); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ControlId; #endif
}
void OControlExport::exportSubTags()
{ // for the upcoming exportRemainingProperties: // if a control has the LabelControl property, this is not stored with the control itself, but instead with // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't // know anything about this, we need to prevent that it tries to export this property
exportedProperty(PROPERTY_CONTROLLABEL);
// if it's a control supporting XText, then we need to declare all text-related properties // as "already exported". This prevents them from being exported as generic "form:property"-tags. // *If* we would export them this way, they would be completely superfluous, and sometimes even // disastrous, since they may, at import time, override paragraph properties which already have // been set before
Reference< XText > xControlText( m_xProps, UNO_QUERY ); if ( xControlText.is() )
{ const XMLPropertyMapEntry* pCharAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TextPropMap::TEXT ); while ( !pCharAttributeProperties->IsEnd() )
{
exportedProperty( pCharAttributeProperties->getApiName() );
++pCharAttributeProperties;
}
// the RichText property is not exported. The presence of the text:p element // will be used - upon reading - as indicator for the value of the RichText property
exportedProperty( PROPERTY_RICH_TEXT );
// strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property // The former is a short/enum value, the latter a boolean. The former has a real meaning // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and // later on imported, it overwrites anything which has previously been imported for // CharStrikeout. // #i27729#
exportedProperty( u"CharCrossedOut"_ustr );
}
if ( m_eType == LISTBOX )
{ // will be exported in exportListSourceAsElements: if ( controlHasUserSuppliedListEntries() )
exportedProperty( PROPERTY_DEFAULT_SELECT_SEQ );
// will not be exported in a generic way. Either exportListSourceAsElements cares // for them, or we don't need them
exportedProperty( PROPERTY_STRING_ITEM_LIST );
exportedProperty( PROPERTY_VALUE_SEQ );
exportedProperty( PROPERTY_SELECT_SEQ );
exportedProperty( PROPERTY_LISTSOURCE );
} if ( m_eType == COMBOBOX )
exportedProperty( PROPERTY_STRING_ITEM_LIST );
// let the base class export the remaining properties and the events
OElementExport::exportSubTags();
// special sub tags for some controls switch (m_eType)
{ case LISTBOX: // don't export the list entries if the are not provided by the user, but obtained implicitly // from other sources // #i26944# if ( controlHasUserSuppliedListEntries() )
exportListSourceAsElements(); break; case GRID:
{ // a grid control requires us to store all columns as sub elements
Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!"); if (xColumnContainer.is())
m_rContext.exportCollectionElements(xColumnContainer);
} break; case COMBOBOX:
{ // a combox box description has sub elements: the items
DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< OUString > );
// don't export the list entries if the are not provided by the user, but obtained implicitly // from other sources // #i26944# if ( controlHasUserSuppliedListEntries() )
{ // get the item list
Sequence< OUString > aListItems;
m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems; // loop through it and write the sub elements for (constauto& rListItem : aListItems)
{
m_rContext.getGlobalContext().ClearAttrList();
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Label),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Label),
rListItem);
SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, u"item"_ustr, true, true);
}
}
} break;
case TEXT_AREA:
{ // if we act as rich text control, we need to export some text:p elements if ( xControlText.is() )
{ bool bActingAsRichText = false; if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
{
OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
}
if ( bActingAsRichText )
m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
}
} break; default: // nothing do to break;
}
}
void OControlExport::exportGenericHandlerAttributes()
{ const Sequence< Property > aProperties = m_xPropertyInfo->getProperties(); for ( autoconst & prop : aProperties )
{ try
{ // see if this property can already be handled with an IPropertyHandler (which, on the long // term, should be the case for most, if not all, properties) const PropertyDescription* propDescription = metadata::getPropertyDescription( prop.Name ); if ( propDescription == nullptr ) continue;
// let the factory provide the concrete handler. Note that caching, if desired, is the task // of the factory
PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId ); if ( !handler )
{
SAL_WARN( "xmloff.forms", "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" ); continue;
}
// that's a property which has a direct mapping to an attribute if ( !shouldExportProperty( prop.Name ) ) // TODO: in the future, we surely need a more sophisticated approach to this, involving the property // handler, or the property description
{
exportedProperty( prop.Name ); continue;
}
// I decided to handle all the properties here with some static arrays describing the property-attribute // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now // would require maps and O(log n) searches, which seems somewhat expensive as this code is used // very frequently.
// the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using // map identifiers from the wrong block
// some string properties
{ // the attribute ids of all properties which are expected to be of type string staticconst CCAFlags nStringPropertyAttributeIds[] =
{
CCAFlags::Label, CCAFlags::Title
}; // the names of all properties which are expected to be of type string static constexpr OUString aStringPropertyNames[] =
{
PROPERTY_LABEL, PROPERTY_TITLE
};
OSL_ENSURE( std::size(aStringPropertyNames) ==
std::size(nStringPropertyAttributeIds), "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
for (i=0; i<std::size(nStringPropertyAttributeIds); ++i) if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
{
exportStringPropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
aStringPropertyNames[i]
); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i]; #endif
}
}
if ( m_nIncludeCommon & CCAFlags::MaxLength )
exportedProperty(PROPERTY_MAXTEXTLENGTH);
#if OSL_DEBUG_LEVEL > 0 staticconst sal_Int32 nIdCount = std::size(nIntegerPropertyAttributeIds); staticconst sal_Int32 nNameCount = std::size(pIntegerPropertyNames); staticconst sal_Int32 nDefaultCount = std::size(nIntegerPropertyAttrDefaults);
OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount), "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!"); #endif for (i=0; i<std::size(nIntegerPropertyAttributeIds); ++i) if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
{
exportInt16PropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
pIntegerPropertyNames[i],
nIntegerPropertyAttrDefaults[i]); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i]; #endif
}
}
// some enum properties
{ if (m_nIncludeCommon & CCAFlags::ButtonType)
{
exportEnumPropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::ButtonType),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::ButtonType),
PROPERTY_BUTTONTYPE,
aFormButtonTypeMap,
FormButtonType_PUSH); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ButtonType; #endif
} if ( m_nIncludeCommon & CCAFlags::Orientation )
{
exportEnumPropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace( CCAFlags::Orientation ),
OAttributeMetaData::getCommonControlAttributeName( CCAFlags::Orientation ),
PROPERTY_ORIENTATION,
aOrientationMap,
ScrollBarOrientation::HORIZONTAL
); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::Orientation; #endif
}
if ( m_nIncludeCommon & CCAFlags::VisualEffect )
{
exportEnumPropertyAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace( CCAFlags::VisualEffect ),
OAttributeMetaData::getCommonControlAttributeName( CCAFlags::VisualEffect ),
PROPERTY_VISUAL_EFFECT,
aVisualEffectMap,
VisualEffect::LOOK3D
); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::VisualEffect; #endif
}
}
// some properties which require a special handling
// the target frame if (m_nIncludeCommon & CCAFlags::TargetFrame)
{
exportTargetFrameAttribute(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetFrame; #endif
}
// max text length if ( m_nIncludeCommon & CCAFlags::MaxLength )
{ // normally, the respective property would be "MaxTextLen" // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
// determine the name of the property to export
OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH ); if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
// in either way, both properties count as "exported"
exportedProperty( PROPERTY_MAXTEXTLENGTH );
exportedProperty( PROPERTY_PERSISTENCE_MAXTEXTLENGTH );
#if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::MaxLength; #endif
}
if (m_nIncludeCommon & CCAFlags::TargetLocation)
{
exportTargetLocationAttribute(false); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetLocation; #endif
}
// OJ #99721# if (m_nIncludeCommon & CCAFlags::ImageData)
{
exportImageDataAttribute(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ImageData; #endif
}
// the for attribute // the target frame if (m_nIncludeCommon & CCAFlags::For)
{ if (!m_sReferringControls.isEmpty())
{ // there is at least one control referring to the one we're handling currently
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::For),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::For),
m_sReferringControls);
} #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::For; #endif
}
// get the property names
getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
// add the attributes if necessary and possible if (!pCurrentValuePropertyName.isEmpty() && (CCAFlags::CurrentValue & m_nIncludeCommon))
{ staticconst OUString pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue); // don't export the current-value if this value originates from a data binding // #i26944# if ( controlHasActiveDataBinding() )
exportedProperty( pCurrentValuePropertyName ); else
{ staticconst sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentValue);
exportGenericPropertyAttribute(
nCurrentValueAttributeNamespaceKey,
pCurrentValueAttributeName,
pCurrentValuePropertyName
);
}
}
OSL_ENSURE((pValuePropertyName.isEmpty()) == (CCAFlags::NONE == (CCAFlags::Value & m_nIncludeCommon)), "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
OSL_ENSURE((pCurrentValuePropertyName.isEmpty()) == (CCAFlags::NONE == (CCAFlags::CurrentValue & m_nIncludeCommon)), "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
#if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags(CCAFlags::CurrentValue | CCAFlags::Value); #endif
}
OSL_ENSURE(CCAFlags::NONE == m_nIncludeCommon, "OControlExport::exportCommonControlAttributes: forgot some flags!"); // in the dbg_util version, we should have removed every bit we handled from the mask, so it should // be 0 now ...
}
#if OSL_DEBUG_LEVEL > 0
OSL_ENSURE(DAFlags::NONE == nIncludeDatabase, "OControlExport::exportDatabaseAttributes: forgot some flags!"); // in the dbg_util version, we should have removed every bit we handled from the mask, so it should // be 0 now ... #endif
}
if ( m_nIncludeBindings & BAFlags::LinkedCell )
{
exportCellBindingAttributes( bool(m_nIncludeBindings & BAFlags::ListLinkingType) ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BAFlags( BAFlags::LinkedCell | BAFlags::ListLinkingType ); #endif
}
if ( m_nIncludeBindings & BAFlags::ListCellRange )
{
exportCellListSourceRange(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BAFlags::ListCellRange; #endif
}
if ( m_nIncludeBindings & BAFlags::XFormsBind )
{
exportXFormsBindAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsBind; #endif
}
if ( m_nIncludeBindings & BAFlags::XFormsListBind )
{
exportXFormsListAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsListBind; #endif
}
if ( m_nIncludeBindings & BAFlags::XFormsSubmission )
{
exportXFormsSubmissionAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsSubmission; #endif
}
#if OSL_DEBUG_LEVEL > 0
OSL_ENSURE( BAFlags::NONE == nIncludeBinding, "OControlExport::exportBindingAttributes: forgot some flags!"); // in the debug version, we should have removed every bit we handled from the mask, so it should // be 0 now ... #endif
}
#if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::StepSize; #endif
}
}
// the enum properties
{ if (SCAFlags::State & m_nIncludeSpecial)
{
exportEnumPropertyAttribute(
OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::State),
OAttributeMetaData::getSpecialAttributeName(SCAFlags::State),
PROPERTY_DEFAULT_STATE,
aCheckStateMap,
TRISTATE_FALSE); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::State; #endif
}
if (SCAFlags::CurrentState & m_nIncludeSpecial)
{
exportEnumPropertyAttribute(
OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::CurrentState),
OAttributeMetaData::getSpecialAttributeName(SCAFlags::CurrentState),
PROPERTY_STATE,
aCheckStateMap,
TRISTATE_FALSE); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::CurrentState; #endif
}
}
// some properties which require a special handling // the repeat delay
{ if ( m_nIncludeSpecial & SCAFlags::RepeatDelay )
{
DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY, sal_Int32 );
#if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::RepeatDelay; #endif
}
}
// the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
{ if (SCAFlags::EchoChar & m_nIncludeSpecial)
{
DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
sal_Int16 nValue(0);
m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue; if (nValue)
{
OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
AddAttribute(
OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::EchoChar),
OAttributeMetaData::getSpecialAttributeName(SCAFlags::EchoChar),
sCharacter);
}
exportedProperty(PROPERTY_ECHO_CHAR); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::EchoChar; #endif
}
}
staticconst sal_Int32 nIdCount = std::size( nStringPropertyAttributeIds ); #if OSL_DEBUG_LEVEL > 0 staticconst sal_Int32 nNameCount = std::size( pStringPropertyNames );
OSL_ENSURE( ( nIdCount == nNameCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" ); #endif for ( i = 0; i < nIdCount; ++i ) if ( nStringPropertyAttributeIds[i] & m_nIncludeSpecial )
{
exportStringPropertyAttribute(
OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ),
OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ),
pStringPropertyNames[i]
); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking
m_nIncludeSpecial = m_nIncludeSpecial & ~nStringPropertyAttributeIds[i]; #endif
}
}
if ((SCAFlags::MinValue | SCAFlags::MaxValue) & m_nIncludeSpecial)
{ // need to export the min value and the max value as attributes // It depends on the real type (FormComponentType) of the control, which properties hold these // values
OUString pMinValuePropertyName;
OUString pMaxValuePropertyName;
getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
OSL_ENSURE((pMinValuePropertyName.isEmpty()) == (SCAFlags::NONE == (SCAFlags::MinValue & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
OSL_ENSURE((pMaxValuePropertyName.isEmpty()) == (SCAFlags::NONE == (SCAFlags::MaxValue & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
OSL_ENSURE(SCAFlags::NONE == m_nIncludeSpecial, "OControlExport::exportSpecialAttributes: forgot some flags!"); // in the dbg_util version, we should have removed every bit we handled from the mask, so it should // be 0 now ...
}
void OControlExport::exportListSourceAsAttribute()
{ // DAFlags::ListSource needs some special handling
DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE );
OUString sListSource = getScalarListSourceValue(); if ( !sListSource.isEmpty() )
{ // the ListSource property needs to be exported as attribute, and it is not empty
AddAttribute(
OAttributeMetaData::getDatabaseAttributeNamespace(),
OAttributeMetaData::getDatabaseAttributeName(DAFlags::ListSource),
sListSource);
}
DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE, Sequence< OUString > ); if ( DAFlags::NONE == ( m_nIncludeDatabase & DAFlags::ListSource ) )
m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues; // if we exported the list source as attribute, we do not repeat it as sub elements
// the string for "true"
OUString sTrue;
OUStringBuffer sBuffer;
::sax::Converter::convertBool(sBuffer, true);
sTrue = sBuffer.makeStringAndClear();
// loop through both lists ('til the maximum of both lengths) const OUString* pItems = aItems.getConstArray(); const OUString* pValues = aValues.getConstArray();
for (sal_Int16 i=0; i<nMaxLen; ++i )
{
m_rContext.getGlobalContext().ClearAttrList(); if (i < nItems)
{ // there is an item at this position
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Label),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Label),
*pItems);
++pItems;
} if (i < nValues)
{ // there is a value at this position
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Value),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value),
*pValues);
++pValues;
}
Int16Set::const_iterator aSelectedPos = aSelection.find(i); if (aSelection.end() != aSelectedPos)
{ // the item at this position is selected
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentSelected),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentSelected),
sTrue
);
aSelection.erase(aSelectedPos);
}
Int16Set::const_iterator aDefaultSelectedPos = aDefaultSelection.find(i); if (aDefaultSelection.end() != aDefaultSelectedPos)
{ // the item at this position is selected as default
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Selected),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Selected),
sTrue
);
aDefaultSelection.erase(aDefaultSelectedPos);
}
SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, u"option"_ustr, true, true);
}
// There may be more "selected" or "default-selected" items than there are in the lists in real, // so we need to store some additional "form:option" items which have no name and no label, but // one or both of the selected flags. // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
if (aSelection.empty() && aDefaultSelection.empty()) return;
// the maximum element in both sets
sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!"); // if the maximum (selected or default selected) entry number is less than the maximum item count // in both lists, the entry number should have been removed from the set
for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
{ if (aSelection.end() != aSelection.find(i))
{ // the (not existent) item at this position is selected
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentSelected),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentSelected),
sTrue
);
}
if (aDefaultSelection.end() != aDefaultSelection.find(i))
{ // the (not existent) item at this position is selected as default
AddAttribute(
OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Selected),
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Selected),
sTrue
);
}
SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, u"option"_ustr, true, true);
}
}
void OControlExport::implStartElement(const OUString& _pName)
{ // before we let the base class start it's outer element, we add a wrapper element
OUString pOuterElementName = getOuterXMLElementName(); if (!pOuterElementName.isEmpty())
m_pOuterElement = std::make_unique<SvXMLElementExport>(
m_rContext.getGlobalContext(),
XML_NAMESPACE_FORM,
pOuterElementName, true, true);
// add the attributes for the inner element
exportInnerAttributes();
// and start the inner element
OElementExport::implStartElement(_pName);
}
void OControlExport::implEndElement()
{ // end the inner element
OElementExport::implEndElement();
// end the outer element if it exists
m_pOuterElement.reset();
}
// get the class id to decide which kind of element we need in the XML stream
m_nClassId = FormComponentType::CONTROL;
DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId; bool knownType = false; switch (m_nClassId)
{ case FormComponentType::DATEFIELD:
m_eType = DATE;
knownType = true;
[[fallthrough]]; case FormComponentType::TIMEFIELD: if ( !knownType )
{
m_eType = TIME;
knownType = true;
}
m_nIncludeSpecial |= SCAFlags::Validation;
[[fallthrough]]; case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: case FormComponentType::PATTERNFIELD: if ( !knownType )
{
m_eType = FORMATTED_TEXT;
knownType = true;
}
[[fallthrough]]; case FormComponentType::TEXTFIELD:
{ // it's some kind of edit. To know which type we need further investigation
if ( !knownType )
{ // check if it's a formatted field if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
{
m_eType = FORMATTED_TEXT;
} else
{ // all other controls are represented by an ordinary edit control, but which XML control type // it is depends on the current values of some properties
// if the EchoChar string is not empty, it is a password field
sal_Int16 nEchoChar = 0; if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR)) // grid columns do not have this property...
m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar; if (nEchoChar)
{
m_eType = PASSWORD;
m_nIncludeSpecial |= SCAFlags::EchoChar;
} else
{ // if the MultiLine property is sal_True, it is a TextArea bool bMultiLine = false; if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE)) // grid columns do not have this property...
bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
if ( bMultiLine )
m_eType = TEXT_AREA; else // the only case left is represented by a Text element
m_eType = TEXT;
}
}
}
// attributes which are common to all the types: // common attributes
m_nIncludeCommon =
CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled |
CCAFlags::Printable | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title;
if ( ( m_nClassId != FormComponentType::DATEFIELD )
&& ( m_nClassId != FormComponentType::TIMEFIELD )
) // date and time field values are handled differently nowadays
m_nIncludeCommon |= CCAFlags::Value;
// only text and pattern fields have a ConvertEmptyToNull property if ( ( m_nClassId == FormComponentType::TEXTFIELD )
|| ( m_nClassId == FormComponentType::PATTERNFIELD )
)
m_nIncludeDatabase |= DAFlags::ConvertEmpty;
// all controls but the file control fields have a readonly property if ( m_nClassId != FormComponentType::FILECONTROL )
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
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.