LibreOffice Module xmloff (master)  1
propertyimport.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 <sal/config.h>
21 
22 #include <cmath>
23 
24 #include "propertyimport.hxx"
25 
26 #include <sax/tools/converter.hxx>
27 
28 #include <xmloff/xmlimp.hxx>
29 #include <xmloff/xmluconv.hxx>
30 #include <xmloff/namespacemap.hxx>
31 #include <o3tl/temporary.hxx>
32 #include <osl/diagnose.h>
33 #include <sal/log.hxx>
34 #include <comphelper/extract.hxx>
35 #include <xmloff/xmlnamespace.hxx>
36 #include <tools/date.hxx>
37 #include <tools/time.hxx>
38 #include <com/sun/star/util/Date.hpp>
39 #include <com/sun/star/util/Time.hpp>
40 #include <com/sun/star/util/DateTime.hpp>
41 #include <unotools/datetime.hxx>
42 #include <rtl/strbuf.hxx>
43 
44 namespace xmloff
45 {
46 
47  using namespace ::com::sun::star::uno;
48  using namespace ::com::sun::star::beans;
49  using namespace ::com::sun::star::xml;
50  using ::com::sun::star::xml::sax::XAttributeList;
51 
52  // NO using namespace ...util !!!
53  // need a tools Date/Time/DateTime below, which would conflict with the uno types then
54 
55 #define TYPE_DATE 1
56 #define TYPE_TIME 2
57 #define TYPE_DATETIME 3
58 
59 //= PropertyConversion
60 namespace
61 {
62  css::util::Time lcl_getTime(double _nValue)
63  {
64  css::util::Time aTime;
65  sal_uInt64 nIntValue = static_cast<sal_uInt64>(_nValue * ::tools::Time::nanoSecPerDay);
66  aTime.NanoSeconds = nIntValue % ::tools::Time::nanoSecPerSec;
67  nIntValue /= ::tools::Time::nanoSecPerSec;
68  aTime.Seconds = nIntValue % ::tools::Time::secondPerMinute;
69  nIntValue /= ::tools::Time::secondPerMinute;
70  aTime.Minutes = nIntValue % ::tools::Time::minutePerHour;
71  nIntValue /= ::tools::Time::minutePerHour;
72  OSL_ENSURE(nIntValue < 24, "lcl_getTime: more than a day?");
73  aTime.Hours = nIntValue;
74 
75  return aTime;
76  }
77 
78  css::util::Date lcl_getDate( double _nValue )
79  {
80  Date aToolsDate(static_cast<sal_uInt32>(_nValue));
81  css::util::Date aDate;
82  ::utl::typeConvert(aToolsDate, aDate);
83  return aDate;
84  }
85 }
86 
87 Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType,
88  const OUString& _rReadCharacters, const SvXMLEnumMapEntry<sal_uInt16>* _pEnumMap, const bool _bInvertBoolean )
89 {
90  Any aReturn;
91  bool bEnumAsInt = false;
92  switch (_rExpectedType.getTypeClass())
93  {
94  case TypeClass_BOOLEAN: // sal_Bool
95  {
96  bool bValue;
97  bool bSuccess =
98  ::sax::Converter::convertBool(bValue, _rReadCharacters);
99  OSL_ENSURE(bSuccess,
100  OStringBuffer("PropertyConversion::convertString: could not convert \"").
101  append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)).
102  append("\" into a boolean!").getStr());
103  aReturn <<= (_bInvertBoolean ? !bValue : bValue);
104  }
105  break;
106  case TypeClass_SHORT: // sal_Int16
107  case TypeClass_LONG: // sal_Int32
108  if (!_pEnumMap)
109  { // it's a real int32/16 property
110  sal_Int32 nValue(0);
111  bool bSuccess =
112  ::sax::Converter::convertNumber(nValue, _rReadCharacters);
113  OSL_ENSURE(bSuccess,
114  OStringBuffer("PropertyConversion::convertString: could not convert \"").
115  append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)).
116  append("\" into an integer!").getStr());
117  if (TypeClass_SHORT == _rExpectedType.getTypeClass())
118  aReturn <<= static_cast<sal_Int16>(nValue);
119  else
120  aReturn <<= nValue;
121  break;
122  }
123  bEnumAsInt = true;
124  [[fallthrough]];
125  case TypeClass_ENUM:
126  {
127  sal_uInt16 nEnumValue(0);
128  bool bSuccess = SvXMLUnitConverter::convertEnum(nEnumValue, _rReadCharacters, _pEnumMap);
129  OSL_ENSURE(bSuccess, "PropertyConversion::convertString: could not convert to an enum value!");
130 
131  if (bEnumAsInt)
132  if (TypeClass_SHORT == _rExpectedType.getTypeClass())
133  aReturn <<= static_cast<sal_Int16>(nEnumValue);
134  else
135  aReturn <<= static_cast<sal_Int32>(nEnumValue);
136  else
137  aReturn = ::cppu::int2enum(static_cast<sal_Int32>(nEnumValue), _rExpectedType);
138  }
139  break;
140  case TypeClass_HYPER:
141  {
142  OSL_FAIL("PropertyConversion::convertString: 64-bit integers not implemented yet!");
143  }
144  break;
145  case TypeClass_DOUBLE:
146  {
147  double nValue;
148  bool bSuccess =
149  ::sax::Converter::convertDouble(nValue, _rReadCharacters);
150  OSL_ENSURE(bSuccess,
151  OStringBuffer("PropertyConversion::convertString: could not convert \"").
152  append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)).
153  append("\" into a double!").getStr());
154  aReturn <<= nValue;
155  }
156  break;
157  case TypeClass_STRING:
158  aReturn <<= _rReadCharacters;
159  break;
160  case TypeClass_STRUCT:
161  {
162  sal_Int32 nType = 0;
163  if ( _rExpectedType.equals( ::cppu::UnoType< css::util::Date >::get() ) )
164  nType = TYPE_DATE;
165  else if ( _rExpectedType.equals( ::cppu::UnoType< css::util::Time >::get() ) )
166  nType = TYPE_TIME;
167  else if ( _rExpectedType.equals( ::cppu::UnoType< css::util::DateTime >::get() ) )
168  nType = TYPE_DATETIME;
169 
170  if ( nType )
171  {
172  // first extract the double
173  double nValue = 0;
174  bool bSuccess =
175  ::sax::Converter::convertDouble(nValue, _rReadCharacters);
176  OSL_ENSURE(bSuccess,
177  OStringBuffer("PropertyConversion::convertString: could not convert \"").
178  append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)).
179  append("\" into a double!").getStr());
180 
181  // then convert it into the target type
182  switch (nType)
183  {
184  case TYPE_DATE:
185  {
186  OSL_ENSURE(std::modf(nValue, &o3tl::temporary(double())) == 0,
187  "PropertyConversion::convertString: a Date value with a fractional part?");
188  aReturn <<= lcl_getDate(nValue);
189  }
190  break;
191  case TYPE_TIME:
192  {
193  OSL_ENSURE((static_cast<sal_uInt32>(nValue)) == 0,
194  "PropertyConversion::convertString: a tools::Time value with more than a fractional part?");
195  aReturn <<= lcl_getTime(nValue);
196  }
197  break;
198  case TYPE_DATETIME:
199  {
200  css::util::Time aTime = lcl_getTime(nValue);
201  css::util::Date aDate = lcl_getDate(nValue);
202 
203  css::util::DateTime aDateTime;
204  aDateTime.NanoSeconds = aTime.NanoSeconds;
205  aDateTime.Seconds = aTime.Seconds;
206  aDateTime.Minutes = aTime.Minutes;
207  aDateTime.Hours = aTime.Hours;
208  aDateTime.Day = aDate.Day;
209  aDateTime.Month = aDate.Month;
210  aDateTime.Year = aDate.Year;
211  aReturn <<= aDateTime;
212  }
213  break;
214  }
215  }
216  else
217  OSL_FAIL("PropertyConversion::convertString: unsupported property type!");
218  }
219  break;
220  default:
221  OSL_FAIL("PropertyConversion::convertString: invalid type class!");
222  }
223 
224  return aReturn;
225 }
226 
228 {
229  Type aUnoType( cppu::UnoType<void>::get() );
230 
231  static std::map< OUString, css::uno::Type > s_aTypeNameMap
232  {
234  // Not a copy paste error, quotation from:
235  // http://nabble.documentfoundation.org/Question-unoType-for-getXmlToken-dbaccess-reportdesign-module-tp4109071p4109116.html
236  // all numeric types (including the UNO double)
237  // consistently map to XML_FLOAT, so taking the extra precision from the
238  // C++ type "float" to "double" makes absolute sense
242  };
243 
244  const std::map< OUString, css::uno::Type >::iterator aTypePos = s_aTypeNameMap.find( _rType );
245  OSL_ENSURE( s_aTypeNameMap.end() != aTypePos, "PropertyConversion::xmlTypeToUnoType: invalid property name!" );
246  if ( s_aTypeNameMap.end() != aTypePos )
247  aUnoType = aTypePos->second;
248 
249  return aUnoType;
250 }
251 
252 //= OPropertyImport
253 OPropertyImport::OPropertyImport(OFormLayerXMLImport_Impl& _rImport, sal_uInt16 _nPrefix, const OUString& _rName)
254  :SvXMLImportContext(_rImport.getGlobalContext(), _nPrefix, _rName)
255  ,m_rContext(_rImport)
256  ,m_bTrackAttributes(false)
257 {
258 }
259 
260 SvXMLImportContextRef OPropertyImport::CreateChildContext(sal_uInt16 _nPrefix, const OUString& _rLocalName,
261  const Reference< XAttributeList >& /*_rxAttrList*/)
262 {
263  if( token::IsXMLToken( _rLocalName, token::XML_PROPERTIES) )
264  {
266  _nPrefix, _rLocalName, this);
267  }
268  return nullptr;
269 }
270 
271 void OPropertyImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
272 {
273  OSL_ENSURE(_rxAttrList.is(), "OPropertyImport::StartElement: invalid attribute list!");
274  const sal_Int32 nAttributeCount = _rxAttrList->getLength();
275 
276  // assume the 'worst' case: all attributes describe properties. This should save our property array
277  // some reallocs
278  m_aValues.reserve(nAttributeCount);
279 
281  sal_uInt16 nNamespace;
282  OUString sLocalName;
283  for (sal_Int32 i=0; i<nAttributeCount; ++i)
284  {
285  nNamespace = rMap.GetKeyByAttrName(_rxAttrList->getNameByIndex(i), &sLocalName);
286  handleAttribute(nNamespace, sLocalName, _rxAttrList->getValueByIndex(i));
287 
288  if (m_bTrackAttributes)
289  m_aEncounteredAttributes.insert(sLocalName);
290  }
291 
292  // TODO: create PropertyValues for all the attributes which were not present, because they were implied
293  // this is necessary as soon as we have properties where the XML default is different from the property
294  // default
295 }
296 
297 bool OPropertyImport::encounteredAttribute(const OUString& _rAttributeName) const
298 {
299  OSL_ENSURE(m_bTrackAttributes, "OPropertyImport::encounteredAttribute: attribute tracking not enabled!");
300  return m_aEncounteredAttributes.end() != m_aEncounteredAttributes.find(_rAttributeName);
301 }
302 
303 void OPropertyImport::Characters(const OUString& _rChars )
304 {
305  // ignore them (should be whitespace only)
306  OSL_ENSURE(_rChars.trim().isEmpty(), "OPropertyImport::Characters: non-whitespace characters!");
307 }
308 
309 bool OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const OUString& _rLocalName, const OUString& _rValue)
310 {
312  if (pProperty)
313  {
314  // create and store a new PropertyValue
315  PropertyValue aNewValue;
316  aNewValue.Name = pProperty->sPropertyName;
317 
318  // convert the value string into the target type
319  if (token::IsXMLToken(_rLocalName, token::XML_HREF))
320  {
321  aNewValue.Value <<= m_rContext.getGlobalContext().GetAbsoluteReference(_rValue);
322  }
323  else
324  {
325  aNewValue.Value = PropertyConversion::convertString(
326  pProperty->aPropertyType, _rValue, pProperty->pEnumMap,
327  pProperty->bInverseSemantics);
328  }
329  implPushBackPropertyValue( aNewValue );
330  return true;
331  }
332  if (!token::IsXMLToken(_rLocalName, token::XML_TYPE)) // xlink:type is valid but ignored for <form:form>
333  {
334  SAL_WARN( "xmloff", "OPropertyImport::handleAttribute: Can't handle the following:\n"
335  " Attribute name: " << _rLocalName << "\n value: " << _rValue );
336  return false;
337  }
338  return true;
339 }
340 
341 //= OPropertyElementsContext
342 OPropertyElementsContext::OPropertyElementsContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
343  const OPropertyImportRef& _rPropertyImporter)
344  :SvXMLImportContext(_rImport, _nPrefix, _rName)
345  ,m_xPropertyImporter(_rPropertyImporter)
346 {
347 }
348 
349 SvXMLImportContextRef OPropertyElementsContext::CreateChildContext(sal_uInt16 _nPrefix, const OUString& _rLocalName,
350  const Reference< XAttributeList >&)
351 {
352  if( token::IsXMLToken( _rLocalName, token::XML_PROPERTY ) )
353  {
354  return new OSinglePropertyContext(GetImport(), _nPrefix, _rLocalName, m_xPropertyImporter);
355  }
356  else if( token::IsXMLToken( _rLocalName, token::XML_LIST_PROPERTY ) )
357  {
358  return new OListPropertyContext( GetImport(), _nPrefix, _rLocalName, m_xPropertyImporter );
359  }
360  return nullptr;
361 }
362 
363 #if OSL_DEBUG_LEVEL > 0
364  void OPropertyElementsContext::StartElement(const Reference< XAttributeList >& _rxAttrList)
365  {
366  OSL_ENSURE(0 == _rxAttrList->getLength(), "OPropertyElementsContext::StartElement: the form:properties element should not have attributes!");
368  }
369 
370  void OPropertyElementsContext::Characters(const OUString& _rChars)
371  {
372  OSL_ENSURE(_rChars.trim().isEmpty(), "OPropertyElementsContext::Characters: non-whitespace characters detected!");
374  }
375 
376 #endif
377 
378 //= OSinglePropertyContext
379 OSinglePropertyContext::OSinglePropertyContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
380  const OPropertyImportRef& _rPropertyImporter)
381  :SvXMLImportContext(_rImport, _nPrefix, _rName)
382  ,m_xPropertyImporter(_rPropertyImporter)
383 {
384 }
385 
386 SvXMLImportContextRef OSinglePropertyContext::CreateChildContext(sal_uInt16 /*_nPrefix*/, const OUString& /*_rLocalName*/,
387  const Reference< XAttributeList >&)
388 {
389  return nullptr;
390 }
391 
392 void OSinglePropertyContext::StartElement(const Reference< XAttributeList >& _rxAttrList)
393 {
394  css::beans::PropertyValue aPropValue; // the property the instance imports currently
395  css::uno::Type aPropType; // the type of the property the instance imports currently
396 
397  OUString sType, sValue;
398  const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
399  const sal_Int16 nAttrCount = _rxAttrList.is() ? _rxAttrList->getLength() : 0;
400  for( sal_Int16 i=0; i < nAttrCount; i++ )
401  {
402  const OUString& rAttrName = _rxAttrList->getNameByIndex( i );
403 
404  OUString aLocalName;
405  sal_uInt16 nPrefix =
406  rMap.GetKeyByAttrName( rAttrName,
407  &aLocalName );
408  if( XML_NAMESPACE_FORM == nPrefix )
409  {
410  if( token::IsXMLToken( aLocalName, token::XML_PROPERTY_NAME ) )
411  aPropValue.Name = _rxAttrList->getValueByIndex( i );
412 
413  }
414  else if( XML_NAMESPACE_OFFICE == nPrefix )
415  {
416  if( token::IsXMLToken( aLocalName, token::XML_VALUE_TYPE ) )
417  sType = _rxAttrList->getValueByIndex( i );
418  else if( token::IsXMLToken( aLocalName,
419  token::XML_VALUE ) ||
420  token::IsXMLToken( aLocalName,
422  token::IsXMLToken( aLocalName,
424  sValue = _rxAttrList->getValueByIndex( i );
425  }
426  }
427 
428  // the name of the property
429  OSL_ENSURE(!aPropValue.Name.isEmpty(), "OSinglePropertyContext::StartElement: invalid property name!");
430 
431  // needs to be translated into a css::uno::Type
432  aPropType = PropertyConversion::xmlTypeToUnoType( sType );
433  if( TypeClass_VOID == aPropType.getTypeClass() )
434  {
435  aPropValue.Value = Any();
436  }
437  else
438  {
439  aPropValue.Value =
441  sValue);
442  }
443 
444  // now that we finally have our property value, add it to our parent object
445  if( !aPropValue.Name.isEmpty() )
446  m_xPropertyImporter->implPushBackGenericPropertyValue(aPropValue);
447 }
448 
449 //= OListPropertyContext
450 OListPropertyContext::OListPropertyContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
451  const OPropertyImportRef& _rPropertyImporter )
452  :SvXMLImportContext( _rImport, _nPrefix, _rName )
453  ,m_xPropertyImporter( _rPropertyImporter )
454 {
455 }
456 
457 void OListPropertyContext::StartElement( const Reference< XAttributeList >& _rxAttrList )
458 {
459  sal_Int32 nAttributeCount = _rxAttrList->getLength();
460 
461  sal_uInt16 nNamespace;
462  OUString sAttributeName;
463  const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
464  for ( sal_Int32 i = 0; i < nAttributeCount; ++i )
465  {
466  nNamespace = rMap.GetKeyByAttrName( _rxAttrList->getNameByIndex( i ), &sAttributeName );
467  if ( ( XML_NAMESPACE_FORM == nNamespace )
468  && ( token::IsXMLToken( sAttributeName, token::XML_PROPERTY_NAME ) )
469  )
470  {
471  m_sPropertyName = _rxAttrList->getValueByIndex( i );
472  }
473  else if ( ( XML_NAMESPACE_OFFICE == nNamespace )
474  && ( token::IsXMLToken( sAttributeName, token::XML_VALUE_TYPE ) )
475  )
476  {
477  m_sPropertyType = _rxAttrList->getValueByIndex( i );
478  }
479  else
480  {
481  OSL_FAIL( OStringBuffer( "OListPropertyContext::StartElement: unknown child element (\"").
482  append(OUStringToOString(sAttributeName, RTL_TEXTENCODING_ASCII_US)).
483  append("\")!").getStr() );
484  }
485  }
486 }
487 
489 {
490  OSL_ENSURE( !m_sPropertyName.isEmpty() && !m_sPropertyType.isEmpty(),
491  "OListPropertyContext::EndElement: no property name or type!" );
492 
493  if ( m_sPropertyName.isEmpty() || m_sPropertyType.isEmpty() )
494  return;
495 
496  Sequence< Any > aListElements( m_aListValues.size() );
497  Any* pListElement = aListElements.getArray();
498  css::uno::Type aType = PropertyConversion::xmlTypeToUnoType( m_sPropertyType );
499  for ( const auto& rListValue : m_aListValues )
500  {
501  *pListElement = PropertyConversion::convertString( aType, rListValue );
502  ++pListElement;
503  }
504 
505  PropertyValue aSequenceValue;
506  aSequenceValue.Name = m_sPropertyName;
507  aSequenceValue.Value <<= aListElements;
508 
509  m_xPropertyImporter->implPushBackGenericPropertyValue( aSequenceValue );
510 }
511 
512 SvXMLImportContextRef OListPropertyContext::CreateChildContext( sal_uInt16 _nPrefix, const OUString& _rLocalName, const Reference< XAttributeList >& /*_rxAttrList*/ )
513 {
514  if ( token::IsXMLToken( _rLocalName, token::XML_LIST_VALUE ) )
515  {
516  m_aListValues.emplace_back();
517  return new OListValueContext( GetImport(), _nPrefix, _rLocalName, *m_aListValues.rbegin() );
518  }
519  return nullptr;
520 }
521 
522 //= OListValueContext
523 OListValueContext::OListValueContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName, OUString& _rListValueHolder )
524  :SvXMLImportContext( _rImport, _nPrefix, _rName )
525  ,m_rListValueHolder( _rListValueHolder )
526 {
527 }
528 
529 void OListValueContext::StartElement( const Reference< XAttributeList >& _rxAttrList )
530 {
531  const sal_Int32 nAttributeCount = _rxAttrList->getLength();
532 
533  sal_uInt16 nNamespace;
534  OUString sAttributeName;
535  const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
536  for ( sal_Int32 i = 0; i < nAttributeCount; ++i )
537  {
538  nNamespace = rMap.GetKeyByAttrName( _rxAttrList->getNameByIndex( i ), &sAttributeName );
539  if ( XML_NAMESPACE_OFFICE == nNamespace )
540  {
541  if ( token::IsXMLToken( sAttributeName, token::XML_VALUE )
542  || token::IsXMLToken( sAttributeName, token::XML_STRING_VALUE )
543  || token::IsXMLToken( sAttributeName, token::XML_BOOLEAN_VALUE )
544  )
545  {
546  m_rListValueHolder = _rxAttrList->getValueByIndex( i );
547  continue;
548  }
549  }
550 
551  OSL_FAIL( OStringBuffer( "OListValueContext::StartElement: unknown child element (\"").
552  append(OUStringToOString(sAttributeName, RTL_TEXTENCODING_ASCII_US)).
553  append("\")!").getStr() );
554  }
555 }
556 
557 } // namespace xmloff
558 
559 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const sal_Int64 minutePerHour
Type
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
static const sal_Int64 nanoSecPerSec
static const sal_Int64 secondPerMinute
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
virtual void Characters(const OUString &_rChars) override
This method is called for all characters that are contained in the current element.
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:128
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
#define TYPE_DATE
static css::uno::Any convertString(const css::uno::Type &_rExpectedType, const OUString &_rReadCharacters, const SvXMLEnumMapEntry< EnumT > *_pEnumMap=nullptr)
const SvXMLEnumMapEntry< sal_uInt16 > * pEnumMap
static bool convertBool(bool &rBool, const OUString &rString)
const AttributeAssignment * getAttributeTranslation(const OUString &_rAttribName)
return the AttributeAssignment which corresponds to the given attribute
helper class for importing a single element
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
OListValueContext(SvXMLImport &_rImport, sal_uInt16 _nPrefix, const OUString &_rName, OUString &_rListValueHolder)
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:402
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 _nPrefix, const OUString &_rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
Create a children element context.
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
StartElement is called after a context has been constructed and before an elements context is parsed...
Definition: xmlictxt.cxx:58
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
OPropertyImportRef m_xPropertyImporter
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 _nPrefix, const OUString &_rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
Create a children element context.
#define TYPE_TIME
OListPropertyContext(SvXMLImport &_rImport, sal_uInt16 _nPrefix, const OUString &_rName, const OPropertyImportRef &_rPropertyImporter)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
helper class for importing the element
virtual void Characters(const OUString &rChars)
This method is called for all characters that are contained in the current element.
Definition: xmlictxt.cxx:66
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 _nPrefix, const OUString &_rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
Create a children element context.
const Reference< XComponentContext > & m_rContext
constexpr sal_uInt16 XML_NAMESPACE_FORM
sal_Int32 _nValue
OPropertyImportRef m_xPropertyImporter
OptionalString sType
int i
virtual void Characters(const OUString &_rChars) override
This method is called for all characters that are contained in the current element.
css::uno::Type const & get()
OPropertyElementsContext(SvXMLImport &_rImport, sal_uInt16 _nPrefix, const OUString &_rName, const OPropertyImportRef &_rPropertyImporter)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
constexpr T & temporary(T &&x)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
OFormLayerXMLImport_Impl & m_rContext
::std::vector< OUString > m_aListValues
PropertyValueArray m_aValues
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
std::set< OUString > m_aEncounteredAttributes
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
void implPushBackPropertyValue(const css::beans::PropertyValue &_rProp)
OPropertyImport(OFormLayerXMLImport_Impl &_rImport, sal_uInt16 _nPrefix, const OUString &_rName)
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1690
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const OUString &_rLocalName, const OUString &_rValue)
handle one single attribute.
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 _nPrefix, const OUString &_rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
Create a children element context.
OAttribute2Property & getAttributeMap()
Definition: layerimport.hxx:95
OPropertyImportRef m_xPropertyImporter
OReadImagesDocumentHandler::Image_XML_Namespace nNamespace
QPRO_FUNC_TYPE nType
static const sal_Int64 nanoSecPerDay
#define SAL_WARN(area, stream)
OSinglePropertyContext(SvXMLImport &_rImport, sal_uInt16 _nPrefix, const OUString &_rName, const OPropertyImportRef &_rPropertyImporter)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &_rxAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
#define TYPE_DATETIME
static css::uno::Type xmlTypeToUnoType(const OUString &_rType)
bool encounteredAttribute(const OUString &_rAttributeName) const
determine if the element imported by the object had a given attribute.
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)