LibreOffice Module xmloff (master)  1
elementexport.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 "elementexport.hxx"
21 
22 #include "strings.hxx"
23 #include <xmloff/xmlnamespace.hxx>
24 #include "eventexport.hxx"
25 #include "formenums.hxx"
26 #include "formcellbinding.hxx"
27 #include <xmloff/xformsexport.hxx>
28 #include "property_meta_data.hxx"
29 
30 #include <com/sun/star/text/XText.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/io/XPersistObject.hpp>
33 #include <com/sun/star/util/Duration.hpp>
34 #include <com/sun/star/form/FormComponentType.hpp>
35 #include <com/sun/star/form/FormSubmitEncoding.hpp>
36 #include <com/sun/star/form/FormSubmitMethod.hpp>
37 #include <com/sun/star/sdb/CommandType.hpp>
38 #include <com/sun/star/form/NavigationBarMode.hpp>
39 #include <com/sun/star/form/TabulatorCycle.hpp>
40 #include <com/sun/star/form/FormButtonType.hpp>
41 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
42 #include <com/sun/star/awt/VisualEffect.hpp>
43 #include <com/sun/star/form/ListSourceType.hpp>
44 #include <com/sun/star/awt/ImagePosition.hpp>
45 
46 #include <sax/tools/converter.hxx>
47 #include <tools/gen.hxx>
48 #include <xmloff/txtprmap.hxx>
49 #include <com/sun/star/form/binding/XBindableValue.hpp>
50 #include <com/sun/star/form/binding/XListEntrySink.hpp>
51 #include <tools/urlobj.hxx>
52 #include <xmloff/xmlexp.hxx>
53 #include <xmloff/namespacemap.hxx>
55 #include <xmloff/xmluconv.hxx>
56 #include <xmloff/xmltoken.hxx>
57 #include <xmloff/maptype.hxx>
58 #include <tools/time.hxx>
59 #include <tools/diagnose_ex.h>
60 #include <comphelper/extract.hxx>
61 #include <sal/macros.h>
62 #include <sal/log.hxx>
63 
64 #include <algorithm>
65 #include <string_view>
66 
67 namespace xmloff
68 {
69 
70  #if OSL_DEBUG_LEVEL > 0
71  #define RESET_BIT( bitfield, bit ) \
72  bitfield = bitfield & ~bit
73  #else
74  #define RESET_BIT( bitfield, bit )
75  #endif
76 
77  using namespace ::xmloff::token;
78  using namespace ::com::sun::star;
79  using namespace ::com::sun::star::uno;
80  using namespace ::com::sun::star::sdb;
81  using namespace ::com::sun::star::awt;
82  using namespace ::com::sun::star::form;
83  using namespace ::com::sun::star::lang;
84  using namespace ::com::sun::star::beans;
85  using namespace ::com::sun::star::container;
86  using namespace ::com::sun::star::script;
87  using namespace ::com::sun::star::io;
88  using namespace ::com::sun::star::table;
89  using namespace ::com::sun::star::text;
90  using namespace ::com::sun::star::form::binding;
91 
92  //= OElementExport
94  const Sequence< ScriptEventDescriptor >& _rEvents)
95  :OPropertyExport(_rContext, _rxProps)
96  ,m_aEvents(_rEvents)
97  {
98  }
99 
101  {
102  }
103 
105  {
106  // collect some general information about the element
107  examine();
108 
109  // first add the attributes necessary for the element
111 
112  // add the attributes
114 
115  // start the XML element
117 
118  // the sub elements (mostly control type dependent)
119  exportSubTags();
120 
121  implEndElement();
122  }
123 
125  {
126  // nothing to do here
127  }
128 
130  {
131  // nothing to do here
132  }
133 
135  {
136  // the properties which where not exported 'til now
138 
139  // the script:events sub tags
140  exportEvents();
141  }
142 
143  void OElementExport::implStartElement(const char* _pName)
144  {
145  m_pXMLElement = std::make_unique<SvXMLElementExport>(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, true, true);
146  }
147 
149  {
150  m_pXMLElement.reset();
151  }
152 
154  {
155  Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY);
156  if (!xPersistence.is())
157  {
158  OSL_FAIL("OElementExport::exportServiceNameAttribute: no XPersistObject!");
159  return;
160  }
161 
162  OUString sServiceName = xPersistence->getServiceName();
163  // we don't want to write the old service name directly: it's a name used for compatibility reasons, but
164  // as we start some kind of new file format here (with this xml export), we don't care about
165  // compatibility ...
166  // So we translate the old persistence service name into new ones, if possible
167 
168  OUString sToWriteServiceName = sServiceName;
169 #define CHECK_N_TRANSLATE( name ) \
170  else if (sServiceName == SERVICE_PERSISTENT_COMPONENT_##name) \
171  sToWriteServiceName = SERVICE_##name
172 
173  if (sServiceName == SERVICE_PERSISTENT_COMPONENT_EDIT)
174  {
175  // special handling for the edit field: we have two controls using this as persistence service name
176  sToWriteServiceName = SERVICE_EDIT;
177  Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
178  if (xSI.is() && xSI->supportsService(SERVICE_FORMATTEDFIELD))
179  sToWriteServiceName = SERVICE_FORMATTEDFIELD;
180  }
187  CHECK_N_TRANSLATE( COMMANDBUTTON );
189  CHECK_N_TRANSLATE( GRID );
191  CHECK_N_TRANSLATE( FILECONTROL );
194  CHECK_N_TRANSLATE( NUMERICFIELD );
197  CHECK_N_TRANSLATE( HIDDENCONTROL );
198  CHECK_N_TRANSLATE( IMAGECONTROL );
200 #if OSL_DEBUG_LEVEL > 0
201  Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
202  OSL_ENSURE(xSI.is() && xSI->supportsService(sToWriteServiceName),
203  "OElementExport::exportServiceNameAttribute: wrong service name translation!");
204 
205 #endif
206  sToWriteServiceName =
208  XML_NAMESPACE_OOO, sToWriteServiceName );
209 
210  // now write this
211  AddAttribute(
214  sToWriteServiceName);
215  }
216 
218  {
219  if (!m_aEvents.hasElements())
220  // nothing to do
221  return;
222 
223  Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
225  }
226 
227  //= OControlExport
229  const OUString& _rControlId, const OUString& _rReferringControls,
230  const Sequence< ScriptEventDescriptor >& _rEvents)
231  :OElementExport(_rContext, _rxControl, _rEvents)
232  ,m_sControlId(_rControlId)
233  ,m_sReferringControls(_rReferringControls)
234  ,m_nClassId(FormComponentType::CONTROL)
235  ,m_eType( UNKNOWN )
236  ,m_nIncludeCommon(CCAFlags::NONE)
237  ,m_nIncludeDatabase(DAFlags::NONE)
238  ,m_nIncludeSpecial(SCAFlags::NONE)
239  ,m_nIncludeEvents(EAFlags::NONE)
240  ,m_nIncludeBindings(BAFlags::NONE)
241  {
242  OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
243  }
244 
246  {
247  // the control id
249  {
254  );
255  #if OSL_DEBUG_LEVEL > 0
256  // reset the bit for later checking
257  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::Name;
258  #endif
259  }
260 
261  // the service name
262  if (m_nIncludeCommon & CCAFlags::ServiceName)
263  {
265  #if OSL_DEBUG_LEVEL > 0
266  // reset the bit for later checking
267  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ServiceName;
268  #endif
269  }
270  }
271 
273  {
274  // the control id
276  {
277  OSL_ENSURE(!m_sControlId.isEmpty(), "OControlExport::exportInnerAttributes: have no control id for the control!");
280  #if OSL_DEBUG_LEVEL > 0
281  // reset the bit for later checking
282  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ControlId;
283  #endif
284  }
285 
286  // "new-style" properties ...
288 
289  // common control attributes
291 
292  // common database attributes
294 
295  // attributes related to external bindings
297 
298  // attributes special to the respective control type
300 
301  // add the style references to the attributes
303  }
304 
306  {
308  }
309 
311  {
312  // for the upcoming exportRemainingProperties:
313  // if a control has the LabelControl property, this is not stored with the control itself, but instead with
314  // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
315  // know anything about this, we need to prevent that it tries to export this property
317 
318  // if it's a control supporting XText, then we need to declare all text-related properties
319  // as "already exported". This prevents them from being exported as generic "form:property"-tags.
320  // *If* we would export them this way, they would be completely superfluous, and sometimes even
321  // disastrous, since they may, at import time, override paragraph properties which already have
322  // been set before
323  Reference< XText > xControlText( m_xProps, UNO_QUERY );
324  if ( xControlText.is() )
325  {
327  while ( pCharAttributeProperties->msApiName )
328  {
329  exportedProperty( OUString::createFromAscii( pCharAttributeProperties->msApiName ) );
330  ++pCharAttributeProperties;
331  }
332 
334  while ( pParaAttributeProperties->msApiName )
335  {
336  exportedProperty( OUString::createFromAscii( pParaAttributeProperties->msApiName ) );
337  ++pParaAttributeProperties;
338  }
339 
340  // the RichText property is not exported. The presence of the text:p element
341  // will be used - upon reading - as indicator for the value of the RichText property
343 
344  // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
345  // The former is a short/enum value, the latter a boolean. The former has a real meaning
346  // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
347  // later on imported, it overwrites anything which has previously been imported for
348  // CharStrikeout.
349  // #i27729#
350  exportedProperty( "CharCrossedOut" );
351  }
352 
353  if ( m_eType == LISTBOX )
354  {
355  // will be exported in exportListSourceAsElements:
358 
359  // will not be exported in a generic way. Either exportListSourceAsElements cares
360  // for them, or we don't need them
365  }
366  if ( m_eType == COMBOBOX )
368 
369  // let the base class export the remaining properties and the events
371 
372  // special sub tags for some controls
373  switch (m_eType)
374  {
375  case LISTBOX:
376  // don't export the list entries if the are not provided by the user, but obtained implicitly
377  // from other sources
378  // #i26944#
381  break;
382  case GRID:
383  { // a grid control requires us to store all columns as sub elements
384  Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
385  OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
386  if (xColumnContainer.is())
387  m_rContext.exportCollectionElements(xColumnContainer);
388  }
389  break;
390  case COMBOBOX:
391  { // a combox box description has sub elements: the items
393 
394  // don't export the list entries if the are not provided by the user, but obtained implicitly
395  // from other sources
396  // #i26944#
398  {
399  // get the item list
400  Sequence< OUString > aListItems;
401  m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
402  // loop through it and write the sub elements
403  for (const auto& rListItem : std::as_const(aListItems))
404  {
406  AddAttribute(
409  rListItem);
410  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", true, true);
411  }
412  }
413  }
414  break;
415 
416  case TEXT_AREA:
417  {
418  // if we act as rich text control, we need to export some text:p elements
419  if ( xControlText.is() )
420  {
421  bool bActingAsRichText = false;
422  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
423  {
424  OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
425  }
426 
427  if ( bActingAsRichText )
428  m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
429  }
430  }
431  break;
432  default:
433  // nothing do to
434  break;
435  }
436  }
437 
439  {
440  const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
441  for ( auto const & prop : aProperties )
442  {
443  try
444  {
445  // see if this property can already be handled with an IPropertyHandler (which, on the long
446  // term, should be the case for most, if not all, properties)
447  const PropertyDescription* propDescription = metadata::getPropertyDescription( prop.Name );
448  if ( propDescription == nullptr )
449  continue;
450 
451  // let the factory provide the concrete handler. Note that caching, if desired, is the task
452  // of the factory
453  PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId );
454  if ( !handler )
455  {
456  SAL_WARN( "xmloff.forms", "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" );
457  continue;
458  }
459 
460  // that's a property which has a direct mapping to an attribute
461  if ( !shouldExportProperty( prop.Name ) )
462  // TODO: in the future, we surely need a more sophisticated approach to this, involving the property
463  // handler, or the property description
464  {
465  exportedProperty( prop.Name );
466  continue;
467  }
468 
469  const Any propValue = m_xProps->getPropertyValue( prop.Name );
470  OUString attributeValue = handler->getAttributeValue( propValue );
471 
472  AddAttribute(
473  propDescription->attribute.namespacePrefix,
474  token::GetXMLToken( propDescription->attribute.attributeToken ),
475  attributeValue
476  );
477 
478  exportedProperty( prop.Name );
479  }
480  catch( const Exception& )
481  {
482  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
483  }
484  }
485  }
486 
488  {
489  size_t i=0;
490 
491  // I decided to handle all the properties here with some static arrays describing the property-attribute
492  // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
493  // would require maps and O(log n) searches, which seems somewhat expensive as this code is used
494  // very frequently.
495 
496  // the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
497  // map identifiers from the wrong block
498 
499  // some string properties
500  {
501  // the attribute ids of all properties which are expected to be of type string
502  static const CCAFlags nStringPropertyAttributeIds[] =
503  {
505  };
506  // the names of all properties which are expected to be of type string
507  static const char * aStringPropertyNames[] =
508  {
510  };
511  OSL_ENSURE( SAL_N_ELEMENTS(aStringPropertyNames) ==
512  SAL_N_ELEMENTS(nStringPropertyAttributeIds),
513  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
514 
515  for (i=0; i<SAL_N_ELEMENTS(nStringPropertyAttributeIds); ++i)
516  if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
517  {
519  OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
520  OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
521  OUString::createFromAscii(aStringPropertyNames[i])
522  );
523  #if OSL_DEBUG_LEVEL > 0
524  // reset the bit for later checking
525  m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i];
526  #endif
527  }
528  }
529 
530  // some boolean properties
531  {
532  static const CCAFlags nBooleanPropertyAttributeIds[] =
533  { // attribute flags
535  };
536  static const char * pBooleanPropertyNames[] =
537  { // property names
542  };
543  static const BoolAttrFlags nBooleanPropertyAttrFlags[] =
544  { // attribute defaults
546  };
547  #if OSL_DEBUG_LEVEL > 0
548  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds);
549  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
550  static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags);
551  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
552  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
553  #endif
554  for (i=0; i<SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); ++i)
555  if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
556  {
558  OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds[i]),
559  OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds[i]),
560  OUString::createFromAscii(pBooleanPropertyNames[i]),
561  nBooleanPropertyAttrFlags[i]);
562  #if OSL_DEBUG_LEVEL > 0
563  // reset the bit for later checking
564  m_nIncludeCommon = m_nIncludeCommon & ~nBooleanPropertyAttributeIds[i];
565  #endif
566  }
567  }
568 
569  // some integer properties
570  {
571  // now the common handling
572  static const CCAFlags nIntegerPropertyAttributeIds[] =
573  { // attribute flags
575  };
576  static const char * pIntegerPropertyNames[] =
577  { // property names
579  };
580  static const sal_Int16 nIntegerPropertyAttrDefaults[] =
581  { // attribute defaults
582  5, 0
583  };
584 
587 
588  #if OSL_DEBUG_LEVEL > 0
589  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nIntegerPropertyAttributeIds);
590  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pIntegerPropertyNames);
591  static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nIntegerPropertyAttrDefaults);
592  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
593  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
594  #endif
595  for (i=0; i<SAL_N_ELEMENTS(nIntegerPropertyAttributeIds); ++i)
596  if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
597  {
599  OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
600  OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
601  OUString::createFromAscii(pIntegerPropertyNames[i]),
602  nIntegerPropertyAttrDefaults[i]);
603  #if OSL_DEBUG_LEVEL > 0
604  // reset the bit for later checking
605  m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i];
606  #endif
607  }
608 
609  }
610 
611  // some enum properties
612  {
614  {
620  FormButtonType_PUSH);
621  #if OSL_DEBUG_LEVEL > 0
622  // reset the bit for later checking
624  #endif
625  }
627  {
630  OAttributeMetaData::getCommonControlAttributeName( CCAFlags::Orientation ),
633  ScrollBarOrientation::HORIZONTAL
634  );
635  #if OSL_DEBUG_LEVEL > 0
636  // reset the bit for later checking
638  #endif
639  }
640 
642  {
645  OAttributeMetaData::getCommonControlAttributeName( CCAFlags::VisualEffect ),
648  VisualEffect::LOOK3D
649  );
650  #if OSL_DEBUG_LEVEL > 0
651  // reset the bit for later checking
652  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::VisualEffect;
653  #endif
654  }
655  }
656 
657  // some properties which require a special handling
658 
659  // the target frame
661  {
663  #if OSL_DEBUG_LEVEL > 0
664  // reset the bit for later checking
665  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetFrame;
666  #endif
667  }
668 
669  // max text length
671  {
672  // normally, the respective property would be "MaxTextLen"
673  // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
674 
675  // determine the name of the property to export
676  OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH );
677  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
678  sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
679 
680  // export it
684  sTextLenPropertyName,
685  0
686  );
687 
688  // in either way, both properties count as "exported"
691 
692  #if OSL_DEBUG_LEVEL > 0
693  // reset the bit for later checking
695  #endif
696  }
697 
699  {
701  #if OSL_DEBUG_LEVEL > 0
702  // reset the bit for later checking
703  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetLocation;
704  #endif
705  }
706 
707  // OJ #99721#
709  {
711  #if OSL_DEBUG_LEVEL > 0
712  // reset the bit for later checking
714  #endif
715  }
716 
717  // the for attribute
718  // the target frame
720  {
721  if (!m_sReferringControls.isEmpty())
722  { // there is at least one control referring to the one we're handling currently
723  AddAttribute(
727  }
728  #if OSL_DEBUG_LEVEL > 0
729  // reset the bit for later checking
731  #endif
732  }
733 
735  {
736  const char* pCurrentValuePropertyName = nullptr;
737  const char* pValuePropertyName = nullptr;
738 
739  // get the property names
740  getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
741 
742  // add the attributes if necessary and possible
743  if (pCurrentValuePropertyName && (CCAFlags::CurrentValue & m_nIncludeCommon))
744  {
745  static const char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue);
746  // don't export the current-value if this value originates from a data binding
747  // #i26944#
749  exportedProperty( OUString::createFromAscii( pCurrentValuePropertyName ) );
750  else
751  {
752  static const sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentValue);
754  nCurrentValueAttributeNamespaceKey,
755  pCurrentValueAttributeName,
756  pCurrentValuePropertyName
757  );
758  }
759  }
760 
761  if (pValuePropertyName && (CCAFlags::Value & m_nIncludeCommon))
762  {
763  static const char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value);
764  static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Value);
766  nValueAttributeNamespaceKey,
767  pValueAttributeName,
768  pValuePropertyName);
769  }
770 
771  OSL_ENSURE((nullptr == pValuePropertyName) == (CCAFlags::NONE == (CCAFlags::Value & m_nIncludeCommon)),
772  "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
773  OSL_ENSURE((nullptr == pCurrentValuePropertyName ) == (CCAFlags::NONE == (CCAFlags::CurrentValue & m_nIncludeCommon)),
774  "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
775 
776  #if OSL_DEBUG_LEVEL > 0
777  // reset the bit for later checking
778  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags(CCAFlags::CurrentValue | CCAFlags::Value);
779  #endif
780  }
781 
782  OSL_ENSURE(CCAFlags::NONE == m_nIncludeCommon,
783  "OControlExport::exportCommonControlAttributes: forgot some flags!");
784  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
785  // be 0 now ...
786  }
787 
789  {
790 #if OSL_DEBUG_LEVEL > 0
791  DAFlags nIncludeDatabase = m_nIncludeDatabase;
792 #endif
793  // the only string property: DataField
795  {
800  RESET_BIT( nIncludeDatabase, DAFlags::DataField );
801  }
802 
803  // InputRequired
804  if ( DAFlags::InputRequired & m_nIncludeDatabase )
805  {
811  );
812  RESET_BIT( nIncludeDatabase, DAFlags::InputRequired );
813  }
814 
815  // the only int16 property: BoundColumn
816  if (DAFlags::BoundColumn & m_nIncludeDatabase)
817  {
822  0,
823  true);
824  RESET_BIT( nIncludeDatabase, DAFlags::BoundColumn );
825  }
826 
827  // ConvertEmptyToNull
828  if (DAFlags::ConvertEmpty & m_nIncludeDatabase)
829  {
835  );
836  RESET_BIT( nIncludeDatabase, DAFlags::ConvertEmpty );
837  }
838 
839  // the only enum property: ListSourceType
840  if (DAFlags::ListSource_TYPE & m_nIncludeDatabase)
841  {
847  ListSourceType_VALUELIST
848  );
849  RESET_BIT( nIncludeDatabase, DAFlags::ListSource_TYPE );
850  }
851 
852  if (m_nIncludeDatabase & DAFlags::ListSource)
853  {
855  RESET_BIT( nIncludeDatabase, DAFlags::ListSource );
856  }
857 
858 #if OSL_DEBUG_LEVEL > 0
859  OSL_ENSURE(DAFlags::NONE == nIncludeDatabase,
860  "OControlExport::exportDatabaseAttributes: forgot some flags!");
861  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
862  // be 0 now ...
863 #endif
864  }
865 
867  {
868 #if OSL_DEBUG_LEVEL > 0
869  BAFlags nIncludeBinding = m_nIncludeBindings;
870 #endif
871 
873  {
875  #if OSL_DEBUG_LEVEL > 0
876  // reset the bit for later checking
877  nIncludeBinding = nIncludeBinding & ~BAFlags( BAFlags::LinkedCell | BAFlags::ListLinkingType );
878  #endif
879  }
880 
882  {
884  #if OSL_DEBUG_LEVEL > 0
885  // reset the bit for later checking
886  nIncludeBinding = nIncludeBinding & ~BAFlags::ListCellRange;
887  #endif
888  }
889 
891  {
893  #if OSL_DEBUG_LEVEL > 0
894  // reset the bit for later checking
895  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsBind;
896  #endif
897  }
898 
900  {
902  #if OSL_DEBUG_LEVEL > 0
903  // reset the bit for later checking
904  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsListBind;
905  #endif
906  }
907 
909  {
911  #if OSL_DEBUG_LEVEL > 0
912  // reset the bit for later checking
913  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsSubmission;
914  #endif
915  }
916 
917  #if OSL_DEBUG_LEVEL > 0
918  OSL_ENSURE( BAFlags::NONE == nIncludeBinding,
919  "OControlExport::exportBindingAttributes: forgot some flags!");
920  // in the debug version, we should have removed every bit we handled from the mask, so it should
921  // be 0 now ...
922  #endif
923  }
924 
926  {
927  sal_Int32 i=0;
928 
929  // the boolean properties
930  {
931  static const SCAFlags nBooleanPropertyAttributeIds[] =
932  { // attribute flags
935  };
936  static const char * pBooleanPropertyNames[] =
937  { // property names
943  };
944  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds);
945  #if OSL_DEBUG_LEVEL > 0
946  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
947  OSL_ENSURE((nIdCount == nNameCount),
948  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
949  #endif
950  const SCAFlags* pAttributeId = nBooleanPropertyAttributeIds;
951  for ( i = 0; i < nIdCount; ++i, ++pAttributeId )
952  {
953  if ( *pAttributeId & m_nIncludeSpecial)
954  {
958  OUString::createFromAscii(pBooleanPropertyNames[i]),
960  );
961  #if OSL_DEBUG_LEVEL > 0
962  // reset the bit for later checking
963  m_nIncludeSpecial = m_nIncludeSpecial & ~*pAttributeId;
964  #endif
965  }
966  }
967  }
968 
969  // the integer properties
970  {
971  static const SCAFlags nIntegerPropertyAttributeIds[] =
972  { // attribute flags
974  };
975  static const char * pIntegerPropertyNames[] =
976  { // property names
978  };
979  static const sal_Int32 nIntegerPropertyAttrDefaults[] =
980  { // attribute defaults (XML defaults, not runtime defaults!)
981  10
982  };
983 
984  static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nIntegerPropertyAttributeIds );
985  #if OSL_DEBUG_LEVEL > 0
986  static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pIntegerPropertyNames );
987  OSL_ENSURE( ( nIdCount == nNameCount ),
988  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
989  static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS( nIntegerPropertyAttrDefaults );
990  OSL_ENSURE( ( nIdCount == nDefaultCount ),
991  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
992  #endif
993  for ( i = 0; i < nIdCount; ++i )
994  if ( nIntegerPropertyAttributeIds[i] & m_nIncludeSpecial )
995  {
997  OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds[i] ),
998  OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds[i] ),
999  OUString::createFromAscii(pIntegerPropertyNames[i]),
1000  nIntegerPropertyAttrDefaults[i]
1001  );
1002  #if OSL_DEBUG_LEVEL > 0
1003  // reset the bit for later checking
1004  m_nIncludeSpecial = m_nIncludeSpecial & ~nIntegerPropertyAttributeIds[i];
1005  #endif
1006  }
1007 
1008  if ( SCAFlags::StepSize & m_nIncludeSpecial )
1009  {
1010  OUString sPropertyName;
1011  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1012  sPropertyName = PROPERTY_LINE_INCREMENT;
1013  else if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1014  sPropertyName = PROPERTY_SPIN_INCREMENT;
1015  else
1016  OSL_FAIL( "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1017 
1018  if ( !sPropertyName.isEmpty() )
1022  sPropertyName,
1023  1
1024  );
1025 
1026  #if OSL_DEBUG_LEVEL > 0
1027  // reset the bit for later checking
1028  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::StepSize;
1029  #endif
1030  }
1031 
1032  }
1033 
1034  // the enum properties
1035  {
1037  {
1043  TRISTATE_FALSE);
1044  #if OSL_DEBUG_LEVEL > 0
1045  // reset the bit for later checking
1046  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::State;
1047  #endif
1048  }
1049 
1050  if (SCAFlags::CurrentState & m_nIncludeSpecial)
1051  {
1057  TRISTATE_FALSE);
1058  #if OSL_DEBUG_LEVEL > 0
1059  // reset the bit for later checking
1060  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::CurrentState;
1061  #endif
1062  }
1063  }
1064 
1065  // some properties which require a special handling
1066  // the repeat delay
1067  {
1069  {
1071 
1072  sal_Int32 nRepeatDelay = 0;
1073  m_xProps->getPropertyValue( PROPERTY_REPEAT_DELAY ) >>= nRepeatDelay;
1075  aTime.MakeTimeFromMS( nRepeatDelay );
1076  util::Duration aDuration;
1077  aDuration.Hours = aTime.GetHour();
1078  aDuration.Minutes = aTime.GetMin();
1079  aDuration.Seconds = aTime.GetSec();
1080  aDuration.NanoSeconds = (nRepeatDelay % 1000) * 1000000;
1081 
1082  OUStringBuffer buf;
1083  ::sax::Converter::convertDuration(buf, aDuration);
1085  ,OAttributeMetaData::getSpecialAttributeName( SCAFlags::RepeatDelay )
1086  ,buf.makeStringAndClear());
1087 
1089 
1090  #if OSL_DEBUG_LEVEL > 0
1091  // reset the bit for later checking
1092  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::RepeatDelay;
1093  #endif
1094  }
1095  }
1096 
1097  // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1098  {
1100  {
1101  DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
1102  sal_Int16 nValue(0);
1103  m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue;
1104  if (nValue)
1105  {
1106  OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
1107  AddAttribute(
1110  sCharacter);
1111  }
1113  #if OSL_DEBUG_LEVEL > 0
1114  // reset the bit for later checking
1115  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::EchoChar;
1116  #endif
1117  }
1118  }
1119 
1120  // the string properties
1121  {
1122  static const SCAFlags nStringPropertyAttributeIds[] =
1123  { // attribute flags
1125  };
1126  static const std::u16string_view pStringPropertyNames[] =
1127  { // property names
1129  };
1130 
1131  static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nStringPropertyAttributeIds );
1132  #if OSL_DEBUG_LEVEL > 0
1133  static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pStringPropertyNames );
1134  OSL_ENSURE( ( nIdCount == nNameCount ),
1135  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1136  #endif
1137  for ( i = 0; i < nIdCount; ++i )
1138  if ( nStringPropertyAttributeIds[i] & m_nIncludeSpecial )
1139  {
1141  OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ),
1142  OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ),
1143  pStringPropertyNames[i]
1144  );
1145  #if OSL_DEBUG_LEVEL > 0
1146  // reset the bit for later checking
1147  m_nIncludeSpecial = m_nIncludeSpecial & ~nStringPropertyAttributeIds[i];
1148  #endif
1149  }
1150  }
1151 
1153  {
1154  // need to export the min value and the max value as attributes
1155  // It depends on the real type (FormComponentType) of the control, which properties hold these
1156  // values
1157  const char* pMinValuePropertyName = nullptr;
1158  const char* pMaxValuePropertyName = nullptr;
1159  getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
1160 
1161  OSL_ENSURE((nullptr == pMinValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MinValue & m_nIncludeSpecial)),
1162  "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1163  OSL_ENSURE((nullptr == pMaxValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MaxValue & m_nIncludeSpecial)),
1164  "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1165 
1166  // add the two attributes
1167  static const char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue);
1168  static const char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue);
1169  static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MinValue);
1170  static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MaxValue);
1171 
1172  if (pMinValuePropertyName && (SCAFlags::MinValue & m_nIncludeSpecial))
1174  nMinValueNamespaceKey,
1175  pMinValueAttributeName,
1176  pMinValuePropertyName);
1177 
1178  if (pMaxValuePropertyName && (SCAFlags::MaxValue & m_nIncludeSpecial))
1180  nMaxValueNamespaceKey,
1181  pMaxValueAttributeName,
1182  pMaxValuePropertyName);
1183  #if OSL_DEBUG_LEVEL > 0
1184  // reset the bit for later checking
1185  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags(SCAFlags::MinValue | SCAFlags::MaxValue);
1186  #endif
1187  }
1188 
1189  if ( SCAFlags::ImagePosition & m_nIncludeSpecial )
1190  {
1192  RESET_BIT( m_nIncludeSpecial, SCAFlags::ImagePosition );
1193  }
1194 
1195  OSL_ENSURE(SCAFlags::NONE == m_nIncludeSpecial,
1196  "OControlExport::exportSpecialAttributes: forgot some flags!");
1197  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1198  // be 0 now ...
1199  }
1200 
1202  {
1203  OUString sListSource;
1204  Any aListSource = m_xProps->getPropertyValue( PROPERTY_LISTSOURCE );
1205  if ( !( aListSource >>= sListSource ) )
1206  {
1207  Sequence< OUString > aListSourceSequence;
1208  aListSource >>= aListSourceSequence;
1209  if ( aListSourceSequence.hasElements() )
1210  sListSource = aListSourceSequence[ 0 ];
1211  }
1212  return sListSource;
1213  }
1214 
1216  {
1217  // DAFlags::ListSource needs some special handling
1219 
1220  OUString sListSource = getScalarListSourceValue();
1221  if ( !sListSource.isEmpty() )
1222  { // the ListSource property needs to be exported as attribute, and it is not empty
1223  AddAttribute(
1226  sListSource);
1227  }
1228 
1230  }
1231 
1232  void OControlExport::getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut)
1233  {
1234  Sequence< sal_Int16 > aValueSequence;
1235  DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
1236  m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
1237 
1238  for (const auto& rValue : std::as_const(aValueSequence))
1239  _rOut.insert(rValue);
1240  }
1241 
1243  {
1244  // the string lists
1245  Sequence< OUString > aItems, aValues;
1247  m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
1248 
1251  m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
1252  // if we exported the list source as attribute, we do not repeat it as sub elements
1253 
1254  // the selection lists
1255  Int16Set aSelection, aDefaultSelection;
1258 
1259  // the string for "true"
1260  OUString sTrue;
1261  OUStringBuffer sBuffer;
1262  ::sax::Converter::convertBool(sBuffer, true);
1263  sTrue = sBuffer.makeStringAndClear();
1264 
1265  // loop through both lists ('til the maximum of both lengths)
1266  const OUString* pItems = aItems.getConstArray();
1267  const OUString* pValues = aValues.getConstArray();
1268 
1269  sal_Int32 nItems = aItems.getLength();
1270  sal_Int32 nValues = aValues.getLength();
1271 
1272  sal_Int16 nMaxLen = static_cast<sal_Int16>(std::max(nItems, nValues));
1273 
1274  for (sal_Int16 i=0; i<nMaxLen; ++i )
1275  {
1277  if (i < nItems)
1278  {
1279  // there is an item at this position
1280  AddAttribute(
1283  *pItems);
1284  ++pItems;
1285  }
1286  if (i < nValues)
1287  {
1288  // there is a value at this position
1289  AddAttribute(
1292  *pValues);
1293  ++pValues;
1294  }
1295 
1296  Int16Set::const_iterator aSelectedPos = aSelection.find(i);
1297  if (aSelection.end() != aSelectedPos)
1298  { // the item at this position is selected
1299  AddAttribute(
1302  sTrue
1303  );
1304  aSelection.erase(aSelectedPos);
1305  }
1306 
1307  Int16Set::const_iterator aDefaultSelectedPos = aDefaultSelection.find(i);
1308  if (aDefaultSelection.end() != aDefaultSelectedPos)
1309  { // the item at this position is selected as default
1310  AddAttribute(
1313  sTrue
1314  );
1315  aDefaultSelection.erase(aDefaultSelectedPos);
1316  }
1317  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1318  }
1319 
1320  // There may be more "selected" or "default-selected" items than there are in the lists in real,
1321  // so we need to store some additional "form:option" items which have no name and no label, but
1322  // one or both of the selected flags.
1323  // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1324 
1325  if (aSelection.empty() && aDefaultSelection.empty())
1326  return;
1327 
1328  sal_Int16 nLastSelected = -1;
1329  if ( !aSelection.empty() )
1330  nLastSelected = *(--aSelection.end());
1331 
1332  sal_Int16 nLastDefaultSelected = -1;
1333  if ( !aDefaultSelection.empty() )
1334  nLastDefaultSelected = *(--aDefaultSelection.end());
1335 
1336  // the maximum element in both sets
1337  sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
1338  OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!");
1339  // if the maximum (selected or default selected) entry number is less than the maximum item count
1340  // in both lists, the entry number should have been removed from the set
1341 
1342  for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
1343  {
1344  if (aSelection.end() != aSelection.find(i))
1345  { // the (not existent) item at this position is selected
1346  AddAttribute(
1349  sTrue
1350  );
1351  }
1352 
1353  if (aDefaultSelection.end() != aDefaultSelection.find(i))
1354  { // the (not existent) item at this position is selected as default
1355  AddAttribute(
1358  sTrue
1359  );
1360  }
1361  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1362  }
1363  }
1364 
1365  void OControlExport::implStartElement(const char* _pName)
1366  {
1367  // before we let the base class start it's outer element, we add a wrapper element
1368  const char *pOuterElementName = getOuterXMLElementName();
1369  if (pOuterElementName)
1370  m_pOuterElement = std::make_unique<SvXMLElementExport>(
1373  pOuterElementName, true,
1374  true);
1375 
1376  // add the attributes for the inner element
1378 
1379  // and start the inner element
1381  }
1382 
1384  {
1385  // end the inner element
1387 
1388  // end the outer element if it exists
1389  m_pOuterElement.reset();
1390  }
1391 
1393  {
1394  return nullptr;
1395  }
1396 
1398  {
1399  return getElementName(m_eType);
1400  }
1401 
1403  {
1406  "OControlExport::examine: called me twice? Not initialized?" );
1407 
1408  // get the class id to decide which kind of element we need in the XML stream
1409  m_nClassId = FormComponentType::CONTROL;
1410  DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
1411  m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId;
1412  bool knownType = false;
1413  switch (m_nClassId)
1414  {
1415  case FormComponentType::DATEFIELD:
1416  m_eType = DATE;
1417  knownType = true;
1418  [[fallthrough]];
1419  case FormComponentType::TIMEFIELD:
1420  if ( !knownType )
1421  {
1422  m_eType = TIME;
1423  knownType = true;
1424  }
1426  [[fallthrough]];
1427  case FormComponentType::NUMERICFIELD:
1428  case FormComponentType::CURRENCYFIELD:
1429  case FormComponentType::PATTERNFIELD:
1430  if ( !knownType )
1431  {
1433  knownType = true;
1434  }
1435  [[fallthrough]];
1436  case FormComponentType::TEXTFIELD:
1437  { // it's some kind of edit. To know which type we need further investigation
1438 
1439  if ( !knownType )
1440  {
1441  // check if it's a formatted field
1442  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
1443  {
1445  }
1446  else
1447  {
1448  // all other controls are represented by an ordinary edit control, but which XML control type
1449  // it is depends on the current values of some properties
1450 
1451  // if the EchoChar string is not empty, it is a password field
1452  sal_Int16 nEchoChar = 0;
1453  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR))
1454  // grid columns do not have this property...
1455  m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar;
1456  if (nEchoChar)
1457  {
1458  m_eType = PASSWORD;
1460  }
1461  else
1462  {
1463  // if the MultiLine property is sal_True, it is a TextArea
1464  bool bMultiLine = false;
1465  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE))
1466  // grid columns do not have this property...
1467  bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
1468 
1469  if ( bMultiLine )
1470  m_eType = TEXT_AREA;
1471  else
1472  // the only case left is represented by a Text element
1473  m_eType = TEXT;
1474  }
1475  }
1476  }
1477 
1478  // attributes which are common to all the types:
1479  // common attributes
1483 
1484  if ( ( m_nClassId != FormComponentType::DATEFIELD )
1485  && ( m_nClassId != FormComponentType::TIMEFIELD )
1486  )
1487  // date and time field values are handled differently nowadays
1489 
1490  // database attributes
1492 
1493  // event attributes
1495 
1496  // only text and pattern fields have a ConvertEmptyToNull property
1497  if ( ( m_nClassId == FormComponentType::TEXTFIELD )
1498  || ( m_nClassId == FormComponentType::PATTERNFIELD )
1499  )
1501 
1502  // all controls but the file control fields have a readonly property
1503  if ( m_nClassId != FormComponentType::FILECONTROL )
1505 
1506  // a text field has a max text len
1507  if ( m_nClassId == FormComponentType::TEXTFIELD )
1509 
1510  // max and min values and validation:
1511  if (FORMATTED_TEXT == m_eType)
1512  { // in general all controls represented as formatted-text have these props
1513  if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField
1515 
1516  if (FormComponentType::TEXTFIELD != m_nClassId)
1517  // and the FormattedField does not have a validation flag
1519  }
1520 
1521  // if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1522  if ( ( PASSWORD != m_eType )
1523  && ( DATE != m_eType )
1524  && ( TIME != m_eType )
1525  )
1526  {
1528  }
1529  }
1530  break;
1531 
1532  case FormComponentType::FILECONTROL:
1533  m_eType = FILE;
1539  break;
1540 
1541  case FormComponentType::FIXEDTEXT:
1542  m_eType = FIXED_TEXT;
1548  break;
1549 
1550  case FormComponentType::COMBOBOX:
1551  m_eType = COMBOBOX;
1559  break;
1560 
1561  case FormComponentType::LISTBOX:
1562  m_eType = LISTBOX;
1569  // check if we need to export the ListSource as attribute
1570  {
1571  // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1572  // a sequence of pairs which is build from the StringItemList and the ValueList
1573  ListSourceType eListSourceType = ListSourceType_VALUELIST;
1574  bool bSuccess =
1575  m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType;
1576  OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1577  if (ListSourceType_VALUELIST != eListSourceType)
1578  {
1580  }
1581  }
1582 
1583  break;
1584 
1585  case FormComponentType::COMMANDBUTTON:
1586  m_eType = BUTTON;
1589  [[fallthrough]];
1590  case FormComponentType::IMAGEBUTTON:
1591  if (BUTTON != m_eType)
1592  {
1593  // not coming from the previous case
1594  m_eType = IMAGE;
1595  }
1596  m_nIncludeCommon |=
1601  break;
1602 
1603  case FormComponentType::CHECKBOX:
1604  m_eType = CHECKBOX;
1606  [[fallthrough]];
1607  case FormComponentType::RADIOBUTTON:
1611  if (CHECKBOX != m_eType)
1612  { // not coming from the previous case
1613  m_eType = RADIO;
1615  }
1616  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) )
1618  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) )
1622  break;
1623 
1624  case FormComponentType::GROUPBOX:
1625  m_eType = FRAME;
1630  break;
1631 
1632  case FormComponentType::IMAGECONTROL:
1633  m_eType = IMAGE_FRAME;
1639  break;
1640 
1641  case FormComponentType::HIDDENCONTROL:
1642  m_eType = HIDDEN;
1645  break;
1646 
1647  case FormComponentType::GRIDCONTROL:
1648  m_eType = GRID;
1653  break;
1654 
1655  case FormComponentType::SCROLLBAR:
1656  case FormComponentType::SPINBUTTON:
1657  m_eType = VALUERANGE;
1662 
1663  if ( m_nClassId == FormComponentType::SCROLLBAR )
1665 
1667  break;
1668 
1669  default:
1670  OSL_FAIL("OControlExport::examineControl: unknown control type (class id)!");
1671  [[fallthrough]];
1672 
1673  case FormComponentType::NAVIGATIONBAR:
1674  // TODO: should we have an own file format for this?
1675  // NO break
1676 
1677  case FormComponentType::CONTROL:
1679  // unknown control type
1681  // at least a name should be there, 'cause without a name the control could never have been
1682  // inserted into its parent container
1683  // In addition, the service name is absolutely necessary to create the control upon reading.
1685  // we always should be able to export events - this is not control type dependent
1686  break;
1687  }
1688 
1689  // in general, all control types need to export the control id
1691 
1692  // is it a control bound to a calc cell?
1694  {
1696  {
1698  {
1700  if ( m_nClassId == FormComponentType::LISTBOX )
1702  }
1703  }
1704 
1705  // is it a list-like control which uses a calc cell range as list source?
1706  {
1709  }
1710  }
1711 
1712  // is control bound to XForms?
1713  if( !getXFormsBindName( m_xProps ).isEmpty() )
1714  {
1716  }
1717 
1718  // is (list-)control bound to XForms list?
1719  if( !getXFormsListBindName( m_xProps ).isEmpty() )
1720  {
1722  }
1723 
1724  // does the control have an XForms submission?
1725  if( !getXFormsSubmissionName( m_xProps ).isEmpty() )
1726  {
1728  }
1729  }
1730 
1731  void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType )
1732  {
1733  try
1734  {
1736  Reference< XValueBinding > xBinding( aHelper.getCurrentBinding() );
1737  OSL_ENSURE( xBinding.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1738  if ( xBinding.is() )
1739  {
1740  AddAttribute(
1743  aHelper.getStringAddressFromCellBinding( xBinding )
1744  );
1745 
1746  if ( _bIncludeListLinkageType )
1747  {
1748  sal_Int16 nLinkageType = FormCellBindingHelper::isCellIntegerBinding( xBinding ) ? 1 : 0;
1749 
1750  OUStringBuffer sBuffer;
1752  sBuffer,
1753  nLinkageType,
1755  );
1756 
1757  AddAttribute(
1760  sBuffer.makeStringAndClear()
1761  );
1762  }
1763 
1764  }
1765  }
1766  catch( const Exception& )
1767  {
1768  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OControlExport::exportCellBindingAttributes" );
1769  }
1770  }
1771 
1773  {
1774  OUString sBindName = getXFormsBindName( m_xProps );
1776  }
1778  {
1779  OUString sBindName = getXFormsListBindName( m_xProps );
1781  }
1783  {
1784  OUString sSubmission = getXFormsSubmissionName( m_xProps );
1786  }
1788  {
1789  try
1790  {
1791  Reference< XListEntrySink > xSink( m_xProps, UNO_QUERY );
1792  Reference< XListEntrySource > xSource;
1793  if ( xSink.is() )
1794  xSource = xSink->getListEntrySource();
1795  OSL_ENSURE( xSource.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1796  if ( xSource.is() )
1797  {
1799 
1800  AddAttribute(
1803  aHelper.getStringAddressFromCellListSource( xSource )
1804  );
1805  }
1806  }
1807  catch( const Exception& )
1808  {
1809  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OControlExport::exportCellListSourceRange" );
1810  }
1811  }
1812 
1814  {
1815  try
1816  {
1817  sal_Int16 nImagePosition = ImagePosition::Centered;
1818  OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_IMAGE_POSITION ) >>= nImagePosition );
1819  OSL_ENSURE( ( nImagePosition >= ImagePosition::LeftTop ) && ( nImagePosition <= ImagePosition::Centered ),
1820  "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1821 
1822  if ( ( nImagePosition < ImagePosition::LeftTop ) || ( nImagePosition > ImagePosition::Centered ) )
1823  // this is important to prevent potential buffer overflows below, so don't optimize
1824  nImagePosition = ImagePosition::Centered;
1825 
1826  if ( nImagePosition == ImagePosition::Centered )
1827  {
1829  }
1830  else
1831  {
1832  const XMLTokenEnum eXmlImagePositions[] =
1833  {
1835  };
1836  const XMLTokenEnum eXmlImageAligns[] =
1837  {
1839  };
1840 
1841  XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ nImagePosition / 3 ];
1842  XMLTokenEnum eXmlImageAlign = eXmlImageAligns [ nImagePosition % 3 ];
1843 
1846  }
1847 
1849  // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1850  // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1851  // we don't need to export ImageAlign anymore
1853  }
1854  catch( const Exception& )
1855  {
1856  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
1857  }
1858  }
1859 
1861  {
1862  try
1863  {
1864  // currently exchanging the data with a database column?
1865  OUString sBoundFieldPropertyName( "BoundField" );
1866  if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( sBoundFieldPropertyName ) )
1867  {
1868  Reference< XPropertySet > xBoundField;
1869  m_xProps->getPropertyValue( sBoundFieldPropertyName ) >>= xBoundField;
1870  if ( xBoundField.is() )
1871  return true;
1872  }
1873 
1874  // currently exchanging data with an external binding?
1875  Reference< XBindableValue > xBindable( m_xProps, UNO_QUERY );
1876  if ( xBindable.is() && xBindable->getValueBinding().is() )
1877  return true;
1878  }
1879  catch( const Exception& )
1880  {
1881  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OColumnExport::controlHasActiveDataBinding" );
1882  }
1883 
1884  return false;
1885  }
1886 
1888  {
1889  try
1890  {
1891  // an external list source?
1892  Reference< XListEntrySink > xEntrySink( m_xProps, UNO_QUERY );
1893  if ( xEntrySink.is() && xEntrySink->getListEntrySource().is() )
1894  return false;
1895 
1896  if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( PROPERTY_LISTSOURCETYPE ) )
1897  {
1898  ListSourceType eListSourceType = ListSourceType_VALUELIST;
1899  OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eListSourceType );
1900  if ( eListSourceType == ListSourceType_VALUELIST )
1901  // for value lists, the list entries as entered by the user are used
1902  return true;
1903 
1904  // for every other type, the list entries are filled with some data obtained
1905  // from a database - if and only if the ListSource property is not empty
1906  return getScalarListSourceValue().isEmpty();
1907  }
1908  }
1909  catch( const Exception& )
1910  {
1911  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
1912  }
1913 
1914  OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
1915  // this method should be called for list and combo boxes only
1916  return true;
1917  }
1918 
1919  //= OColumnExport
1920  OColumnExport::OColumnExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl, const OUString& _rControlId,
1921  const Sequence< ScriptEventDescriptor >& _rEvents)
1922  :OControlExport(_rContext, _rxControl, _rControlId, OUString(), _rEvents)
1923  {
1924  }
1925 
1927  {
1928  }
1929 
1931  {
1932  // the attribute "service name" (which has a slightly different meaning for columns
1934  OUString sColumnServiceName;
1935  m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName;
1936  // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
1937  // real service name for the column (for use with the XGridColumnFactory) is only the last
1938  // token of this complete name.
1939  sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.');
1940  OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!");
1941  sColumnServiceName = sColumnServiceName.copy(nLastSep + 1);
1942  sColumnServiceName =
1944  XML_NAMESPACE_OOO, sColumnServiceName );
1945  // add the attribute
1948  , sColumnServiceName);
1949  // flag the property as "handled"
1951 
1952  }
1953 
1955  {
1956  return "column";
1957  }
1958 
1960  {
1962 
1963  // the attribute "label"
1967  PROPERTY_LABEL);
1968 
1969  // the style attribute
1970  OUString sStyleName = m_rContext.getObjectStyleName( m_xProps );
1971  if ( !sStyleName.isEmpty() )
1972  {
1973  AddAttribute(
1976  sStyleName
1977  );
1978  }
1979  }
1980 
1982  {
1984 
1985  // grid columns miss some properties of the controls they're representing
1988 
1989  if (FormComponentType::DATEFIELD != m_nClassId)
1990  // except date fields, no column has the DropDown property
1991  m_nIncludeCommon &= ~CCAFlags::Dropdown;
1992  }
1993 
1994  //= OFormExport
1996  const Sequence< ScriptEventDescriptor >& _rEvents)
1997  :OElementExport(_rContext, _rxForm, _rEvents)
1998  ,m_bCreateConnectionResourceElement(false)
1999  {
2000  OSL_ENSURE(m_xProps.is(), "OFormExport::OFormExport: invalid arguments!");
2001  }
2002 
2004  {
2005  return "form";
2006  }
2007 
2009  {
2011  {
2013  OUString sPropValue;
2014  m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; // if set it is a file url
2015  if ( sPropValue.isEmpty() )
2016  m_xProps->getPropertyValue( PROPERTY_URL ) >>= sPropValue;
2017  if ( !sPropValue.isEmpty() )
2018  AddAttribute(
2023  {
2025  }
2026  }
2027 
2028  // let the base class export the remaining properties and the events
2030  // loop through all children
2031  Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY);
2032  OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspicious!");
2033 
2034  if (xCollection.is())
2035  m_rContext.exportCollectionElements(xCollection);
2036  }
2037 
2039  {
2040  sal_Int32 i=0;
2041 
2042  // the string properties
2043  {
2044  static const FormAttributes eStringPropertyIds[] =
2045  {
2046  faName, /*faAction,*/ faCommand, faFilter, faOrder
2047  };
2048  static const char * aStringPropertyNames[] =
2049  {
2051  };
2052  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eStringPropertyIds);
2053  #if OSL_DEBUG_LEVEL > 0
2054  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(aStringPropertyNames);
2055  OSL_ENSURE((nIdCount == nNameCount),
2056  "OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2057  #endif
2058  for (i=0; i<nIdCount; ++i)
2060  OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]),
2061  OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]),
2062  OUString::createFromAscii(aStringPropertyNames[i]));
2063 
2064  // #i112082# xlink:type is added as part of exportTargetLocationAttribute
2065 
2066  // now export the data source name or databaselocation or connection resource
2067  OUString sPropValue;
2068  m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue;
2069  m_bCreateConnectionResourceElement = sPropValue.isEmpty();
2071  {
2072  INetURLObject aURL(sPropValue);
2073  m_bCreateConnectionResourceElement = ( aURL.GetProtocol() == INetProtocol::File );
2079  }
2080  else
2084  }
2085 
2086  // the boolean properties
2087  {
2088  static const FormAttributes eBooleanPropertyIds[] =
2089  {
2091  };
2092  static const char * pBooleanPropertyNames[] =
2093  {
2100  };
2101  static const BoolAttrFlags nBooleanPropertyAttrFlags[] =
2102  {
2104  };
2105  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eBooleanPropertyIds);
2106  #if OSL_DEBUG_LEVEL > 0
2107  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
2108  static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags);
2109  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
2110  "OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2111  #endif
2112  for (i=0; i<nIdCount; ++i)
2114  OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds[i]),
2115  OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds[i]),
2116  OUString::createFromAscii(pBooleanPropertyNames[i]),
2117  nBooleanPropertyAttrFlags[i]
2118  );
2119  }
2120 
2121  // the enum properties
2122  {
2128  FormSubmitEncoding_URL,
2129  false
2130  );
2136  FormSubmitMethod_GET,
2137  false
2138  );
2144  CommandType::COMMAND,
2145  false
2146  );
2152  NavigationBarMode_CURRENT,
2153  false
2154  );
2160  TabulatorCycle_RECORDS,
2161  true
2162  );
2163  }
2164 
2165  // the service name
2167  // the target frame
2169  // the target URL
2170  exportTargetLocationAttribute(true); // #i110911# add type attribute (for form, but not for control)
2171 
2172  // master fields
2177  // detail fields
2182  }
2183 } // namespace xmloff
2184 
2185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertyInfo
tools::SvRef< SvBaseLink > xSink
BAFlags
#define PROPERTY_MASTERFIELDS
Definition: strings.hxx:103
static bool isCellRangeListSource(const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource)
checks whether a given list source is a spreadsheet cell list source
#define PROPERTY_LISTSOURCE
Definition: strings.hxx:67
void exportedProperty(const OUString &_rPropertyName)
indicates that a property has been handled by a derived class, without using the helper methods of th...
static sal_uInt16 getCommonControlAttributeNamespace(CCAFlags _nId)
calculates the xml namespace key to use for a common control attribute
URL aURL
#define PROPERTY_LABEL
Definition: strings.hxx:32
#define PROPERTY_APPLYFILTER
Definition: strings.hxx:54
void exportXFormsSubmissionAttributes()
exports the attribute(s) for an XForms submission
DAFlags
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
#define PROPERTY_CONTROLLABEL
Definition: strings.hxx:75
OControlExport(IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rControlId, const OUString &_rReferringControls, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rxEvents)
constructs an object capable of exporting controls
virtual void implStartElement(const char *_pName)
start the XML element
const SvXMLEnumMapEntry< sal_Int32 > aCommandTypeMap[]
Definition: formenums.cxx:59
#define PROPERTY_DETAILFIELDS
Definition: strings.hxx:104
static const char * getBindingAttributeName(BAFlags _nId)
calculates the xml attribute representation of a binding attribute.
static bool convertBool(bool &rBool, const OUString &rString)
void exportDatabaseAttributes()
adds database attributes to the XMLExport context given
#define PROPERTY_ORDER
Definition: strings.hxx:50
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
virtual void exportSubTags()
export any sub tags
void exportBindingAttributes()
adds the XML attributes which are related to binding controls to external values and/or list sources ...
void exportEnumPropertyAttribute(const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const SvXMLEnumMapEntry< EnumT > *_pValueMap, const EnumT _nDefault, const bool _bVoidDefault=false)
add an attribute which is represented by an enum property to the export context
virtual const char * getXMLElementName() const override
get the name of the XML element
#define PROPERTY_ALLOWINSERTS
Definition: strings.hxx:52
OUString getScalarListSourceValue() const
retrieves the string specifying the ListSource of a list or combo box
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:560
SCAFlags
#define PROPERTY_ENABLEVISIBLE
Definition: strings.hxx:43
const SvXMLEnumMapEntry< sal_Int32 > aOrientationMap[]
Definition: formenums.cxx:151
void exportCommonControlAttributes()
adds common control attributes to the XMLExport context given
static const char * getCommonControlAttributeName(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
#define PROPERTY_DEFAULT_SELECT_SEQ
Definition: strings.hxx:78
provides export related tools for attribute handling
#define PROPERTY_BOUNDCOLUMN
Definition: strings.hxx:64
helper class wrapping different script event representations
Definition: eventexport.hxx:48
const SvXMLEnumMapEntry< NavigationBarMode > aNavigationTypeMap[]
Definition: formenums.cxx:66
virtual void exportServiceNameAttribute()
add the service-name attribute to the export context
constexpr sal_uInt16 XML_NAMESPACE_OOO
OUString getXFormsSubmissionName(const Reference< XPropertySet > &xBinding)
const SvXMLEnumMapEntry< FormSubmitEncoding > aSubmitEncodingMap[]
Definition: formenums.cxx:46
const SvXMLEnumMapEntry< FormSubmitMethod > aSubmitMethodMap[]
Definition: formenums.cxx:53
const_iterator find(const Value &x) const
css::uno::Sequence< css::script::ScriptEventDescriptor > m_aEvents
#define PROPERTY_AUTOCOMPLETE
Definition: strings.hxx:71
#define PROPERTY_TABSTOP
Definition: strings.hxx:40
FormAttributes
attributes in the xml tag representing a form
#define PROPERTY_MULTILINE
Definition: strings.hxx:29
void exportListSourceAsAttribute()
exports the ListSource property of a control as attribute
#define PROPERTY_INPUT_REQUIRED
Definition: strings.hxx:66
const sal_Int16 FORMATTEDFIELD
void exportOuterAttributes()
exports the attributes for the outer element
#define CHECK_N_TRANSLATE(name)
ButtonType
void exportSubTags() override
writes everything which needs to be represented as sub tag
#define PROPERTY_COMMAND_TYPE
Definition: strings.hxx:59
#define PROPERTY_SPIN_INCREMENT
Definition: strings.hxx:128
virtual void exportSubTags() override
export any sub tags
const css::uno::Reference< css::beans::XPropertySet > m_xProps
void SAL_DLLPRIVATE AddAttributeIdLegacy(sal_uInt16 const nLegacyPrefix, OUString const &rValue)
add xml:id and legacy namespace id
Definition: xmlexp.cxx:2307
#define PROPERTY_DEFAULT_STATE
Definition: strings.hxx:39
#define PROPERTY_DATASOURCENAME
Definition: strings.hxx:48
virtual void exportAttributes() override
export the attributes
virtual void exportAttributes()
export the attributes
OUString getXFormsListBindName(const Reference< XPropertySet > &xControl)
NONE
static bool livesInSpreadsheetDocument(const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel)
determines whether the given control model lives in a spreadsheet document
sal_uInt16 GetHour() const
#define PROPERTY_FOCUS_ON_CLICK
Definition: strings.hxx:131
virtual const char * getOuterXMLElementName() const override
get the name of the outer XML element
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
SvXMLAttributeList & GetAttrList()
Definition: xmlexp.hxx:380
#define PROPERTY_URL
Definition: strings.hxx:100
std::unique_ptr< SvXMLElementExport > m_pXMLElement
#define PROPERTY_DATAFIELD
Definition: strings.hxx:63
#define PROPERTY_PRINTABLE
Definition: strings.hxx:37
const PropertyId propertyId
the unique ID of the property. The property meta data table must not contain two entries with the sam...
#define PROPERTY_RICH_TEXT
Definition: strings.hxx:142
PropertiesInfo aProperties
#define PROPERTY_IMAGE_POSITION
Definition: strings.hxx:133
#define DBG_CHECK_PROPERTY(name, type)
const SvXMLEnumMapEntry< TriState > aCheckStateMap[]
Definition: formenums.cxx:99
#define SERVICE_PERSISTENT_COMPONENT_EDIT
Definition: strings.hxx:154
const SvXMLEnumMapEntry< ListSourceType > aListSourceTypeMap[]
Definition: formenums.cxx:88
virtual void exportCollectionElements(const css::uno::Reference< css::container::XIndexAccess > &_rxCollection)=0
steps through a collection and exports all children of this collection
#define PROPERTY_LISTSOURCETYPE
Definition: strings.hxx:68
sal_uInt16 GetMin() const
#define PROPERTY_STATE
Definition: strings.hxx:41
#define PROPERTY_TITLE
Definition: strings.hxx:35
constexpr sal_uInt16 XML_NAMESPACE_FORM
virtual const char * getXMLElementName() const override
get the name of the XML element
#define PROPERTY_GROUP_NAME
Definition: strings.hxx:136
#define SERVICE_EDIT
Definition: strings.hxx:176
IFormsExportContext & m_rContext
#define PROPERTY_SELECT_SEQ
Definition: strings.hxx:79
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2089
#define PROPERTY_BUTTONTYPE
Definition: strings.hxx:62
#define PROPERTY_SUBMIT_METHOD
Definition: strings.hxx:58
bool shouldExportProperty(const OUString &i_propertyName) const
determines whether the given property is to be exported
UNKNOWN
static const char * getElementName(ElementType _eType)
retrieves the tag name to be used to describe a control of the given type
#define PROPERTY_IMAGE_ALIGN
Definition: strings.hxx:134
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
CCAFlags
#define SAL_N_ELEMENTS(arr)
#define PROPERTY_COLUMNSERVICENAME
Definition: strings.hxx:105
::xmloff::token::XMLTokenEnum attributeToken
void exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags)
add an attribute which is represented by a boolean property to the export context ...
#define PROPERTY_IGNORERESULT
Definition: strings.hxx:56
#define PROPERTY_LINE_INCREMENT
Definition: strings.hxx:121
#define PROPERTY_TRISTATE
Definition: strings.hxx:74
sal_uInt16 GetSec() const
const SvXMLEnumMapEntry< FormButtonType > aFormButtonTypeMap[]
Definition: formenums.cxx:80
#define PROPERTY_TABINDEX
Definition: strings.hxx:46
void exportImageDataAttribute()
add the form:image attribute to the export context.
#define DBG_UNHANDLED_EXCEPTION(...)
#define PROPERTY_NAME
Definition: strings.hxx:30
Orientation
#define SERVICE_FORMATTEDFIELD
Definition: strings.hxx:194
#define TOOLS_WARN_EXCEPTION(area, stream)
void exportXFormsBindAttributes()
exports the attribute(s) which bind this control to XForms
void exportImagePositionAttributes()
exports the attribute(s) for the ImagePosition property
#define PROPERTY_TOGGLE
Definition: strings.hxx:130
#define PROPERTY_READONLY
Definition: strings.hxx:38
static const char * getSpecialAttributeName(SCAFlags _nId)
calculates the xml attribute representation of a special attribute.
int i
virtual void exportAttributes() override
export the attributes
#define PROPERTY_ECHO_CHAR
Definition: strings.hxx:69
encapsulates functionality related to binding a form control to a spreadsheet cell ...
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:2009
bool controlHasUserSuppliedListEntries() const
determines whether the list entries (of a combo or list box) are supplied by the user ...
virtual SvXMLExport & getGlobalContext()=0
static bool isCellBinding(const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
checks whether a given binding is a spreadsheet cell binding
virtual void implEndElement() override
ends the XML element
#define RESET_BIT(bitfield, bit)
Any aHelper
TRISTATE_FALSE
const char * msApiName
Definition: maptype.hxx:33
virtual sal_Int16 SAL_CALL getLength() override
Definition: attrlist.cxx:34
const AttributeDescription attribute
denotes the attribute which represents the property.
#define PROPERTY_CLASSID
Definition: strings.hxx:27
#define PROPERTY_NAVIGATION
Definition: strings.hxx:60
Represents a property with its API-name, its XML-name and the type of its value.
Definition: maptype.hxx:31
float u
#define PROPERTY_VALUE_SEQ
Definition: strings.hxx:77
static bool isCellIntegerBinding(const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
checks whether a given binding is a spreadsheet cell binding, exchanging integer values ...
bool m_bCreateConnectionResourceElement
void exportXFormsListAttributes()
exports the attribute(s) which bind the list of a list control to XForms
#define PROPERTY_REPEAT_DELAY
Definition: strings.hxx:123
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
#define PROPERTY_ALLOWUPDATES
Definition: strings.hxx:53
static const char * getDatabaseAttributeName(DAFlags _nId)
calculates the xml attribute representation of a database attribute.
void exportGenericHandlerAttributes()
adds the attributes which are handled via generic IPropertyHandlers
const_iterator end() const
#define PROPERTY_FILTER
Definition: strings.hxx:49
bool empty() const
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
#define PROPERTY_ALLOWDELETES
Definition: strings.hxx:51
virtual const char * getXMLElementName() const =0
get the name of the XML element
#define PROPERTY_ENABLED
Definition: strings.hxx:42
#define PROPERTY_ORIENTATION
Definition: strings.hxx:129
#define PROPERTY_VISUAL_EFFECT
Definition: strings.hxx:132
void exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const sal_Int16 _nDefault, const bool force=false)
add an attribute which is represented by a sal_Int16 property to the export context ...
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:391
void exportCellBindingAttributes(bool _bIncludeListLinkageType)
exports the attribute which descrives a cell value binding of a control in a spreadsheet document ...
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.
#define PROPERTY_PERSISTENCE_MAXTEXTLENGTH
Definition: strings.hxx:116
static sal_uInt16 getDatabaseAttributeNamespace()
calculates the xml namespace key to use for a database attribute.
virtual void implStartElement(const char *_pName) override
start the XML element
css::uno::Reference< css::form::binding::XListEntrySource > getCurrentListSource() const
returns the current external list source of the control model, if any
void exportCellListSourceRange()
exports the attribute which descrives a cell range which acts as list source for a list-like control ...
void exportInt32PropertyAttribute(const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const sal_Int32 _nDefault)
add an attribute which is represented by a sal_Int32 property to the export context ...
virtual void implEndElement()
ends the XML element
#define DBG_CHECK_PROPERTY_NO_TYPE(name)
const PropertyValue * pValues
void ClearAttrList()
Definition: xmlexp.cxx:1024
OUString getXFormsBindName(const Reference< XPropertySet > &xControl)
void flagStyleProperties()
flag the style properties as 'already exported'
#define PROPERTY_ECHOCHAR
Definition: strings.hxx:28
#define PROPERTY_MULTISELECTION
Definition: strings.hxx:72
virtual ~OColumnExport() override
static const XMLPropertyMapEntry * getPropertyMapForType(TextPropMap _nType)
Definition: txtprmap.cxx:1131
OUString getStringAddressFromCellListSource(const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource) const
creates a string representation for the given list source's range address
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3405
bool controlHasActiveDataBinding() const
determines whether the control we're exporting has an active data binding.
std::unique_ptr< SvXMLElementExport > m_pOuterElement
static sal_uInt16 getBindingAttributeNamespace()
calculates the xml namespace key to use for a binding attribute.
Handling of tokens in XML:
void exportTargetFrameAttribute()
add the hlink:target-frame attribute to the export context.
const SvXMLEnumMapEntry< sal_Int16 > aListLinkageMap[]
Definition: formenums.cxx:145
State
OElementExport(IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxProps, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
INetProtocol GetProtocol() const
#define PROPERTY_STRICTFORMAT
Definition: strings.hxx:70
FORM
virtual OUString getObjectStyleName(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)=0
virtual void examine() override
examine the control.
virtual void exportAttributes() override
export the attributes
#define PROPERTY_DROPDOWN
Definition: strings.hxx:36
OUString getStringAddressFromCellBinding(const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding) const
creates a string representation for the given value binding's address
void exportInnerAttributes()
exports the attributes for the inner element
#define PROPERTY_DEFAULTBUTTON
Definition: strings.hxx:73
Helper class for handling xml elements representing a form control.
#define PROPERTY_LINECOUNT
Definition: strings.hxx:45
#define PROPERTY_BLOCK_INCREMENT
Definition: strings.hxx:122
void getSequenceInt16PropertyAsSet(const OUString &_rPropertyName, Int16Set &_rOut)
gets a Sequence< sal_Int16 > property value as set of sal_Int16's
#define PROPERTY_MAXTEXTLENGTH
Definition: strings.hxx:44
void exportGenericPropertyAttribute(const sal_uInt16 _nAttributeNamespaceKey, const char *_pAttributeName, const char *_pPropertyName)
add an arbitrary attribute extracted from an arbitrary property to the export context ...
const SvXMLEnumMapEntry< sal_Int16 > aVisualEffectMap[]
Definition: formenums.cxx:157
#define SAL_WARN(area, stream)
#define PROPERTY_STRING_ITEM_LIST
Definition: strings.hxx:76
#define PROPERTY_CYCLE
Definition: strings.hxx:61
const char sServiceName[]
void AddAttribute(sal_uInt16 _nPrefix, const char *_pName, const OUString &_rValue)
virtual const char * getOuterXMLElementName() const
get the name of the outer XML element
virtual void exportServiceNameAttribute() override
add the service-name attribute to the export context
const EnumerationType m_eType
const SvXMLEnumMapEntry< TabulatorCycle > aTabulatorCycleMap[]
Definition: formenums.cxx:73
OFormExport(IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxForm, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rxEvents)
constructs an object capable of exporting controls
void MakeTimeFromMS(sal_Int32 nMS)
virtual void examine() override
examine the control.
void exportListSourceAsElements()
exports the ListSource property of a control as XML elements
void exportEvents()
exports the events (as script:events tag)
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.
OColumnExport(IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const OUString &_rControlId, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rxEvents)
ctor
std::pair< const_iterator, bool > insert(Value &&x)
#define PROPERTY_FORMATKEY
Definition: strings.hxx:106
static sal_uInt16 getSpecialAttributeNamespace(SCAFlags _nId)
calculates the xml namespace key to use for a special attribute.
void exportStringPropertyAttribute(const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName)
add an attribute which is represented by a string property to the export context
#define PROPERTY_EMPTY_IS_NULL
Definition: strings.hxx:65
void exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName)
exports a property value, which is a string sequence, as attribute
#define PROPERTY_COMMAND
Definition: strings.hxx:47
BoolAttrFlags
css::uno::Reference< css::form::binding::XValueBinding > getCurrentBinding() const
returns the current binding of our control model, if any.
void exportSpecialAttributes()
adds attributes which are special to a control type to the export context's attribute list ...
#define PROPERTY_SUBMIT_ENCODING
Definition: strings.hxx:57
EAFlags
static const char * getFormAttributeName(FormAttributes _eAttrib)
retrieves the name of an attribute of a form xml representation
const PropertyHandlerFactory factory
is the factory for creating a handler for reading and writing the property
#define PROPERTY_ESCAPEPROCESSING
Definition: strings.hxx:55
static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib)
calculates the xml namespace key to use for an attribute of a form xml representation ...
std::vector< sal_Int16 >::const_iterator const_iterator
bool any2bool(const css::uno::Any &rAny)
void exportTargetLocationAttribute(bool _bAddType)
add the form:href attribute to the export context.
size_type erase(const Value &x)
const PropertyDescription * getPropertyDescription(const OUString &i_propertyName)
sal_Int16 nValue
virtual void examine()
examine the element we're exporting
void Export(css::uno::Reference< css::document::XEventsSupplier > const &xAccess, bool bUseWhitespace=true)
export the events (calls EventExport::Export(Reference) )