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