35#include <com/sun/star/uno/XComponentContext.hpp>
36#include <com/sun/star/text/XText.hpp>
37#include <com/sun/star/util/XCloneable.hpp>
38#include <com/sun/star/util/Duration.hpp>
39#include <com/sun/star/form/FormComponentType.hpp>
40#include <com/sun/star/awt/ImagePosition.hpp>
41#include <com/sun/star/beans/XMultiPropertySet.hpp>
42#include <com/sun/star/beans/XPropertyContainer.hpp>
43#include <com/sun/star/beans/PropertyAttribute.hpp>
48#include <rtl/strbuf.hxx>
76#define PROPID_CURRENT_VALUE 2
77#define PROPID_MIN_VALUE 3
78#define PROPID_MAX_VALUE 4
82 struct PropertyValueLess
84 bool operator()(
const PropertyValue& _rLeft,
const PropertyValue& _rRight)
86 return _rLeft.Name < _rRight.Name;
98 sal_Int32 nAsInt =
static_cast<sal_Int32
>(e);
119 const Reference< XNameContainer >& _rxParentContainer)
121 ,m_rFormImport(_rImport)
122 ,m_rEventManager(_rEventManager)
123 ,m_pStyleElement( nullptr )
125 ,m_bImplicitGenericAttributeHandling( true )
127 OSL_ENSURE(
m_xParentContainer.is(),
"OElementImport::OElementImport: invalid parent container!");
146 if ( !sControlImplementation.isEmpty() )
148 OUString sOOoImplementationName;
149 const sal_uInt16 nImplPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrValueQName( sControlImplementation, &sOOoImplementationName );
170 const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList )
180 OSL_ENSURE(
m_xElement.is(),
"OElementImport::EndElement: invalid element created!");
193 Reference< XPropertySet > xPropTranslation =
198 if ( !sNumberStyleName.isEmpty() )
206 OSL_FAIL(
"OElementImport::EndElement: did not find a name attribute!");
222#if OSL_DEBUG_LEVEL > 0
229 OSL_ENSURE(
m_xInfo->hasPropertyByName(rCheck.Name),
230 OStringBuffer(
"OElementImport::implApplySpecificProperties: read a property (" +
232 ") which does not exist on the element!").getStr());
238 const Reference< XMultiPropertySet > xMultiProps(
m_xElement, UNO_QUERY);
239 bool bSuccess =
false;
240 if (xMultiProps.is())
248 Sequence< OUString > aNames(
m_aValues.size());
249 OUString* pNames = aNames.getArray();
251 Sequence< Any > aValues(
m_aValues.size());
255 for (
const auto& rPropValues :
m_aValues )
257 *pNames = rPropValues.Name;
265 xMultiProps->setPropertyValues(aNames, aValues);
271 OSL_FAIL(
"OElementImport::implApplySpecificProperties: could not set the properties (using the XMultiPropertySet)!");
279 for (
const auto& rPropValues :
m_aValues )
285 m_xElement->setPropertyValue(rPropValues.Name, rPropValues.Value);
290 OSL_FAIL(OStringBuffer(
"OElementImport::implApplySpecificProperties: could not set the property \"" +
302 Reference< XPropertyContainer > xDynamicProperties(
m_xElement, UNO_QUERY );
312 const bool bExistentProperty =
m_xInfo->hasPropertyByName( rPropValues.Name );
313 if ( !bExistentProperty )
315 if ( !xDynamicProperties.is() )
317 SAL_WARN(
"xmloff",
"OElementImport::implApplyGenericProperties: encountered an unknown property ("
318 << rPropValues.Name <<
"), but component is no PropertyBag!");
322 xDynamicProperties->addProperty(
324 PropertyAttribute::BOUND | PropertyAttribute::REMOVABLE,
333 TypeClass eValueTypeClass = rPropValues.Value.getValueTypeClass();
334 const bool bValueIsSequence = TypeClass_SEQUENCE == eValueTypeClass;
335 if ( bValueIsSequence )
338 eValueTypeClass = aSimpleType.getTypeClass();
342 const Property aProperty(
m_xInfo->getPropertyByName( rPropValues.Name ) );
343 TypeClass ePropTypeClass = aProperty.Type.getTypeClass();
344 const bool bPropIsSequence = TypeClass_SEQUENCE == ePropTypeClass;
345 if( bPropIsSequence )
347 uno::Type aSimpleType( ::comphelper::getSequenceElementType( aProperty.Type ) );
348 ePropTypeClass = aSimpleType.getTypeClass();
351 if ( bPropIsSequence != bValueIsSequence )
353 OSL_FAIL(
"OElementImport::implImportGenericProperties: either both value and property should be a sequence, or none of them!" );
357 if ( bValueIsSequence )
359 Sequence< Any > aXMLValueList;
360 rPropValues.Value >>= aXMLValueList;
362 if (!aXMLValueList.getLength())
365 Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() );
367 SAL_WARN_IF( eValueTypeClass != TypeClass_ANY,
"xmloff",
368 "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" );
371 SAL_WARN_IF( ePropTypeClass != TypeClass_SHORT,
"xmloff",
372 "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" );
375 std::transform(std::cbegin(aXMLValueList), std::cend(aXMLValueList), aPropertyValueList.getArray(),
376 [](
const Any& rXMLValue) -> sal_Int16 {
379 OSL_VERIFY( rXMLValue >>= nVal );
380 return static_cast< sal_Int16 >( nVal );
383 rPropValues.Value <<= aPropertyValueList;
385 else if ( ePropTypeClass != eValueTypeClass )
387 switch ( eValueTypeClass )
389 case TypeClass_DOUBLE:
392 rPropValues.Value >>= nVal;
393 switch( ePropTypeClass )
396 rPropValues.Value <<=
static_cast< sal_Int8 >( nVal );
398 case TypeClass_SHORT:
399 rPropValues.Value <<=
static_cast< sal_Int16
>( nVal );
401 case TypeClass_UNSIGNED_SHORT:
402 rPropValues.Value <<=
static_cast< sal_uInt16
>( nVal );
406 rPropValues.Value <<=
static_cast< sal_Int32
>( nVal );
408 case TypeClass_UNSIGNED_LONG:
409 rPropValues.Value <<=
static_cast< sal_uInt32
>( nVal );
411 case TypeClass_UNSIGNED_HYPER:
412 rPropValues.Value <<=
static_cast< sal_uInt64
>( nVal );
414 case TypeClass_HYPER:
415 rPropValues.Value <<=
static_cast< sal_Int64
>( nVal );
418 OSL_FAIL(
"OElementImport::implImportGenericProperties: unsupported value type!" );
424 OSL_FAIL(
"OElementImport::implImportGenericProperties: non-double values not supported!" );
429 m_xElement->setPropertyValue( rPropValues.Name, rPropValues.Value );
434 OSL_FAIL(OStringBuffer(
"OElementImport::EndElement: could not set the property \"" +
445 static constexpr OUStringLiteral sUnnamedName =
u"unnamed";
446 OSL_ENSURE(
m_xParentContainer.is(),
"OElementImport::implGetDefaultName: no parent container!");
451 for (sal_Int32
i=0;
i<32768; ++
i)
454 OUString sReturn = sUnnamedName + OUString::number(
i);
460 OSL_FAIL(
"OElementImport::implGetDefaultName: did not find a free name!");
466 ENSURE_OR_RETURN(
m_xInfo.is(),
"OElementImport::impl_matchPropertyGroup: no property set info!", i_propertyGroups.end() );
468 return std::find_if(i_propertyGroups.cbegin(), i_propertyGroups.cend(), [&](
const PropertyDescriptionList& rGroup) {
469 return std::all_of(rGroup.cbegin(), rGroup.cend(), [&](const PropertyDescription* prop) {
470 return m_xInfo->hasPropertyByName( prop->propertyName );
475 bool OElementImport::tryGenericAttribute( sal_Int32 nElement,
const OUString& _rValue )
483 const PropertyGroups::const_iterator
pos = impl_matchPropertyGroup( propertyGroups );
484 if (
pos == propertyGroups.end() )
493 SAL_WARN(
"xmloff.forms",
"OElementImport::handleAttribute: invalid property description!" );
500 SAL_WARN(
"xmloff.forms",
"OElementImport::handleAttribute: invalid property handler!" );
505 for (
const auto& propDesc : rProperties )
507 aValues[ propDesc->propertyId ] =
Any();
509 if ( handler->getPropertyValues( _rValue, aValues ) )
511 for (
const auto& propDesc : rProperties )
513 implPushBackPropertyValue( propDesc->propertyName, aValues[ propDesc->propertyId ] );
525 bool OElementImport::handleAttribute(sal_Int32 nElement,
const OUString& _rValue)
544 OSL_ENSURE( pStyleContext,
"OElementImport::handleAttribute: do not know the style!" );
550 if ( m_bImplicitGenericAttributeHandling )
551 if ( tryGenericAttribute( nElement, _rValue ) )
555 return OPropertyImport::handleAttribute( nElement, _rValue);
558 Reference< XPropertySet > OElementImport::createElement()
560 Reference< XPropertySet > xReturn;
561 if (!m_sServiceName.isEmpty())
563 Reference< XComponentContext > xContext = m_rFormImport.getGlobalContext().GetComponentContext();
564 Reference< XInterface > xPure = xContext->getServiceManager()->createInstanceWithContext(m_sServiceName, xContext);
565 OSL_ENSURE(xPure.is(),
566 OStringBuffer(
"OElementImport::createElement: service factory gave me no object (service name: " +
569 xReturn.set(xPure, UNO_QUERY);
572 OSL_FAIL(
"OElementImport::createElement: no service name to create an element!");
577 void OElementImport::registerEvents(
const Sequence< ScriptEventDescriptor >& _rEvents)
579 OSL_ENSURE(
m_xElement.is(),
"OElementImport::registerEvents: no element to register events for!");
580 m_rEventManager.registerEvents(
m_xElement, _rEvents);
583 void OElementImport::simulateDefaultedAttribute(sal_Int32 nElement,
const OUString& _rPropertyName,
const char* _pAttributeDefault)
585 OSL_ENSURE(
m_xInfo.is(),
"OPropertyImport::simulateDefaultedAttribute: the component should be more gossipy about it's properties!" );
587 if ( !
m_xInfo.is() ||
m_xInfo->hasPropertyByName( _rPropertyName ) )
589 if ( !encounteredAttribute( nElement ) )
590 OSL_VERIFY( handleAttribute(
XML_ELEMENT(
FORM, (nElement &
TOKEN_MASK)), OUString::createFromAscii( _pAttributeDefault ) ) );
596 const Reference< XNameContainer >& _rxParentContainer)
605 :OElementImport(_rImport, _rEventManager, _rxParentContainer)
606 ,m_eElementType(_eType)
613 const char* pServiceName =
nullptr;
637 if ( pServiceName !=
nullptr )
638 return OUString::createFromAscii( pServiceName );
644 OSL_ENSURE(!
m_xOuterAttributes.is(),
"OControlImport::addOuterAttributes: already have these attributes!");
668 if ( (nElement &
TOKEN_MASK) == nLinkedCellAttributeName )
703 if ( (nElement &
TOKEN_MASK) == nValueAttributeName )
705 else if ( (nElement &
TOKEN_MASK) == nCurrentValueAttributeName )
707 else if ( (nElement &
TOKEN_MASK) == nMinValueAttributeName )
709 else if ( (nElement &
TOKEN_MASK) == nMaxValueAttributeName )
715 aProp.Name = SvXMLImport::getNameFromToken(nElement);
717 aProp.Value <<= _rValue;
722 if ( (nElement &
TOKEN_MASK) == nRepeatDelayAttributeName )
724 util::Duration aDuration;
729 sal_Int32
const nMS =
730 ((aDuration.Hours * 60 + aDuration.Minutes) * 60
731 + aDuration.Seconds) * 1000 + aDuration.NanoSeconds/1000000;
744 css::uno::Reference< css::xml::sax::XFastAttributeList > xMergedAttributes;
751 xMergedAttributes = xMerger.get();
755 xMergedAttributes = _rxAttrList;
767 OSL_FAIL(
"OControlImport::StartElement: no PropertySetInfo!");
771 OUString pValueProperty;
772 OUString pCurrentValueProperty;
773 OUString pMinValueProperty;
774 OUString pMaxValueProperty;
776 bool bRetrievedValues =
false;
777 bool bRetrievedValueLimits =
false;
780 sal_Int16 nClassId = FormComponentType::CONTROL;
786 bool bSuccess =
false;
787 switch (rValueProps.Handle)
793 if (!bRetrievedValues)
796 if ( pCurrentValueProperty.isEmpty() && pValueProperty.isEmpty() )
798 SAL_WARN(
"xmloff.forms",
"OControlImport::StartElement: illegal value property names!" );
802 bRetrievedValues =
true;
804 if (
PROPID_VALUE == rValueProps.Handle && pValueProperty.isEmpty() )
806 SAL_WARN(
"xmloff.forms",
"OControlImport::StartElement: the control does not have a value property!");
812 SAL_WARN(
"xmloff.forms",
"OControlImport::StartElement: the control does not have a current-value property!");
818 rValueProps.Name = pValueProperty;
820 rValueProps.Name = pCurrentValueProperty;
828 if (!bRetrievedValueLimits)
831 if ( pMinValueProperty.isEmpty() || pMaxValueProperty.isEmpty() )
833 SAL_WARN(
"xmloff.forms",
"OControlImport::StartElement: illegal value limit property names!" );
837 bRetrievedValueLimits =
true;
839 OSL_ENSURE((
PROPID_MIN_VALUE != rValueProps.Handle) || !pMinValueProperty.isEmpty(),
840 "OControlImport::StartElement: the control does not have a value property!");
841 OSL_ENSURE((
PROPID_MAX_VALUE != rValueProps.Handle) || !pMaxValueProperty.isEmpty(),
842 "OControlImport::StartElement: the control does not have a current-value property!");
846 rValueProps.Name = pMinValueProperty;
848 rValueProps.Name = pMaxValueProperty;
866 PropertyValue& _rPropValue)
868 OSL_ENSURE(_rxPropInfo->hasPropertyByName(_rPropValue.Name),
869 "OControlImport::implTranslateValueProperty: invalid property name!");
872 Property aProp = _rxPropInfo->getPropertyByName(_rPropValue.Name);
875 bool bSuccess = _rPropValue.Value >>= sValue;
876 OSL_ENSURE(bSuccess,
"OControlImport::implTranslateValueProperty: supposed to be called with non-translated string values!");
878 if (TypeClass_ANY == aProp.Type.getTypeClass())
884 "OControlImport::implTranslateValueProperty: invalid property type/name combination, Any and " << _rPropValue.Name);
890 _rPropValue.Value <<=
nValue;
892 _rPropValue.Value <<= sValue;
900 OSL_ENSURE(
m_xElement.is(),
"OControlImport::EndElement: invalid control!");
917 bool bRestoreValuePropertyValue =
false;
918 Any aValuePropertyValue;
920 sal_Int16 nClassId = FormComponentType::CONTROL;
929 "caught an exception while retrieving the class id!");
932 OUString pValueProperty;
933 OUString pDefaultValueProperty;
935 if ( !pDefaultValueProperty.isEmpty() && !pValueProperty.isEmpty() )
937 bool bNonDefaultValuePropertyValue =
false;
943 if ( rCheck.Name == pDefaultValueProperty )
944 bRestoreValuePropertyValue =
true;
945 else if ( rCheck.Name == pValueProperty )
947 bNonDefaultValuePropertyValue =
true;
949 aValuePropertyValue = rCheck.Value;
953 if ( bRestoreValuePropertyValue && !bNonDefaultValuePropertyValue )
958 aValuePropertyValue =
m_xElement->getPropertyValue( pValueProperty );
964 "caught an exception while retrieving the current value property!");
973 if ( bRestoreValuePropertyValue && !pValueProperty.isEmpty() )
977 m_xElement->setPropertyValue( pValueProperty, aValuePropertyValue );
982 "caught an exception while restoring the value property!");
1005 OSL_PRECOND(
m_xElement.is(),
"OControlImport::doRegisterCellValueBinding: invalid element!" );
1006 OSL_PRECOND( !_rBoundCellAddress.isEmpty(),
1007 "OControlImport::doRegisterCellValueBinding: invalid address!" );
1014 OSL_PRECOND(
m_xElement.is(),
"need element" );
1015 OSL_PRECOND( !_rBindingID.isEmpty(),
"binding ID is not valid" );
1022 OSL_PRECOND(
m_xElement.is(),
"need element" );
1023 OSL_PRECOND( !_rBindingID.isEmpty(),
"binding ID is not valid" );
1030 OSL_PRECOND(
m_xElement.is(),
"need element" );
1031 OSL_PRECOND( !_rSubmissionID.isEmpty(),
"binding ID is not valid" );
1039 if ( xPropSet.is() )
1041 m_xInfo = xPropSet->getPropertySetInfo();
1053 const Reference< XNameContainer >& _rxParentContainer,
1055 :
OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1056 ,m_nImagePosition( -1 )
1058 ,m_bHaveImagePosition( false )
1063 const OUString& _rValue )
1067 if ( (nElement &
TOKEN_MASK) == s_nImageDataAttributeName)
1099 PropertyValue aGraphicProperty;
1107 sal_Int16 nUnoImagePosition = ImagePosition::Centered;
1111 "OImagePositionImport::StartElement: unknown image align and/or position!" );
1115 PropertyValue aImagePosition;
1117 aImagePosition.Value <<= nUnoImagePosition;
1124 const Reference< XNameContainer >& _rxParentContainer )
1139 const OUString& _rValue)
1142 if ((nElement &
TOKEN_MASK) == s_nReferenceAttributeName)
1153 :
OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1160 if ((nElement &
TOKEN_MASK) == s_nEchoCharAttributeName)
1163 PropertyValue aEchoChar;
1165 OSL_ENSURE(_rValue.getLength() == 1,
"OPasswordImport::handleAttribute: invalid echo char attribute!");
1167 if (_rValue.getLength() >= 1)
1168 aEchoChar.Value <<=
static_cast<sal_Int16
>(_rValue[0]);
1170 aEchoChar.Value <<= sal_Int16(0);
1190 if ( (nElement &
TOKEN_MASK) == nCurrentSelectedAttributeName
1191 || (nElement &
TOKEN_MASK) == nSelectedAttributeName
1195 assert(pProperty &&
"ORadioImport::handleAttribute: invalid property map!");
1201 PropertyValue aNewValue;
1203 aNewValue.Value <<=
static_cast<sal_Int16
>(::cppu::any2bool(aBooleanValue));
1214 const Reference< XNameContainer >& _rxParentContainer,
1228 bool bMakeAbsolute =
1229 (nElement &
TOKEN_MASK) == s_nImageDataAttributeName
1230 || ( (nElement &
TOKEN_MASK) == s_nTargetLocationAttributeName
1236 if (bMakeAbsolute && !_rValue.isEmpty())
1238 OUString sAdjustedValue = _rValue;
1239 if ((nElement &
TOKEN_MASK) != s_nImageDataAttributeName)
1249 const Reference< XNameContainer >& _rxParentContainer,
1267 :
OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1268 ,m_nStepSizeValue( 1 )
1298 const Reference< XNameContainer >& _rxParentContainer,
1300 :
OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1301 ,m_bEncounteredTextPara( false )
1308 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1313 "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" );
1317 Reference< XText > xTextElement(
m_xElement, UNO_QUERY );
1318 if ( xTextElement.is() )
1325 m_xCursor = xTextElement->createTextCursor();
1328 xTextImportHelper->SetCursor(
m_xCursor );
1364 explicit EqualHandle( sal_Int32 _nHandle ) :
m_nHandle( _nHandle ) { }
1366 bool operator()(
const PropertyValue& _rProp )
1385 PropertyValueArray::iterator aValuePropertyPos = ::std::find_if(
1390 if ( aValuePropertyPos !=
m_aValues.end() )
1392 OSL_ENSURE( aValuePropertyPos->Name ==
PROPERTY_TEXT,
"OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" );
1401 bool bHasRichTextProperty =
false;
1404 OSL_ENSURE( bHasRichTextProperty,
"OTextLikeImport::EndElement: text:p, but no rich text control?" );
1405 if ( bHasRichTextProperty )
1416 explicit EqualName(
const OUString& _rName ) :
m_sName( _rName ) { }
1418 bool operator()(
const PropertyValue& _rProp )
1420 return _rProp.Name ==
m_sName;
1431 PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if(
1434 EqualName(
"DefaultControl" )
1436 if ( aDefaultControlPropertyPos !=
m_aValues.end() )
1438 OUString sDefaultControl;
1439 OSL_VERIFY( aDefaultControlPropertyPos->Value >>= sDefaultControl );
1440 if ( sDefaultControl ==
"stardiv.one.form.control.Edit" )
1444 m_aValues.erase(aDefaultControlPropertyPos);
1468 xTextImportHelper->ResetCursor();
1478 const Reference< XNameContainer >& _rxParentContainer,
1480 :
OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1481 ,m_nEmptyListItems( 0 )
1482 ,m_nEmptyValueItems( 0 )
1483 ,m_bEncounteredLSAttrib( false )
1484 ,m_bLinkWithIndexes( false )
1492 const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList )
1528 PropertyValue aItemList;
1536 "OListAndComboImport::EndElement: inconsistence between labels and values!");
1541 PropertyValue aValueList;
1548 PropertyValue aSelected;
1554 PropertyValue aDefaultSelected;
1569 OUString sBoundCellAddress( _rBoundCellAddress );
1576 sBoundCellAddress +=
":index";
1585 if ( (nElement &
TOKEN_MASK) == nListSourceAttributeName )
1587 PropertyValue aListSource;
1594 aListSource.Value <<= _rValue;
1601 Sequence<OUString> aListSourcePropValue { _rValue };
1602 aListSource.Value <<= aListSourcePropValue;
1617 sal_Int16 nLinkageType = 0;
1633 OSL_ENSURE(!
m_nEmptyListItems,
"OListAndComboImport::implPushBackValue: label list is already done!");
1640 OSL_ENSURE(!
m_nEmptyValueItems,
"OListAndComboImport::implPushBackValue: value list is already done!");
1643 OSL_ENSURE( !
m_bEncounteredLSAttrib,
"OListAndComboImport::implPushBackValue: invalid structure! Did you save this document with a version prior SRC641 m?" );
1666 "OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!");
1675 "OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!");
1685 ,m_xListBoxImport(
std::move(_xListBox))
1692 const sal_Int32 nLabelAttribute = (nElement & ~TOKEN_MASK) |
XML_LABEL;
1693 const sal_Int32 nValueAttribute = (nElement & ~TOKEN_MASK) |
XML_VALUE;
1696 OUString sValue = _rxAttrList->getOptionalValue(nLabelAttribute);
1697 bool bNonexistentAttribute = !_rxAttrList->hasAttribute(nLabelAttribute);
1699 if (bNonexistentAttribute)
1705 sValue = _rxAttrList->getOptionalValue(nValueAttribute);
1706 bNonexistentAttribute = !_rxAttrList->hasAttribute(nValueAttribute);
1708 if (bNonexistentAttribute)
1718 bool bSelected(
false);
1720 _rxAttrList->getOptionalValue(nSelectedAttribute));
1725 bool bDefaultSelected(
false);
1727 _rxAttrList->getOptionalValue(nDefaultSelectedAttribute));
1728 if (bDefaultSelected)
1736 ,m_xListBoxImport(
std::move(_xListBox))
1742 const sal_Int32 nLabelAttributeName = (nElement & ~TOKEN_MASK) |
1744 m_xListBoxImport->implPushBackLabel(_rxAttrList->getOptionalValue(nLabelAttributeName));
1750 const Reference< XNameContainer >& _rxParentContainer)
1753 ,m_rFormImport(_rImport)
1754 ,m_rEventManager(_rEventManager)
1759 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
1764 OSL_ENSURE(
m_xOwnAttributes.is(),
"OColumnWrapperImport::CreateChildContext: had no form:column element!");
1771 OSL_ENSURE(!
m_xOwnAttributes.is(),
"OColumnWrapperImport::StartElement: already have the cloned list!");
1774 Reference< XCloneable > xCloneList(_rxAttrList, UNO_QUERY_THROW);
1790 "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!");
1813 const Reference< XNameContainer >& _rxParentContainer,
1822 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1831 OSL_FAIL(
"OGridImport::CreateChildContext: don't have an element!");
1844 css::uno::Reference< css::container::XIndexAccess > xIndexContainer(
m_xMeAsContainer, css::uno::UNO_QUERY);
1845 if (xIndexContainer.is())
1860 OSL_FAIL(
"OContainerImport::createElement: invalid element (no XNameContainer) created!");
1869 const Reference< XNameContainer >& _rxParentContainer)
1877 const uno::Reference< xml::sax::XFastAttributeList>& _rxAttrList )
1936 css::uno::Reference< css::container::XIndexAccess > xIndexContainer(
m_xMeAsContainer, css::uno::UNO_QUERY);
1937 if (xIndexContainer.is())
1954 OSL_FAIL(
"OContainerImport::createElement: invalid element (no XNameContainer) created!");
1967 if ( (nElement &
TOKEN_MASK) == s_nMasterFieldsAttributeName)
1973 if ( (nElement &
TOKEN_MASK) == s_nDetailFieldsAttributeName)
1984 PropertyValue aProp;
1985 aProp.Name = _rPropertyName;
1987 Sequence< OUString > aList;
1990 if (!_rValue.isEmpty())
1994 ::std::vector< OUString > aElements;
1996 sal_Int32 nEstimate = 0,
nLength = _rValue.getLength();
1998 for (sal_Int32
i=0;
i<
nLength; ++
i, ++pChars)
2001 aElements.reserve(nEstimate + 1);
2004 sal_Int32 nElementStart = 0;
2005 sal_Int32 nNextSep = 0;
2010 _rValue, nElementStart);
2013 std::u16string_view sElement = _rValue.subView(nElementStart, nNextSep - nElementStart);
2015 size_t nElementLength = sElement.size();
2018 "OFormImport::implTranslateStringListProperty: invalid quoted element name.");
2019 sElement = sElement.substr(1, nElementLength - 2);
2021 aElements.push_back(OUString(sElement));
2024 nElementStart = 1 + nNextSep;
2026 while (nElementStart <
nLength);
2028 aList = Sequence< OUString >(aElements.data(), aElements.size());
2032 OSL_FAIL(
"OFormImport::implTranslateStringListProperty: invalid value (empty)!");
2035 aProp.Value <<= aList;
2042 SvXMLImport& _rImport
2043 ,
const Reference< css::xml::sax::XFastAttributeList > & _xAttrList
2044 ,
const css::uno::Reference< css::beans::XPropertySet >& _xElement) :
2049 if ( aIter.getToken() ==
2052 OUString sValue = aIter.toString();
2053 sValue = _rImport.GetAbsoluteReference(sValue);
2055 if (
aURL.GetProtocol() == INetProtocol::File )
2062 SAL_WARN(
"xmloff",
"unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
"=" << aIter.toString());
2068 return "com.sun.star.form.component.Form";
const PropertyValue * pValues
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
const OUString & GetDataStyleName() const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static sal_Int32 indexOfComma(std::u16string_view rStr, sal_Int32 nPos)
static bool convertBool(bool &rBool, std::u16string_view rString)
const AttributeAssignment * getAttributeTranslation(sal_Int32 nAttributeToken)
return the AttributeAssignment which corresponds to the given attribute
helper class importing a single grid column (without the <form:column> element wrapping the column).
OControlImport * implCreateChildContext(sal_Int32 nElement, OControlElement::ElementType _eType)
OColumnWrapperImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, sal_Int32 nElement, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
IEventAttacherManager & m_rEventManager
OFormLayerXMLImport_Impl & m_rFormImport
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOwnAttributes
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
OListAndComboImportRef m_xListBoxImport
OComboItemImport(SvXMLImport &_rImport, OListAndComboImportRef _xListBox)
helper for translating between control types and XML tags
static sal_Int32 getElementToken(ElementType _eType)
retrieves the tag name to be used to describe a control of the given type
helper class for importing the description of a single control
OUString m_sSubmissionID
name of a submission (xforms:submission attribute)
static void implTranslateValueProperty(const css::uno::Reference< css::beans::XPropertySetInfo > &_rxPropInfo, css::beans::PropertyValue &_rPropValue)
OUString m_sListBindingID
name of a list binding (form:xforms-list-source attribute)
void doRegisterXFormsValueBinding(const OUString &)
register the given XForms binding
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOuterAttributes
void setElementType(OControlElement::ElementType _eType)
void doRegisterXFormsSubmission(const OUString &)
register the given XForms submission
OUString m_sBoundCellAddress
the address of the calc cell which the control model should be bound to, if applicable
virtual OUString determineDefaultServiceName() const override
void addOuterAttributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxOuterAttribs)
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress)
registers the given cell address as value binding address for our element
OControlElement::ElementType m_eElementType
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
OUString m_sBindingID
name of a value binding (xforms:bind attribute)
PropertyValueArray m_aValueProperties
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
void doRegisterXFormsListBinding(const OUString &)
register the given XForms list binding
void setEvents(const css::uno::Reference< css::container::XIndexAccess > &_rxContainer)
implements common behaviour for importing forms, controls and columns
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
void implApplySpecificProperties()
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
PropertyGroups::const_iterator impl_matchPropertyGroup(const PropertyGroups &i_propertyGroups) const
virtual css::uno::Reference< css::beans::XPropertySet > createElement()
create the (uninitialized) element which is to represent the read data
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
the parent container to insert the new element into
virtual ~OElementImport() override
OElementImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
ctor
bool tryGenericAttribute(sal_Int32 nElement, const OUString &_rValue)
to be called from within handleAttribute, checks whether the given attribute is covered by our generi...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::beans::XPropertySet > m_xElement
the element we're creating. Valid after StartElement
OFormLayerXMLImport_Impl & m_rFormImport
OUString implGetDefaultName() const
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void disableImplicitGenericAttributeHandling()
controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived cla...
const XMLTextStyleContext * m_pStyleElement
virtual OUString determineDefaultServiceName() const
void implApplyGenericProperties()
void simulateDefaultedAttribute(sal_Int32 nElement, const OUString &_rPropertyName, const char *_pAttributeDefault)
can be used to handle properties where the attribute default and the property default differ.
static ElementType getElementType(sal_Int32 nToken)
static std::map< sal_Int32, ElementType > s_sElementTranslations2
helper class importing a single <form:grid> element
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
OGridImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
OImagePositionImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
css::uno::Reference< css::graphic::XGraphic > m_xGraphic
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
sal_Int16 m_nImagePosition
bool m_bHaveImagePosition
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
A specialized version of the <type>OControlImport</type> class, which handles attributes / sub elemen...
std::vector< sal_Int16 > m_aDefaultSelectedSeq
void implPushBackLabel(const OUString &_rLabel)
void implDefaultSelectCurrentItem()
bool m_bEncounteredLSAttrib
number of empty value items encountered during reading
void implSelectCurrentItem()
std::vector< sal_Int16 > m_aSelectedSeq
void implPushBackValue(const OUString &_rValue)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress) override
registers the given cell address as value binding address for our element
sal_Int32 m_nEmptyValueItems
number of empty list items encountered during reading
friend class OComboItemImport
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
std::vector< OUString > m_aValueList
std::vector< OUString > m_aListSource
void implEmptyLabelFound()
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
void implEmptyValueFound()
friend class OListOptionImport
OUString m_sCellListSource
sal_Int32 m_nEmptyListItems
the cell range which acts as list source for the control
OListAndComboImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
<TRUE> if and only if we should use a cell value binding which exchanges the selection index (instead...
OListOptionImport(SvXMLImport &_rImport, OListAndComboImportRef _xListBox)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
OListAndComboImportRef m_xListBoxImport
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OPasswordImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
Helper class for importing property values.
PropertyValueArray m_aValues
void implPushBackPropertyValue(const css::beans::PropertyValue &_rProp)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
void enableTrackAttributes()
enables the tracking of the encountered attributes
PropertyValueArray m_aGenericValues
OFormLayerXMLImport_Impl & m_rContext
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
ORadioImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OReferredControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
OUString m_sReferringControls
A specialized version of the <type>OControlImport</type> class, which handles text like controls whic...
bool m_bEncounteredTextPara
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void removeRedundantCurrentValue()
void adjustDefaultControlProperty()
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::text::XTextCursor > m_xCursor
css::uno::Reference< css::text::XTextCursor > m_xOldCursor
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
OTextLikeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
a specialized version of the <type>OControlImport</type> class, which is able to handle attributes wh...
OURLReferenceImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
A specialized version of the <type>OControlImport</type> class, which imports the value-range element...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
sal_Int32 m_nStepSizeValue
OValueRangeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
OXMLDataSourceImport(SvXMLImport &_rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const css::uno::Reference< css::beans::XPropertySet > &_xElement)
static css::uno::Any convertString(const css::uno::Type &_rExpectedType, const OUString &_rReadCharacters, const SvXMLEnumMapEntry< EnumT > *_pEnumMap=nullptr)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_RETURN(c, m, r)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XContent > m_xParentContainer
#define PROPID_CURRENT_VALUE
const sal_Int32 m_nHandle
Reference< beans::XPropertySetInfo > m_xInfo
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define LEAVE_LOG_CONTEXT()
#define ENTER_LOG_CONTEXT(name)
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
Type getSequenceElementType(const Type &_rSequenceType)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
constexpr OUStringLiteral first
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_CONNECTION_RESOURCE
@ XML_CONTROL_IMPLEMENTATION
constexpr OUStringLiteral PROPERTY_SPIN_INCREMENT
constexpr OUStringLiteral PROPERTY_ECHOCHAR
constexpr OUStringLiteral PROPERTY_SELECT_SEQ
::std::vector< PropertyDescriptionList > PropertyGroups
constexpr OUStringLiteral PROPERTY_DETAILFIELDS
constexpr OUStringLiteral PROPERTY_TARGETFRAME
constexpr OUStringLiteral PROPERTY_GRAPHIC
::std::map< PropertyId, css::uno::Any > PropertyValues
constexpr OUStringLiteral PROPERTY_CLASSID
constexpr OUStringLiteral PROPERTY_LINE_INCREMENT
const OControlElement::ElementType & operator++(OControlElement::ElementType &_e)
constexpr OUStringLiteral PROPERTY_URL
const SvXMLEnumMapEntry< sal_uInt16 > aImageAlignMap[]
constexpr OUStringLiteral PROPERTY_DEFAULT_SELECT_SEQ
constexpr OUStringLiteral PROPERTY_EFFECTIVE_DEFAULT
const SvXMLEnumMapEntry< sal_Int16 > aImagePositionMap[]
constexpr OUStringLiteral PROPERTY_REPEAT_DELAY
constexpr OUStringLiteral PROPERTY_RICH_TEXT
constexpr OUStringLiteral PROPERTY_TEXT
constexpr OUStringLiteral PROPERTY_LISTSOURCE
::std::vector< const PropertyDescription * > PropertyDescriptionList
constexpr OUStringLiteral PROPERTY_EFFECTIVE_VALUE
const SvXMLEnumMapEntry< sal_Int16 > aListLinkageMap[]
constexpr OUStringLiteral PROPERTY_EMPTY_IS_NULL
constexpr OUStringLiteral PROPERTY_STRING_ITEM_LIST
constexpr OUStringLiteral PROPERTY_MASTERFIELDS
constexpr OUStringLiteral PROPERTY_DATASOURCENAME
constexpr OUStringLiteral PROPERTY_ALIGN
constexpr OUStringLiteral PROPERTY_AUTOCOMPLETE
constexpr OUStringLiteral PROPERTY_IMAGE_POSITION
const SvXMLEnumMapEntry< sal_uInt16 > * pEnumMap
css::uno::Type aPropertyType
const Reference< XComponentContext > & m_rContext
Reference< xml::input::XElement > m_xElement
#define XML_ELEMENT(prefix, name)
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
constexpr sal_Int32 TOKEN_MASK
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_XML
constexpr sal_uInt16 XML_NAMESPACE_OOO