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>
23#include "strings.hxx"
24#include "callbacks.hxx"
26#include "eventimport.hxx"
27#include <xmloff/txtstyli.hxx>
28#include "formenums.hxx"
29#include <xmloff/xmltoken.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
45#include <tools/urlobj.hxx>
46#include <tools/diagnose_ex.h>
47#include <rtl/strbuf.hxx>
48#include <sal/log.hxx>
50#include <comphelper/types.hxx>
52#include <o3tl/string_view.hxx>
53
54#include <algorithm>
55
56namespace xmloff
57{
58
59 using namespace ::xmloff::token;
60 using namespace ::com::sun::star;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::awt;
63 using namespace ::com::sun::star::container;
64 using namespace ::com::sun::star::beans;
65 using namespace ::com::sun::star::script;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::form;
68 using namespace ::com::sun::star::xml;
69 using namespace ::com::sun::star::xml::sax;
70 using namespace ::com::sun::star::util;
71 using namespace ::com::sun::star::text;
72 using namespace ::comphelper;
73 using ::com::sun::star::xml::sax::XAttributeList;
74
75#define PROPID_VALUE 1
76#define PROPID_CURRENT_VALUE 2
77#define PROPID_MIN_VALUE 3
78#define PROPID_MAX_VALUE 4
79
80 namespace {
81
82 struct PropertyValueLess
83 {
84 bool operator()(const PropertyValue& _rLeft, const PropertyValue& _rRight)
85 {
86 return _rLeft.Name < _rRight.Name;
87 }
88 };
89
90 }
91
92 //= 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, Any(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 OUStringToOString(rCheck.Name, RTL_TEXTENCODING_ASCII_US) +
232 ") 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 OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) +
292 "\"!").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(std::cbegin(aXMLValueList), std::cend(aXMLValueList), aPropertyValueList.getArray(),
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 OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) +
436 "\"!").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
550 if ( m_bImplicitGenericAttributeHandling )
551 if ( tryGenericAttribute( nElement, _rValue ) )
552 return true;
553
554 // let the base class handle it
555 return OPropertyImport::handleAttribute( nElement, _rValue);
556 }
557
558 Reference< XPropertySet > OElementImport::createElement()
559 {
560 Reference< XPropertySet > xReturn;
561 if (!m_sServiceName.isEmpty())
562 {
563 Reference< XComponentContext > xContext = m_rFormImport.getGlobalContext().GetComponentContext();
564 Reference< XInterface > xPure = xContext->getServiceManager()->createInstanceWithContext(m_sServiceName, xContext);
565 OSL_ENSURE(xPure.is(),
566 OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: " +
567 OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) +
568 ")!").getStr());
569 xReturn.set(xPure, UNO_QUERY);
570 }
571 else
572 OSL_FAIL("OElementImport::createElement: no service name to create an element!");
573
574 return xReturn;
575 }
576
577 void OElementImport::registerEvents(const Sequence< ScriptEventDescriptor >& _rEvents)
578 {
579 OSL_ENSURE(m_xElement.is(), "OElementImport::registerEvents: no element to register events for!");
580 m_rEventManager.registerEvents(m_xElement, _rEvents);
581 }
582
583 void OElementImport::simulateDefaultedAttribute(sal_Int32 nElement, const OUString& _rPropertyName, const char* _pAttributeDefault)
584 {
585 OSL_ENSURE( m_xInfo.is(), "OPropertyImport::simulateDefaultedAttribute: the component should be more gossipy about it's properties!" );
586
587 if ( !m_xInfo.is() || m_xInfo->hasPropertyByName( _rPropertyName ) )
588 {
589 if ( !encounteredAttribute( nElement ) )
590 OSL_VERIFY( handleAttribute( XML_ELEMENT(FORM, (nElement & TOKEN_MASK)), OUString::createFromAscii( _pAttributeDefault ) ) );
591 }
592 }
593
594 //= OControlImport
595 OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
596 const Reference< XNameContainer >& _rxParentContainer)
597 :OElementImport(_rImport, _rEventManager, _rxParentContainer)
598 ,m_eElementType(OControlElement::UNKNOWN)
599 {
601 }
602
603 OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
604 const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
605 :OElementImport(_rImport, _rEventManager, _rxParentContainer)
606 ,m_eElementType(_eType)
607 {
609 }
610
612 {
613 const char* pServiceName = nullptr;
614 switch ( m_eElementType )
615 {
618 case OControlElement::PASSWORD: pServiceName = "com.sun.star.form.component.TextField"; break;
619 case OControlElement::FILE: pServiceName = "com.sun.star.form.component.FileControl"; break;
620 case OControlElement::FORMATTED_TEXT: pServiceName = "com.sun.star.form.component.FormattedField"; break;
621 case OControlElement::FIXED_TEXT: pServiceName = "com.sun.star.form.component.FixedText"; break;
622 case OControlElement::COMBOBOX: pServiceName = "com.sun.star.form.component.ComboBox"; break;
623 case OControlElement::LISTBOX: pServiceName = "com.sun.star.form.component.ListBox"; break;
624 case OControlElement::BUTTON: pServiceName = "com.sun.star.form.component.CommandButton"; break;
625 case OControlElement::IMAGE: pServiceName = "com.sun.star.form.component.ImageButton"; break;
626 case OControlElement::CHECKBOX: pServiceName = "com.sun.star.form.component.CheckBox"; break;
627 case OControlElement::RADIO: pServiceName = "com.sun.star.form.component.RadioButton"; break;
628 case OControlElement::FRAME: pServiceName = "com.sun.star.form.component.GroupBox"; break;
629 case OControlElement::IMAGE_FRAME: pServiceName = "com.sun.star.form.component.DatabaseImageControl"; break;
630 case OControlElement::HIDDEN: pServiceName = "com.sun.star.form.component.HiddenControl"; break;
631 case OControlElement::GRID: pServiceName = "com.sun.star.form.component.GridControl"; break;
632 case OControlElement::VALUERANGE: pServiceName = "com.sun.star.form.component.ScrollBar"; break;
633 case OControlElement::TIME: pServiceName = "com.sun.star.form.component.TimeField"; break;
634 case OControlElement::DATE: pServiceName = "com.sun.star.form.component.DateField"; break;
635 default: break;
636 }
637 if ( pServiceName != nullptr )
638 return OUString::createFromAscii( pServiceName );
639 return OUString();
640 }
641
642 void OControlImport::addOuterAttributes(const Reference< XFastAttributeList >& _rxOuterAttribs)
643 {
644 OSL_ENSURE(!m_xOuterAttributes.is(), "OControlImport::addOuterAttributes: already have these attributes!");
645 m_xOuterAttributes = _rxOuterAttribs;
646 }
647
648 bool OControlImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
649 {
650 static sal_Int32 nLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeToken(BAFlags::LinkedCell);
651
652 if ((nElement & TOKEN_MASK) == XML_ID)
653 { // it's the control id
655 {
656 m_sControlId = _rValue;
657 }
658 else if (IsTokenInNamespace(nElement, XML_NAMESPACE_FORM))
659 {
660 if (m_sControlId.isEmpty())
661 {
662 m_sControlId = _rValue;
663 }
664 }
665 return true;
666 }
667
668 if ( (nElement & TOKEN_MASK) == nLinkedCellAttributeName )
669 { // it's the address of a spreadsheet cell
670 m_sBoundCellAddress = _rValue;
671 return true;
672 }
673
674 if ( nElement == XML_ELEMENT(XFORMS, XML_BIND ) )
675 {
676 m_sBindingID = _rValue;
677 return true;
678 }
679
680 if ( nElement == XML_ELEMENT(FORM, XML_XFORMS_LIST_SOURCE) )
681 {
682 m_sListBindingID = _rValue;
683 return true;
684 }
685
686 if ( nElement == XML_ELEMENT(FORM, XML_XFORMS_SUBMISSION)
687 || nElement == XML_ELEMENT(XFORMS, XML_SUBMISSION) )
688 {
689 m_sSubmissionID = _rValue;
690 return true;
691 }
692
693 if ( OElementImport::tryGenericAttribute( nElement, _rValue ) )
694 return true;
695
696 static const sal_Int32 nValueAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Value);
697 static const sal_Int32 nCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentValue);
698 static const sal_Int32 nMinValueAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::MinValue);
699 static const sal_Int32 nMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::MaxValue);
700 static const sal_Int32 nRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeToken( SCAFlags::RepeatDelay );
701
702 sal_Int32 nHandle = -1;
703 if ( (nElement & TOKEN_MASK) == nValueAttributeName )
705 else if ( (nElement & TOKEN_MASK) == nCurrentValueAttributeName )
707 else if ( (nElement & TOKEN_MASK) == nMinValueAttributeName )
709 else if ( (nElement & TOKEN_MASK) == nMaxValueAttributeName )
711 if ( nHandle != -1 )
712 {
713 // for the moment, simply remember the name and the value
714 PropertyValue aProp;
715 aProp.Name = SvXMLImport::getNameFromToken(nElement);
716 aProp.Handle = nHandle;
717 aProp.Value <<= _rValue;
718 m_aValueProperties.push_back(aProp);
719 return true;
720 }
721
722 if ( (nElement & TOKEN_MASK) == nRepeatDelayAttributeName )
723 {
724 util::Duration aDuration;
725 if (::sax::Converter::convertDuration(aDuration, _rValue))
726 {
727 PropertyValue aProp;
728 aProp.Name = PROPERTY_REPEAT_DELAY;
729 sal_Int32 const nMS =
730 ((aDuration.Hours * 60 + aDuration.Minutes) * 60
731 + aDuration.Seconds) * 1000 + aDuration.NanoSeconds/1000000;
732 aProp.Value <<= nMS;
733
735 }
736 return true;
737 }
738
739 return OElementImport::handleAttribute( nElement, _rValue );
740 }
741
742 void OControlImport::startFastElement(sal_Int32 nElement, const Reference< css::xml::sax::XFastAttributeList >& _rxAttrList)
743 {
744 css::uno::Reference< css::xml::sax::XFastAttributeList > xMergedAttributes;
745 if( m_xOuterAttributes.is() )
746 {
747 // merge the attribute lists, our own one
749 // and the ones of our enclosing element
750 xMerger->add(m_xOuterAttributes);
751 xMergedAttributes = xMerger.get();
752 }
753 else
754 {
755 xMergedAttributes = _rxAttrList;
756 }
757
758 // let the base class handle all the attributes
759 OElementImport::startFastElement(nElement, xMergedAttributes);
760
761 if ( m_aValueProperties.empty() || !m_xElement.is())
762 return;
763
764 // get the property set info
765 if (!m_xInfo.is())
766 {
767 OSL_FAIL("OControlImport::StartElement: no PropertySetInfo!");
768 return;
769 }
770
771 const char* pValueProperty = nullptr;
772 const char* pCurrentValueProperty = nullptr;
773 const char* pMinValueProperty = nullptr;
774 const char* pMaxValueProperty = nullptr;
775
776 bool bRetrievedValues = false;
777 bool bRetrievedValueLimits = false;
778
779 // get the class id of our element
780 sal_Int16 nClassId = FormComponentType::CONTROL;
781 m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
782
783 // translate the value properties we collected in handleAttributes
784 for ( auto& rValueProps : m_aValueProperties )
785 {
786 bool bSuccess = false;
787 switch (rValueProps.Handle)
788 {
789 case PROPID_VALUE:
791 {
792 // get the property names
793 if (!bRetrievedValues)
794 {
795 getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty);
796 if ( !pCurrentValueProperty && !pValueProperty )
797 {
798 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value property names!" );
799 break;
800 }
801
802 bRetrievedValues = true;
803 }
804 if ( PROPID_VALUE == rValueProps.Handle && !pValueProperty )
805 {
806 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a value property!");
807 break;
808 }
809
810 if ( PROPID_CURRENT_VALUE == rValueProps.Handle && !pCurrentValueProperty )
811 {
812 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a current-value property!");
813 break;
814 }
815
816 // transfer the name
817 if (PROPID_VALUE == rValueProps.Handle)
818 rValueProps.Name = OUString::createFromAscii(pValueProperty);
819 else
820 rValueProps.Name = OUString::createFromAscii(pCurrentValueProperty);
821 bSuccess = true;
822 }
823 break;
824 case PROPID_MIN_VALUE:
825 case PROPID_MAX_VALUE:
826 {
827 // get the property names
828 if (!bRetrievedValueLimits)
829 {
830 getValueLimitPropertyNames(nClassId, pMinValueProperty, pMaxValueProperty);
831 if ( !pMinValueProperty || !pMaxValueProperty )
832 {
833 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value limit property names!" );
834 break;
835 }
836
837 bRetrievedValueLimits = true;
838 }
839 OSL_ENSURE((PROPID_MIN_VALUE != rValueProps.Handle) || pMinValueProperty,
840 "OControlImport::StartElement: the control does not have a value property!");
841 OSL_ENSURE((PROPID_MAX_VALUE != rValueProps.Handle) || pMaxValueProperty,
842 "OControlImport::StartElement: the control does not have a current-value property!");
843
844 // transfer the name
845 if (PROPID_MIN_VALUE == rValueProps.Handle)
846 rValueProps.Name = OUString::createFromAscii(pMinValueProperty);
847 else
848 rValueProps.Name = OUString::createFromAscii(pMaxValueProperty);
849 bSuccess = true;
850 }
851 break;
852 }
853
854 if ( !bSuccess )
855 continue;
856
857 // translate the value
859 // add the property to the base class' array
860 implPushBackPropertyValue(rValueProps);
861 }
862
863 }
864
865 void OControlImport::implTranslateValueProperty(const Reference< XPropertySetInfo >& _rxPropInfo,
866 PropertyValue& _rPropValue)
867 {
868 OSL_ENSURE(_rxPropInfo->hasPropertyByName(_rPropValue.Name),
869 "OControlImport::implTranslateValueProperty: invalid property name!");
870
871 // retrieve the type of the property
872 Property aProp = _rxPropInfo->getPropertyByName(_rPropValue.Name);
873 // the untranslated string value as read in handleAttribute
874 OUString sValue;
875 bool bSuccess = _rPropValue.Value >>= sValue;
876 OSL_ENSURE(bSuccess, "OControlImport::implTranslateValueProperty: supposed to be called with non-translated string values!");
877
878 if (TypeClass_ANY == aProp.Type.getTypeClass())
879 {
880 // we have exactly 2 properties where this type class is allowed:
882 _rPropValue.Name != PROPERTY_EFFECTIVE_VALUE
883 && _rPropValue.Name != PROPERTY_EFFECTIVE_DEFAULT, "xmloff",
884 "OControlImport::implTranslateValueProperty: invalid property type/name combination, Any and " << _rPropValue.Name);
885
886 // Both properties are allowed to have a double or a string value,
887 // so first try to convert the string into a number
888 double nValue;
890 _rPropValue.Value <<= nValue;
891 else
892 _rPropValue.Value <<= sValue;
893 }
894 else
895 _rPropValue.Value = PropertyConversion::convertString(aProp.Type, sValue);
896 }
897
898 void OControlImport::endFastElement(sal_Int32 nElement)
899 {
900 OSL_ENSURE(m_xElement.is(), "OControlImport::EndElement: invalid control!");
901 if ( !m_xElement.is() )
902 return;
903
904 // register our control with its id
905 if (!m_sControlId.isEmpty())
907 // it's allowed to have no control id. In this case we're importing a column
908
909 // one more pre-work to do:
910 // when we set default values, then by definition the respective value is set
911 // to this default value, too. This means if the sequence contains for example
912 // a DefaultText value, then the Text will be affected by this, too.
913 // In case the Text is not part of the property sequence (or occurs _before_
914 // the DefaultText, which can happen for other value/default-value property names),
915 // this means that the Text (the value property) is incorrectly imported.
916
917 bool bRestoreValuePropertyValue = false;
918 Any aValuePropertyValue;
919
920 sal_Int16 nClassId = FormComponentType::CONTROL;
921 try
922 {
923 // get the class id of our element
924 m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
925 }
926 catch( const Exception& )
927 {
928 TOOLS_WARN_EXCEPTION("xmloff.forms",
929 "caught an exception while retrieving the class id!");
930 }
931
932 const char* pValueProperty = nullptr;
933 const char* pDefaultValueProperty = nullptr;
934 getRuntimeValuePropertyNames(m_eElementType, nClassId, pValueProperty, pDefaultValueProperty);
935 if ( pDefaultValueProperty && pValueProperty )
936 {
937 bool bNonDefaultValuePropertyValue = false;
938 // is the "value property" part of the sequence?
939
940 // look up this property in our sequence
941 for ( const auto& rCheck : m_aValues )
942 {
943 if ( rCheck.Name.equalsAscii( pDefaultValueProperty ) )
944 bRestoreValuePropertyValue = true;
945 else if ( rCheck.Name.equalsAscii( pValueProperty ) )
946 {
947 bNonDefaultValuePropertyValue = true;
948 // we need to restore the value property we found here, nothing else
949 aValuePropertyValue = rCheck.Value;
950 }
951 }
952
953 if ( bRestoreValuePropertyValue && !bNonDefaultValuePropertyValue )
954 {
955 // found it -> need to remember (and restore) the "value property value", which is not set explicitly
956 try
957 {
958 aValuePropertyValue = m_xElement->getPropertyValue( OUString::createFromAscii( pValueProperty ) );
959 }
960 catch( const Exception& )
961 {
963 "xmloff.forms",
964 "caught an exception while retrieving the current value property!");
965 }
966 }
967 }
968
969 // let the base class set all the values
971
972 // restore the "value property value", if necessary
973 if ( bRestoreValuePropertyValue && pValueProperty )
974 {
975 try
976 {
977 m_xElement->setPropertyValue( OUString::createFromAscii( pValueProperty ), aValuePropertyValue );
978 }
979 catch( const Exception& )
980 {
981 TOOLS_WARN_EXCEPTION("xmloff.forms",
982 "caught an exception while restoring the value property!");
983 }
984 }
985
986 // the external cell binding, if applicable
987 if ( m_xElement.is() && !m_sBoundCellAddress.isEmpty() )
989
990 // XForms binding, if applicable
991 if ( m_xElement.is() && !m_sBindingID.isEmpty() )
993
994 // XForms list binding, if applicable
995 if ( m_xElement.is() && !m_sListBindingID.isEmpty() )
997
998 // XForms submission, if applicable
999 if ( m_xElement.is() && !m_sSubmissionID.isEmpty() )
1001 }
1002
1003 void OControlImport::doRegisterCellValueBinding( const OUString& _rBoundCellAddress )
1004 {
1005 OSL_PRECOND( m_xElement.is(), "OControlImport::doRegisterCellValueBinding: invalid element!" );
1006 OSL_PRECOND( !_rBoundCellAddress.isEmpty(),
1007 "OControlImport::doRegisterCellValueBinding: invalid address!" );
1008
1009 m_rContext.registerCellValueBinding( m_xElement, _rBoundCellAddress );
1010 }
1011
1012 void OControlImport::doRegisterXFormsValueBinding( const OUString& _rBindingID )
1013 {
1014 OSL_PRECOND( m_xElement.is(), "need element" );
1015 OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
1016
1018 }
1019
1020 void OControlImport::doRegisterXFormsListBinding( const OUString& _rBindingID )
1021 {
1022 OSL_PRECOND( m_xElement.is(), "need element" );
1023 OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
1024
1026 }
1027
1028 void OControlImport::doRegisterXFormsSubmission( const OUString& _rSubmissionID )
1029 {
1030 OSL_PRECOND( m_xElement.is(), "need element" );
1031 OSL_PRECOND( !_rSubmissionID.isEmpty(), "binding ID is not valid" );
1032
1034 }
1035
1036 Reference< XPropertySet > OControlImport::createElement()
1037 {
1038 const Reference<XPropertySet> xPropSet = OElementImport::createElement();
1039 if ( xPropSet.is() )
1040 {
1041 m_xInfo = xPropSet->getPropertySetInfo();
1042 if ( m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_ALIGN) )
1043 {
1044 Any aValue;
1045 xPropSet->setPropertyValue(PROPERTY_ALIGN,aValue);
1046 }
1047 }
1048 return xPropSet;
1049 }
1050
1051 //= OImagePositionImport
1053 const Reference< XNameContainer >& _rxParentContainer,
1055 :OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1056 ,m_nImagePosition( -1 )
1057 ,m_nImageAlign( 0 )
1058 ,m_bHaveImagePosition( false )
1059 {
1060 }
1061
1063 const OUString& _rValue )
1064 {
1065 static const sal_Int32 s_nImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::ImageData);
1066
1067 if ( (nElement & TOKEN_MASK) == s_nImageDataAttributeName)
1068 {
1070 return true;
1071 }
1072 else if ( (nElement & TOKEN_MASK) == XML_IMAGE_POSITION )
1073 {
1075 cppu::UnoType<decltype(m_nImagePosition)>::get(),
1076 _rValue, aImagePositionMap
1077 ) >>= m_nImagePosition );
1078 m_bHaveImagePosition = true;
1079 return true;
1080 }
1081 else if ( (nElement & TOKEN_MASK) == XML_IMAGE_ALIGN )
1082 {
1084 cppu::UnoType<decltype(m_nImageAlign)>::get(),
1085 _rValue, aImageAlignMap
1086 ) >>= m_nImageAlign );
1087 return true;
1088 }
1089
1090 return OControlImport::handleAttribute( nElement, _rValue );
1091 }
1092
1093 void OImagePositionImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1094 {
1095 OControlImport::startFastElement( nElement, _rxAttrList );
1096
1097 if (m_xGraphic.is())
1098 {
1099 PropertyValue aGraphicProperty;
1100 aGraphicProperty.Name = PROPERTY_GRAPHIC;
1101 aGraphicProperty.Value <<= m_xGraphic;
1102 implPushBackPropertyValue(aGraphicProperty);
1103 }
1104 if ( !m_bHaveImagePosition )
1105 return;
1106
1107 sal_Int16 nUnoImagePosition = ImagePosition::Centered;
1108 if ( m_nImagePosition >= 0 )
1109 {
1110 OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ),
1111 "OImagePositionImport::StartElement: unknown image align and/or position!" );
1112 nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign;
1113 }
1114
1115 PropertyValue aImagePosition;
1116 aImagePosition.Name = PROPERTY_IMAGE_POSITION;
1117 aImagePosition.Value <<= nUnoImagePosition;
1118 implPushBackPropertyValue( aImagePosition );
1119 }
1120
1121 //= OReferredControlImport
1123 OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
1124 const Reference< XNameContainer >& _rxParentContainer )
1125 :OControlImport(_rImport, _rEventManager, _rxParentContainer)
1126 {
1127 }
1128
1129 void OReferredControlImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1130 {
1131 OControlImport::startFastElement(nElement, _rxAttrList);
1132
1133 // the base class should have created the control, so we can register it
1134 if ( !m_sReferringControls.isEmpty() )
1136 }
1137
1139 const OUString& _rValue)
1140 {
1141 static const sal_Int32 s_nReferenceAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::For);
1142 if ((nElement & TOKEN_MASK) == s_nReferenceAttributeName)
1143 {
1144 m_sReferringControls = _rValue;
1145 return true;
1146 }
1147 return OControlImport::handleAttribute(nElement, _rValue);
1148 }
1149
1150 //= OPasswordImport
1152 const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
1153 :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1154 {
1155 }
1156
1157 bool OPasswordImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1158 {
1159 static const sal_Int32 s_nEchoCharAttributeName = OAttributeMetaData::getSpecialAttributeToken(SCAFlags::EchoChar);
1160 if ((nElement & TOKEN_MASK) == s_nEchoCharAttributeName)
1161 {
1162 // need a special handling for the EchoChar property
1163 PropertyValue aEchoChar;
1164 aEchoChar.Name = PROPERTY_ECHOCHAR;
1165 OSL_ENSURE(_rValue.getLength() == 1, "OPasswordImport::handleAttribute: invalid echo char attribute!");
1166 // we ourself should not have written values other than of length 1
1167 if (_rValue.getLength() >= 1)
1168 aEchoChar.Value <<= static_cast<sal_Int16>(_rValue[0]);
1169 else
1170 aEchoChar.Value <<= sal_Int16(0);
1171 implPushBackPropertyValue(aEchoChar);
1172 return true;
1173 }
1174 return OControlImport::handleAttribute(nElement, _rValue);
1175 }
1176
1177 //= ORadioImport
1179 const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
1180 :OImagePositionImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1181 {
1182 }
1183
1184 bool ORadioImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1185 {
1186 // need special handling for the State & CurrentState properties:
1187 // they're stored as booleans, but expected to be int16 properties
1188 static const sal_Int32 nCurrentSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentSelected);
1189 static const sal_Int32 nSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Selected);
1190 if ( (nElement & TOKEN_MASK) == nCurrentSelectedAttributeName
1191 || (nElement & TOKEN_MASK) == nSelectedAttributeName
1192 )
1193 {
1195 assert(pProperty && "ORadioImport::handleAttribute: invalid property map!");
1196 if (pProperty)
1197 {
1198 const Any aBooleanValue( PropertyConversion::convertString(pProperty->aPropertyType, _rValue, pProperty->pEnumMap) );
1199
1200 // create and store a new PropertyValue
1201 PropertyValue aNewValue;
1202 aNewValue.Name = pProperty->sPropertyName;
1203 aNewValue.Value <<= static_cast<sal_Int16>(::cppu::any2bool(aBooleanValue));
1204
1205 implPushBackPropertyValue(aNewValue);
1206 }
1207 return true;
1208 }
1209 return OImagePositionImport::handleAttribute( nElement, _rValue );
1210 }
1211
1212 //= OURLReferenceImport
1214 const Reference< XNameContainer >& _rxParentContainer,
1216 :OImagePositionImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1217 {
1218 }
1219
1220 bool OURLReferenceImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1221 {
1222 static const sal_Int32 s_nTargetLocationAttributeName = OAttributeMetaData::getCommonControlAttributeToken( CCAFlags::TargetLocation );
1223 static const sal_Int32 s_nImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeToken( CCAFlags::ImageData );
1224
1225 // need to make the URL absolute if
1226 // * it's the image-data attribute
1227 // * it's the target-location attribute, and we're dealing with an object which has the respective property
1228 bool bMakeAbsolute =
1229 (nElement & TOKEN_MASK) == s_nImageDataAttributeName
1230 || ( (nElement & TOKEN_MASK) == s_nTargetLocationAttributeName
1233 )
1234 );
1235
1236 if (bMakeAbsolute && !_rValue.isEmpty())
1237 {
1238 OUString sAdjustedValue = _rValue;
1239 if ((nElement & TOKEN_MASK) != s_nImageDataAttributeName)
1240 sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue );
1241 return OImagePositionImport::handleAttribute( nElement, sAdjustedValue );
1242 }
1243
1244 return OImagePositionImport::handleAttribute( nElement, _rValue );
1245 }
1246
1247 //= OButtonImport
1249 const Reference< XNameContainer >& _rxParentContainer,
1251 :OURLReferenceImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1252 {
1254 }
1255
1256 void OButtonImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1257 {
1258 OURLReferenceImport::startFastElement(nElement, _rxAttrList);
1259
1260 // handle the target-frame attribute
1262 }
1263
1264 //= OValueRangeImport
1266 const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType )
1267 :OControlImport( _rImport, _rEventManager, _rxParentContainer, _eType )
1268 ,m_nStepSizeValue( 1 )
1269 {
1270
1271 }
1272
1273 bool OValueRangeImport::handleAttribute( sal_Int32 nElement, const OUString& _rValue )
1274 {
1276 {
1278 return true;
1279 }
1280 return OControlImport::handleAttribute( nElement, _rValue );
1281 }
1282
1283 void OValueRangeImport::startFastElement( sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList )
1284 {
1285 OControlImport::startFastElement( nElement, _rxAttrList );
1286
1287 if ( m_xInfo.is() )
1288 {
1289 if ( m_xInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1290 m_xElement->setPropertyValue( PROPERTY_SPIN_INCREMENT, Any( m_nStepSizeValue ) );
1291 else if ( m_xInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1292 m_xElement->setPropertyValue( PROPERTY_LINE_INCREMENT, Any( m_nStepSizeValue ) );
1293 }
1294 }
1295
1296 //= OTextLikeImport
1298 const Reference< XNameContainer >& _rxParentContainer,
1300 :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1301 ,m_bEncounteredTextPara( false )
1302 {
1304 }
1305
1306 css::uno::Reference< css::xml::sax::XFastContextHandler > OTextLikeImport::createFastChildContext(
1307 sal_Int32 nElement,
1308 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1309 {
1310 if ( nElement == XML_ELEMENT(TEXT, XML_P) )
1311 {
1313 "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" );
1314
1316 {
1317 Reference< XText > xTextElement( m_xElement, UNO_QUERY );
1318 if ( xTextElement.is() )
1319 {
1321
1322 if ( !m_xCursor.is() )
1323 {
1324 m_xOldCursor = xTextImportHelper->GetCursor();
1325 m_xCursor = xTextElement->createTextCursor();
1326
1327 if ( m_xCursor.is() )
1328 xTextImportHelper->SetCursor( m_xCursor );
1329 }
1330 if ( m_xCursor.is() )
1331 {
1333 return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), nElement, xAttrList );
1334 }
1335 }
1336 else
1337 {
1338 // in theory, we could accumulate all the text portions (without formatting),
1339 // and set it as Text property at the model ...
1340 }
1341 }
1342 }
1343
1344 return OControlImport::createFastChildContext( nElement, xAttrList );
1345 }
1346
1347 void OTextLikeImport::startFastElement(sal_Int32 nElement, const Reference< css::xml::sax::XFastAttributeList >& _rxAttrList)
1348 {
1349 OControlImport::startFastElement(nElement, _rxAttrList);
1350
1351 // handle the convert-empty-to-null attribute, whose default is different from the property default
1352 // unfortunately, different classes are imported by this class ('cause they're represented by the
1353 // same XML element), though not all of them know this property.
1354 // So we have to do a check ...
1355 if (m_xElement.is() && m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_EMPTY_IS_NULL) )
1357 }
1358
1359 namespace {
1360
1361 struct EqualHandle
1362 {
1363 const sal_Int32 m_nHandle;
1364 explicit EqualHandle( sal_Int32 _nHandle ) : m_nHandle( _nHandle ) { }
1365
1366 bool operator()( const PropertyValue& _rProp )
1367 {
1368 return _rProp.Handle == m_nHandle;
1369 }
1370 };
1371
1372 }
1373
1375 {
1377 return;
1378
1379 // In case the text is written in the text:p elements, we need to ignore what we read as
1380 // current-value attribute, since it's redundant.
1381 // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE
1382 // handle, so we do not need to determine the name of our value property here
1383 // (normally, it should be "Text", since no other controls than the edit field should
1384 // have the text:p elements)
1385 PropertyValueArray::iterator aValuePropertyPos = ::std::find_if(
1386 m_aValues.begin(),
1387 m_aValues.end(),
1388 EqualHandle( PROPID_CURRENT_VALUE )
1389 );
1390 if ( aValuePropertyPos != m_aValues.end() )
1391 {
1392 OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" );
1393 if ( aValuePropertyPos->Name == PROPERTY_TEXT )
1394 {
1395 m_aValues.erase(aValuePropertyPos);
1396 }
1397 }
1398
1399 // additionally, we need to set the "RichText" property of our element to sal_True
1400 // (the presence of the text:p is used as indicator for the value of the RichText property)
1401 bool bHasRichTextProperty = false;
1402 if ( m_xInfo.is() )
1403 bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT );
1404 OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" );
1405 if ( bHasRichTextProperty )
1406 m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, Any( true ) );
1407 // Note that we do *not* set the RichText property (in case our element has one) to sal_False here
1408 // since this is the default of this property, anyway.
1409 }
1410
1411 namespace {
1412
1413 struct EqualName
1414 {
1415 const OUString & m_sName;
1416 explicit EqualName( const OUString& _rName ) : m_sName( _rName ) { }
1417
1418 bool operator()( const PropertyValue& _rProp )
1419 {
1420 return _rProp.Name == m_sName;
1421 }
1422 };
1423
1424 }
1425
1427 {
1428 // In OpenOffice.org 2.0, we changed the implementation of the css.form.component.TextField (the model of a text field control),
1429 // so that it now uses another default control. So if we encounter a text field where the *old* default
1430 // control property is writing, we are not allowed to use it
1431 PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if(
1432 m_aValues.begin(),
1433 m_aValues.end(),
1434 EqualName( "DefaultControl" )
1435 );
1436 if ( aDefaultControlPropertyPos != m_aValues.end() )
1437 {
1438 OUString sDefaultControl;
1439 OSL_VERIFY( aDefaultControlPropertyPos->Value >>= sDefaultControl );
1440 if ( sDefaultControl == "stardiv.one.form.control.Edit" )
1441 {
1442 // complete remove this property value from the array. Today's "default value" of the "DefaultControl"
1443 // property is sufficient
1444 m_aValues.erase(aDefaultControlPropertyPos);
1445 }
1446 }
1447 }
1448
1449 void OTextLikeImport::endFastElement(sal_Int32 nElement)
1450 {
1453
1454 // let the base class do the stuff
1456
1457 // some cleanups
1459 if ( m_xCursor.is() )
1460 {
1461 // delete the newline which has been imported erroneously
1462 // TODO (fs): stole this code somewhere - why don't we fix the text import??
1463 m_xCursor->gotoEnd( false );
1464 m_xCursor->goLeft( 1, true );
1465 m_xCursor->setString( OUString() );
1466
1467 // reset cursor
1468 xTextImportHelper->ResetCursor();
1469 }
1470
1471 if ( m_xOldCursor.is() )
1472 xTextImportHelper->SetCursor( m_xOldCursor );
1473
1474 }
1475
1476 //= OListAndComboImport
1478 const Reference< XNameContainer >& _rxParentContainer,
1480 :OControlImport(_rImport, _rEventManager, _rxParentContainer, _eType)
1481 ,m_nEmptyListItems( 0 )
1482 ,m_nEmptyValueItems( 0 )
1483 ,m_bEncounteredLSAttrib( false )
1484 ,m_bLinkWithIndexes( false )
1485 {
1488 }
1489
1490 css::uno::Reference< css::xml::sax::XFastContextHandler > OListAndComboImport::createFastChildContext(
1491 sal_Int32 nElement,
1492 const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttrList )
1493 {
1494 // is it the "option" sub tag of a listbox ?
1495 if ((nElement & TOKEN_MASK) == XML_OPTION)
1496 return new OListOptionImport(GetImport(), this);
1497
1498 // is it the "item" sub tag of a combobox ?
1499 if ((nElement & TOKEN_MASK) == XML_ITEM)
1500 return new OComboItemImport(GetImport(), this);
1501
1502 // everything else
1503 return OControlImport::createFastChildContext(nElement, _rxAttrList);
1504 }
1505
1506 void OListAndComboImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1507 {
1508 m_bLinkWithIndexes = false;
1509
1510 OControlImport::startFastElement(nElement, _rxAttrList);
1511
1513 {
1514 // for the auto-completion
1515 // the attribute default does not equal the property default, so in case we did not read this attribute,
1516 // we have to simulate it
1518
1519 // same for the convert-empty-to-null attribute, which's default is different from the property default
1521 }
1522 }
1523
1525 {
1526 // append the list source property the properties sequence of our importer
1527 // the string item list
1528 PropertyValue aItemList;
1529 aItemList.Name = PROPERTY_STRING_ITEM_LIST;
1531 implPushBackPropertyValue(aItemList);
1532
1534 {
1535 OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1536 "OListAndComboImport::EndElement: inconsistence between labels and values!");
1537
1539 {
1540 // the value sequence
1541 PropertyValue aValueList;
1542 aValueList.Name = PROPERTY_LISTSOURCE;
1543 aValueList.Value <<= comphelper::containerToSequence(m_aValueList);
1544 implPushBackPropertyValue(aValueList);
1545 }
1546
1547 // the select sequence
1548 PropertyValue aSelected;
1549 aSelected.Name = PROPERTY_SELECT_SEQ;
1551 implPushBackPropertyValue(aSelected);
1552
1553 // the default select sequence
1554 PropertyValue aDefaultSelected;
1555 aDefaultSelected.Name = PROPERTY_DEFAULT_SELECT_SEQ;
1556 aDefaultSelected.Value <<= comphelper::containerToSequence(m_aDefaultSelectedSeq);
1557 implPushBackPropertyValue(aDefaultSelected);
1558 }
1559
1561
1562 // the external list source, if applicable
1563 if ( m_xElement.is() && !m_sCellListSource.isEmpty() )
1565 }
1566
1567 void OListAndComboImport::doRegisterCellValueBinding( const OUString& _rBoundCellAddress )
1568 {
1569 OUString sBoundCellAddress( _rBoundCellAddress );
1570 if ( m_bLinkWithIndexes )
1571 {
1572 // This is a HACK. We register a string which is no valid address, but allows
1573 // (somewhere else) to determine that a non-standard binding should be created.
1574 // This hack is acceptable for OOo 1.1.1, since the file format for value
1575 // bindings of form controls is to be changed afterwards, anyway.
1576 sBoundCellAddress += ":index";
1577 }
1578
1579 OControlImport::doRegisterCellValueBinding( sBoundCellAddress );
1580 }
1581
1582 bool OListAndComboImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1583 {
1584 static const sal_Int32 nListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeToken(DAFlags::ListSource);
1585 if ( (nElement & TOKEN_MASK) == nListSourceAttributeName )
1586 {
1587 PropertyValue aListSource;
1588 aListSource.Name = PROPERTY_LISTSOURCE;
1589
1590 // it's the ListSource attribute
1593 {
1594 aListSource.Value <<= _rValue;
1595 }
1596 else
1597 {
1598 // a listbox which has a list-source attribute must have a list-source-type of something
1599 // not equal to ValueList.
1600 // In this case, the list-source value is simply the one and only element of the ListSource property.
1601 Sequence<OUString> aListSourcePropValue { _rValue };
1602 aListSource.Value <<= aListSourcePropValue;
1603 }
1604
1605 implPushBackPropertyValue( aListSource );
1606 return true;
1607 }
1608
1610 {
1611 m_sCellListSource = _rValue;
1612 return true;
1613 }
1614
1616 {
1617 sal_Int16 nLinkageType = 0;
1620 _rValue,
1622 ) >>= nLinkageType;
1623
1624 m_bLinkWithIndexes = ( nLinkageType != 0 );
1625 return true;
1626 }
1627
1628 return OControlImport::handleAttribute(nElement, _rValue);
1629 }
1630
1631 void OListAndComboImport::implPushBackLabel(const OUString& _rLabel)
1632 {
1633 OSL_ENSURE(!m_nEmptyListItems, "OListAndComboImport::implPushBackValue: label list is already done!");
1634 if (!m_nEmptyListItems)
1635 m_aListSource.push_back(_rLabel);
1636 }
1637
1638 void OListAndComboImport::implPushBackValue(const OUString& _rValue)
1639 {
1640 OSL_ENSURE(!m_nEmptyValueItems, "OListAndComboImport::implPushBackValue: value list is already done!");
1641 if (!m_nEmptyValueItems)
1642 {
1643 OSL_ENSURE( !m_bEncounteredLSAttrib, "OListAndComboImport::implPushBackValue: invalid structure! Did you save this document with a version prior SRC641 m?" );
1644 // We already had the list-source attribute, which means that the ListSourceType is
1645 // not ValueList, which means that the ListSource should contain only one string in
1646 // the first element of the sequence
1647 // All other values in the file are invalid
1648
1649 m_aValueList.push_back( _rValue );
1650 }
1651 }
1652
1654 {
1656 }
1657
1659 {
1661 }
1662
1664 {
1665 OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1666 "OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!");
1667
1668 sal_Int16 nItemNumber = static_cast<sal_Int16>(m_aListSource.size() - 1 + m_nEmptyListItems);
1669 m_aSelectedSeq.push_back(nItemNumber);
1670 }
1671
1673 {
1674 OSL_ENSURE((m_aListSource.size() + m_nEmptyListItems) == (m_aValueList.size() + m_nEmptyValueItems),
1675 "OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!");
1676
1677 sal_Int16 nItemNumber = static_cast<sal_Int16>(m_aListSource.size() - 1 + m_nEmptyListItems);
1678 m_aDefaultSelectedSeq.push_back(nItemNumber);
1679 }
1680
1681 //= OListOptionImport
1683 const OListAndComboImportRef& _rListBox)
1684 :SvXMLImportContext(_rImport)
1685 ,m_xListBoxImport(_rListBox)
1686 {
1687 }
1688
1689 void OListOptionImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1690 {
1691 // the label and the value
1692 const sal_Int32 nLabelAttribute = (nElement & ~TOKEN_MASK) | XML_LABEL;
1693 const sal_Int32 nValueAttribute = (nElement & ~TOKEN_MASK) | XML_VALUE;
1694
1695 // the label attribute
1696 OUString sValue = _rxAttrList->getOptionalValue(nLabelAttribute);
1697 bool bNonexistentAttribute = !_rxAttrList->hasAttribute(nLabelAttribute);
1698
1699 if (bNonexistentAttribute)
1700 m_xListBoxImport->implEmptyLabelFound();
1701 else
1702 m_xListBoxImport->implPushBackLabel( sValue );
1703
1704 // the value attribute
1705 sValue = _rxAttrList->getOptionalValue(nValueAttribute);
1706 bNonexistentAttribute = !_rxAttrList->hasAttribute(nValueAttribute);
1707
1708 if (bNonexistentAttribute)
1709 m_xListBoxImport->implEmptyValueFound();
1710 else
1711 m_xListBoxImport->implPushBackValue( sValue );
1712
1713 // the current-selected and selected
1714 const sal_Int32 nSelectedAttribute = (nElement & ~TOKEN_MASK) | OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::CurrentSelected);
1715 const sal_Int32 nDefaultSelectedAttribute = (nElement & ~TOKEN_MASK) | OAttributeMetaData::getCommonControlAttributeToken(CCAFlags::Selected);
1716
1717 // propagate the selected flag
1718 bool bSelected(false);
1719 (void)::sax::Converter::convertBool(bSelected,
1720 _rxAttrList->getOptionalValue(nSelectedAttribute));
1721 if (bSelected)
1722 m_xListBoxImport->implSelectCurrentItem();
1723
1724 // same for the default selected
1725 bool bDefaultSelected(false);
1726 (void)::sax::Converter::convertBool(bDefaultSelected,
1727 _rxAttrList->getOptionalValue(nDefaultSelectedAttribute));
1728 if (bDefaultSelected)
1729 m_xListBoxImport->implDefaultSelectCurrentItem();
1730 }
1731
1732 //= OComboItemImport
1734 const OListAndComboImportRef& _rListBox)
1735 :SvXMLImportContext(_rImport)
1736 ,m_xListBoxImport(_rListBox)
1737 {
1738 }
1739
1740 void OComboItemImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1741 {
1742 const sal_Int32 nLabelAttributeName = (nElement & ~TOKEN_MASK) |
1744 m_xListBoxImport->implPushBackLabel(_rxAttrList->getOptionalValue(nLabelAttributeName));
1745 }
1746
1747 //= OColumnWrapperImport
1749 IEventAttacherManager& _rEventManager, sal_Int32 /*nElement*/,
1750 const Reference< XNameContainer >& _rxParentContainer)
1751 :SvXMLImportContext(_rImport.getGlobalContext())
1752 ,m_xParentContainer(_rxParentContainer)
1753 ,m_rFormImport(_rImport)
1754 ,m_rEventManager(_rEventManager)
1755 {
1756 }
1757 css::uno::Reference< css::xml::sax::XFastContextHandler > OColumnWrapperImport::createFastChildContext(
1758 sal_Int32 nElement,
1759 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
1760 {
1762 if (pReturn)
1763 {
1764 OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::CreateChildContext: had no form:column element!");
1766 }
1767 return pReturn;
1768 }
1769 void OColumnWrapperImport::startFastElement(sal_Int32 /*nElement*/, const Reference< XFastAttributeList >& _rxAttrList)
1770 {
1771 OSL_ENSURE(!m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: already have the cloned list!");
1772
1773 // clone the attributes
1774 Reference< XCloneable > xCloneList(_rxAttrList, UNO_QUERY_THROW);
1775 m_xOwnAttributes.set(xCloneList->createClone(), UNO_QUERY_THROW);
1776 }
1777
1779 sal_Int32 /*nElement*/,
1781 {
1782 OSL_ENSURE( (OControlElement::TEXT == _eType)
1783 || (OControlElement::TEXT_AREA == _eType)
1784 || (OControlElement::FORMATTED_TEXT == _eType)
1785 || (OControlElement::CHECKBOX == _eType)
1786 || (OControlElement::LISTBOX == _eType)
1787 || (OControlElement::COMBOBOX == _eType)
1788 || (OControlElement::TIME == _eType)
1789 || (OControlElement::DATE == _eType),
1790 "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!");
1791
1792 switch (_eType)
1793 {
1797
1800
1805
1806 default:
1808 }
1809 }
1810
1811 //= OGridImport
1813 const Reference< XNameContainer >& _rxParentContainer,
1815 :OControlImport(_rImport, _rEventManager, _rxParentContainer)
1816 {
1817 setElementType(_eType);
1818 }
1819
1820 css::uno::Reference< css::xml::sax::XFastContextHandler > OGridImport::createFastChildContext(
1821 sal_Int32 nElement,
1822 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1823 {
1824 // maybe it's a sub control
1825 if ((nElement & TOKEN_MASK) == XML_COLUMN)
1826 {
1827 if (m_xMeAsContainer.is())
1828 return new OColumnWrapperImport(m_rFormImport, *this, nElement, m_xMeAsContainer);
1829 else
1830 {
1831 OSL_FAIL("OGridImport::CreateChildContext: don't have an element!");
1832 return nullptr;
1833 }
1834 }
1835
1836 return OControlImport::createFastChildContext(nElement, xAttrList);
1837 }
1838
1839 void OGridImport::endFastElement(sal_Int32 nElement)
1840 {
1842
1843 // now that we have all children, attach the events
1844 css::uno::Reference< css::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, css::uno::UNO_QUERY);
1845 if (xIndexContainer.is())
1847 }
1848
1849 css::uno::Reference< css::beans::XPropertySet > OGridImport::createElement()
1850 {
1851 // let the base class create the object
1852 css::uno::Reference< css::beans::XPropertySet > xReturn = OControlImport::createElement();
1853 if (!xReturn.is())
1854 return xReturn;
1855
1856 // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
1857 m_xMeAsContainer.set(xReturn, css::uno::UNO_QUERY);
1858 if (!m_xMeAsContainer.is())
1859 {
1860 OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
1861 xReturn.clear();
1862 }
1863
1864 return xReturn;
1865 }
1866
1867 //= OFormImport
1869 const Reference< XNameContainer >& _rxParentContainer)
1870 :OElementImport(_rImport, _rEventManager, _rxParentContainer)
1871 {
1873 }
1874
1875 css::uno::Reference< css::xml::sax::XFastContextHandler > OFormImport::createFastChildContext(
1876 sal_Int32 nElement,
1877 const uno::Reference< xml::sax::XFastAttributeList>& _rxAttrList )
1878 {
1879 auto nToken = (nElement & TOKEN_MASK);
1880 if( nToken == XML_FORM )
1881 return new OFormImport( m_rFormImport, *this, m_xMeAsContainer);
1882 else if ( nToken == XML_CONNECTION_RESOURCE )
1883 return new OXMLDataSourceImport(GetImport(), _rxAttrList, m_xElement);
1884 else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ||
1886 return OElementImport::createFastChildContext( nElement, _rxAttrList );
1887 else
1888 {
1890 switch (eType)
1891 {
1897 return new OGridImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1906 return new OButtonImport( m_rFormImport, *this, m_xMeAsContainer, eType );
1908 return new ORadioImport(m_rFormImport, *this, m_xMeAsContainer, eType);
1916 default:
1918 }
1919 }
1920 }
1921
1922 void OFormImport::startFastElement(sal_Int32 nElement, const Reference< XFastAttributeList >& _rxAttrList)
1923 {
1925 OElementImport::startFastElement(nElement, _rxAttrList);
1926
1927 // handle the target-frame attribute
1929 }
1930
1931 void OFormImport::endFastElement(sal_Int32 nElement)
1932 {
1934
1935 // now that we have all children, attach the events
1936 css::uno::Reference< css::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, css::uno::UNO_QUERY);
1937 if (xIndexContainer.is())
1939
1941 }
1942
1943 css::uno::Reference< css::beans::XPropertySet > OFormImport::createElement()
1944 {
1945 // let the base class create the object
1946 css::uno::Reference< css::beans::XPropertySet > xReturn = OElementImport::createElement();
1947 if (!xReturn.is())
1948 return xReturn;
1949
1950 // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
1951 m_xMeAsContainer.set(xReturn, css::uno::UNO_QUERY);
1952 if (!m_xMeAsContainer.is())
1953 {
1954 OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
1955 xReturn.clear();
1956 }
1957
1958 return xReturn;
1959 }
1960
1961 bool OFormImport::handleAttribute(sal_Int32 nElement, const OUString& _rValue)
1962 {
1963 // handle the master/details field attributes (they're way too special to let the OPropertyImport handle them)
1964 static const sal_Int32 s_nMasterFieldsAttributeName = OAttributeMetaData::getFormAttributeToken(faMasterFields);
1965 static const sal_Int32 s_nDetailFieldsAttributeName = OAttributeMetaData::getFormAttributeToken(faDetailFields);
1966
1967 if ( (nElement & TOKEN_MASK) == s_nMasterFieldsAttributeName)
1968 {
1970 return true;
1971 }
1972
1973 if ( (nElement & TOKEN_MASK) == s_nDetailFieldsAttributeName)
1974 {
1976 return true;
1977 }
1978
1979 return OElementImport::handleAttribute(nElement, _rValue);
1980 }
1981
1982 void OFormImport::implTranslateStringListProperty(const OUString& _rPropertyName, const OUString& _rValue)
1983 {
1984 PropertyValue aProp;
1985 aProp.Name = _rPropertyName;
1986
1987 Sequence< OUString > aList;
1988
1989 // split up the value string
1990 if (!_rValue.isEmpty())
1991 {
1992 // For the moment, we build a vector instead of a Sequence. It's easier to handle because of its
1993 // push_back method
1994 ::std::vector< OUString > aElements;
1995 // estimate the number of tokens
1996 sal_Int32 nEstimate = 0, nLength = _rValue.getLength();
1997 const sal_Unicode* pChars = _rValue.getStr();
1998 for (sal_Int32 i=0; i<nLength; ++i, ++pChars)
1999 if (*pChars == ',')
2000 ++nEstimate;
2001 aElements.reserve(nEstimate + 1);
2002 // that's the worst case. If the string contains the separator character _quoted_, we reserved too much...
2003
2004 sal_Int32 nElementStart = 0;
2005 sal_Int32 nNextSep = 0;
2006 do
2007 {
2008 // extract the current element
2010 _rValue, nElementStart);
2011 if (-1 == nNextSep)
2012 nNextSep = nLength;
2013 std::u16string_view sElement = _rValue.subView(nElementStart, nNextSep - nElementStart);
2014
2015 size_t nElementLength = sElement.size();
2016 // when writing the sequence, we quoted the single elements with " characters
2017 OSL_ENSURE( o3tl::starts_with(sElement, u"\"") && o3tl::ends_with(sElement, u"\""),
2018 "OFormImport::implTranslateStringListProperty: invalid quoted element name.");
2019 sElement = sElement.substr(1, nElementLength - 2);
2020
2021 aElements.push_back(OUString(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,Any(sValue));
2057 else
2058 _xElement->setPropertyValue(PROPERTY_URL,Any(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: */
const PropertyValue * pValues
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1618
css::uno::Reference< css::graphic::XGraphic > loadGraphicByURL(OUString const &rURL)
Definition: xmlimp.cxx:1285
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:398
static OUString getPrefixAndNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1955
static const OUString & getNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1950
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:601
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
const OUString & GetDataStyleName() const
Definition: txtstyli.hxx:82
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static sal_Int32 indexOfComma(std::u16string_view rStr, sal_Int32 nPos)
static bool convertBool(bool &rBool, std::u16string_view rString)
const AttributeAssignment * getAttributeTranslation(sal_Int32 nAttributeToken)
return the AttributeAssignment which corresponds to the given attribute
static sal_Int32 getFormAttributeToken(FormAttributes _eAttrib)
retrieves the name of an attribute of a form xml representation
static sal_Int32 getCommonControlAttributeToken(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
static sal_Int32 getDatabaseAttributeToken(DAFlags _nId)
calculates the xml attribute representation of a database attribute.
static sal_Int32 getSpecialAttributeToken(SCAFlags _nId)
calculates the xml attribute representation of a special attribute.
static sal_Int32 getBindingAttributeToken(BAFlags _nId)
calculates the xml attribute representation of a binding attribute.
A specialized version of the <type>OControlImport</type> class, which handles the target frame for im...
OButtonImport(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
helper class importing a single grid column (without the <form:column> element wrapping the column).
OControlImport * implCreateChildContext(sal_Int32 nElement, OControlElement::ElementType _eType)
OColumnWrapperImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, sal_Int32 nElement, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
IEventAttacherManager & m_rEventManager
OFormLayerXMLImport_Impl & m_rFormImport
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOwnAttributes
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
OListAndComboImportRef m_xListBoxImport
OComboItemImport(SvXMLImport &_rImport, const OListAndComboImportRef &_rListBox)
helper for translating between control types and XML tags
static sal_Int32 getElementToken(ElementType _eType)
retrieves the tag name to be used to describe a control of the given type
helper class for importing the description of a single control
OUString m_sSubmissionID
name of a submission (xforms:submission attribute)
static void implTranslateValueProperty(const css::uno::Reference< css::beans::XPropertySetInfo > &_rxPropInfo, css::beans::PropertyValue &_rPropValue)
OUString m_sListBindingID
name of a list binding (form:xforms-list-source attribute)
void doRegisterXFormsValueBinding(const OUString &)
register the given XForms binding
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
css::uno::Reference< css::xml::sax::XFastAttributeList > m_xOuterAttributes
void setElementType(OControlElement::ElementType _eType)
void doRegisterXFormsSubmission(const OUString &)
register the given XForms submission
OUString m_sBoundCellAddress
the address of the calc cell which the control model should be bound to, if applicable
virtual OUString determineDefaultServiceName() const override
void addOuterAttributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxOuterAttribs)
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress)
registers the given cell address as value binding address for our element
OControlElement::ElementType m_eElementType
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
OUString m_sBindingID
name of a value binding (xforms:bind attribute)
PropertyValueArray m_aValueProperties
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
void doRegisterXFormsListBinding(const OUString &)
register the given XForms list binding
void setEvents(const css::uno::Reference< css::container::XIndexAccess > &_rxContainer)
implements common behaviour for importing forms, controls and columns
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
PropertyGroups::const_iterator impl_matchPropertyGroup(const PropertyGroups &i_propertyGroups) const
virtual css::uno::Reference< css::beans::XPropertySet > createElement()
create the (uninitialized) element which is to represent the read data
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::container::XNameContainer > m_xParentContainer
the parent container to insert the new element into
virtual ~OElementImport() override
OElementImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
ctor
bool tryGenericAttribute(sal_Int32 nElement, const OUString &_rValue)
to be called from within handleAttribute, checks whether the given attribute is covered by our generi...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::beans::XPropertySet > m_xElement
the element we're creating. Valid after StartElement
OFormLayerXMLImport_Impl & m_rFormImport
OUString implGetDefaultName() const
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void disableImplicitGenericAttributeHandling()
controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived cla...
const XMLTextStyleContext * m_pStyleElement
virtual OUString determineDefaultServiceName() const
void simulateDefaultedAttribute(sal_Int32 nElement, const OUString &_rPropertyName, const char *_pAttributeDefault)
can be used to handle properties where the attribute default and the property default differ.
static ElementType getElementType(sal_Int32 nToken)
static std::map< sal_Int32, ElementType > s_sElementTranslations2
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual OUString determineDefaultServiceName() const override
OFormImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
void implTranslateStringListProperty(const OUString &_rPropertyName, const OUString &_rValue)
void registerControlReferences(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rReferringControls)
OAttribute2Property & getAttributeMap()
Definition: layerimport.hxx:95
void registerCellRangeListSource(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rCellRangeAddress)
void applyControlNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rControlNumberStyleName)
void registerXFormsSubmission(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rSubmissionID)
void registerCellValueBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rCellAddress)
void registerXFormsListBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rBindingID)
void registerXFormsValueBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const OUString &_rBindingID)
void registerControlId(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rId)
helper class importing a single <form:grid> element
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
OGridImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override
create the (uninitialized) element which is to represent the read data
OImagePositionImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
css::uno::Reference< css::graphic::XGraphic > m_xGraphic
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
A specialized version of the <type>OControlImport</type> class, which handles attributes / sub elemen...
std::vector< sal_Int16 > m_aDefaultSelectedSeq
void implPushBackLabel(const OUString &_rLabel)
bool m_bEncounteredLSAttrib
number of empty value items encountered during reading
std::vector< sal_Int16 > m_aSelectedSeq
void implPushBackValue(const OUString &_rValue)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void doRegisterCellValueBinding(const OUString &_rBoundCellAddress) override
registers the given cell address as value binding address for our element
sal_Int32 m_nEmptyValueItems
number of empty list items encountered during reading
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
std::vector< OUString > m_aValueList
std::vector< OUString > m_aListSource
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
sal_Int32 m_nEmptyListItems
the cell range which acts as list source for the control
OListAndComboImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
<TRUE> if and only if we should use a cell value binding which exchanges the selection index (instead...
OListOptionImport(SvXMLImport &_rImport, const OListAndComboImportRef &_rListBox)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
OListAndComboImportRef m_xListBoxImport
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OPasswordImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
Helper class for importing property values.
PropertyValueArray m_aValues
void implPushBackPropertyValue(const css::beans::PropertyValue &_rProp)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
void enableTrackAttributes()
enables the tracking of the encountered attributes
PropertyValueArray m_aGenericValues
OFormLayerXMLImport_Impl & m_rContext
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
ORadioImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OReferredControlImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer)
A specialized version of the <type>OControlImport</type> class, which handles text like controls whic...
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::text::XTextCursor > m_xCursor
css::uno::Reference< css::text::XTextCursor > m_xOldCursor
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
OTextLikeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
a specialized version of the <type>OControlImport</type> class, which is able to handle attributes wh...
OURLReferenceImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
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.
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.
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.
A specialized version of the <type>OControlImport</type> class, which imports the value-range element...
virtual bool handleAttribute(sal_Int32 nElement, const OUString &_rValue) override
handle one single attribute.
OValueRangeImport(OFormLayerXMLImport_Impl &_rImport, IEventAttacherManager &_rEventManager, const css::uno::Reference< css::container::XNameContainer > &_rxParentContainer, OControlElement::ElementType _eType)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_rxAttrList) override
OXMLDataSourceImport(SvXMLImport &_rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const css::uno::Reference< css::beans::XPropertySet > &_xElement)
static css::uno::Any convertString(const css::uno::Type &_rExpectedType, const OUString &_rReadCharacters, const SvXMLEnumMapEntry< EnumT > *_pEnumMap=nullptr)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_RETURN(c, m, r)
#define DBG_UNHANDLED_EXCEPTION(...)
URL aURL
Reference< XContent > m_xParentContainer
float u
const OUString & m_sName
#define PROPID_CURRENT_VALUE
#define PROPID_MIN_VALUE
#define PROPID_VALUE
const sal_Int32 m_nHandle
#define PROPID_MAX_VALUE
Reference< beans::XPropertySetInfo > m_xInfo
UNKNOWN
DocumentType eType
sal_Int16 nValue
@ AutoCompletion
@ ConvertEmpty
@ ListLinkingType
@ ListCellRange
@ TargetLocation
@ CurrentSelected
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define LEAVE_LOG_CONTEXT()
Definition: logging.hxx:53
#define ENTER_LOG_CONTEXT(name)
Definition: logging.hxx:52
@ Exception
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
Type getSequenceElementType(const Type &_rSequenceType)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
FORM
ElementType
int i
constexpr OUStringLiteral first
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void getPropertyGroupList(const AttributeDescription &i_attribute, PropertyGroups &o_propertyGroups)
retrieves all known property groups which are mapped to the given attribute
AttributeDescription getAttributeDescription(sal_Int32 nAttributeToken)
retrieves the attribute descriptor for the attribute given by namespace prefix and attribute name
Handling of tokens in XML:
@ XML_CONNECTION_RESOURCE
Definition: xmltoken.hxx:2368
@ XML_CONTROL_IMPLEMENTATION
Definition: xmltoken.hxx:2735
@ XML_XFORMS_LIST_SOURCE
Definition: xmltoken.hxx:3117
::std::vector< PropertyDescriptionList > PropertyGroups
::std::map< PropertyId, css::uno::Any > PropertyValues
const OControlElement::ElementType & operator++(OControlElement::ElementType &_e)
const SvXMLEnumMapEntry< sal_uInt16 > aImageAlignMap[]
Definition: formenums.cxx:173
const SvXMLEnumMapEntry< sal_Int16 > aImagePositionMap[]
Definition: formenums.cxx:164
::std::vector< const PropertyDescription * > PropertyDescriptionList
const SvXMLEnumMapEntry< sal_Int16 > aListLinkageMap[]
Definition: formenums.cxx:145
sal_Int32 attribute
DefTokenId nToken
sal_Int32 nHandle
#define PROPERTY_ECHOCHAR
Definition: strings.hxx:29
#define PROPERTY_MASTERFIELDS
Definition: strings.hxx:104
#define PROPERTY_EMPTY_IS_NULL
Definition: strings.hxx:66
#define PROPERTY_EFFECTIVE_DEFAULT
Definition: strings.hxx:99
#define PROPERTY_EFFECTIVE_VALUE
Definition: strings.hxx:98
#define PROPERTY_DEFAULT_SELECT_SEQ
Definition: strings.hxx:79
#define PROPERTY_DETAILFIELDS
Definition: strings.hxx:105
#define PROPERTY_TARGETFRAME
Definition: strings.hxx:34
#define PROPERTY_RICH_TEXT
Definition: strings.hxx:143
#define PROPERTY_CLASSID
Definition: strings.hxx:28
#define PROPERTY_TEXT
Definition: strings.hxx:97
#define PROPERTY_REPEAT_DELAY
Definition: strings.hxx:124
#define PROPERTY_DATASOURCENAME
Definition: strings.hxx:49
#define PROPERTY_LISTSOURCE
Definition: strings.hxx:68
#define PROPERTY_SELECT_SEQ
Definition: strings.hxx:80
#define PROPERTY_LINE_INCREMENT
Definition: strings.hxx:122
#define PROPERTY_IMAGE_POSITION
Definition: strings.hxx:134
#define PROPERTY_SPIN_INCREMENT
Definition: strings.hxx:129
#define PROPERTY_STRING_ITEM_LIST
Definition: strings.hxx:77
#define PROPERTY_AUTOCOMPLETE
Definition: strings.hxx:72
#define PROPERTY_GRAPHIC
Definition: strings.hxx:32
#define PROPERTY_ALIGN
Definition: strings.hxx:108
#define PROPERTY_URL
Definition: strings.hxx:101
const SvXMLEnumMapEntry< sal_uInt16 > * pEnumMap
const Reference< XComponentContext > & m_rContext
TEXT
sal_uInt16 sal_Unicode
signed char sal_Int8
size_t pos
Reference< xml::input::XElement > m_xElement
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_XML
constexpr sal_uInt16 XML_NAMESPACE_OOO
sal_Int32 nLength
Definition: xmltoken.cxx:38