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/xmlnmspe.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/nmspmap.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 
66 namespace xmloff
67 {
68 
69  #if OSL_DEBUG_LEVEL > 0
70  #define RESET_BIT( bitfield, bit ) \
71  bitfield = bitfield & ~bit
72  #else
73  #define RESET_BIT( bitfield, bit )
74  #endif
75 
76  using namespace ::xmloff::token;
77  using namespace ::com::sun::star;
78  using namespace ::com::sun::star::uno;
79  using namespace ::com::sun::star::sdb;
80  using namespace ::com::sun::star::awt;
81  using namespace ::com::sun::star::form;
82  using namespace ::com::sun::star::lang;
83  using namespace ::com::sun::star::beans;
84  using namespace ::com::sun::star::container;
85  using namespace ::com::sun::star::script;
86  using namespace ::com::sun::star::io;
87  using namespace ::com::sun::star::table;
88  using namespace ::com::sun::star::text;
89  using namespace ::com::sun::star::form::binding;
90 
91  //= OElementExport
92  OElementExport::OElementExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps,
93  const Sequence< ScriptEventDescriptor >& _rEvents)
94  :OPropertyExport(_rContext, _rxProps)
95  ,m_aEvents(_rEvents)
96  {
97  }
98 
100  {
101  }
102 
104  {
105  // collect some general information about the element
106  examine();
107 
108  // first add the attributes necessary for the element
110 
111  // add the attributes
113 
114  // start the XML element
116 
117  // the sub elements (mostly control type dependent)
118  exportSubTags();
119 
120  implEndElement();
121  }
122 
124  {
125  // nothing to do here
126  }
127 
129  {
130  // nothing to do here
131  }
132 
134  {
135  // the properties which where not exported 'til now
137 
138  // the script:events sub tags
139  exportEvents();
140  }
141 
142  void OElementExport::implStartElement(const char* _pName)
143  {
144  m_pXMLElement = std::make_unique<SvXMLElementExport>(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, true, true);
145  }
146 
148  {
149  m_pXMLElement.reset();
150  }
151 
153  {
154  Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY);
155  if (!xPersistence.is())
156  {
157  OSL_FAIL("OElementExport::exportServiceNameAttribute: no XPersistObject!");
158  return;
159  }
160 
161  OUString sServiceName = xPersistence->getServiceName();
162  // we don't want to write the old service name directly: it's a name used for compatibility reasons, but
163  // as we start some kind of new file format here (with this xml export), we don't care about
164  // compatibility ...
165  // So we translate the old persistence service name into new ones, if possible
166 
167  OUString sToWriteServiceName = sServiceName;
168 #define CHECK_N_TRANSLATE( name ) \
169  else if (sServiceName == SERVICE_PERSISTENT_COMPONENT_##name) \
170  sToWriteServiceName = SERVICE_##name
171 
172  if (sServiceName == SERVICE_PERSISTENT_COMPONENT_EDIT)
173  {
174  // special handling for the edit field: we have two controls using this as persistence service name
175  sToWriteServiceName = SERVICE_EDIT;
176  Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
177  if (xSI.is() && xSI->supportsService(SERVICE_FORMATTEDFIELD))
178  sToWriteServiceName = SERVICE_FORMATTEDFIELD;
179  }
186  CHECK_N_TRANSLATE( COMMANDBUTTON );
188  CHECK_N_TRANSLATE( GRID );
190  CHECK_N_TRANSLATE( FILECONTROL );
196  CHECK_N_TRANSLATE( HIDDENCONTROL );
197  CHECK_N_TRANSLATE( IMAGECONTROL );
198  CHECK_N_TRANSLATE( FORMATTEDFIELD );
199 #if OSL_DEBUG_LEVEL > 0
200  Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
201  OSL_ENSURE(xSI.is() && xSI->supportsService(sToWriteServiceName),
202  "OElementExport::exportServiceNameAttribute: wrong service name translation!");
203 
204 #endif
205  sToWriteServiceName =
207  XML_NAMESPACE_OOO, sToWriteServiceName );
208 
209  // now write this
210  AddAttribute(
213  sToWriteServiceName);
214  }
215 
217  {
218  if (!m_aEvents.hasElements())
219  // nothing to do
220  return;
221 
222  Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
224  }
225 
226  //= OControlExport
227  OControlExport::OControlExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl,
228  const OUString& _rControlId, const OUString& _rReferringControls,
229  const Sequence< ScriptEventDescriptor >& _rEvents)
230  :OElementExport(_rContext, _rxControl, _rEvents)
231  ,m_sControlId(_rControlId)
232  ,m_sReferringControls(_rReferringControls)
233  ,m_nClassId(FormComponentType::CONTROL)
234  ,m_eType( UNKNOWN )
235  ,m_nIncludeCommon(CCAFlags::NONE)
236  ,m_nIncludeDatabase(DAFlags::NONE)
237  ,m_nIncludeSpecial(SCAFlags::NONE)
238  ,m_nIncludeEvents(EAFlags::NONE)
239  ,m_nIncludeBindings(BAFlags::NONE)
240  {
241  OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
242  }
243 
245  {
246  // the control id
248  {
253  );
254  #if OSL_DEBUG_LEVEL > 0
255  // reset the bit for later checking
256  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::Name;
257  #endif
258  }
259 
260  // the service name
261  if (m_nIncludeCommon & CCAFlags::ServiceName)
262  {
264  #if OSL_DEBUG_LEVEL > 0
265  // reset the bit for later checking
266  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ServiceName;
267  #endif
268  }
269  }
270 
272  {
273  // the control id
275  {
276  OSL_ENSURE(!m_sControlId.isEmpty(), "OControlExport::exportInnerAttributes: have no control id for the control!");
279  #if OSL_DEBUG_LEVEL > 0
280  // reset the bit for later checking
281  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::ControlId;
282  #endif
283  }
284 
285  // "new-style" properties ...
287 
288  // common control attributes
290 
291  // common database attributes
293 
294  // attributes related to external bindings
296 
297  // attributes special to the respective control type
299 
300  // add the style references to the attributes
302  }
303 
305  {
307  }
308 
310  {
311  // for the upcoming exportRemainingProperties:
312  // if a control has the LabelControl property, this is not stored with the control itself, but instead with
313  // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
314  // know anything about this, we need to prevent that it tries to export this property
316 
317  // if it's a control supporting XText, then we need to declare all text-related properties
318  // as "already exported". This prevents them from being exported as generic "form:property"-tags.
319  // *If* we would export them this way, they would be completely superfluous, and sometimes even
320  // disastrous, since they may, at import time, override paragraph properties which already have
321  // been set before
322  Reference< XText > xControlText( m_xProps, UNO_QUERY );
323  if ( xControlText.is() )
324  {
326  while ( pCharAttributeProperties->msApiName )
327  {
328  exportedProperty( OUString::createFromAscii( pCharAttributeProperties->msApiName ) );
329  ++pCharAttributeProperties;
330  }
331 
333  while ( pParaAttributeProperties->msApiName )
334  {
335  exportedProperty( OUString::createFromAscii( pParaAttributeProperties->msApiName ) );
336  ++pParaAttributeProperties;
337  }
338 
339  // the RichText property is not exported. The presence of the text:p element
340  // will be used - upon reading - as indicator for the value of the RichText property
342 
343  // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
344  // The former is a short/enum value, the latter a boolean. The former has a real meaning
345  // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
346  // later on imported, it overwrites anything which has previously been imported for
347  // CharStrikeout.
348  // #i27729#
349  exportedProperty( "CharCrossedOut" );
350  }
351 
352  if ( m_eType == LISTBOX )
353  {
354  // will be exported in exportListSourceAsElements:
357 
358  // will not be exported in a generic way. Either exportListSourceAsElements cares
359  // for them, or we don't need them
364  }
365  if ( m_eType == COMBOBOX )
367 
368  // let the base class export the remaining properties and the events
370 
371  // special sub tags for some controls
372  switch (m_eType)
373  {
374  case LISTBOX:
375  // don't export the list entries if the are not provided by the user, but obtained implicitly
376  // from other sources
377  // #i26944#
380  break;
381  case GRID:
382  { // a grid control requires us to store all columns as sub elements
383  Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
384  OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
385  if (xColumnContainer.is())
386  m_rContext.exportCollectionElements(xColumnContainer);
387  }
388  break;
389  case COMBOBOX:
390  { // a combox box description has sub elements: the items
392 
393  // don't export the list entries if the are not provided by the user, but obtained implicitly
394  // from other sources
395  // #i26944#
397  {
398  // get the item list
399  Sequence< OUString > aListItems;
400  m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
401  // loop through it and write the sub elements
402  for (const auto& rListItem : std::as_const(aListItems))
403  {
405  AddAttribute(
408  rListItem);
409  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", true, true);
410  }
411  }
412  }
413  break;
414 
415  case TEXT_AREA:
416  {
417  // if we act as rich text control, we need to export some text:p elements
418  if ( xControlText.is() )
419  {
420  bool bActingAsRichText = false;
421  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
422  {
423  OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
424  }
425 
426  if ( bActingAsRichText )
427  m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
428  }
429  }
430  break;
431  default:
432  // nothing do to
433  break;
434  }
435  }
436 
438  {
439  const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
440  for ( auto const & prop : aProperties )
441  {
442  try
443  {
444  // see if this property can already be handled with an IPropertyHandler (which, on the long
445  // term, should be the case for most, if not all, properties)
446  const PropertyDescription* propDescription = metadata::getPropertyDescription( prop.Name );
447  if ( propDescription == nullptr )
448  continue;
449 
450  // let the factory provide the concrete handler. Note that caching, if desired, is the task
451  // of the factory
452  PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId );
453  if ( !handler.get() )
454  {
455  SAL_WARN( "xmloff.forms", "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" );
456  continue;
457  }
458 
459  // that's a property which has a direct mapping to an attribute
460  if ( !shouldExportProperty( prop.Name ) )
461  // TODO: in the future, we surely need a more sophisticated approach to this, involving the property
462  // handler, or the property description
463  {
464  exportedProperty( prop.Name );
465  continue;
466  }
467 
468  const Any propValue = m_xProps->getPropertyValue( prop.Name );
469  OUString attributeValue = handler->getAttributeValue( propValue );
470 
471  AddAttribute(
472  propDescription->attribute.namespacePrefix,
473  token::GetXMLToken( propDescription->attribute.attributeToken ),
474  attributeValue
475  );
476 
477  exportedProperty( prop.Name );
478  }
479  catch( const Exception& )
480  {
481  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
482  }
483  }
484  }
485 
487  {
488  size_t i=0;
489 
490  // I decided to handle all the properties here with some static arrays describing the property-attribute
491  // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
492  // would require maps and O(log n) searches, which seems somewhat expensive as this code is used
493  // very frequently.
494 
495  // the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
496  // map identifiers from the wrong block
497 
498  // some string properties
499  {
500  // the attribute ids of all properties which are expected to be of type string
501  static const CCAFlags nStringPropertyAttributeIds[] =
502  {
504  };
505  // the names of all properties which are expected to be of type string
506  static const char * aStringPropertyNames[] =
507  {
509  };
510  OSL_ENSURE( SAL_N_ELEMENTS(aStringPropertyNames) ==
511  SAL_N_ELEMENTS(nStringPropertyAttributeIds),
512  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
513 
514  for (i=0; i<SAL_N_ELEMENTS(nStringPropertyAttributeIds); ++i)
515  if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
516  {
518  OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
519  OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
520  OUString::createFromAscii(aStringPropertyNames[i])
521  );
522  #if OSL_DEBUG_LEVEL > 0
523  // reset the bit for later checking
524  m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i];
525  #endif
526  }
527  }
528 
529  // some boolean properties
530  {
531  static const CCAFlags nBooleanPropertyAttributeIds[] =
532  { // attribute flags
534  };
535  static const char * pBooleanPropertyNames[] =
536  { // property names
541  };
542  static const BoolAttrFlags nBooleanPropertyAttrFlags[] =
543  { // attribute defaults
545  };
546  #if OSL_DEBUG_LEVEL > 0
547  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds);
548  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
549  static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags);
550  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
551  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
552  #endif
553  for (i=0; i<SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); ++i)
554  if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
555  {
557  OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds[i]),
558  OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds[i]),
559  OUString::createFromAscii(pBooleanPropertyNames[i]),
560  nBooleanPropertyAttrFlags[i]);
561  #if OSL_DEBUG_LEVEL > 0
562  // reset the bit for later checking
563  m_nIncludeCommon = m_nIncludeCommon & ~nBooleanPropertyAttributeIds[i];
564  #endif
565  }
566  }
567 
568  // some integer properties
569  {
570  // now the common handling
571  static const CCAFlags nIntegerPropertyAttributeIds[] =
572  { // attribute flags
574  };
575  static const char * pIntegerPropertyNames[] =
576  { // property names
578  };
579  static const sal_Int16 nIntegerPropertyAttrDefaults[] =
580  { // attribute defaults
581  5, 0
582  };
583 
586 
587  #if OSL_DEBUG_LEVEL > 0
588  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nIntegerPropertyAttributeIds);
589  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pIntegerPropertyNames);
590  static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nIntegerPropertyAttrDefaults);
591  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
592  "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
593  #endif
594  for (i=0; i<SAL_N_ELEMENTS(nIntegerPropertyAttributeIds); ++i)
595  if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
596  {
598  OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
599  OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
600  OUString::createFromAscii(pIntegerPropertyNames[i]),
601  nIntegerPropertyAttrDefaults[i]);
602  #if OSL_DEBUG_LEVEL > 0
603  // reset the bit for later checking
604  m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i];
605  #endif
606  }
607 
608  }
609 
610  // some enum properties
611  {
613  {
619  FormButtonType_PUSH);
620  #if OSL_DEBUG_LEVEL > 0
621  // reset the bit for later checking
623  #endif
624  }
626  {
629  OAttributeMetaData::getCommonControlAttributeName( CCAFlags::Orientation ),
632  ScrollBarOrientation::HORIZONTAL
633  );
634  #if OSL_DEBUG_LEVEL > 0
635  // reset the bit for later checking
637  #endif
638  }
639 
641  {
644  OAttributeMetaData::getCommonControlAttributeName( CCAFlags::VisualEffect ),
647  VisualEffect::LOOK3D
648  );
649  #if OSL_DEBUG_LEVEL > 0
650  // reset the bit for later checking
651  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::VisualEffect;
652  #endif
653  }
654  }
655 
656  // some properties which require a special handling
657 
658  // the target frame
660  {
662  #if OSL_DEBUG_LEVEL > 0
663  // reset the bit for later checking
664  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetFrame;
665  #endif
666  }
667 
668  // max text length
670  {
671  // normally, the respective property would be "MaxTextLen"
672  // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
673 
674  // determine the name of the property to export
675  OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH );
676  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
677  sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
678 
679  // export it
683  sTextLenPropertyName,
684  0
685  );
686 
687  // in either way, both properties count as "exported"
690 
691  #if OSL_DEBUG_LEVEL > 0
692  // reset the bit for later checking
694  #endif
695  }
696 
698  {
700  #if OSL_DEBUG_LEVEL > 0
701  // reset the bit for later checking
702  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags::TargetLocation;
703  #endif
704  }
705 
706  // OJ #99721#
708  {
710  #if OSL_DEBUG_LEVEL > 0
711  // reset the bit for later checking
713  #endif
714  }
715 
716  // the for attribute
717  // the target frame
719  {
720  if (!m_sReferringControls.isEmpty())
721  { // there is at least one control referring to the one we're handling currently
722  AddAttribute(
726  }
727  #if OSL_DEBUG_LEVEL > 0
728  // reset the bit for later checking
730  #endif
731  }
732 
734  {
735  const char* pCurrentValuePropertyName = nullptr;
736  const char* pValuePropertyName = nullptr;
737 
738  // get the property names
739  getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
740 
741  // add the attributes if necessary and possible
742  if (pCurrentValuePropertyName && (CCAFlags::CurrentValue & m_nIncludeCommon))
743  {
744  static const char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue);
745  // don't export the current-value if this value originates from a data binding
746  // #i26944#
748  exportedProperty( OUString::createFromAscii( pCurrentValuePropertyName ) );
749  else
750  {
751  static const sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentValue);
753  nCurrentValueAttributeNamespaceKey,
754  pCurrentValueAttributeName,
755  pCurrentValuePropertyName
756  );
757  }
758  }
759 
760  if (pValuePropertyName && (CCAFlags::Value & m_nIncludeCommon))
761  {
762  static const char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value);
763  static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Value);
765  nValueAttributeNamespaceKey,
766  pValueAttributeName,
767  pValuePropertyName);
768  }
769 
770  OSL_ENSURE((nullptr == pValuePropertyName) == (CCAFlags::NONE == (CCAFlags::Value & m_nIncludeCommon)),
771  "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
772  OSL_ENSURE((nullptr == pCurrentValuePropertyName ) == (CCAFlags::NONE == (CCAFlags::CurrentValue & m_nIncludeCommon)),
773  "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
774 
775  #if OSL_DEBUG_LEVEL > 0
776  // reset the bit for later checking
777  m_nIncludeCommon = m_nIncludeCommon & ~CCAFlags(CCAFlags::CurrentValue | CCAFlags::Value);
778  #endif
779  }
780 
781  OSL_ENSURE(CCAFlags::NONE == m_nIncludeCommon,
782  "OControlExport::exportCommonControlAttributes: forgot some flags!");
783  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
784  // be 0 now ...
785  }
786 
788  {
789 #if OSL_DEBUG_LEVEL > 0
790  DAFlags nIncludeDatabase = m_nIncludeDatabase;
791 #endif
792  // the only string property: DataField
794  {
799  RESET_BIT( nIncludeDatabase, DAFlags::DataField );
800  }
801 
802  // InputRequired
803  if ( DAFlags::InputRequired & m_nIncludeDatabase )
804  {
810  );
811  RESET_BIT( nIncludeDatabase, DAFlags::InputRequired );
812  }
813 
814  // the only int16 property: BoundColumn
815  if (DAFlags::BoundColumn & m_nIncludeDatabase)
816  {
821  0,
822  true);
823  RESET_BIT( nIncludeDatabase, DAFlags::BoundColumn );
824  }
825 
826  // ConvertEmptyToNull
827  if (DAFlags::ConvertEmpty & m_nIncludeDatabase)
828  {
834  );
835  RESET_BIT( nIncludeDatabase, DAFlags::ConvertEmpty );
836  }
837 
838  // the only enum property: ListSourceType
839  if (DAFlags::ListSource_TYPE & m_nIncludeDatabase)
840  {
846  ListSourceType_VALUELIST
847  );
848  RESET_BIT( nIncludeDatabase, DAFlags::ListSource_TYPE );
849  }
850 
851  if (m_nIncludeDatabase & DAFlags::ListSource)
852  {
854  RESET_BIT( nIncludeDatabase, DAFlags::ListSource );
855  }
856 
857 #if OSL_DEBUG_LEVEL > 0
858  OSL_ENSURE(DAFlags::NONE == nIncludeDatabase,
859  "OControlExport::exportDatabaseAttributes: forgot some flags!");
860  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
861  // be 0 now ...
862 #endif
863  }
864 
866  {
867 #if OSL_DEBUG_LEVEL > 0
868  BAFlags nIncludeBinding = m_nIncludeBindings;
869 #endif
870 
872  {
874  #if OSL_DEBUG_LEVEL > 0
875  // reset the bit for later checking
876  nIncludeBinding = nIncludeBinding & ~BAFlags( BAFlags::LinkedCell | BAFlags::ListLinkingType );
877  #endif
878  }
879 
881  {
883  #if OSL_DEBUG_LEVEL > 0
884  // reset the bit for later checking
885  nIncludeBinding = nIncludeBinding & ~BAFlags::ListCellRange;
886  #endif
887  }
888 
890  {
892  #if OSL_DEBUG_LEVEL > 0
893  // reset the bit for later checking
894  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsBind;
895  #endif
896  }
897 
899  {
901  #if OSL_DEBUG_LEVEL > 0
902  // reset the bit for later checking
903  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsListBind;
904  #endif
905  }
906 
908  {
910  #if OSL_DEBUG_LEVEL > 0
911  // reset the bit for later checking
912  nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsSubmission;
913  #endif
914  }
915 
916  #if OSL_DEBUG_LEVEL > 0
917  OSL_ENSURE( BAFlags::NONE == nIncludeBinding,
918  "OControlExport::exportBindingAttributes: forgot some flags!");
919  // in the debug version, we should have removed every bit we handled from the mask, so it should
920  // be 0 now ...
921  #endif
922  }
923 
925  {
926  sal_Int32 i=0;
927 
928  // the boolean properties
929  {
930  static const SCAFlags nBooleanPropertyAttributeIds[] =
931  { // attribute flags
934  };
935  static const char * pBooleanPropertyNames[] =
936  { // property names
942  };
943  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds);
944  #if OSL_DEBUG_LEVEL > 0
945  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
946  OSL_ENSURE((nIdCount == nNameCount),
947  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
948  #endif
949  const SCAFlags* pAttributeId = nBooleanPropertyAttributeIds;
950  for ( i = 0; i < nIdCount; ++i, ++pAttributeId )
951  {
952  if ( *pAttributeId & m_nIncludeSpecial)
953  {
957  OUString::createFromAscii(pBooleanPropertyNames[i]),
959  );
960  #if OSL_DEBUG_LEVEL > 0
961  // reset the bit for later checking
962  m_nIncludeSpecial = m_nIncludeSpecial & ~*pAttributeId;
963  #endif
964  }
965  }
966  }
967 
968  // the integer properties
969  {
970  static const SCAFlags nIntegerPropertyAttributeIds[] =
971  { // attribute flags
973  };
974  static const char * pIntegerPropertyNames[] =
975  { // property names
977  };
978  static const sal_Int32 nIntegerPropertyAttrDefaults[] =
979  { // attribute defaults (XML defaults, not runtime defaults!)
980  10
981  };
982 
983  static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nIntegerPropertyAttributeIds );
984  #if OSL_DEBUG_LEVEL > 0
985  static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pIntegerPropertyNames );
986  OSL_ENSURE( ( nIdCount == nNameCount ),
987  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
988  static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS( nIntegerPropertyAttrDefaults );
989  OSL_ENSURE( ( nIdCount == nDefaultCount ),
990  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
991  #endif
992  for ( i = 0; i < nIdCount; ++i )
993  if ( nIntegerPropertyAttributeIds[i] & m_nIncludeSpecial )
994  {
996  OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds[i] ),
997  OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds[i] ),
998  OUString::createFromAscii(pIntegerPropertyNames[i]),
999  nIntegerPropertyAttrDefaults[i]
1000  );
1001  #if OSL_DEBUG_LEVEL > 0
1002  // reset the bit for later checking
1003  m_nIncludeSpecial = m_nIncludeSpecial & ~nIntegerPropertyAttributeIds[i];
1004  #endif
1005  }
1006 
1007  if ( SCAFlags::StepSize & m_nIncludeSpecial )
1008  {
1009  OUString sPropertyName;
1010  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1011  sPropertyName = PROPERTY_LINE_INCREMENT;
1012  else if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1013  sPropertyName = PROPERTY_SPIN_INCREMENT;
1014  else
1015  OSL_FAIL( "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1016 
1017  if ( !sPropertyName.isEmpty() )
1021  sPropertyName,
1022  1
1023  );
1024 
1025  #if OSL_DEBUG_LEVEL > 0
1026  // reset the bit for later checking
1027  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::StepSize;
1028  #endif
1029  }
1030 
1031  }
1032 
1033  // the enum properties
1034  {
1036  {
1042  TRISTATE_FALSE);
1043  #if OSL_DEBUG_LEVEL > 0
1044  // reset the bit for later checking
1045  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::State;
1046  #endif
1047  }
1048 
1049  if (SCAFlags::CurrentState & m_nIncludeSpecial)
1050  {
1056  TRISTATE_FALSE);
1057  #if OSL_DEBUG_LEVEL > 0
1058  // reset the bit for later checking
1059  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::CurrentState;
1060  #endif
1061  }
1062  }
1063 
1064  // some properties which require a special handling
1065  // the repeat delay
1066  {
1068  {
1070 
1071  sal_Int32 nRepeatDelay = 0;
1072  m_xProps->getPropertyValue( PROPERTY_REPEAT_DELAY ) >>= nRepeatDelay;
1074  aTime.MakeTimeFromMS( nRepeatDelay );
1075  util::Duration aDuration;
1076  aDuration.Hours = aTime.GetHour();
1077  aDuration.Minutes = aTime.GetMin();
1078  aDuration.Seconds = aTime.GetSec();
1079  aDuration.NanoSeconds = (nRepeatDelay % 1000) * 1000000;
1080 
1081  OUStringBuffer buf;
1082  ::sax::Converter::convertDuration(buf, aDuration);
1084  ,OAttributeMetaData::getSpecialAttributeName( SCAFlags::RepeatDelay )
1085  ,buf.makeStringAndClear());
1086 
1088 
1089  #if OSL_DEBUG_LEVEL > 0
1090  // reset the bit for later checking
1091  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::RepeatDelay;
1092  #endif
1093  }
1094  }
1095 
1096  // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1097  {
1099  {
1100  DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
1101  sal_Int16 nValue(0);
1102  m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue;
1103  if (nValue)
1104  {
1105  OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
1106  AddAttribute(
1109  sCharacter);
1110  }
1112  #if OSL_DEBUG_LEVEL > 0
1113  // reset the bit for later checking
1114  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::EchoChar;
1115  #endif
1116  }
1117  }
1118 
1119  // the string properties
1120  {
1121  static const SCAFlags nStringPropertyAttributeIds[] =
1122  { // attribute flags
1124  };
1125  static const OUStringLiteral pStringPropertyNames[] =
1126  { // property names
1128  };
1129 
1130  static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nStringPropertyAttributeIds );
1131  #if OSL_DEBUG_LEVEL > 0
1132  static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pStringPropertyNames );
1133  OSL_ENSURE( ( nIdCount == nNameCount ),
1134  "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1135  #endif
1136  for ( i = 0; i < nIdCount; ++i )
1137  if ( nStringPropertyAttributeIds[i] & m_nIncludeSpecial )
1138  {
1140  OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ),
1141  OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ),
1142  pStringPropertyNames[i]
1143  );
1144  #if OSL_DEBUG_LEVEL > 0
1145  // reset the bit for later checking
1146  m_nIncludeSpecial = m_nIncludeSpecial & ~nStringPropertyAttributeIds[i];
1147  #endif
1148  }
1149  }
1150 
1152  {
1153  // need to export the min value and the max value as attributes
1154  // It depends on the real type (FormComponentType) of the control, which properties hold these
1155  // values
1156  const char* pMinValuePropertyName = nullptr;
1157  const char* pMaxValuePropertyName = nullptr;
1158  getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
1159 
1160  OSL_ENSURE((nullptr == pMinValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MinValue & m_nIncludeSpecial)),
1161  "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1162  OSL_ENSURE((nullptr == pMaxValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MaxValue & m_nIncludeSpecial)),
1163  "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1164 
1165  // add the two attributes
1166  static const char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue);
1167  static const char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue);
1168  static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MinValue);
1169  static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MaxValue);
1170 
1171  if (pMinValuePropertyName && (SCAFlags::MinValue & m_nIncludeSpecial))
1173  nMinValueNamespaceKey,
1174  pMinValueAttributeName,
1175  pMinValuePropertyName);
1176 
1177  if (pMaxValuePropertyName && (SCAFlags::MaxValue & m_nIncludeSpecial))
1179  nMaxValueNamespaceKey,
1180  pMaxValueAttributeName,
1181  pMaxValuePropertyName);
1182  #if OSL_DEBUG_LEVEL > 0
1183  // reset the bit for later checking
1184  m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags(SCAFlags::MinValue | SCAFlags::MaxValue);
1185  #endif
1186  }
1187 
1188  if ( SCAFlags::ImagePosition & m_nIncludeSpecial )
1189  {
1191  RESET_BIT( m_nIncludeSpecial, SCAFlags::ImagePosition );
1192  }
1193 
1194  OSL_ENSURE(SCAFlags::NONE == m_nIncludeSpecial,
1195  "OControlExport::exportSpecialAttributes: forgot some flags!");
1196  // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1197  // be 0 now ...
1198  }
1199 
1201  {
1202  OUString sListSource;
1203  Any aListSource = m_xProps->getPropertyValue( PROPERTY_LISTSOURCE );
1204  if ( !( aListSource >>= sListSource ) )
1205  {
1206  Sequence< OUString > aListSourceSequence;
1207  aListSource >>= aListSourceSequence;
1208  if ( aListSourceSequence.hasElements() )
1209  sListSource = aListSourceSequence[ 0 ];
1210  }
1211  return sListSource;
1212  }
1213 
1215  {
1216  // DAFlags::ListSource needs some special handling
1218 
1219  OUString sListSource = getScalarListSourceValue();
1220  if ( !sListSource.isEmpty() )
1221  { // the ListSource property needs to be exported as attribute, and it is not empty
1222  AddAttribute(
1225  sListSource);
1226  }
1227 
1229  }
1230 
1231  void OControlExport::getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut)
1232  {
1233  Sequence< sal_Int16 > aValueSequence;
1234  DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
1235  m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
1236 
1237  for (const auto& rValue : std::as_const(aValueSequence))
1238  _rOut.insert(rValue);
1239  }
1240 
1242  {
1243  // the string lists
1244  Sequence< OUString > aItems, aValues;
1246  m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
1247 
1250  m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
1251  // if we exported the list source as attribute, we do not repeat it as sub elements
1252 
1253  // the selection lists
1254  Int16Set aSelection, aDefaultSelection;
1257 
1258  // the string for "true"
1259  OUString sTrue;
1260  OUStringBuffer sBuffer;
1261  ::sax::Converter::convertBool(sBuffer, true);
1262  sTrue = sBuffer.makeStringAndClear();
1263 
1264  // loop through both lists ('til the maximum of both lengths)
1265  const OUString* pItems = aItems.getConstArray();
1266  const OUString* pValues = aValues.getConstArray();
1267 
1268  sal_Int32 nItems = aItems.getLength();
1269  sal_Int32 nValues = aValues.getLength();
1270 
1271  sal_Int16 nMaxLen = static_cast<sal_Int16>(std::max(nItems, nValues));
1272 
1273  for (sal_Int16 i=0; i<nMaxLen; ++i )
1274  {
1276  if (i < nItems)
1277  {
1278  // there is an item at this position
1279  AddAttribute(
1282  *pItems);
1283  ++pItems;
1284  }
1285  if (i < nValues)
1286  {
1287  // there is a value at this position
1288  AddAttribute(
1291  *pValues);
1292  ++pValues;
1293  }
1294 
1295  Int16Set::iterator aSelectedPos = aSelection.find(i);
1296  if (aSelection.end() != aSelectedPos)
1297  { // the item at this position is selected
1298  AddAttribute(
1301  sTrue
1302  );
1303  aSelection.erase(aSelectedPos);
1304  }
1305 
1306  Int16Set::iterator aDefaultSelectedPos = aDefaultSelection.find(i);
1307  if (aDefaultSelection.end() != aDefaultSelectedPos)
1308  { // the item at this position is selected as default
1309  AddAttribute(
1312  sTrue
1313  );
1314  aDefaultSelection.erase(aDefaultSelectedPos);
1315  }
1316  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1317  }
1318 
1319  // There may be more "selected" or "default-selected" items than there are in the lists in real,
1320  // so we need to store some additional "form:option" items which have no name and no label, but
1321  // one or both of the selected flags.
1322  // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1323 
1324  if ( !aSelection.empty() || !aDefaultSelection.empty() )
1325  {
1326  sal_Int16 nLastSelected = -1;
1327  if ( !aSelection.empty() )
1328  nLastSelected = *(--aSelection.end());
1329 
1330  sal_Int16 nLastDefaultSelected = -1;
1331  if ( !aDefaultSelection.empty() )
1332  nLastDefaultSelected = *(--aDefaultSelection.end());
1333 
1334  // the maximum element in both sets
1335  sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
1336  OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!");
1337  // if the maximum (selected or default selected) entry number is less than the maximum item count
1338  // in both lists, the entry number should have been removed from the set
1339 
1340  for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
1341  {
1342  if (aSelection.end() != aSelection.find(i))
1343  { // the (not existent) item at this position is selected
1344  AddAttribute(
1347  sTrue
1348  );
1349  }
1350 
1351  if (aDefaultSelection.end() != aDefaultSelection.find(i))
1352  { // the (not existent) item at this position is selected as default
1353  AddAttribute(
1356  sTrue
1357  );
1358  }
1359  SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1360  }
1361  }
1362  }
1363 
1364  void OControlExport::implStartElement(const char* _pName)
1365  {
1366  // before we let the base class start it's outer element, we add a wrapper element
1367  const char *pOuterElementName = getOuterXMLElementName();
1368  if (pOuterElementName)
1369  m_pOuterElement = std::make_unique<SvXMLElementExport>(
1372  pOuterElementName, true,
1373  true);
1374 
1375  // add the attributes for the inner element
1377 
1378  // and start the inner element
1380  }
1381 
1383  {
1384  // end the inner element
1386 
1387  // end the outer element if it exists
1388  m_pOuterElement.reset();
1389  }
1390 
1392  {
1393  return nullptr;
1394  }
1395 
1397  {
1398  return getElementName(m_eType);
1399  }
1400 
1402  {
1405  "OControlExport::examine: called me twice? Not initialized?" );
1406 
1407  // get the class id to decide which kind of element we need in the XML stream
1408  m_nClassId = FormComponentType::CONTROL;
1409  DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
1410  m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId;
1411  bool knownType = false;
1412  switch (m_nClassId)
1413  {
1414  case FormComponentType::DATEFIELD:
1415  m_eType = DATE;
1416  knownType = true;
1417  [[fallthrough]];
1418  case FormComponentType::TIMEFIELD:
1419  if ( !knownType )
1420  {
1421  m_eType = TIME;
1422  knownType = true;
1423  }
1425  [[fallthrough]];
1426  case FormComponentType::NUMERICFIELD:
1427  case FormComponentType::CURRENCYFIELD:
1428  case FormComponentType::PATTERNFIELD:
1429  if ( !knownType )
1430  {
1432  knownType = true;
1433  }
1434  [[fallthrough]];
1435  case FormComponentType::TEXTFIELD:
1436  { // it's some kind of edit. To know which type we need further investigation
1437 
1438  if ( !knownType )
1439  {
1440  // check if it's a formatted field
1441  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
1442  {
1444  }
1445  else
1446  {
1447  // all other controls are represented by an ordinary edit control, but which XML control type
1448  // it is depends on the current values of some properties
1449 
1450  // if the EchoChar string is not empty, it is a password field
1451  sal_Int16 nEchoChar = 0;
1452  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR))
1453  // grid columns do not have this property...
1454  m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar;
1455  if (nEchoChar)
1456  {
1457  m_eType = PASSWORD;
1459  }
1460  else
1461  {
1462  // if the MultiLine property is sal_True, it is a TextArea
1463  bool bMultiLine = false;
1464  if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE))
1465  // grid columns do not have this property...
1466  bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
1467 
1468  if ( bMultiLine )
1469  m_eType = TEXT_AREA;
1470  else
1471  // the only case left is represented by a Text element
1472  m_eType = TEXT;
1473  }
1474  }
1475  }
1476 
1477  // attributes which are common to all the types:
1478  // common attributes
1482 
1483  if ( ( m_nClassId != FormComponentType::DATEFIELD )
1484  && ( m_nClassId != FormComponentType::TIMEFIELD )
1485  )
1486  // date and time field values are handled differently nowadays
1488 
1489  // database attributes
1491 
1492  // event attributes
1494 
1495  // only text and pattern fields have a ConvertEmptyToNull property
1496  if ( ( m_nClassId == FormComponentType::TEXTFIELD )
1497  || ( m_nClassId == FormComponentType::PATTERNFIELD )
1498  )
1500 
1501  // all controls but the file control fields have a readonly property
1502  if ( m_nClassId != FormComponentType::FILECONTROL )
1504 
1505  // a text field has a max text len
1506  if ( m_nClassId == FormComponentType::TEXTFIELD )
1508 
1509  // max and min values and validation:
1510  if (FORMATTED_TEXT == m_eType)
1511  { // in general all controls represented as formatted-text have these props
1512  if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField
1514 
1515  if (FormComponentType::TEXTFIELD != m_nClassId)
1516  // and the FormattedField does not have a validation flag
1518  }
1519 
1520  // if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1521  if ( ( PASSWORD != m_eType )
1522  && ( DATE != m_eType )
1523  && ( TIME != m_eType )
1524  )
1525  {
1527  }
1528  }
1529  break;
1530 
1531  case FormComponentType::FILECONTROL:
1532  m_eType = FILE;
1538  break;
1539 
1540  case FormComponentType::FIXEDTEXT:
1541  m_eType = FIXED_TEXT;
1547  break;
1548 
1549  case FormComponentType::COMBOBOX:
1550  m_eType = COMBOBOX;
1558  break;
1559 
1560  case FormComponentType::LISTBOX:
1561  m_eType = LISTBOX;
1568  // check if we need to export the ListSource as attribute
1569  {
1570  // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1571  // a sequence of pairs which is build from the StringItemList and the ValueList
1572  ListSourceType eListSourceType = ListSourceType_VALUELIST;
1573  bool bSuccess =
1574  m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType;
1575  OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1576  if (ListSourceType_VALUELIST != eListSourceType)
1577  {
1579  }
1580  }
1581 
1582  break;
1583 
1584  case FormComponentType::COMMANDBUTTON:
1585  m_eType = BUTTON;
1588  [[fallthrough]];
1589  case FormComponentType::IMAGEBUTTON:
1590  if (BUTTON != m_eType)
1591  {
1592  // not coming from the previous case
1593  m_eType = IMAGE;
1594  }
1595  m_nIncludeCommon |=
1600  break;
1601 
1602  case FormComponentType::CHECKBOX:
1603  m_eType = CHECKBOX;
1605  [[fallthrough]];
1606  case FormComponentType::RADIOBUTTON:
1610  if (CHECKBOX != m_eType)
1611  { // not coming from the previous case
1612  m_eType = RADIO;
1614  }
1615  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) )
1617  if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) )
1621  break;
1622 
1623  case FormComponentType::GROUPBOX:
1624  m_eType = FRAME;
1629  break;
1630 
1631  case FormComponentType::IMAGECONTROL:
1632  m_eType = IMAGE_FRAME;
1638  break;
1639 
1640  case FormComponentType::HIDDENCONTROL:
1641  m_eType = HIDDEN;
1644  break;
1645 
1646  case FormComponentType::GRIDCONTROL:
1647  m_eType = GRID;
1652  break;
1653 
1654  case FormComponentType::SCROLLBAR:
1655  case FormComponentType::SPINBUTTON:
1656  m_eType = VALUERANGE;
1661 
1662  if ( m_nClassId == FormComponentType::SCROLLBAR )
1664 
1666  break;
1667 
1668  default:
1669  OSL_FAIL("OControlExport::examineControl: unknown control type (class id)!");
1670  [[fallthrough]];
1671 
1672  case FormComponentType::NAVIGATIONBAR:
1673  // TODO: should we have an own file format for this?
1674  // NO break
1675 
1676  case FormComponentType::CONTROL:
1678  // unknown control type
1680  // at least a name should be there, 'cause without a name the control could never have been
1681  // inserted into its parent container
1682  // In addition, the service name is absolutely necessary to create the control upon reading.
1684  // we always should be able to export events - this is not control type dependent
1685  break;
1686  }
1687 
1688  // in general, all control types need to export the control id
1690 
1691  // is it a control bound to a calc cell?
1693  {
1695  {
1697  {
1699  if ( m_nClassId == FormComponentType::LISTBOX )
1701  }
1702  }
1703 
1704  // is it a list-like control which uses a calc cell range as list source?
1705  {
1708  }
1709  }
1710 
1711  // is control bound to XForms?
1712  if( !getXFormsBindName( m_xProps ).isEmpty() )
1713  {
1715  }
1716 
1717  // is (list-)control bound to XForms list?
1718  if( !getXFormsListBindName( m_xProps ).isEmpty() )
1719  {
1721  }
1722 
1723  // does the control have an XForms submission?
1724  if( !getXFormsSubmissionName( m_xProps ).isEmpty() )
1725  {
1727  }
1728  }
1729 
1730  void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType )
1731  {
1732  try
1733  {
1735  Reference< XValueBinding > xBinding( aHelper.getCurrentBinding() );
1736  OSL_ENSURE( xBinding.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1737  if ( xBinding.is() )
1738  {
1739  AddAttribute(
1742  aHelper.getStringAddressFromCellBinding( xBinding )
1743  );
1744 
1745  if ( _bIncludeListLinkageType )
1746  {
1747  sal_Int16 nLinkageType = FormCellBindingHelper::isCellIntegerBinding( xBinding ) ? 1 : 0;
1748 
1749  OUStringBuffer sBuffer;
1751  sBuffer,
1752  nLinkageType,
1754  );
1755 
1756  AddAttribute(
1759  sBuffer.makeStringAndClear()
1760  );
1761  }
1762 
1763  }
1764  }
1765  catch( const Exception& )
1766  {
1767  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OControlExport::exportCellBindingAttributes" );
1768  }
1769  }
1770 
1772  {
1773  OUString sBindName = getXFormsBindName( m_xProps );
1775  }
1777  {
1778  OUString sBindName = getXFormsListBindName( m_xProps );
1780  }
1782  {
1783  OUString sSubmission = getXFormsSubmissionName( m_xProps );
1785  }
1787  {
1788  try
1789  {
1790  Reference< XListEntrySink > xSink( m_xProps, UNO_QUERY );
1791  Reference< XListEntrySource > xSource;
1792  if ( xSink.is() )
1793  xSource = xSink->getListEntrySource();
1794  OSL_ENSURE( xSource.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1795  if ( xSource.is() )
1796  {
1798 
1799  AddAttribute(
1802  aHelper.getStringAddressFromCellListSource( xSource )
1803  );
1804  }
1805  }
1806  catch( const Exception& )
1807  {
1808  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OControlExport::exportCellListSourceRange" );
1809  }
1810  }
1811 
1813  {
1814  try
1815  {
1816  sal_Int16 nImagePosition = ImagePosition::Centered;
1817  OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_IMAGE_POSITION ) >>= nImagePosition );
1818  OSL_ENSURE( ( nImagePosition >= ImagePosition::LeftTop ) && ( nImagePosition <= ImagePosition::Centered ),
1819  "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1820 
1821  if ( ( nImagePosition < ImagePosition::LeftTop ) || ( nImagePosition > ImagePosition::Centered ) )
1822  // this is important to prevent potential buffer overflows below, so don't optimize
1823  nImagePosition = ImagePosition::Centered;
1824 
1825  if ( nImagePosition == ImagePosition::Centered )
1826  {
1828  }
1829  else
1830  {
1831  const XMLTokenEnum eXmlImagePositions[] =
1832  {
1834  };
1835  const XMLTokenEnum eXmlImageAligns[] =
1836  {
1838  };
1839 
1840  XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ nImagePosition / 3 ];
1841  XMLTokenEnum eXmlImageAlign = eXmlImageAligns [ nImagePosition % 3 ];
1842 
1845  }
1846 
1848  // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1849  // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1850  // we don't need to export ImageAlign anymore
1852  }
1853  catch( const Exception& )
1854  {
1855  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
1856  }
1857  }
1858 
1860  {
1861  try
1862  {
1863  // currently exchanging the data with a database column?
1864  OUString sBoundFieldPropertyName( "BoundField" );
1865  if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( sBoundFieldPropertyName ) )
1866  {
1867  Reference< XPropertySet > xBoundField;
1868  m_xProps->getPropertyValue( sBoundFieldPropertyName ) >>= xBoundField;
1869  if ( xBoundField.is() )
1870  return true;
1871  }
1872 
1873  // currently exchanging data with an external binding?
1874  Reference< XBindableValue > xBindable( m_xProps, UNO_QUERY );
1875  if ( xBindable.is() && xBindable->getValueBinding().is() )
1876  return true;
1877  }
1878  catch( const Exception& )
1879  {
1880  TOOLS_WARN_EXCEPTION( "xmloff.forms", "OColumnExport::controlHasActiveDataBinding" );
1881  }
1882 
1883  return false;
1884  }
1885 
1887  {
1888  try
1889  {
1890  // an external list source?
1891  Reference< XListEntrySink > xEntrySink( m_xProps, UNO_QUERY );
1892  if ( xEntrySink.is() && xEntrySink->getListEntrySource().is() )
1893  return false;
1894 
1895  if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( PROPERTY_LISTSOURCETYPE ) )
1896  {
1897  ListSourceType eListSourceType = ListSourceType_VALUELIST;
1898  OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eListSourceType );
1899  if ( eListSourceType == ListSourceType_VALUELIST )
1900  // for value lists, the list entries as entered by the user are used
1901  return true;
1902 
1903  // for every other type, the list entries are filled with some data obtained
1904  // from a database - if and only if the ListSource property is not empty
1905  return getScalarListSourceValue().isEmpty();
1906  }
1907  }
1908  catch( const Exception& )
1909  {
1910  DBG_UNHANDLED_EXCEPTION("xmloff.forms");
1911  }
1912 
1913  OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
1914  // this method should be called for list and combo boxes only
1915  return true;
1916  }
1917 
1918  //= OColumnExport
1919  OColumnExport::OColumnExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl, const OUString& _rControlId,
1920  const Sequence< ScriptEventDescriptor >& _rEvents)
1921  :OControlExport(_rContext, _rxControl, _rControlId, OUString(), _rEvents)
1922  {
1923  }
1924 
1926  {
1927  }
1928 
1930  {
1931  // the attribute "service name" (which has a slightly different meaning for columns
1933  OUString sColumnServiceName;
1934  m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName;
1935  // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
1936  // real service name for the column (for use with the XGridColumnFactory) is only the last
1937  // token of this complete name.
1938  sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.');
1939  OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!");
1940  sColumnServiceName = sColumnServiceName.copy(nLastSep + 1);
1941  sColumnServiceName =
1943  XML_NAMESPACE_OOO, sColumnServiceName );
1944  // add the attribute
1947  , sColumnServiceName);
1948  // flag the property as "handled"
1950 
1951  }
1952 
1954  {
1955  return "column";
1956  }
1957 
1959  {
1961 
1962  // the attribute "label"
1966  PROPERTY_LABEL);
1967 
1968  // the style attribute
1969  OUString sStyleName = m_rContext.getObjectStyleName( m_xProps );
1970  if ( !sStyleName.isEmpty() )
1971  {
1972  AddAttribute(
1975  sStyleName
1976  );
1977  }
1978  }
1979 
1981  {
1983 
1984  // grid columns miss some properties of the controls they're representing
1987 
1988  if (FormComponentType::DATEFIELD != m_nClassId)
1989  // except date fields, no column has the DropDown property
1990  m_nIncludeCommon &= ~CCAFlags::Dropdown;
1991  }
1992 
1993  //= OFormExport
1994  OFormExport::OFormExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxForm,
1995  const Sequence< ScriptEventDescriptor >& _rEvents)
1996  :OElementExport(_rContext, _rxForm, _rEvents)
1997  ,m_bCreateConnectionResourceElement(false)
1998  {
1999  OSL_ENSURE(m_xProps.is(), "OFormExport::OFormExport: invalid arguments!");
2000  }
2001 
2003  {
2004  return "form";
2005  }
2006 
2008  {
2010  {
2012  OUString sPropValue;
2013  m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; // if set it is a file url
2014  if ( sPropValue.isEmpty() )
2015  m_xProps->getPropertyValue( PROPERTY_URL ) >>= sPropValue;
2016  if ( !sPropValue.isEmpty() )
2017  AddAttribute(
2022  {
2024  }
2025  }
2026 
2027  // let the base class export the remaining properties and the events
2029  // loop through all children
2030  Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY);
2031  OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspicious!");
2032 
2033  if (xCollection.is())
2034  m_rContext.exportCollectionElements(xCollection);
2035  }
2036 
2038  {
2039  sal_Int32 i=0;
2040 
2041  // the string properties
2042  {
2043  static const FormAttributes eStringPropertyIds[] =
2044  {
2045  faName, /*faAction,*/ faCommand, faFilter, faOrder
2046  };
2047  static const char * aStringPropertyNames[] =
2048  {
2050  };
2051  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eStringPropertyIds);
2052  #if OSL_DEBUG_LEVEL > 0
2053  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(aStringPropertyNames);
2054  OSL_ENSURE((nIdCount == nNameCount),
2055  "OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2056  #endif
2057  for (i=0; i<nIdCount; ++i)
2059  OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]),
2060  OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]),
2061  OUString::createFromAscii(aStringPropertyNames[i]));
2062 
2063  // #i112082# xlink:type is added as part of exportTargetLocationAttribute
2064 
2065  // now export the data source name or databaselocation or connection resource
2066  OUString sPropValue;
2067  m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue;
2068  m_bCreateConnectionResourceElement = sPropValue.isEmpty();
2070  {
2071  INetURLObject aURL(sPropValue);
2072  m_bCreateConnectionResourceElement = ( aURL.GetProtocol() == INetProtocol::File );
2078  }
2079  else
2083  }
2084 
2085  // the boolean properties
2086  {
2087  static const FormAttributes eBooleanPropertyIds[] =
2088  {
2090  };
2091  static const char * pBooleanPropertyNames[] =
2092  {
2099  };
2100  static const BoolAttrFlags nBooleanPropertyAttrFlags[] =
2101  {
2103  };
2104  static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eBooleanPropertyIds);
2105  #if OSL_DEBUG_LEVEL > 0
2106  static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames);
2107  static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags);
2108  OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
2109  "OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2110  #endif
2111  for (i=0; i<nIdCount; ++i)
2113  OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds[i]),
2114  OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds[i]),
2115  OUString::createFromAscii(pBooleanPropertyNames[i]),
2116  nBooleanPropertyAttrFlags[i]
2117  );
2118  }
2119 
2120  // the enum properties
2121  {
2127  FormSubmitEncoding_URL,
2128  false
2129  );
2135  FormSubmitMethod_GET,
2136  false
2137  );
2143  CommandType::COMMAND,
2144  false
2145  );
2151  NavigationBarMode_CURRENT,
2152  false
2153  );
2159  TabulatorCycle_RECORDS,
2160  true
2161  );
2162  }
2163 
2164  // the service name
2166  // the target frame
2168  // the target URL
2169  exportTargetLocationAttribute(true); // #i110911# add type attribute (for form, but not for control)
2170 
2171  // master fields
2176  // detail fields
2181  }
2182 } // namespace xmloff
2183 
2184 /* 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
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:561
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
OUString getXFormsSubmissionName(const Reference< XPropertySet > &xBinding)
const SvXMLEnumMapEntry< FormSubmitEncoding > aSubmitEncodingMap[]
Definition: formenums.cxx:46
const SvXMLEnumMapEntry< FormSubmitMethod > aSubmitMethodMap[]
Definition: formenums.cxx:53
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
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:2322
#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:381
#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
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:2094
#define PROPERTY_BUTTONTYPE
Definition: strings.hxx:62
UNKNOWN
#define PROPERTY_SUBMIT_METHOD
Definition: strings.hxx:58
bool shouldExportProperty(const OUString &i_propertyName) const
determines whether the given property is to be exported
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:47
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
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
Definition: xmlnmspe.hxx:48
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:2014
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:64
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
constexpr sal_uInt16 XML_NAMESPACE_OOO
Definition: xmlnmspe.hxx:62
#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
#define PROPERTY_FILTER
Definition: strings.hxx:49
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
Definition: nmspmap.cxx:187
#define PROPERTY_ALLOWDELETES
Definition: strings.hxx:51
constexpr sal_uInt16 XML_NAMESPACE_FORM
Definition: xmlnmspe.hxx:44
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:392
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:1041
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:1129
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:3366
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[]
std::set< sal_Int16 > Int16Set
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
#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 ...
bool any2bool(const css::uno::Any &rAny)
void exportTargetLocationAttribute(bool _bAddType)
add the form:href attribute to the export context.
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) )