LibreOffice Module xmloff (master)  1
elementimport.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 #include "elementimport.hxx"
21 #include <xmloff/xmlimp.hxx>
22 #include <xmloff/namespacemap.hxx>
23 #include "strings.hxx"
24 #include "callbacks.hxx"
25 #include <xmloff/xmlnamespace.hxx>
26 #include "eventimport.hxx"
27 #include <xmloff/txtstyli.hxx>
28 #include "formenums.hxx"
29 #include <xmloff/xmltoken.hxx>
31 #include "property_description.hxx"
32 #include "property_meta_data.hxx"
33 
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/text/XText.hpp>
36 #include <com/sun/star/util/XCloneable.hpp>
37 #include <com/sun/star/util/Duration.hpp>
38 #include <com/sun/star/form/FormComponentType.hpp>
39 #include <com/sun/star/awt/ImagePosition.hpp>
40 #include <com/sun/star/beans/XMultiPropertySet.hpp>
41 #include <com/sun/star/beans/XPropertyContainer.hpp>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 
44 #include <sax/tools/converter.hxx>
45 #include <tools/urlobj.hxx>
46 #include <tools/diagnose_ex.h>
47 #include <rtl/strbuf.hxx>
48 #include <sal/log.hxx>
49 #include <comphelper/extract.hxx>
50 #include <comphelper/types.hxx>
51 #include <comphelper/sequence.hxx>
52 
53 #include <algorithm>
54 
55 namespace xmloff
56 {
57 
58  using namespace ::xmloff::token;
59  using namespace ::com::sun::star;
60  using namespace ::com::sun::star::uno;
61  using namespace ::com::sun::star::awt;
62  using namespace ::com::sun::star::container;
63  using namespace ::com::sun::star::beans;
64  using namespace ::com::sun::star::script;
65  using namespace ::com::sun::star::lang;
66  using namespace ::com::sun::star::form;
67  using namespace ::com::sun::star::xml;
68  using namespace ::com::sun::star::xml::sax;
69  using namespace ::com::sun::star::util;
70  using namespace ::com::sun::star::text;
71  using namespace ::comphelper;
72  using ::com::sun::star::xml::sax::XAttributeList;
73 
74 #define PROPID_VALUE 1
75 #define PROPID_CURRENT_VALUE 2
76 #define PROPID_MIN_VALUE 3
77 #define PROPID_MAX_VALUE 4
78 
79  namespace {
80 
81  struct PropertyValueLess
82  {
83  bool operator()(const PropertyValue& _rLeft, const PropertyValue& _rRight)
84  {
85  return _rLeft.Name < _rRight.Name;
86  }
87  };
88 
89  }
90 
91  //= OElementNameMap
92  std::map<sal_Int32, OControlElement::ElementType> OElementNameMap::s_sElementTranslations2;
93 
95  {
97  sal_Int32 nAsInt = static_cast<sal_Int32>(e);
98  _e = static_cast<OControlElement::ElementType>( ++nAsInt );
99  return _e;
100  }
101 
103  {
104  if ( s_sElementTranslations2.empty() )
105  { // initialize
108  }
109  auto aPos = s_sElementTranslations2.find(nElement & TOKEN_MASK);
110  if (s_sElementTranslations2.end() != aPos)
111  return aPos->second;
112 
113  return UNKNOWN;
114  }
115 
116  //= OElementImport
118  const Reference< XNameContainer >& _rxParentContainer)
119  :OPropertyImport(_rImport)
120  ,m_rFormImport(_rImport)
121  ,m_rEventManager(_rEventManager)
122  ,m_pStyleElement( nullptr )
123  ,m_xParentContainer(_rxParentContainer)
124  ,m_bImplicitGenericAttributeHandling( true )
125  {
126  OSL_ENSURE(m_xParentContainer.is(), "OElementImport::OElementImport: invalid parent container!");
127  }
128 
130  {
131  }
132 
134  {
135  return OUString();
136  }
137 
138  void OElementImport::startFastElement(sal_Int32 nElement, const Reference< css::xml::sax::XFastAttributeList >& _rxAttrList)
139  {
140  ENTER_LOG_CONTEXT( "xmloff::OElementImport - importing one element" );
141 
142  const OUString sControlImplementation = _rxAttrList->getOptionalValue( XML_ELEMENT(FORM, XML_CONTROL_IMPLEMENTATION) );
143 
144  // retrieve the service name
145  if ( !sControlImplementation.isEmpty() )
146  {
147  OUString sOOoImplementationName;
148  const sal_uInt16 nImplPrefix = GetImport().GetNamespaceMap().GetKeyByAttrValueQName( sControlImplementation, &sOOoImplementationName );
149  m_sServiceName = ( nImplPrefix == XML_NAMESPACE_OOO ) ? sOOoImplementationName : sControlImplementation;
150  }
151 
152  if ( m_sServiceName.isEmpty() )
154 
155  // create the object *now*. This allows setting properties in the various handleAttribute methods.
156  // (Though currently not all code is migrated to this pattern, most attributes are still handled
157  // by remembering the value (via implPushBackPropertyValue), and setting the correct property value
158  // later (in OControlImport::StartElement).)
160  if ( m_xElement.is() )
161  m_xInfo = m_xElement->getPropertySetInfo();
162 
163  // call the base class
164  OPropertyImport::startFastElement( nElement, _rxAttrList );
165  }
166 
167  css::uno::Reference< css::xml::sax::XFastContextHandler > OElementImport::createFastChildContext(
168  sal_Int32 nElement,
169  const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList )
170  {
171  if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
173 
174  return OPropertyImport::createFastChildContext(nElement, _rxAttrList);
175  }
176 
178  {
179  OSL_ENSURE(m_xElement.is(), "OElementImport::EndElement: invalid element created!");
180  if (!m_xElement.is())
181  return;
182 
183  // apply the non-generic properties
185 
186  // set the generic properties
188 
189  // set the style properties
190  if ( m_pStyleElement && m_xElement.is() )
191  {
192  Reference< XPropertySet > xPropTranslation =
193  new OGridColumnPropertyTranslator( Reference< XMultiPropertySet >( m_xElement, UNO_QUERY ) );
194  const_cast< XMLTextStyleContext* >( m_pStyleElement )->FillPropertySet( xPropTranslation );
195 
196  const OUString sNumberStyleName = m_pStyleElement->GetDataStyleName( );
197  if ( !sNumberStyleName.isEmpty() )
198  // the style also has a number (sub) style
199  m_rContext.applyControlNumberStyle( m_xElement, sNumberStyleName );
200  }
201 
202  // insert the element into the parent container
203  if (m_sName.isEmpty())
204  {
205  OSL_FAIL("OElementImport::EndElement: did not find a name attribute!");
207  }
208 
209  if (m_xParentContainer.is())
210  m_xParentContainer->insertByName(m_sName, makeAny(m_xElement));
211 
213  }
214 
216  {
217  if ( m_aValues.empty() )
218  return;
219 
220  // set all the properties we collected
221 #if OSL_DEBUG_LEVEL > 0
222  // check if the object has all the properties
223  // (We do this in the non-pro version only. Doing it all the time would be too much expensive)
224  if ( m_xInfo.is() )
225  {
226  for ( const auto& rCheck : m_aValues )
227  {
228  OSL_ENSURE(m_xInfo->hasPropertyByName(rCheck.Name),
229  OStringBuffer("OElementImport::implApplySpecificProperties: read a property (" +
230  OUStringToOString(rCheck.Name, RTL_TEXTENCODING_ASCII_US) +
231  ") which does not exist on the element!").getStr());
232  }
233  }
234 #endif
235 
236  // set the properties
237  const Reference< XMultiPropertySet > xMultiProps(m_xElement, UNO_QUERY);
238  bool bSuccess = false;
239  if (xMultiProps.is())
240  {
241  // translate our properties so that the XMultiPropertySet can handle them
242 
243  // sort our property value array so that we can use it in a setPropertyValues
244  ::std::sort( m_aValues.begin(), m_aValues.end(), PropertyValueLess());
245 
246  // the names
247  Sequence< OUString > aNames(m_aValues.size());
248  OUString* pNames = aNames.getArray();
249  // the values
250  Sequence< Any > aValues(m_aValues.size());
251  Any* pValues = aValues.getArray();
252  // copy
253 
254  for ( const auto& rPropValues : m_aValues )
255  {
256  *pNames = rPropValues.Name;
257  *pValues = rPropValues.Value;
258  ++pNames;
259  ++pValues;
260  }
261 
262  try
263  {
264  xMultiProps->setPropertyValues(aNames, aValues);
265  bSuccess = true;
266  }
267  catch(const Exception&)
268  {
269  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
270  OSL_FAIL("OElementImport::implApplySpecificProperties: could not set the properties (using the XMultiPropertySet)!");
271  }
272  }
273 
274  if (bSuccess)
275  return;
276 
277  // no XMultiPropertySet or setting all properties at once failed
278  for ( const auto& rPropValues : m_aValues )
279  {
280  // this try/catch here is expensive, but because this is just a fallback which should normally not be
281  // used it's acceptable this way ...
282  try
283  {
284  m_xElement->setPropertyValue(rPropValues.Name, rPropValues.Value);
285  }
286  catch(const Exception&)
287  {
288  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
289  OSL_FAIL(OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \"" +
290  OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) +
291  "\"!").getStr());
292  }
293  }
294  }
295 
297  {
298  if ( m_aGenericValues.empty() )
299  return;
300 
301  Reference< XPropertyContainer > xDynamicProperties( m_xElement, UNO_QUERY );
302 
303  // PropertyValueArray::iterator aEnd = m_aGenericValues.end();
304  for ( auto& rPropValues : m_aGenericValues )
305  {
306  // check property type for numeric types before setting
307  // the property
308  try
309  {
310  // if such a property does not yet exist at the element, create it if necessary
311  const bool bExistentProperty = m_xInfo->hasPropertyByName( rPropValues.Name );
312  if ( !bExistentProperty )
313  {
314  if ( !xDynamicProperties.is() )
315  {
316  SAL_WARN( "xmloff", "OElementImport::implApplyGenericProperties: encountered an unknown property ("
317  << rPropValues.Name << "), but component is no PropertyBag!");
318  continue;
319  }
320 
321  xDynamicProperties->addProperty(
322  rPropValues.Name,
323  PropertyAttribute::BOUND | PropertyAttribute::REMOVABLE,
324  rPropValues.Value
325  );
326 
327  // re-fetch the PropertySetInfo
328  m_xInfo = m_xElement->getPropertySetInfo();
329  }
330 
331  // determine the type of the value (source for the following conversion)
332  TypeClass eValueTypeClass = rPropValues.Value.getValueTypeClass();
333  const bool bValueIsSequence = TypeClass_SEQUENCE == eValueTypeClass;
334  if ( bValueIsSequence )
335  {
336  uno::Type aSimpleType( getSequenceElementType( rPropValues.Value.getValueType() ) );
337  eValueTypeClass = aSimpleType.getTypeClass();
338  }
339 
340  // determine the type of the property (target for the following conversion)
341  const Property aProperty( m_xInfo->getPropertyByName( rPropValues.Name ) );
342  TypeClass ePropTypeClass = aProperty.Type.getTypeClass();
343  const bool bPropIsSequence = TypeClass_SEQUENCE == ePropTypeClass;
344  if( bPropIsSequence )
345  {
346  uno::Type aSimpleType( ::comphelper::getSequenceElementType( aProperty.Type ) );
347  ePropTypeClass = aSimpleType.getTypeClass();
348  }
349 
350  if ( bPropIsSequence != bValueIsSequence )
351  {
352  OSL_FAIL( "OElementImport::implImportGenericProperties: either both value and property should be a sequence, or none of them!" );
353  continue;
354  }
355 
356  if ( bValueIsSequence )
357  {
358  Sequence< Any > aXMLValueList;
359  rPropValues.Value >>= aXMLValueList;
360  // just skip this part if empty sequence
361  if (!aXMLValueList.getLength())
362  continue;
363 
364  Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() );
365 
366  SAL_WARN_IF( eValueTypeClass != TypeClass_ANY, "xmloff",
367  "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" );
368  // (OPropertyImport should produce only Sequencer< Any >, since it cannot know the real type
369 
370  SAL_WARN_IF( ePropTypeClass != TypeClass_SHORT, "xmloff",
371  "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" );
372 
373 
374  std::transform(aXMLValueList.begin(), aXMLValueList.end(), aPropertyValueList.begin(),
375  [](const Any& rXMLValue) -> sal_Int16 {
376  // only value sequences of numeric types implemented so far.
377  double nVal( 0 );
378  OSL_VERIFY( rXMLValue >>= nVal );
379  return static_cast< sal_Int16 >( nVal );
380  });
381 
382  rPropValues.Value <<= aPropertyValueList;
383  }
384  else if ( ePropTypeClass != eValueTypeClass )
385  {
386  switch ( eValueTypeClass )
387  {
388  case TypeClass_DOUBLE:
389  {
390  double nVal = 0;
391  rPropValues.Value >>= nVal;
392  switch( ePropTypeClass )
393  {
394  case TypeClass_BYTE:
395  rPropValues.Value <<= static_cast< sal_Int8 >( nVal );
396  break;
397  case TypeClass_SHORT:
398  rPropValues.Value <<= static_cast< sal_Int16 >( nVal );
399  break;
400  case TypeClass_UNSIGNED_SHORT:
401  rPropValues.Value <<= static_cast< sal_uInt16 >( nVal );
402  break;
403  case TypeClass_LONG:
404  case TypeClass_ENUM:
405  rPropValues.Value <<= static_cast< sal_Int32 >( nVal );
406  break;
407  case TypeClass_UNSIGNED_LONG:
408  rPropValues.Value <<= static_cast< sal_uInt32 >( nVal );
409  break;
410  case TypeClass_UNSIGNED_HYPER:
411  rPropValues.Value <<= static_cast< sal_uInt64 >( nVal );
412  break;
413  case TypeClass_HYPER:
414  rPropValues.Value <<= static_cast< sal_Int64 >( nVal );
415  break;
416  default:
417  OSL_FAIL( "OElementImport::implImportGenericProperties: unsupported value type!" );
418  break;
419  }
420  }
421  break;
422  default:
423  OSL_FAIL( "OElementImport::implImportGenericProperties: non-double values not supported!" );
424  break;
425  }
426  }
427 
428  m_xElement->setPropertyValue( rPropValues.Name, rPropValues.Value );
429  }
430  catch(const Exception&)
431  {
432  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
433  OSL_FAIL(OStringBuffer("OElementImport::EndElement: could not set the property \"" +
434  OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) +
435  "\"!").getStr());
436  }
437  }
438  }
439 
441  {
442  // no optimization here. If this method gets called, the XML stream did not contain a name for the
443  // element, which is a heavy error. So in this case we don't care for performance
444  static constexpr OUStringLiteral sUnnamedName = u"unnamed";
445  OSL_ENSURE(m_xParentContainer.is(), "OElementImport::implGetDefaultName: no parent container!");
446  if (!m_xParentContainer.is())
447  return sUnnamedName;
448  Sequence< OUString > aNames = m_xParentContainer->getElementNames();
449 
450  for (sal_Int32 i=0; i<32768; ++i) // the limit is nearly arbitrary...
451  {
452  // assemble the new name (suggestion)
453  OUString sReturn = sUnnamedName + OUString::number(i);
454  // check the existence (this is the bad performance part...)
455  if (comphelper::findValue(aNames, sReturn) == -1)
456  // not found the name
457  return sReturn;
458  }
459  OSL_FAIL("OElementImport::implGetDefaultName: did not find a free name!");
460  return sUnnamedName;
461  }
462 
463  PropertyGroups::const_iterator OElementImport::impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const
464  {
465  ENSURE_OR_RETURN( m_xInfo.is(), "OElementImport::impl_matchPropertyGroup: no property set info!", i_propertyGroups.end() );
466 
467  return std::find_if(i_propertyGroups.cbegin(), i_propertyGroups.cend(), [&](const PropertyDescriptionList& rGroup) {
468  return std::all_of(rGroup.cbegin(), rGroup.cend(), [&](const PropertyDescription* prop) {
469  return m_xInfo->hasPropertyByName( prop->propertyName );
470  });
471  });
472  }
473 
474  bool OElementImport::tryGenericAttribute( sal_Int32 nElement, const OUString& _rValue )
475  {
476  // the generic approach (which I hope all props will be migrated to, on the medium term): property handlers
478  if ( attribute.attributeToken != XML_TOKEN_INVALID )
479  {
480  PropertyGroups propertyGroups;
481  metadata::getPropertyGroupList( attribute, propertyGroups );
482  const PropertyGroups::const_iterator pos = impl_matchPropertyGroup( propertyGroups );
483  if ( pos == propertyGroups.end() )
484  return false;
485 
486  do
487  {
488  const PropertyDescriptionList& rProperties( *pos );
489  const PropertyDescription* first = *rProperties.begin();
490  if ( !first )
491  {
492  SAL_WARN( "xmloff.forms", "OElementImport::handleAttribute: invalid property description!" );
493  break;
494  }
495 
496  const PPropertyHandler handler = (*first->factory)( first->propertyId );
497  if ( !handler )
498  {
499  SAL_WARN( "xmloff.forms", "OElementImport::handleAttribute: invalid property handler!" );
500  break;
501  }
502 
503  PropertyValues aValues;
504  for ( const auto& propDesc : rProperties )
505  {
506  aValues[ propDesc->propertyId ] = Any();
507  }
508  if ( handler->getPropertyValues( _rValue, aValues ) )
509  {
510  for ( const auto& propDesc : rProperties )
511  {
512  implPushBackPropertyValue( propDesc->propertyName, aValues[ propDesc->propertyId ] );
513  }
514  }
515  }
516  while ( false );
517 
518  // handled
519  return true;
520  }
521  return false;
522  }
523 
524  bool OElementImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
525  {
526  auto nLocal = nElement & TOKEN_MASK;
527  if ( nLocal == XML_CONTROL_IMPLEMENTATION )
528  // ignore this, it has already been handled in OElementImport::StartElement
529  return true;
530 
531  if ( nLocal == XML_NAME )
532  {
533  if ( m_sName.isEmpty() )
534  // remember the name for later use in EndElement
535  m_sName = _rValue;
536  return true;
537  }
538 
539  // maybe it's the style attribute?
540  if ( nLocal == XML_TEXT_STYLE_NAME )
541  {
542  const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue );
543  OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" );
544  // remember the element for later usage.
545  m_pStyleElement = dynamic_cast<const XMLTextStyleContext*>( pStyleContext );
546  return true;
547  }
548 
550  if ( tryGenericAttribute( nElement, _rValue ) )
551  return true;
552 
553  // let the base class handle it
554  return OPropertyImport::handleAttribute( nElement, _rValue);
555  }
556 
558  {
560  if (!m_sServiceName.isEmpty())
561  {
563  Reference< XInterface > xPure = xContext->getServiceManager()->createInstanceWithContext(m_sServiceName, xContext);
564  OSL_ENSURE(xPure.is(),
565  OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: " +
566  OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) +
567  ")!").getStr());
568  xReturn.set(xPure, UNO_QUERY);
569  }
570  else
571  OSL_FAIL("OElementImport::createElement: no service name to create an element!");
572 
573  return xReturn;
574  }
575 
576  void OElementImport::registerEvents(const Sequence< ScriptEventDescriptor >& _rEvents)
577  {
578  OSL_ENSURE(m_xElement.is(), "OElementImport::registerEvents: no element to register events for!");
580  }
581 
582  void OElementImport::simulateDefaultedAttribute(sal_Int32 nElement, const OUString& _rPropertyName, const char* _pAttributeDefault)
583  {
584  OSL_ENSURE( m_xInfo.is(), "OPropertyImport::simulateDefaultedAttribute: the component should be more gossipy about it's properties!" );
585 
586  if ( !m_xInfo.is() || m_xInfo->hasPropertyByName( _rPropertyName ) )
587  {
588  if ( !encounteredAttribute( nElement ) )
589  OSL_VERIFY( handleAttribute( XML_ELEMENT(FORM, (nElement & TOKEN_MASK)), OUString::createFromAscii( _pAttributeDefault ) ) );
590  }
591  }
592 
593  //= OControlImport
595  const Reference< XNameContainer >& _rxParentContainer)
596  :OElementImport(_rImport, _rEventManager, _rxParentContainer)
597  ,m_eElementType(OControlElement::UNKNOWN)
598  {
600  }
601 
602  OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
603  const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
604  :OElementImport(_rImport, _rEventManager, _rxParentContainer)
605  ,m_eElementType(_eType)
606  {
608  }
609 
611  {
612  const char* pServiceName = nullptr;
613  switch ( m_eElementType )
614  {
617  case OControlElement::PASSWORD: pServiceName = "com.sun.star.form.component.TextField"; break;
618  case OControlElement::FILE: pServiceName = "com.sun.star.form.component.FileControl"; break;
619  case OControlElement::FORMATTED_TEXT: pServiceName = "com.sun.star.form.component.FormattedField"; break;
620  case OControlElement::FIXED_TEXT: pServiceName = "com.sun.star.form.component.FixedText"; break;
621  case OControlElement::COMBOBOX: pServiceName = "com.sun.star.form.component.ComboBox"; break;
622  case OControlElement::LISTBOX: pServiceName = "com.sun.star.form.component.ListBox"; break;
623  case OControlElement::BUTTON: pServiceName = "com.sun.star.form.component.CommandButton"; break;
624  case OControlElement::IMAGE: pServiceName = "com.sun.star.form.component.ImageButton"; break;
625  case OControlElement::CHECKBOX: pServiceName = "com.sun.star.form.component.CheckBox"; break;
626  case OControlElement::RADIO: pServiceName = "com.sun.star.form.component.RadioButton"; break;
627  case OControlElement::FRAME: pServiceName = "com.sun.star.form.component.GroupBox"; break;
628  case OControlElement::IMAGE_FRAME: pServiceName = "com.sun.star.form.component.DatabaseImageControl"; break;
629  case OControlElement::HIDDEN: pServiceName = "com.sun.star.form.component.HiddenControl"; break;
630  case OControlElement::GRID: pServiceName = "com.sun.star.form.component.GridControl"; break;
631  case OControlElement::VALUERANGE: pServiceName = "com.sun.star.form.component.ScrollBar"; break;
632  case OControlElement::TIME: pServiceName = "com.sun.star.form.component.TimeField"; break;
633  case OControlElement::DATE: pServiceName = "com.sun.star.form.component.DateField"; break;
634  default: break;
635  }
636  if ( pServiceName != nullptr )
637  return OUString::createFromAscii( pServiceName );
638  return OUString();
639  }
640 
641  void OControlImport::addOuterAttributes(const Reference< XFastAttributeList >& _rxOuterAttribs)
642  {
643  OSL_ENSURE(!m_xOuterAttributes.is(), "OControlImport::addOuterAttributes: already have these attributes!");
644  m_xOuterAttributes = _rxOuterAttribs;
645  }
646 
647  bool OControlImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
648  {
649  static sal_Int32 nLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeToken(BAFlags::LinkedCell);
650 
651  if ((nElement & TOKEN_MASK) == XML_ID)
652  { // it's the control id
653  if (IsTokenInNamespace(nElement, XML_NAMESPACE_XML))
654  {
655  m_sControlId = _rValue;
656  }
657  else if (IsTokenInNamespace(nElement, XML_NAMESPACE_FORM))
658  {
659  if (m_sControlId.isEmpty())
660  {
661  m_sControlId = _rValue;
662  }
663  }
664  return true;
665  }
666 
667  if ( (nElement & TOKEN_MASK) == nLinkedCellAttributeName )
668  { // it's the address of a spreadsheet cell
669  m_sBoundCellAddress = _rValue;
670  return true;
671  }
672 
673  if ( nElement == XML_ELEMENT(XFORMS, XML_BIND ) )
674  {
675  m_sBindingID = _rValue;
676  return true;
677  }
678 
679  if ( nElement == XML_ELEMENT(FORM, XML_XFORMS_LIST_SOURCE) )
680  {
681  m_sListBindingID = _rValue;
682  return true;
683  }
684 
685  if ( nElement == XML_ELEMENT(FORM, XML_XFORMS_SUBMISSION)
686  || nElement == XML_ELEMENT(XFORMS, XML_SUBMISSION) )
687  {
688  m_sSubmissionID = _rValue;
689  return true;
690  }
691 
692  if ( OElementImport::tryGenericAttribute( nElement, _rValue ) )
693  return true;
694 
695  static const sal_Int32 nValueAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Value);
696  static const sal_Int32 nCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentValue);
697  static const sal_Int32 nMinValueAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::MinValue);
698  static const sal_Int32 nMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::MaxValue);
699  static const sal_Int32 nRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeToken( SCAFlags::RepeatDelay );
700 
701  sal_Int32 nHandle = -1;
702  if ( (nElement & TOKEN_MASK) == nValueAttributeName )
703  nHandle = PROPID_VALUE;
704  else if ( (nElement & TOKEN_MASK) == nCurrentValueAttributeName )
705  nHandle = PROPID_CURRENT_VALUE;
706  else if ( (nElement & TOKEN_MASK) == nMinValueAttributeName )
707  nHandle = PROPID_MIN_VALUE;
708  else if ( (nElement & TOKEN_MASK) == nMaxValueAttributeName )
709  nHandle = PROPID_MAX_VALUE;
710  if ( nHandle != -1 )
711  {
712  // for the moment, simply remember the name and the value
713  PropertyValue aProp;
714  aProp.Name = SvXMLImport::getNameFromToken(nElement);
715  aProp.Handle = nHandle;
716  aProp.Value <<= _rValue;
717  m_aValueProperties.push_back(aProp);
718  return true;
719  }
720 
721  if ( (nElement & TOKEN_MASK) == nRepeatDelayAttributeName )
722  {
723  util::Duration aDuration;
724  if (::sax::Converter::convertDuration(aDuration, _rValue))
725  {
726  PropertyValue aProp;
727  aProp.Name = PROPERTY_REPEAT_DELAY;
728  sal_Int32 const nMS =
729  ((aDuration.Hours * 60 + aDuration.Minutes) * 60
730  + aDuration.Seconds) * 1000 + aDuration.NanoSeconds/1000000;
731  aProp.Value <<= nMS;
732 
734  }
735  return true;
736  }
737 
738  return OElementImport::handleAttribute( nElement, _rValue );
739  }
740 
741  void OControlImport::startFastElement(sal_Int32 nElement, const Reference< css::xml::sax::XFastAttributeList >& _rxAttrList)
742  {
743  css::uno::Reference< css::xml::sax::XFastAttributeList > xMergedAttributes;
744  if( m_xOuterAttributes.is() )
745  {
746  // merge the attribute lists, our own one
748  // and the ones of our enclosing element
749  xMerger->add(m_xOuterAttributes);
750  xMergedAttributes = xMerger.get();
751  }
752  else
753  {
754  xMergedAttributes = _rxAttrList;
755  }
756 
757  // let the base class handle all the attributes
758  OElementImport::startFastElement(nElement, xMergedAttributes);
759 
760  if ( m_aValueProperties.empty() || !m_xElement.is())
761  return;
762 
763  // get the property set info
764  if (!m_xInfo.is())
765  {
766  OSL_FAIL("OControlImport::StartElement: no PropertySetInfo!");
767  return;
768  }
769 
770  const char* pValueProperty = nullptr;
771  const char* pCurrentValueProperty = nullptr;
772  const char* pMinValueProperty = nullptr;
773  const char* pMaxValueProperty = nullptr;
774 
775  bool bRetrievedValues = false;
776  bool bRetrievedValueLimits = false;
777 
778  // get the class id of our element
779  sal_Int16 nClassId = FormComponentType::CONTROL;
780  m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
781 
782  // translate the value properties we collected in handleAttributes
783  for ( auto& rValueProps : m_aValueProperties )
784  {
785  bool bSuccess = false;
786  switch (rValueProps.Handle)
787  {
788  case PROPID_VALUE:
790  {
791  // get the property names
792  if (!bRetrievedValues)
793  {
794  getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty);
795  if ( !pCurrentValueProperty && !pValueProperty )
796  {
797  SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value property names!" );
798  break;
799  }
800 
801  bRetrievedValues = true;
802  }
803  if ( PROPID_VALUE == rValueProps.Handle && !pValueProperty )
804  {
805  SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a value property!");
806  break;
807  }
808 
809  if ( PROPID_CURRENT_VALUE == rValueProps.Handle && !pCurrentValueProperty )
810  {
811  SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a current-value property!");
812  break;
813  }
814 
815  // transfer the name
816  if (PROPID_VALUE == rValueProps.Handle)
817  rValueProps.Name = OUString::createFromAscii(pValueProperty);
818  else
819  rValueProps.Name = OUString::createFromAscii(pCurrentValueProperty);
820  bSuccess = true;
821  }
822  break;
823  case PROPID_MIN_VALUE:
824  case PROPID_MAX_VALUE:
825  {
826  // get the property names
827  if (!bRetrievedValueLimits)
828  {
829  getValueLimitPropertyNames(nClassId, pMinValueProperty, pMaxValueProperty);
830  if ( !pMinValueProperty || !pMaxValueProperty )
831  {
832  SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value limit property names!" );
833  break;
834  }
835 
836  bRetrievedValueLimits = true;
837  }
838  OSL_ENSURE((PROPID_MIN_VALUE != rValueProps.Handle) || pMinValueProperty,
839  "OControlImport::StartElement: the control does not have a value property!");
840  OSL_ENSURE((PROPID_MAX_VALUE != rValueProps.Handle) || pMaxValueProperty,
841  "OControlImport::StartElement: the control does not have a current-value property!");
842 
843  // transfer the name
844  if (PROPID_MIN_VALUE == rValueProps.Handle)
845  rValueProps.Name = OUString::createFromAscii(pMinValueProperty);
846  else
847  rValueProps.Name = OUString::createFromAscii(pMaxValueProperty);
848  bSuccess = true;
849  }
850  break;
851  }
852 
853  if ( !bSuccess )
854  continue;
855 
856  // translate the value
857  implTranslateValueProperty(m_xInfo, rValueProps);
858  // add the property to the base class' array
859  implPushBackPropertyValue(rValueProps);
860  }
861 
862  }
863 
864  void OControlImport::implTranslateValueProperty(const Reference< XPropertySetInfo >& _rxPropInfo,
865  PropertyValue& _rPropValue)
866  {
867  OSL_ENSURE(_rxPropInfo->hasPropertyByName(_rPropValue.Name),
868  "OControlImport::implTranslateValueProperty: invalid property name!");
869 
870  // retrieve the type of the property
871  Property aProp = _rxPropInfo->getPropertyByName(_rPropValue.Name);
872  // the untranslated string value as read in handleAttribute
873  OUString sValue;
874  bool bSuccess = _rPropValue.Value >>= sValue;
875  OSL_ENSURE(bSuccess, "OControlImport::implTranslateValueProperty: supposed to be called with non-translated string values!");
876 
877  if (TypeClass_ANY == aProp.Type.getTypeClass())
878  {
879  // we have exactly 2 properties where this type class is allowed:
880  SAL_WARN_IF(
881  _rPropValue.Name != PROPERTY_EFFECTIVE_VALUE
882  && _rPropValue.Name != PROPERTY_EFFECTIVE_DEFAULT, "xmloff",
883  "OControlImport::implTranslateValueProperty: invalid property type/name combination, Any and " << _rPropValue.Name);
884 
885  // Both properties are allowed to have a double or a string value,
886  // so first try to convert the string into a number
887  double nValue;
888  if (::sax::Converter::convertDouble(nValue, sValue))
889  _rPropValue.Value <<= nValue;
890  else
891  _rPropValue.Value <<= sValue;
892  }
893  else
894  _rPropValue.Value = PropertyConversion::convertString(aProp.Type, sValue);
895  }
896 
897  void OControlImport::endFastElement(sal_Int32 nElement)
898  {
899  OSL_ENSURE(m_xElement.is(), "OControlImport::EndElement: invalid control!");
900  if ( !m_xElement.is() )
901  return;
902 
903  // register our control with its id
904  if (!m_sControlId.isEmpty())
906  // it's allowed to have no control id. In this case we're importing a column
907 
908  // one more pre-work to do:
909  // when we set default values, then by definition the respective value is set
910  // to this default value, too. This means if the sequence contains for example
911  // a DefaultText value, then the Text will be affected by this, too.
912  // In case the Text is not part of the property sequence (or occurs _before_
913  // the DefaultText, which can happen for other value/default-value property names),
914  // this means that the Text (the value property) is incorrectly imported.
915 
916  bool bRestoreValuePropertyValue = false;
917  Any aValuePropertyValue;
918 
919  sal_Int16 nClassId = FormComponentType::CONTROL;
920  try
921  {
922  // get the class id of our element
923  m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
924  }
925  catch( const Exception& )
926  {
927  TOOLS_WARN_EXCEPTION("xmloff.forms",
928  "caught an exception while retrieving the class id!");
929  }
930 
931  const char* pValueProperty = nullptr;
932  const char* pDefaultValueProperty = nullptr;
933  getRuntimeValuePropertyNames(m_eElementType, nClassId, pValueProperty, pDefaultValueProperty);
934  if ( pDefaultValueProperty && pValueProperty )
935  {
936  bool bNonDefaultValuePropertyValue = false;
937  // is the "value property" part of the sequence?
938 
939  // look up this property in our sequence
940  for ( const auto& rCheck : m_aValues )
941  {
942  if ( rCheck.Name.equalsAscii( pDefaultValueProperty ) )
943  bRestoreValuePropertyValue = true;
944  else if ( rCheck.Name.equalsAscii( pValueProperty ) )
945  {
946  bNonDefaultValuePropertyValue = true;
947  // we need to restore the value property we found here, nothing else
948  aValuePropertyValue = rCheck.Value;
949  }
950  }
951 
952  if ( bRestoreValuePropertyValue && !bNonDefaultValuePropertyValue )
953  {
954  // found it -> need to remember (and restore) the "value property value", which is not set explicitly
955  try
956  {
957  aValuePropertyValue = m_xElement->getPropertyValue( OUString::createFromAscii( pValueProperty ) );
958  }
959  catch( const Exception& )
960  {
962  "xmloff.forms",
963  "caught an exception while retrieving the current value property!");
964  }
965  }
966  }
967 
968  // let the base class set all the values
970 
971  // restore the "value property value", if necessary
972  if ( bRestoreValuePropertyValue && pValueProperty )
973  {
974  try
975  {
976  m_xElement->setPropertyValue( OUString::createFromAscii( pValueProperty ), aValuePropertyValue );
977  }
978  catch( const Exception& )
979  {
980  TOOLS_WARN_EXCEPTION("xmloff.forms",
981  "caught an exception while restoring the value property!");
982  }
983  }
984 
985  // the external cell binding, if applicable
986  if ( m_xElement.is() && !m_sBoundCellAddress.isEmpty() )
988 
989  // XForms binding, if applicable
990  if ( m_xElement.is() && !m_sBindingID.isEmpty() )
992 
993  // XForms list binding, if applicable
994  if ( m_xElement.is() && !m_sListBindingID.isEmpty() )
996 
997  // XForms submission, if applicable
998  if ( m_xElement.is() && !m_sSubmissionID.isEmpty() )
1000  }
1001 
1002  void OControlImport::doRegisterCellValueBinding( const OUString& _rBoundCellAddress )
1003  {
1004  OSL_PRECOND( m_xElement.is(), "OControlImport::doRegisterCellValueBinding: invalid element!" );
1005  OSL_PRECOND( !_rBoundCellAddress.isEmpty(),
1006  "OControlImport::doRegisterCellValueBinding: invalid address!" );
1007 
1008  m_rContext.registerCellValueBinding( m_xElement, _rBoundCellAddress );
1009  }
1010 
1011  void OControlImport::doRegisterXFormsValueBinding( const OUString& _rBindingID )
1012  {
1013  OSL_PRECOND( m_xElement.is(), "need element" );
1014  OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
1015 
1017  }
1018 
1019  void OControlImport::doRegisterXFormsListBinding( const OUString& _rBindingID )
1020  {
1021  OSL_PRECOND( m_xElement.is(), "need element" );
1022  OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
1023 
1025  }
1026 
1027  void OControlImport::doRegisterXFormsSubmission( const OUString& _rSubmissionID )
1028  {
1029  OSL_PRECOND( m_xElement.is(), "need element" );
1030  OSL_PRECOND( !_rSubmissionID.isEmpty(), "binding ID is not valid" );
1031 
1032  m_rContext.registerXFormsSubmission( m_xElement, _rSubmissionID );
1033  }
1034 
1036  {
1038  if ( xPropSet.is() )
1039  {
1040  m_xInfo = xPropSet->getPropertySetInfo();
1041  if ( m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_ALIGN) )
1042  {
1043  Any aValue;
1044  xPropSet->setPropertyValue(PROPERTY_ALIGN,aValue);
1045  }
1046  }
1047  return xPropSet;
1048  }
1049 
1050  //= OImagePositionImport
1052  const Reference< XNameContainer >& _rxParentContainer,
1054  :OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1055  ,m_nImagePosition( -1 )
1056  ,m_nImageAlign( 0 )
1057  ,m_bHaveImagePosition( false )
1058  {
1059  }
1060 
1061  bool OImagePositionImport::handleAttribute( sal_Int32 nElement,
1062  const OUString& _rValue )
1063  {
1064  static const sal_Int32 s_nImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::ImageData);
1065 
1066  if ( (nElement & TOKEN_MASK) == s_nImageDataAttributeName)
1067  {
1069  return true;
1070  }
1071  else if ( (nElement & TOKEN_MASK) == XML_IMAGE_POSITION )
1072  {
1074  cppu::UnoType<decltype(m_nImagePosition)>::get(),
1075  _rValue, aImagePositionMap
1076  ) >>= m_nImagePosition );
1077  m_bHaveImagePosition = true;
1078  return true;
1079  }
1080  else if ( (nElement & TOKEN_MASK) == XML_IMAGE_ALIGN )
1081  {
1083  cppu::UnoType<decltype(m_nImageAlign)>::get(),
1084  _rValue, aImageAlignMap
1085  ) >>= m_nImageAlign );
1086  return true;
1087  }
1088 
1089  return OControlImport::handleAttribute( nElement, _rValue );
1090  }
1091 
1092  void OImagePositionImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1093  {
1094  OControlImport::startFastElement( nElement, _rxAttrList );
1095 
1096  if (m_xGraphic.is())
1097  {
1098  PropertyValue aGraphicProperty;
1099  aGraphicProperty.Name = PROPERTY_GRAPHIC;
1100  aGraphicProperty.Value <<= m_xGraphic;
1101  implPushBackPropertyValue(aGraphicProperty);
1102  }
1103  if ( !m_bHaveImagePosition )
1104  return;
1105 
1106  sal_Int16 nUnoImagePosition = ImagePosition::Centered;
1107  if ( m_nImagePosition >= 0 )
1108  {
1109  OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ),
1110  "OImagePositionImport::StartElement: unknown image align and/or position!" );
1111  nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign;
1112  }
1113 
1114  PropertyValue aImagePosition;
1115  aImagePosition.Name = PROPERTY_IMAGE_POSITION;
1116  aImagePosition.Value <<= nUnoImagePosition;
1117  implPushBackPropertyValue( aImagePosition );
1118  }
1119 
1120  //= OReferredControlImport
1122  OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
1123  const Reference< XNameContainer >& _rxParentContainer )
1124  :OControlImport(_rImport, _rEventManager, _rxParentContainer)
1125  {
1126  }
1127 
1128  void OReferredControlImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1129  {
1130  OControlImport::startFastElement(nElement, _rxAttrList);
1131 
1132  // the base class should have created the control, so we can register it
1133  if ( !m_sReferringControls.isEmpty() )
1135  }
1136 
1138  const OUString& _rValue)
1139  {
1140  static const sal_Int32 s_nReferenceAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::For);
1141  if ((nElement & TOKEN_MASK) == s_nReferenceAttributeName)
1142  {
1143  m_sReferringControls = _rValue;
1144  return true;
1145  }
1146  return OControlImport::handleAttribute(nElement, _rValue);
1147  }
1148 
1149  //= OPasswordImport
1151  const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
1152  :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1153  {
1154  }
1155 
1156  bool OPasswordImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1157  {
1158  static const sal_Int32 s_nEchoCharAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::EchoChar);
1159  if ((nElement & TOKEN_MASK) == s_nEchoCharAttributeName)
1160  {
1161  // need a special handling for the EchoChar property
1162  PropertyValue aEchoChar;
1163  aEchoChar.Name = PROPERTY_ECHOCHAR;
1164  OSL_ENSURE(_rValue.getLength() == 1, "OPasswordImport::handleAttribute: invalid echo char attribute!");
1165  // we ourself should not have written values other than of length 1
1166  if (_rValue.getLength() >= 1)
1167  aEchoChar.Value <<= static_cast<sal_Int16>(_rValue[0]);
1168  else
1169  aEchoChar.Value <<= sal_Int16(0);
1170  implPushBackPropertyValue(aEchoChar);
1171  return true;
1172  }
1173  return OControlImport::handleAttribute(nElement, _rValue);
1174  }
1175 
1176  //= ORadioImport
1178  const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
1179  :OImagePositionImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1180  {
1181  }
1182 
1183  bool ORadioImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1184  {
1185  // need special handling for the State & CurrentState properties:
1186  // they're stored as booleans, but expected to be int16 properties
1187  static const sal_Int32 nCurrentSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentSelected);
1188  static const sal_Int32 nSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Selected);
1189  if ( (nElement & TOKEN_MASK) == nCurrentSelectedAttributeName
1190  || (nElement & TOKEN_MASK) == nSelectedAttributeName
1191  )
1192  {
1194  assert(pProperty && "ORadioImport::handleAttribute: invalid property map!");
1195  if (pProperty)
1196  {
1197  const Any aBooleanValue( PropertyConversion::convertString(pProperty->aPropertyType, _rValue, pProperty->pEnumMap) );
1198 
1199  // create and store a new PropertyValue
1200  PropertyValue aNewValue;
1201  aNewValue.Name = pProperty->sPropertyName;
1202  aNewValue.Value <<= static_cast<sal_Int16>(::cppu::any2bool(aBooleanValue));
1203 
1204  implPushBackPropertyValue(aNewValue);
1205  }
1206  return true;
1207  }
1208  return OImagePositionImport::handleAttribute( nElement, _rValue );
1209  }
1210 
1211  //= OURLReferenceImport
1213  const Reference< XNameContainer >& _rxParentContainer,
1215  :OImagePositionImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1216  {
1217  }
1218 
1219  bool OURLReferenceImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1220  {
1221  static const sal_Int32 s_nTargetLocationAttributeName = OAttributeMetaData::getCommonControlAttributeToken( CCAFlags::TargetLocation );
1222  static const sal_Int32 s_nImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeToken( CCAFlags::ImageData );
1223 
1224  // need to make the URL absolute if
1225  // * it's the image-data attribute
1226  // * it's the target-location attribute, and we're dealing with an object which has the respective property
1227  bool bMakeAbsolute =
1228  (nElement & TOKEN_MASK) == s_nImageDataAttributeName
1229  || ( (nElement & TOKEN_MASK) == s_nTargetLocationAttributeName
1232  )
1233  );
1234 
1235  if (bMakeAbsolute && !_rValue.isEmpty())
1236  {
1237  OUString sAdjustedValue = _rValue;
1238  if ((nElement & TOKEN_MASK) != s_nImageDataAttributeName)
1239  sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue );
1240  return OImagePositionImport::handleAttribute( nElement, sAdjustedValue );
1241  }
1242 
1243  return OImagePositionImport::handleAttribute( nElement, _rValue );
1244  }
1245 
1246  //= OButtonImport
1248  const Reference< XNameContainer >& _rxParentContainer,
1250  :OURLReferenceImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1251  {
1253  }
1254 
1255  void OButtonImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1256  {
1257  OURLReferenceImport::startFastElement(nElement, _rxAttrList);
1258 
1259  // handle the target-frame attribute
1261  }
1262 
1263  //= OValueRangeImport
1265  const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType )
1266  :OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1267  ,m_nStepSizeValue( 1 )
1268  {
1269 
1270  }
1271 
1272  bool OValueRangeImport::handleAttribute( sal_Int32 nElement, const OUString& _rValue )
1273  {
1275  {
1277  return true;
1278  }
1279  return OControlImport::handleAttribute( nElement, _rValue );
1280  }
1281 
1282  void OValueRangeImport::startFastElement( sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList )
1283  {
1284  OControlImport::startFastElement( nElement, _rxAttrList );
1285 
1286  if ( m_xInfo.is() )
1287  {
1288  if ( m_xInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1290  else if ( m_xInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1292  }
1293  }
1294 
1295  //= OTextLikeImport
1297  const Reference< XNameContainer >& _rxParentContainer,
1299  :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1300  ,m_bEncounteredTextPara( false )
1301  {
1303  }
1304 
1305  css::uno::Reference< css::xml::sax::XFastContextHandler > OTextLikeImport::createFastChildContext(
1306  sal_Int32 nElement,
1307  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1308  {
1309  if ( nElement == XML_ELEMENT(TEXT, XML_P) )
1310  {
1312  "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" );
1313 
1315  {
1316  Reference< XText > xTextElement( m_xElement, UNO_QUERY );
1317  if ( xTextElement.is() )
1318  {
1320 
1321  if ( !m_xCursor.is() )
1322  {
1323  m_xOldCursor = xTextImportHelper->GetCursor();
1324  m_xCursor = xTextElement->createTextCursor();
1325 
1326  if ( m_xCursor.is() )
1327  xTextImportHelper->SetCursor( m_xCursor );
1328  }
1329  if ( m_xCursor.is() )
1330  {
1331  m_bEncounteredTextPara = true;
1332  return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), nElement, xAttrList );
1333  }
1334  }
1335  else
1336  {
1337  // in theory, we could accumulate all the text portions (without formatting),
1338  // and set it as Text property at the model ...
1339  }
1340  }
1341  }
1342 
1343  return OControlImport::createFastChildContext( nElement, xAttrList );
1344  }
1345 
1346  void OTextLikeImport::startFastElement(sal_Int32 nElement, const Reference< css::xml::sax::XFastAttributeList >& _rxAttrList)
1347  {
1348  OControlImport::startFastElement(nElement, _rxAttrList);
1349 
1350  // handle the convert-empty-to-null attribute, whose default is different from the property default
1351  // unfortunately, different classes are imported by this class ('cause they're represented by the
1352  // same XML element), though not all of them know this property.
1353  // So we have to do a check ...
1354  if (m_xElement.is() && m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_EMPTY_IS_NULL) )
1356  }
1357 
1358  namespace {
1359 
1360  struct EqualHandle
1361  {
1362  const sal_Int32 m_nHandle;
1363  explicit EqualHandle( sal_Int32 _nHandle ) : m_nHandle( _nHandle ) { }
1364 
1365  bool operator()( const PropertyValue& _rProp )
1366  {
1367  return _rProp.Handle == m_nHandle;
1368  }
1369  };
1370 
1371  }
1372 
1374  {
1375  if ( !m_bEncounteredTextPara )
1376  return;
1377 
1378  // In case the text is written in the text:p elements, we need to ignore what we read as
1379  // current-value attribute, since it's redundant.
1380  // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE
1381  // handle, so we do not need to determine the name of our value property here
1382  // (normally, it should be "Text", since no other controls than the edit field should
1383  // have the text:p elements)
1384  PropertyValueArray::iterator aValuePropertyPos = ::std::find_if(
1385  m_aValues.begin(),
1386  m_aValues.end(),
1387  EqualHandle( PROPID_CURRENT_VALUE )
1388  );
1389  if ( aValuePropertyPos != m_aValues.end() )
1390  {
1391  OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" );
1392  if ( aValuePropertyPos->Name == PROPERTY_TEXT )
1393  {
1394  m_aValues.erase(aValuePropertyPos);
1395  }
1396  }
1397 
1398  // additionally, we need to set the "RichText" property of our element to sal_True
1399  // (the presence of the text:p is used as indicator for the value of the RichText property)
1400  bool bHasRichTextProperty = false;
1401  if ( m_xInfo.is() )
1402  bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT );
1403  OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" );
1404  if ( bHasRichTextProperty )
1405  m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, makeAny( true ) );
1406  // Note that we do *not* set the RichText property (in case our element has one) to sal_False here
1407  // since this is the default of this property, anyway.
1408  }
1409 
1410  namespace {
1411 
1412  struct EqualName
1413  {
1414  const OUString & m_sName;
1415  explicit EqualName( const OUString& _rName ) : m_sName( _rName ) { }
1416 
1417  bool operator()( const PropertyValue& _rProp )
1418  {
1419  return _rProp.Name == m_sName;
1420  }
1421  };
1422 
1423  }
1424 
1426  {
1427  // In OpenOffice.org 2.0, we changed the implementation of the css.form.component.TextField (the model of a text field control),
1428  // so that it now uses another default control. So if we encounter a text field where the *old* default
1429  // control property is writing, we are not allowed to use it
1430  PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if(
1431  m_aValues.begin(),
1432  m_aValues.end(),
1433  EqualName( "DefaultControl" )
1434  );
1435  if ( aDefaultControlPropertyPos != m_aValues.end() )
1436  {
1437  OUString sDefaultControl;
1438  OSL_VERIFY( aDefaultControlPropertyPos->Value >>= sDefaultControl );
1439  if ( sDefaultControl == "stardiv.one.form.control.Edit" )
1440  {
1441  // complete remove this property value from the array. Today's "default value" of the "DefaultControl"
1442  // property is sufficient
1443  m_aValues.erase(aDefaultControlPropertyPos);
1444  }
1445  }
1446  }
1447 
1448  void OTextLikeImport::endFastElement(sal_Int32 nElement)
1449  {
1452 
1453  // let the base class do the stuff
1455 
1456  // some cleanups
1458  if ( m_xCursor.is() )
1459  {
1460  // delete the newline which has been imported erroneously
1461  // TODO (fs): stole this code somewhere - why don't we fix the text import??
1462  m_xCursor->gotoEnd( false );
1463  m_xCursor->goLeft( 1, true );
1464  m_xCursor->setString( OUString() );
1465 
1466  // reset cursor
1467  xTextImportHelper->ResetCursor();
1468  }
1469 
1470  if ( m_xOldCursor.is() )
1471  xTextImportHelper->SetCursor( m_xOldCursor );
1472 
1473  }
1474 
1475  //= OListAndComboImport
1477  const Reference< XNameContainer >& _rxParentContainer,
1479  :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1480  ,m_nEmptyListItems( 0 )
1481  ,m_nEmptyValueItems( 0 )
1482  ,m_bEncounteredLSAttrib( false )
1483  ,m_bLinkWithIndexes( false )
1484  {
1487  }
1488 
1489  css::uno::Reference< css::xml::sax::XFastContextHandler > OListAndComboImport::createFastChildContext(
1490  sal_Int32 nElement,
1491  const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList )
1492  {
1493  // is it the "option" sub tag of a listbox ?
1494  if ((nElement & TOKEN_MASK) == XML_OPTION)
1495  return new OListOptionImport(GetImport(), this);
1496 
1497  // is it the "item" sub tag of a combobox ?
1498  if ((nElement & TOKEN_MASK) == XML_ITEM)
1499  return new OComboItemImport(GetImport(), this);
1500 
1501  // everything else
1502  return OControlImport::createFastChildContext(nElement, _rxAttrList);
1503  }
1504 
1505  void OListAndComboImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1506  {
1507  m_bLinkWithIndexes = false;
1508 
1509  OControlImport::startFastElement(nElement, _rxAttrList);
1510 
1512  {
1513  // for the auto-completion
1514  // the attribute default does not equal the property default, so in case we did not read this attribute,
1515  // we have to simulate it
1517 
1518  // same for the convert-empty-to-null attribute, which's default is different from the property default
1520  }
1521  }
1522 
1523  void OListAndComboImport::endFastElement(sal_Int32 nElement)
1524  {
1525  // append the list source property the properties sequence of our importer
1526  // the string item list
1527  PropertyValue aItemList;
1528  aItemList.Name = PROPERTY_STRING_ITEM_LIST;
1529  aItemList.Value <<= comphelper::containerToSequence(m_aListSource);
1530  implPushBackPropertyValue(aItemList);
1531 
1533  {
1534  OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1535  "OListAndComboImport::EndElement: inconsistence between labels and values!");
1536 
1537  if ( !m_bEncounteredLSAttrib )
1538  {
1539  // the value sequence
1540  PropertyValue aValueList;
1541  aValueList.Name = PROPERTY_LISTSOURCE;
1542  aValueList.Value <<= comphelper::containerToSequence(m_aValueList);
1543  implPushBackPropertyValue(aValueList);
1544  }
1545 
1546  // the select sequence
1547  PropertyValue aSelected;
1548  aSelected.Name = PROPERTY_SELECT_SEQ;
1549  aSelected.Value <<= comphelper::containerToSequence(m_aSelectedSeq);
1550  implPushBackPropertyValue(aSelected);
1551 
1552  // the default select sequence
1553  PropertyValue aDefaultSelected;
1554  aDefaultSelected.Name = PROPERTY_DEFAULT_SELECT_SEQ;
1555  aDefaultSelected.Value <<= comphelper::containerToSequence(m_aDefaultSelectedSeq);
1556  implPushBackPropertyValue(aDefaultSelected);
1557  }
1558 
1560 
1561  // the external list source, if applicable
1562  if ( m_xElement.is() && !m_sCellListSource.isEmpty() )
1564  }
1565 
1566  void OListAndComboImport::doRegisterCellValueBinding( const OUString& _rBoundCellAddress )
1567  {
1568  OUString sBoundCellAddress( _rBoundCellAddress );
1569  if ( m_bLinkWithIndexes )
1570  {
1571  // This is a HACK. We register a string which is no valid address, but allows
1572  // (somewhere else) to determine that a non-standard binding should be created.
1573  // This hack is acceptable for OOo 1.1.1, since the file format for value
1574  // bindings of form controls is to be changed afterwards, anyway.
1575  sBoundCellAddress += ":index";
1576  }
1577 
1578  OControlImport::doRegisterCellValueBinding( sBoundCellAddress );
1579  }
1580 
1581  bool OListAndComboImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1582  {
1583  static const sal_Int32 nListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeToken(DAFlags::ListSource);
1584  if ( (nElement & TOKEN_MASK) == nListSourceAttributeName )
1585  {
1586  PropertyValue aListSource;
1587  aListSource.Name = PROPERTY_LISTSOURCE;
1588 
1589  // it's the ListSource attribute
1590  m_bEncounteredLSAttrib = true;
1592  {
1593  aListSource.Value <<= _rValue;
1594  }
1595  else
1596  {
1597  // a listbox which has a list-source attribute must have a list-source-type of something
1598  // not equal to ValueList.
1599  // In this case, the list-source value is simply the one and only element of the ListSource property.
1600  Sequence<OUString> aListSourcePropValue { _rValue };
1601  aListSource.Value <<= aListSourcePropValue;
1602  }
1603 
1604  implPushBackPropertyValue( aListSource );
1605  return true;
1606  }
1607 
1608  if ( (nElement & TOKEN_MASK) == OAttributeMetaData::getBindingAttributeToken( BAFlags::ListCellRange ) )
1609  {
1610  m_sCellListSource = _rValue;
1611  return true;
1612  }
1613 
1614  if ( (nElement & TOKEN_MASK) == OAttributeMetaData::getBindingAttributeToken( BAFlags::ListLinkingType ) )
1615  {
1616  sal_Int16 nLinkageType = 0;
1619  _rValue,
1621  ) >>= nLinkageType;
1622 
1623  m_bLinkWithIndexes = ( nLinkageType != 0 );
1624  return true;
1625  }
1626 
1627  return OControlImport::handleAttribute(nElement, _rValue);
1628  }
1629 
1630  void OListAndComboImport::implPushBackLabel(const OUString& _rLabel)
1631  {
1632  OSL_ENSURE(!m_nEmptyListItems, "OListAndComboImport::implPushBackValue: label list is already done!");
1633  if (!m_nEmptyListItems)
1634  m_aListSource.push_back(_rLabel);
1635  }
1636 
1637  void OListAndComboImport::implPushBackValue(const OUString& _rValue)
1638  {
1639  OSL_ENSURE(!m_nEmptyValueItems, "OListAndComboImport::implPushBackValue: value list is already done!");
1640  if (!m_nEmptyValueItems)
1641  {
1642  OSL_ENSURE( !m_bEncounteredLSAttrib, "OListAndComboImport::implPushBackValue: invalid structure! Did you save this document with a version prior SRC641 m?" );
1643  // We already had the list-source attribute, which means that the ListSourceType is
1644  // not ValueList, which means that the ListSource should contain only one string in
1645  // the first element of the sequence
1646  // All other values in the file are invalid
1647 
1648  m_aValueList.push_back( _rValue );
1649  }
1650  }
1651 
1653  {
1655  }
1656 
1658  {
1660  }
1661 
1663  {
1664  OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1665  "OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!");
1666 
1667  sal_Int16 nItemNumber = static_cast<sal_Int16>(m_aListSource.size() - 1 + m_nEmptyListItems);
1668  m_aSelectedSeq.push_back(nItemNumber);
1669  }
1670 
1672  {
1673  OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1674  "OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!");
1675 
1676  sal_Int16 nItemNumber = static_cast<sal_Int16>(m_aListSource.size() - 1 + m_nEmptyListItems);
1677  m_aDefaultSelectedSeq.push_back(nItemNumber);
1678  }
1679 
1680  //= OListOptionImport
1682  const OListAndComboImportRef& _rListBox)
1683  :SvXMLImportContext(_rImport)
1684  ,m_xListBoxImport(_rListBox)
1685  {
1686  }
1687 
1688  void OListOptionImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1689  {
1690  // the label and the value
1691  const sal_Int32 nLabelAttribute = (nElement & ~TOKEN_MASK) | XML_LABEL;
1692  const sal_Int32 nValueAttribute = (nElement & ~TOKEN_MASK) | XML_VALUE;
1693 
1694  // the label attribute
1695  OUString sValue = _rxAttrList->getOptionalValue(nLabelAttribute);
1696  bool bNonexistentAttribute = !_rxAttrList->hasAttribute(nLabelAttribute);
1697 
1698  if (bNonexistentAttribute)
1699  m_xListBoxImport->implEmptyLabelFound();
1700  else
1701  m_xListBoxImport->implPushBackLabel( sValue );
1702 
1703  // the value attribute
1704  sValue = _rxAttrList->getOptionalValue(nValueAttribute);
1705  bNonexistentAttribute = !_rxAttrList->hasAttribute(nValueAttribute);
1706 
1707  if (bNonexistentAttribute)
1708  m_xListBoxImport->implEmptyValueFound();
1709  else
1710  m_xListBoxImport->implPushBackValue( sValue );
1711 
1712  // the current-selected and selected
1713  const sal_Int32 nSelectedAttribute = (nElement & ~TOKEN_MASK) | OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentSelected);
1714  const sal_Int32 nDefaultSelectedAttribute = (nElement & ~TOKEN_MASK) | OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Selected);
1715 
1716  // propagate the selected flag
1717  bool bSelected(false);
1718  (void)::sax::Converter::convertBool(bSelected,
1719  _rxAttrList->getOptionalValue(nSelectedAttribute));
1720  if (bSelected)
1721  m_xListBoxImport->implSelectCurrentItem();
1722 
1723  // same for the default selected
1724  bool bDefaultSelected(false);
1725  (void)::sax::Converter::convertBool(bDefaultSelected,
1726  _rxAttrList->getOptionalValue(nDefaultSelectedAttribute));
1727  if (bDefaultSelected)
1728  m_xListBoxImport->implDefaultSelectCurrentItem();
1729  }
1730 
1731  //= OComboItemImport
1733  const OListAndComboImportRef& _rListBox)
1734  :SvXMLImportContext(_rImport)
1735  ,m_xListBoxImport(_rListBox)
1736  {
1737  }
1738 
1739  void OComboItemImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1740  {
1741  const sal_Int32 nLabelAttributeName = (nElement & ~TOKEN_MASK) |
1743  m_xListBoxImport->implPushBackLabel(_rxAttrList->getOptionalValue(nLabelAttributeName));
1744  }
1745 
1746  //= OColumnWrapperImport
1748  IEventAttacherManager& _rEventManager, sal_Int32 /*nElement*/,
1749  const Reference< XNameContainer >& _rxParentContainer)
1750  :SvXMLImportContext(_rImport.getGlobalContext())
1751  ,m_xParentContainer(_rxParentContainer)
1752  ,m_rFormImport(_rImport)
1753  ,m_rEventManager(_rEventManager)
1754  {
1755  }
1756  css::uno::Reference< css::xml::sax::XFastContextHandler > OColumnWrapperImport::createFastChildContext(
1757  sal_Int32 nElement,
1758  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
1759  {
1761  if (pReturn)
1762  {
1763  OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::CreateChildContext: had no form:column element!");
1765  }
1766  return pReturn;
1767  }
1768  void OColumnWrapperImport::startFastElement(sal_Int32 /*nElement*/, const Reference< XFastAttributeList >& _rxAttrList)
1769  {
1770  OSL_ENSURE(!m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: already have the cloned list!");
1771 
1772  // clone the attributes
1773  Reference< XCloneable > xCloneList(_rxAttrList, UNO_QUERY_THROW);
1774  m_xOwnAttributes.set(xCloneList->createClone(), UNO_QUERY_THROW);
1775  }
1776 
1778  sal_Int32 /*nElement*/,
1780  {
1781  OSL_ENSURE( (OControlElement::TEXT == _eType)
1782  || (OControlElement::TEXT_AREA == _eType)
1783  || (OControlElement::FORMATTED_TEXT == _eType)
1784  || (OControlElement::CHECKBOX == _eType)
1785  || (OControlElement::LISTBOX == _eType)
1786  || (OControlElement::COMBOBOX == _eType)
1787  || (OControlElement::TIME == _eType)
1788  || (OControlElement::DATE == _eType),
1789  "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!");
1790 
1791  switch (_eType)
1792  {
1796 
1799 
1800  case OControlElement::TEXT:
1804 
1805  default:
1807  }
1808  }
1809 
1810  //= OGridImport
1812  const Reference< XNameContainer >& _rxParentContainer,
1814  :OControlImport(_rImport, _rEventManager, _rxParentContainer)
1815  {
1816  setElementType(_eType);
1817  }
1818 
1819  css::uno::Reference< css::xml::sax::XFastContextHandler > OGridImport::createFastChildContext(
1820  sal_Int32 nElement,
1821  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1822  {
1823  // maybe it's a sub control
1824  if ((nElement & TOKEN_MASK) == XML_COLUMN)
1825  {
1826  if (m_xMeAsContainer.is())
1827  return new OColumnWrapperImport(m_rFormImport, *this, nElement, m_xMeAsContainer);
1828  else
1829  {
1830  OSL_FAIL("OGridImport::CreateChildContext: don't have an element!");
1831  return nullptr;
1832  }
1833  }
1834 
1835  return OControlImport::createFastChildContext(nElement, xAttrList);
1836  }
1837 
1838  void OGridImport::endFastElement(sal_Int32 nElement)
1839  {
1841 
1842  // now that we have all children, attach the events
1843  css::uno::Reference< css::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, css::uno::UNO_QUERY);
1844  if (xIndexContainer.is())
1845  ODefaultEventAttacherManager::setEvents(xIndexContainer);
1846  }
1847 
1848  css::uno::Reference< css::beans::XPropertySet > OGridImport::createElement()
1849  {
1850  // let the base class create the object
1851  css::uno::Reference< css::beans::XPropertySet > xReturn = OControlImport::createElement();
1852  if (!xReturn.is())
1853  return xReturn;
1854 
1855  // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
1856  m_xMeAsContainer.set(xReturn, css::uno::UNO_QUERY);
1857  if (!m_xMeAsContainer.is())
1858  {
1859  OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
1860  xReturn.clear();
1861  }
1862 
1863  return xReturn;
1864  }
1865 
1866  //= OFormImport
1868  const Reference< XNameContainer >& _rxParentContainer)
1869  :OElementImport(_rImport, _rEventManager, _rxParentContainer)
1870  {
1872  }
1873 
1874  css::uno::Reference< css::xml::sax::XFastContextHandler > OFormImport::createFastChildContext(
1875  sal_Int32 nElement,
1876  const uno::Reference< xml::sax::XFastAttributeList>& _rxAttrList )
1877  {
1878  auto nToken = (nElement & TOKEN_MASK);
1879  if( nToken == XML_FORM )
1880  return new OFormImport( m_rFormImport, *this, m_xMeAsContainer);
1881  else if ( nToken == XML_CONNECTION_RESOURCE )
1882  return new OXMLDataSourceImport(GetImport(), _rxAttrList, m_xElement);
1883  else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ||
1884  nToken == XML_PROPERTIES )
1885  return OElementImport::createFastChildContext( nElement, _rxAttrList );
1886  else
1887  {
1889  switch (eType)
1890  {
1891  case OControlElement::TEXT:
1894  return new OTextLikeImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1895  case OControlElement::GRID:
1896  return new OGridImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1899  return new OListAndComboImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1901  return new OPasswordImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1905  return new OButtonImport( m_rFormImport, *this, m_xMeAsContainer, eType );
1907  return new ORadioImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1909  return new OImagePositionImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1914  return new OValueRangeImport( m_rFormImport, *this, m_xMeAsContainer, eType );
1915  default:
1916  return new OControlImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1917  }
1918  }
1919  }
1920 
1921  void OFormImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1922  {
1924  OElementImport::startFastElement(nElement, _rxAttrList);
1925 
1926  // handle the target-frame attribute
1928  }
1929 
1930  void OFormImport::endFastElement(sal_Int32 nElement)
1931  {
1933 
1934  // now that we have all children, attach the events
1935  css::uno::Reference< css::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, css::uno::UNO_QUERY);
1936  if (xIndexContainer.is())
1937  ODefaultEventAttacherManager::setEvents(xIndexContainer);
1938 
1940  }
1941 
1942  css::uno::Reference< css::beans::XPropertySet > OFormImport::createElement()
1943  {
1944  // let the base class create the object
1945  css::uno::Reference< css::beans::XPropertySet > xReturn = OElementImport::createElement();
1946  if (!xReturn.is())
1947  return xReturn;
1948 
1949  // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
1950  m_xMeAsContainer.set(xReturn, css::uno::UNO_QUERY);
1951  if (!m_xMeAsContainer.is())
1952  {
1953  OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
1954  xReturn.clear();
1955  }
1956 
1957  return xReturn;
1958  }
1959 
1960  bool OFormImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1961  {
1962  // handle the master/details field attributes (they're way too special to let the OPropertyImport handle them)
1963  static const sal_Int32 s_nMasterFieldsAttributeName = OAttributeMetaData::getFormAttributeToken(faMasterFields);
1964  static const sal_Int32 s_nDetailFieldsAttributeName = OAttributeMetaData::getFormAttributeToken(faDetailFields);
1965 
1966  if ( (nElement & TOKEN_MASK) == s_nMasterFieldsAttributeName)
1967  {
1969  return true;
1970  }
1971 
1972  if ( (nElement & TOKEN_MASK) == s_nDetailFieldsAttributeName)
1973  {
1975  return true;
1976  }
1977 
1978  return OElementImport::handleAttribute(nElement, _rValue);
1979  }
1980 
1981  void OFormImport::implTranslateStringListProperty(const OUString& _rPropertyName, const OUString& _rValue)
1982  {
1983  PropertyValue aProp;
1984  aProp.Name = _rPropertyName;
1985 
1986  Sequence< OUString > aList;
1987 
1988  // split up the value string
1989  if (!_rValue.isEmpty())
1990  {
1991  // For the moment, we build a vector instead of a Sequence. It's easier to handle because of its
1992  // push_back method
1993  ::std::vector< OUString > aElements;
1994  // estimate the number of tokens
1995  sal_Int32 nEstimate = 0, nLength = _rValue.getLength();
1996  const sal_Unicode* pChars = _rValue.getStr();
1997  for (sal_Int32 i=0; i<nLength; ++i, ++pChars)
1998  if (*pChars == ',')
1999  ++nEstimate;
2000  aElements.reserve(nEstimate + 1);
2001  // that's the worst case. If the string contains the separator character _quoted_, we reserved too much...
2002 
2003  sal_Int32 nElementStart = 0;
2004  sal_Int32 nNextSep = 0;
2005  sal_Int32 nElementLength;
2006  OUString sElement;
2007  do
2008  {
2009  // extract the current element
2010  nNextSep = ::sax::Converter::indexOfComma(
2011  _rValue, nElementStart);
2012  if (-1 == nNextSep)
2013  nNextSep = nLength;
2014  sElement = _rValue.copy(nElementStart, nNextSep - nElementStart);
2015 
2016  nElementLength = sElement.getLength();
2017  // when writing the sequence, we quoted the single elements with " characters
2018  OSL_ENSURE( sElement.startsWith("\"") && sElement.endsWith("\""),
2019  "OFormImport::implTranslateStringListProperty: invalid quoted element name.");
2020  sElement = sElement.copy(1, nElementLength - 2);
2021 
2022  aElements.push_back(sElement);
2023 
2024  // switch to the next element
2025  nElementStart = 1 + nNextSep;
2026  }
2027  while (nElementStart < nLength);
2028 
2029  aList = Sequence< OUString >(aElements.data(), aElements.size());
2030  }
2031  else
2032  {
2033  OSL_FAIL("OFormImport::implTranslateStringListProperty: invalid value (empty)!");
2034  }
2035 
2036  aProp.Value <<= aList;
2037 
2038  // add the property to the base class' array
2040  }
2041  //= OXMLDataSourceImport
2043  SvXMLImport& _rImport
2044  ,const Reference< css::xml::sax::XFastAttributeList > & _xAttrList
2045  ,const css::uno::Reference< css::beans::XPropertySet >& _xElement) :
2046  SvXMLImportContext( _rImport)
2047  {
2048  for( auto& aIter : sax_fastparser::castToFastAttributeList(_xAttrList) )
2049  {
2050  if ( aIter.getToken() ==
2052  {
2053  OUString sValue = aIter.toString();
2054  sValue = _rImport.GetAbsoluteReference(sValue);
2055  INetURLObject aURL(sValue);
2056  if ( aURL.GetProtocol() == INetProtocol::File )
2057  _xElement->setPropertyValue(PROPERTY_DATASOURCENAME,makeAny(sValue));
2058  else
2059  _xElement->setPropertyValue(PROPERTY_URL,makeAny(sValue)); // the url is the "sdbc:" string
2060  break;
2061  }
2062  else
2063  SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
2064  }
2065  }
2066 
2068  {
2069  return "com.sun.star.form.component.Form";
2070  }
2071 
2072 } // namespace xmloff
2073 
2074 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type getSequenceElementType(const Type &_rSequenceType)
void registerCellValueBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rCellAddress)
OUString m_sListBindingID
name of a list binding (form:xforms-list-source attribute)
::std::map< PropertyId, css::uno::Any > PropertyValues
#define PROPERTY_MASTERFIELDS
Definition: strings.hxx:102
OReferredControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
OGridImport(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.
#define PROPERTY_LISTSOURCE
Definition: strings.hxx:66
virtual OUString determineDefaultServiceName() const
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
URL aURL
void registerXFormsValueBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rBindingID)
IEventAttacherManager & m_rEventManager
OListAndComboImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
if and only if we should use a cell value binding which exchanges the selection index (instead...
::std::vector< PropertyDescriptionList > PropertyGroups
OListAndComboImportRef m_xListBoxImport
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer
static css::uno::Any convertString(const css::uno::Type &_rExpectedType, const OUString &_rReadCharacters, const SvXMLEnumMapEntry< EnumT > *_pEnumMap=nullptr)
#define PROPID_MAX_VALUE
const SvXMLEnumMapEntry< sal_uInt16 > * pEnumMap
#define PROPERTY_DETAILFIELDS
Definition: strings.hxx:103
#define PROPID_MIN_VALUE
OTextLikeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
OUString m_sSubmissionID
name of a submission (xforms:submission attribute)
void registerCellRangeListSource(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rCellRangeAddress)
signed char sal_Int8
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
::std::vector< const PropertyDescription * > PropertyDescriptionList
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
bool encounteredAttribute(sal_Int32 nElement) const
determine if the element imported by the object had a given attribute.
OButtonImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
css::uno::Reference< css::text::XTextCursor > m_xCursor
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
OURLReferenceImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
#define PROPERTY_DEFAULT_SELECT_SEQ
Definition: strings.hxx:77
helper class importing a single grid column (without the element wrapping the column)...
#define PROPID_VALUE
static sal_Int32 getDatabaseAttributeToken(DAFlags _nId)
calculates the xml attribute representation of a database attribute.
constexpr sal_uInt16 XML_NAMESPACE_OOO
helper for translating between control types and XML tags
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
PropertyValueArray m_aGenericValues
#define LEAVE_LOG_CONTEXT()
Definition: logging.hxx:53
#define PROPERTY_AUTOCOMPLETE
Definition: strings.hxx:70
A specialized version of the OControlImport class, which handles the target frame for im...
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
static void implTranslateValueProperty(const css::uno::Reference< css::beans::XPropertySetInfo > &_rxPropInfo, css::beans::PropertyValue &_rPropValue)
void implTranslateStringListProperty(const OUString &_rPropertyName, 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
css::uno::Reference< css::graphic::XGraphic > loadGraphicByURL(OUString const &rURL)
Definition: xmlimp.cxx:1275
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:599
static sal_Int32 getBindingAttributeToken(BAFlags _nId)
calculates the xml attribute representation of a binding attribute.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
#define PROPERTY_SPIN_INCREMENT
Definition: strings.hxx:127
#define PROPERTY_DATASOURCENAME
Definition: strings.hxx:47
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 ...
helper class importing a single element
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
a specialized version of the OControlImport class, which is able to handle attributes wh...
sal_uInt16 sal_Unicode
#define PROPERTY_URL
Definition: strings.hxx:99
#define PROPERTY_RICH_TEXT
Definition: strings.hxx:141
const PropertyId propertyId
the unique ID of the property. The property meta data table must not contain two entries with the sam...
sal_Int32 m_nEmptyValueItems
number of empty list items encountered during reading
OFormLayerXMLImport_Impl & m_rFormImport
static sal_Int32 getSpecialAttributeToken(SCAFlags _nId)
calculates the xml attribute representation of a special attribute.
#define PROPERTY_IMAGE_POSITION
Definition: strings.hxx:132
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
A specialized version of the OControlImport class, which handles text like controls whic...
size_t pos
AttributeDescription getAttributeDescription(sal_Int32 nAttributeToken)
retrieves the attribute descriptor for the attribute given by namespace prefix and attribute name ...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OColumnWrapperImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, sal_Int32 nElement, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
A specialized version of the OControlImport class, which handles attributes / sub elemen...
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
void doRegisterXFormsListBinding(const OUString &)
register the given XForms list binding
OControlImport * implCreateChildContext(sal_Int32 nElement, OControlElement::ElementType _eType)
constexpr sal_uInt16 XML_NAMESPACE_FORM
static sal_Int32 getElementToken(ElementType _eType)
retrieves the tag name to be used to describe a control of the given type
const SvXMLEnumMapEntry< sal_Int16 > aImagePositionMap[]
Definition: formenums.cxx:164
static sal_Int32 getFormAttributeToken(FormAttributes _eAttrib)
retrieves the name of an attribute of a form xml representation
css::uno::Reference< css::graphic::XGraphic > m_xGraphic
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 OUString determineDefaultServiceName() const override
void getPropertyGroupList(const AttributeDescription &i_attribute, PropertyGroups &o_propertyGroups)
retrieves all known property groups which are mapped to the given attribute
void setEvents(const css::uno::Reference< css::container::XIndexAccess > &_rxContainer)
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
#define PROPERTY_SELECT_SEQ
Definition: strings.hxx:78
static OUString getPrefixAndNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1929
OComboItemImport(SvXMLImport &_rImport, const OListAndComboImportRef &_rListBox)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
OXMLDataSourceImport(SvXMLImport &_rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const css::uno::Reference< css::beans::XPropertySet > &_xElement)
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
static sal_Int32 indexOfComma(std::u16string_view rStr, sal_Int32 nPos)
UNKNOWN
OFormImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
sal_Int32 nHandle
void registerControlId(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rId)
DocumentType eType
OListOptionImport(SvXMLImport &_rImport, const OListAndComboImportRef &_rListBox)
::xmloff::token::XMLTokenEnum attributeToken
const OControlElement::ElementType & operator++(OControlElement::ElementType &_e)
#define PROPERTY_LINE_INCREMENT
Definition: strings.hxx:120
OListAndComboImportRef m_xListBoxImport
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
constexpr sal_uInt16 XML_NAMESPACE_XML
const OUString & m_sName
OElementImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
ctor
OValueRangeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
#define DBG_UNHANDLED_EXCEPTION(...)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
#define TOOLS_WARN_EXCEPTION(area, stream)
void enableTrackAttributes()
enables the tracking of the encountered attributes
void registerControlReferences(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rReferringControls)
int i
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOuterAttributes
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
bool m_bEncounteredLSAttrib
number of empty value items encountered during reading
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
sal_Int32 m_nEmptyListItems
the cell range which acts as list source for the control
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
#define PROPERTY_EFFECTIVE_DEFAULT
Definition: strings.hxx:97
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
void registerXFormsSubmission(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rSubmissionID)
OUString implGetDefaultName() const
#define PROPERTY_CLASSID
Definition: strings.hxx:26
virtual void registerEvents(const css::uno::Reference< css::beans::XPropertySet > &_rxElement, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)=0
Reference< XContent > m_xParentContainer
#define ENSURE_OR_RETURN(c, m, r)
static void getRuntimeValuePropertyNames(OControlElement::ElementType _eType, sal_Int16 _nFormComponentType, char const *&_rpValuePropertyName, char const *&_rpDefaultValuePropertyName)
calculate the names of the properties which, at runtime, are used for value and default value...
float u
#define PROPERTY_ALIGN
Definition: strings.hxx:106
OUString m_sBindingID
name of a value binding (xforms:bind attribute)
void implPushBackLabel(const OUString &_rLabel)
A specialized version of the OControlImport class, which imports the value-range element...
#define PROPERTY_REPEAT_DELAY
Definition: strings.hxx:122
const SvXMLEnumMapEntry< sal_uInt16 > aImageAlignMap[]
Definition: formenums.cxx:173
OControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
virtual OUString determineDefaultServiceName() const override
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
OImagePositionImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
PropertyGroups::const_iterator impl_matchPropertyGroup(const PropertyGroups &i_propertyGroups) const
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 SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
const AttributeAssignment * getAttributeTranslation(sal_Int32 nAttributeToken)
return the AttributeAssignment which corresponds to the given attribute
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress)
registers the given cell address as value binding address for our element
void applyControlNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rControlNumberStyleName)
ElementType
IEventAttacherManager & m_rEventManager
#define PROPERTY_GRAPHIC
Definition: strings.hxx:30
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
std::vector< OUString > m_aListSource
bool tryGenericAttribute(sal_Int32 nElement, const OUString &_rValue)
to be called from within handleAttribute, checks whether the given attribute is covered by our generi...
static ElementType getElementType(sal_Int32 nToken)
static void getValueLimitPropertyNames(sal_Int16 _nFormComponentType, char const *&_rpMinValuePropertyName, char const *&_rpMaxValuePropertyName)
calculate the property names for the min-value and the max-value attribute.
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress) override
registers the given cell address as value binding address for our element
void doRegisterXFormsValueBinding(const OUString &)
register the given XForms binding
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
static bool convertBool(bool &rBool, std::u16string_view rString)
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
#define PROPERTY_EFFECTIVE_VALUE
Definition: strings.hxx:96
OControlElement::ElementType m_eElementType
static const OUString & getNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1924
void setElementType(OControlElement::ElementType _eType)
sal_Int32 attribute
OFormLayerXMLImport_Impl & m_rFormImport
OFormLayerXMLImport_Impl & m_rContext
PropertyValueArray m_aValues
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOwnAttributes
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
helper class for importing the description of a single control
#define PROPERTY_TARGETFRAME
Definition: strings.hxx:32
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
const PropertyValue * pValues
DefTokenId nToken
static std::map< sal_Int32, ElementType > s_sElementTranslations2
void implPushBackPropertyValue(const css::beans::PropertyValue &_rProp)
#define PROPERTY_ECHOCHAR
Definition: strings.hxx:27
virtual ~OElementImport() override
implements common behaviour for importing forms, controls and columns
std::vector< sal_Int16 > m_aSelectedSeq
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:103
std::vector< sal_Int16 > m_aDefaultSelectedSeq
css::uno::Reference< css::uno::XComponentContext > const & GetComponentContext() const
Definition: xmlimp.cxx:1787
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1606
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue)
handle one single attribute.
#define SAL_WARN_IF(condition, area, stream)
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 ...
PropertyValueArray m_aValueProperties
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Helper class for importing property values.
Handling of tokens in XML:
OAttribute2Property & getAttributeMap()
Definition: layerimport.hxx:94
const SvXMLEnumMapEntry< sal_Int16 > aListLinkageMap[]
Definition: formenums.cxx:145
virtual void registerEvents(const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents) override
INetProtocol GetProtocol() 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 > &) override
const OUString & GetDataStyleName() const
Definition: txtstyli.hxx:76
void registerXFormsListBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rBindingID)
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
FORM
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:96
const sal_Int32 m_nHandle
css::uno::Reference< css::beans::XPropertySet > m_xElement
the element we're creating. Valid after StartElement
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
css::uno::Reference< css::text::XTextCursor > m_xOldCursor
#define ENTER_LOG_CONTEXT(name)
Definition: logging.hxx:52
#define PROPID_CURRENT_VALUE
OUString m_sBoundCellAddress
the address of the calc cell which the control model should be bound to, if applicable ...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
static sal_Int32 getCommonControlAttributeToken(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
void implPushBackValue(const OUString &_rValue)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
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 ...
#define SAL_WARN(area, stream)
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:93
#define PROPERTY_STRING_ITEM_LIST
Definition: strings.hxx:75
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 ...
sal_Int32 nLength
Definition: xmltoken.cxx:36
void disableImplicitGenericAttributeHandling()
controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived cla...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
void doRegisterXFormsSubmission(const OUString &)
register the given XForms submission
static void getValuePropertyNames(OControlElement::ElementType _eType, sal_Int16 _nFormComponentType, char const *&_rpCurrentValuePropertyName, char const *&_rpValuePropertyName)
calculate the property names for the current-value and the value attribute.
#define PROPERTY_TEXT
Definition: strings.hxx:95
#define PROPERTY_EMPTY_IS_NULL
Definition: strings.hxx:64
constexpr OUStringLiteral first
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
OPasswordImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
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 ...
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer
const XMLTextStyleContext * m_pStyleElement
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...
void addOuterAttributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxOuterAttribs)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
TEXT
std::vector< OUString > m_aValueList
const PropertyHandlerFactory factory
is the factory for creating a handler for reading and writing the property
sal_Int16 nValue
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
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 ...
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
the parent container to insert the new element into
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
const SvXMLStyleContext * getStyleElement(const OUString &_rStyleName) const