bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / forms / elementexport.cxx
blobca2834822586b2002e184d13a29fec6fca71b5b6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "elementexport.hxx"
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"
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/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/form/FormSubmitEncoding.hpp>
37 #include <com/sun/star/form/FormSubmitMethod.hpp>
38 #include <com/sun/star/sdb/CommandType.hpp>
39 #include <com/sun/star/form/NavigationBarMode.hpp>
40 #include <com/sun/star/form/TabulatorCycle.hpp>
41 #include <com/sun/star/form/FormButtonType.hpp>
42 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
43 #include <com/sun/star/awt/VisualEffect.hpp>
44 #include <com/sun/star/form/ListSourceType.hpp>
45 #include <com/sun/star/awt/ImagePosition.hpp>
47 #include <sax/tools/converter.hxx>
48 #include <tools/wintypes.hxx> // for check states
49 #include <xmloff/txtprmap.hxx>
50 #include <com/sun/star/form/binding/XBindableValue.hpp>
51 #include <com/sun/star/form/binding/XListEntrySink.hpp>
52 #include <tools/urlobj.hxx>
53 #include <xmloff/xmlexp.hxx>
54 #include <xmloff/nmspmap.hxx>
55 #include <xmloff/XMLEventExport.hxx>
56 #include <xmloff/xmluconv.hxx>
57 #include <xmloff/xmltoken.hxx>
58 #include <tools/time.hxx>
59 #include <tools/diagnose_ex.h>
60 #include <comphelper/extract.hxx>
61 #include <sal/macros.h>
63 #include <stdio.h>
64 #include <algorithm>
66 //.........................................................................
67 namespace xmloff
69 //.........................................................................
71 #if OSL_DEBUG_LEVEL > 0
72 #define RESET_BIT( bitfield, bit ) \
73 bitfield = bitfield & ~bit
74 #else
75 #define RESET_BIT( bitfield, bit )
76 #endif
78 using namespace ::xmloff::token;
79 using namespace ::com::sun::star;
80 using namespace ::com::sun::star::uno;
81 using namespace ::com::sun::star::sdb;
82 using namespace ::com::sun::star::awt;
83 using namespace ::com::sun::star::form;
84 using namespace ::com::sun::star::lang;
85 using namespace ::com::sun::star::beans;
86 using namespace ::com::sun::star::container;
87 using namespace ::com::sun::star::script;
88 using namespace ::com::sun::star::io;
89 using namespace ::com::sun::star::table;
90 using namespace ::com::sun::star::text;
91 using namespace ::com::sun::star::form::binding;
93 //=====================================================================
94 //= OElementExport
95 //=====================================================================
96 OElementExport::OElementExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps,
97 const Sequence< ScriptEventDescriptor >& _rEvents)
98 :OPropertyExport(_rContext, _rxProps)
99 ,m_aEvents(_rEvents)
100 ,m_pXMLElement(NULL)
104 //---------------------------------------------------------------------
105 OElementExport::~OElementExport()
107 implEndElement();
110 //---------------------------------------------------------------------
111 void OElementExport::doExport()
113 // collect some general information about the element
114 examine();
116 // first add the attributes necessary for the element
117 m_rContext.getGlobalContext().ClearAttrList();
119 // add the attributes
120 exportAttributes();
122 // start the XML element
123 implStartElement(getXMLElementName());
125 // the sub elements (mostly control type dependent)
126 exportSubTags();
128 implEndElement();
131 //---------------------------------------------------------------------
132 void OElementExport::examine()
134 // nothing to do here
137 //---------------------------------------------------------------------
138 void OElementExport::exportAttributes()
140 // nothing to do here
143 //---------------------------------------------------------------------
144 void OElementExport::exportSubTags()
146 // the properties which where not exported 'til now
147 exportRemainingProperties();
149 // the script:events sub tags
150 exportEvents();
153 //---------------------------------------------------------------------
154 void OElementExport::implStartElement(const sal_Char* _pName)
156 m_pXMLElement = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, sal_True, sal_True);
159 //---------------------------------------------------------------------
160 void OElementExport::implEndElement()
162 delete m_pXMLElement;
163 m_pXMLElement = NULL;
166 //---------------------------------------------------------------------
167 void OElementExport::exportServiceNameAttribute()
169 Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY);
170 if (!xPersistence.is())
172 OSL_FAIL("OElementExport::exportServiceNameAttribute: no XPersistObject!");
173 return;
176 OUString sServiceName = xPersistence->getServiceName();
177 // we don't want to write the old service name directly: it's a name used for compatibility reasons, but
178 // as we start some kind of new file format here (with this xml export), we don't care about
179 // compatibility ...
180 // So we translate the old persistence service name into new ones, if possible
182 OUString sToWriteServiceName = sServiceName;
183 #define CHECK_N_TRANSLATE( name ) \
184 else if (sServiceName.equals(SERVICE_PERSISTENT_COMPONENT_##name)) \
185 sToWriteServiceName = SERVICE_##name
187 if (sal_False)
189 CHECK_N_TRANSLATE( FORM );
190 CHECK_N_TRANSLATE( FORM );
191 CHECK_N_TRANSLATE( LISTBOX );
192 CHECK_N_TRANSLATE( COMBOBOX );
193 CHECK_N_TRANSLATE( RADIOBUTTON );
194 CHECK_N_TRANSLATE( GROUPBOX );
195 CHECK_N_TRANSLATE( FIXEDTEXT );
196 CHECK_N_TRANSLATE( COMMANDBUTTON );
197 CHECK_N_TRANSLATE( CHECKBOX );
198 CHECK_N_TRANSLATE( GRID );
199 CHECK_N_TRANSLATE( IMAGEBUTTON );
200 CHECK_N_TRANSLATE( FILECONTROL );
201 CHECK_N_TRANSLATE( TIMEFIELD );
202 CHECK_N_TRANSLATE( DATEFIELD );
203 CHECK_N_TRANSLATE( NUMERICFIELD );
204 CHECK_N_TRANSLATE( CURRENCYFIELD );
205 CHECK_N_TRANSLATE( PATTERNFIELD );
206 CHECK_N_TRANSLATE( HIDDENCONTROL );
207 CHECK_N_TRANSLATE( IMAGECONTROL );
208 CHECK_N_TRANSLATE( FORMATTEDFIELD );
209 else if (sServiceName.equals(SERVICE_PERSISTENT_COMPONENT_EDIT))
211 // special handling for the edit field: we have two controls using this as persistence service name
212 sToWriteServiceName = SERVICE_EDIT;
213 Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
214 if (xSI.is() && xSI->supportsService(SERVICE_FORMATTEDFIELD))
215 sToWriteServiceName = SERVICE_FORMATTEDFIELD;
217 #if OSL_DEBUG_LEVEL > 0
218 Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
219 OSL_ENSURE(xSI.is() && xSI->supportsService(sToWriteServiceName),
220 "OElementExport::exportServiceNameAttribute: wrong service name translation!");
222 #endif
223 sToWriteServiceName =
224 m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
225 XML_NAMESPACE_OOO, sToWriteServiceName );
227 // now write this
228 AddAttribute(
229 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME),
230 OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME),
231 sToWriteServiceName);
234 //---------------------------------------------------------------------
235 void OElementExport::exportEvents()
237 if (!m_aEvents.getLength())
238 // nothing to do
239 return;
241 Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
242 m_rContext.getGlobalContext().GetEventExport().Export(xWrapper);
245 //=====================================================================
246 //= OControlExport
247 //=====================================================================
248 //---------------------------------------------------------------------
249 OControlExport::OControlExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl,
250 const OUString& _rControlId, const OUString& _rReferringControls,
251 const Sequence< ScriptEventDescriptor >& _rEvents)
252 :OElementExport(_rContext, _rxControl, _rEvents)
253 ,m_sControlId(_rControlId)
254 ,m_sReferringControls(_rReferringControls)
255 ,m_nClassId(FormComponentType::CONTROL)
256 ,m_eType( UNKNOWN )
257 ,m_nIncludeCommon(0)
258 ,m_nIncludeDatabase(0)
259 ,m_nIncludeSpecial(0)
260 ,m_nIncludeEvents(0)
261 ,m_nIncludeBindings(0)
262 ,m_pOuterElement(NULL)
264 OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
267 //---------------------------------------------------------------------
268 OControlExport::~OControlExport()
270 implEndElement();
273 //---------------------------------------------------------------------
274 void OControlExport::exportOuterAttributes()
276 // the control id
277 if (CCA_NAME & m_nIncludeCommon)
279 exportStringPropertyAttribute(
280 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_NAME),
281 OAttributeMetaData::getCommonControlAttributeName(CCA_NAME),
282 PROPERTY_NAME
284 #if OSL_DEBUG_LEVEL > 0
285 // reset the bit for later checking
286 m_nIncludeCommon = m_nIncludeCommon & ~CCA_NAME;
287 #endif
290 // the service name
291 if (m_nIncludeCommon & CCA_SERVICE_NAME)
293 exportServiceNameAttribute();
294 #if OSL_DEBUG_LEVEL > 0
295 // reset the bit for later checking
296 m_nIncludeCommon = m_nIncludeCommon & ~CCA_SERVICE_NAME;
297 #endif
301 //---------------------------------------------------------------------
302 void OControlExport::exportInnerAttributes()
304 // the control id
305 if (CCA_CONTROL_ID & m_nIncludeCommon)
307 OSL_ENSURE(!m_sControlId.isEmpty(), "OControlExport::exportInnerAttributes: have no control id for the control!");
308 m_rContext.getGlobalContext().AddAttributeIdLegacy(
309 XML_NAMESPACE_FORM, m_sControlId);
310 #if OSL_DEBUG_LEVEL > 0
311 // reset the bit for later checking
312 m_nIncludeCommon = m_nIncludeCommon & ~CCA_CONTROL_ID;
313 #endif
316 // "new-style" properties ...
317 exportGenericHandlerAttributes();
319 // common control attributes
320 exportCommonControlAttributes();
322 // common database attributes
323 exportDatabaseAttributes();
325 // attributes related to external bindings
326 exportBindingAtributes();
328 // attributes special to the respective control type
329 exportSpecialAttributes();
331 // add the style references to the attributes
332 flagStyleProperties();
335 //---------------------------------------------------------------------
336 void OControlExport::exportAttributes()
338 exportOuterAttributes();
341 //---------------------------------------------------------------------
342 void OControlExport::exportSubTags() throw (Exception)
344 // for the upcoming exportRemainingProperties:
345 // if a control has the LabelControl property, this is not stored with the control itself, but instead with
346 // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
347 // know anything about this, we need to prevent that it tries to export this property
348 exportedProperty(PROPERTY_CONTROLLABEL);
350 // if it's a control supporting XText, then we need to declare all text-related properties
351 // as "already exported". This prevents them from being exported as generic "form:property"-tags.
352 // *If* we would export them this way, they would be completely superfluous, and sometimes even
353 // disastrous, since they may, at import time, override paragraph properties which already have
354 // been set before
355 Reference< XText > xControlText( m_xProps, UNO_QUERY );
356 if ( xControlText.is() )
358 const XMLPropertyMapEntry* pCharAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_TEXT );
359 while ( pCharAttributeProperties->msApiName )
361 exportedProperty( OUString::createFromAscii( pCharAttributeProperties->msApiName ) );
362 ++pCharAttributeProperties;
365 const XMLPropertyMapEntry* pParaAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_SHAPE_PARA );
366 while ( pParaAttributeProperties->msApiName )
368 exportedProperty( OUString::createFromAscii( pParaAttributeProperties->msApiName ) );
369 ++pParaAttributeProperties;
372 // the RichText property is not exported. The presence of the text:p element
373 // will be used - upon reading - as indicator for the value of the RichText property
374 exportedProperty( PROPERTY_RICH_TEXT );
376 // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
377 // The former is a short/enum value, the latter a boolean. The former has a real meaning
378 // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
379 // later on imported, it overwrites anything which has previously been imported for
380 // CharStrikeout.
381 // #i27729#
382 exportedProperty( OUString( "CharCrossedOut" ) );
385 if ( m_eType == LISTBOX )
387 // will be exported in exportListSourceAsElements:
388 if ( controlHasUserSuppliedListEntries() )
389 exportedProperty( PROPERTY_DEFAULT_SELECT_SEQ );
391 // will not be exported in a generic way. Either exportListSourceAsElements cares
392 // for them, or we don't need them
393 exportedProperty( PROPERTY_STRING_ITEM_LIST );
394 exportedProperty( PROPERTY_VALUE_SEQ );
395 exportedProperty( PROPERTY_SELECT_SEQ );
396 exportedProperty( PROPERTY_LISTSOURCE );
398 if ( m_eType == COMBOBOX )
399 exportedProperty( PROPERTY_STRING_ITEM_LIST );
401 // let the base class export the remaining properties and the events
402 OElementExport::exportSubTags();
404 // special sub tags for some controls
405 switch (m_eType)
407 case LISTBOX:
408 // don't export the list entries if the are not provided by the user, but obtained implicitly
409 // from other sources
410 // #i26944#
411 if ( controlHasUserSuppliedListEntries() )
412 exportListSourceAsElements();
413 break;
414 case GRID:
415 { // a grid control requires us to store all columns as sub elements
416 Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
417 OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
418 if (xColumnContainer.is())
419 m_rContext.exportCollectionElements(xColumnContainer);
421 break;
422 case COMBOBOX:
423 { // a combox box description has sub elements: the items
424 DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< OUString > );
426 // don't export the list entries if the are not provided by the user, but obtained implicitly
427 // from other sources
428 // #i26944#
429 if ( controlHasUserSuppliedListEntries() )
431 // get the item list
432 Sequence< OUString > aListItems;
433 m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
434 // loop through it and write the sub elements
435 const OUString* pListItems = aListItems.getConstArray();
436 for (sal_Int32 i=0; i<aListItems.getLength(); ++i, ++pListItems)
438 m_rContext.getGlobalContext().ClearAttrList();
439 AddAttribute(
440 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
441 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
442 *pListItems);
443 SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", sal_True, sal_True);
447 break;
449 case TEXT_AREA:
451 // if we act as rich text control, we need to export some text:p elements
452 if ( xControlText.is() )
454 sal_Bool bActingAsRichText = sal_False;
455 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
457 OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
460 if ( bActingAsRichText )
461 m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
464 break;
465 default:
466 // nothing do to
467 break;
471 //---------------------------------------------------------------------
472 void OControlExport::exportGenericHandlerAttributes()
474 const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
475 for ( const Property* prop = aProperties.getConstArray();
476 prop != aProperties.getConstArray() + aProperties.getLength();
477 ++prop
482 // see if this property can already be handled with an IPropertyHandler (which, on the long
483 // term, should be the case for most, if not all, properties)
484 const PropertyDescription* propDescription = metadata::getPropertyDescription( prop->Name );
485 if ( propDescription == NULL )
486 continue;
488 // let the factory provide the concrete handler. Note that caching, if desired, is the task
489 // of the factory
490 PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId );
491 if ( !handler.get() )
493 SAL_WARN( "xmloff.forms", "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" );
494 continue;
497 OUString attributeValue;
498 if ( propDescription->propertyGroup == NO_GROUP )
500 // that's a property which has a direct mapping to an attribute
501 if ( !shouldExportProperty( prop->Name ) )
502 // TODO: in the future, we surely need a more sophisticated approach to this, involving the property
503 // handler, or the property description
505 exportedProperty( prop->Name );
506 continue;
509 const Any propValue = m_xProps->getPropertyValue( prop->Name );
510 attributeValue = handler->getAttributeValue( propValue );
512 else
514 // that's a property which is part of a group of properties, whose values, in their entity, comprise
515 // a single attribute value
517 // retrieve the descriptions of all other properties which add to the attribute value
518 PropertyDescriptionList descriptions;
519 metadata::getPropertyGroup( propDescription->propertyGroup, descriptions );
521 // retrieve the values for all those properties
522 PropertyValues aValues;
523 for ( PropertyDescriptionList::iterator desc = descriptions.begin();
524 desc != descriptions.end();
525 ++desc
528 // TODO: XMultiPropertySet?
529 const Any propValue = m_xProps->getPropertyValue( (*desc)->propertyName );
530 aValues[ (*desc)->propertyId ] = propValue;
533 // let the handler translate into an XML attribute value
534 attributeValue = handler->getAttributeValue( aValues );
537 AddAttribute(
538 propDescription->attribute.namespacePrefix,
539 token::GetXMLToken( propDescription->attribute.attributeToken ),
540 attributeValue
543 exportedProperty( prop->Name );
545 catch( const Exception& )
547 DBG_UNHANDLED_EXCEPTION();
552 //---------------------------------------------------------------------
553 void OControlExport::exportCommonControlAttributes()
555 size_t i=0;
557 // I decided to handle all the properties here with some static arrays describing the property-attribute
558 // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
559 // would require maps and O(log n) searches, which seems somewhat expensive as this code is used
560 // very frequently.
562 // the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
563 // map identifiers from the wrong block
565 // --------------------------------------------------------------------
566 // some string properties
568 // the attribute ids of all properties which are expected to be of type string
569 static sal_Int32 nStringPropertyAttributeIds[] =
571 CCA_LABEL, CCA_TITLE
573 // the names of all properties which are expected to be of type string
574 static OUString aStringPropertyNames[] =
576 OUString(PROPERTY_LABEL), OUString(PROPERTY_TITLE)
578 OSL_ENSURE( sizeof(aStringPropertyNames)/sizeof(aStringPropertyNames[0]) ==
579 sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]),
580 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
582 for (i=0; i<sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]); ++i)
583 if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
585 exportStringPropertyAttribute(
586 OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
587 OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
588 aStringPropertyNames[i]
590 #if OSL_DEBUG_LEVEL > 0
591 // reset the bit for later checking
592 m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i];
593 #endif
597 // --------------------------------------------------------------------
598 // some boolean properties
600 static sal_Int32 nBooleanPropertyAttributeIds[] =
601 { // attribute flags
602 CCA_CURRENT_SELECTED, CCA_DISABLED, CCA_DROPDOWN, CCA_PRINTABLE, CCA_READONLY, CCA_SELECTED, CCA_TAB_STOP, CCA_ENABLEVISIBLE
604 static const OUString pBooleanPropertyNames[] =
605 { // property names
606 OUString(PROPERTY_STATE), OUString(PROPERTY_ENABLED),
607 OUString(PROPERTY_DROPDOWN), OUString(PROPERTY_PRINTABLE),
608 OUString(PROPERTY_READONLY), OUString(PROPERTY_DEFAULT_STATE),
609 OUString(PROPERTY_TABSTOP), OUString(PROPERTY_ENABLEVISIBLE)
611 static sal_Bool nBooleanPropertyAttrFlags[] =
612 { // attribute defaults
613 BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE | BOOLATTR_INVERSE_SEMANTICS, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_VOID, BOOLATTR_DEFAULT_FALSE
615 #if OSL_DEBUG_LEVEL > 0
616 sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
617 sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
618 sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
619 OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
620 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
621 #endif
622 for (i=0; i<sizeof(nBooleanPropertyAttributeIds)/sizeof(nBooleanPropertyAttributeIds[0]); ++i)
623 if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
625 exportBooleanPropertyAttribute(
626 OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds[i]),
627 OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds[i]),
628 pBooleanPropertyNames[i],
629 nBooleanPropertyAttrFlags[i]);
630 #if OSL_DEBUG_LEVEL > 0
631 // reset the bit for later checking
632 m_nIncludeCommon = m_nIncludeCommon & ~nBooleanPropertyAttributeIds[i];
633 #endif
638 // --------------------------------------------------------------------
639 // some integer properties
641 // now the common handling
642 static sal_Int32 nIntegerPropertyAttributeIds[] =
643 { // attribute flags
644 CCA_SIZE, CCA_TAB_INDEX
646 static const OUString pIntegerPropertyNames[] =
647 { // property names
648 OUString(PROPERTY_LINECOUNT), OUString(PROPERTY_TABINDEX)
650 static const sal_Int16 nIntegerPropertyAttrDefaults[] =
651 { // attribute defaults
652 5, 0
655 if ( m_nIncludeCommon & CCA_MAX_LENGTH )
656 exportedProperty(PROPERTY_MAXTEXTLENGTH);
658 #if OSL_DEBUG_LEVEL > 0
659 sal_Int32 nIdCount = sizeof(nIntegerPropertyAttributeIds) / sizeof(nIntegerPropertyAttributeIds[0]);
660 sal_Int32 nNameCount = sizeof(pIntegerPropertyNames) / sizeof(pIntegerPropertyNames[0]);
661 sal_Int32 nDefaultCount = sizeof(nIntegerPropertyAttrDefaults) / sizeof(nIntegerPropertyAttrDefaults[0]);
662 OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
663 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
664 #endif
665 for (i=0; i<sizeof(nIntegerPropertyAttributeIds)/sizeof(nIntegerPropertyAttributeIds[0]); ++i)
666 if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
668 exportInt16PropertyAttribute(
669 OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
670 OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
671 pIntegerPropertyNames[i],
672 nIntegerPropertyAttrDefaults[i]);
673 #if OSL_DEBUG_LEVEL > 0
674 // reset the bit for later checking
675 m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i];
676 #endif
682 // --------------------------------------------------------------------
683 // some enum properties
685 if (m_nIncludeCommon & CCA_BUTTON_TYPE)
687 exportEnumPropertyAttribute(
688 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_BUTTON_TYPE),
689 OAttributeMetaData::getCommonControlAttributeName(CCA_BUTTON_TYPE),
690 PROPERTY_BUTTONTYPE,
691 OEnumMapper::getEnumMap(OEnumMapper::epButtonType),
692 FormButtonType_PUSH);
693 #if OSL_DEBUG_LEVEL > 0
694 // reset the bit for later checking
695 m_nIncludeCommon = m_nIncludeCommon & ~CCA_BUTTON_TYPE;
696 #endif
698 if ( m_nIncludeCommon & CCA_ORIENTATION )
700 exportEnumPropertyAttribute(
701 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_ORIENTATION ),
702 OAttributeMetaData::getCommonControlAttributeName( CCA_ORIENTATION ),
703 PROPERTY_ORIENTATION,
704 OEnumMapper::getEnumMap( OEnumMapper::epOrientation ),
705 ScrollBarOrientation::HORIZONTAL
707 #if OSL_DEBUG_LEVEL > 0
708 // reset the bit for later checking
709 m_nIncludeCommon = m_nIncludeCommon & ~CCA_ORIENTATION;
710 #endif
713 if ( m_nIncludeCommon & CCA_VISUAL_EFFECT )
715 exportEnumPropertyAttribute(
716 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_VISUAL_EFFECT ),
717 OAttributeMetaData::getCommonControlAttributeName( CCA_VISUAL_EFFECT ),
718 PROPERTY_VISUAL_EFFECT,
719 OEnumMapper::getEnumMap( OEnumMapper::epVisualEffect ),
720 VisualEffect::LOOK3D
722 #if OSL_DEBUG_LEVEL > 0
723 // reset the bit for later checking
724 m_nIncludeCommon = m_nIncludeCommon & ~CCA_VISUAL_EFFECT;
725 #endif
729 // --------------------------------------------------------------------
730 // some properties which require a special handling
732 // the target frame
733 if (m_nIncludeCommon & CCA_TARGET_FRAME)
735 exportTargetFrameAttribute();
736 #if OSL_DEBUG_LEVEL > 0
737 // reset the bit for later checking
738 m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_FRAME;
739 #endif
742 // max text length
743 if ( m_nIncludeCommon & CCA_MAX_LENGTH )
745 // normally, the respective property would be "MaxTextLen"
746 // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
748 // determine the name of the property to export
749 OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH );
750 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
751 sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
753 // export it
754 exportInt16PropertyAttribute(
755 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_MAX_LENGTH ),
756 OAttributeMetaData::getCommonControlAttributeName( CCA_MAX_LENGTH ),
757 sTextLenPropertyName,
761 // in either way, both properties count as "exported"
762 exportedProperty( PROPERTY_MAXTEXTLENGTH );
763 exportedProperty( PROPERTY_PERSISTENCE_MAXTEXTLENGTH );
765 #if OSL_DEBUG_LEVEL > 0
766 // reset the bit for later checking
767 m_nIncludeCommon = m_nIncludeCommon & ~CCA_MAX_LENGTH;
768 #endif
771 if (m_nIncludeCommon & CCA_TARGET_LOCATION)
773 exportTargetLocationAttribute(false);
774 #if OSL_DEBUG_LEVEL > 0
775 // reset the bit for later checking
776 m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_LOCATION;
777 #endif
780 // OJ #99721#
781 if (m_nIncludeCommon & CCA_IMAGE_DATA)
783 exportImageDataAttribute();
784 #if OSL_DEBUG_LEVEL > 0
785 // reset the bit for later checking
786 m_nIncludeCommon = m_nIncludeCommon & ~CCA_IMAGE_DATA;
787 #endif
790 // the for attribute
791 // the target frame
792 if (m_nIncludeCommon & CCA_FOR)
794 if (!m_sReferringControls.isEmpty())
795 { // there is at least one control referring to the one we're handling currently
796 AddAttribute(
797 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_FOR),
798 OAttributeMetaData::getCommonControlAttributeName(CCA_FOR),
799 m_sReferringControls);
801 #if OSL_DEBUG_LEVEL > 0
802 // reset the bit for later checking
803 m_nIncludeCommon = m_nIncludeCommon & ~CCA_FOR;
804 #endif
807 if ((CCA_CURRENT_VALUE | CCA_VALUE) & m_nIncludeCommon)
809 const sal_Char* pCurrentValuePropertyName = NULL;
810 const sal_Char* pValuePropertyName = NULL;
812 // get the property names
813 getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
815 static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE);
816 static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE);
817 static const sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_VALUE);
818 static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE);
820 // add the atrtributes if necessary and possible
821 if (pCurrentValuePropertyName && (CCA_CURRENT_VALUE & m_nIncludeCommon))
823 // don't export the current-value if this value originates from a data binding
824 // #i26944#
825 if ( controlHasActiveDataBinding() )
826 exportedProperty( OUString::createFromAscii( pCurrentValuePropertyName ) );
827 else
828 exportGenericPropertyAttribute(
829 nCurrentValueAttributeNamespaceKey,
830 pCurrentValueAttributeName,
831 pCurrentValuePropertyName
835 if (pValuePropertyName && (CCA_VALUE & m_nIncludeCommon))
836 exportGenericPropertyAttribute(
837 nValueAttributeNamespaceKey,
838 pValueAttributeName,
839 pValuePropertyName);
841 OSL_ENSURE((NULL == pValuePropertyName) == (0 == (CCA_VALUE & m_nIncludeCommon)),
842 "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
843 OSL_ENSURE((NULL == pCurrentValuePropertyName ) == (0 == (CCA_CURRENT_VALUE & m_nIncludeCommon)),
844 "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
846 #if OSL_DEBUG_LEVEL > 0
847 // reset the bit for later checking
848 m_nIncludeCommon = m_nIncludeCommon & ~(CCA_CURRENT_VALUE | CCA_VALUE);
849 #endif
852 OSL_ENSURE(0 == m_nIncludeCommon,
853 "OControlExport::exportCommonControlAttributes: forgot some flags!");
854 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
855 // be 0 now ...
858 //---------------------------------------------------------------------
859 void OControlExport::exportDatabaseAttributes()
861 #if OSL_DEBUG_LEVEL > 0
862 sal_Int32 nIncludeDatabase = m_nIncludeDatabase;
863 #endif
864 // the only string property: DataField
865 if (DA_DATA_FIELD & m_nIncludeDatabase)
867 exportStringPropertyAttribute(
868 OAttributeMetaData::getDatabaseAttributeNamespace(DA_DATA_FIELD),
869 OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD),
870 PROPERTY_DATAFIELD);
871 RESET_BIT( nIncludeDatabase, DA_DATA_FIELD );
874 // InputRequired
875 if ( DA_INPUT_REQUIRED & m_nIncludeDatabase )
877 exportBooleanPropertyAttribute(
878 OAttributeMetaData::getDatabaseAttributeNamespace( DA_INPUT_REQUIRED ),
879 OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ),
880 PROPERTY_INPUT_REQUIRED,
881 BOOLATTR_DEFAULT_TRUE
883 RESET_BIT( nIncludeDatabase, DA_INPUT_REQUIRED );
886 // the only int16 property: BoundColumn
887 if (DA_BOUND_COLUMN & m_nIncludeDatabase)
889 exportInt16PropertyAttribute(
890 OAttributeMetaData::getDatabaseAttributeNamespace(DA_BOUND_COLUMN),
891 OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN),
892 PROPERTY_BOUNDCOLUMN,
894 true);
895 RESET_BIT( nIncludeDatabase, DA_BOUND_COLUMN );
898 // ConvertEmptyToNull
899 if (DA_CONVERT_EMPTY & m_nIncludeDatabase)
901 exportBooleanPropertyAttribute(
902 OAttributeMetaData::getDatabaseAttributeNamespace(DA_CONVERT_EMPTY),
903 OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY),
904 PROPERTY_EMPTY_IS_NULL,
905 BOOLATTR_DEFAULT_FALSE
907 RESET_BIT( nIncludeDatabase, DA_CONVERT_EMPTY );
910 // the only enum property: ListSourceType
911 if (DA_LIST_SOURCE_TYPE & m_nIncludeDatabase)
913 exportEnumPropertyAttribute(
914 OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE_TYPE),
915 OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE),
916 PROPERTY_LISTSOURCETYPE,
917 OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
918 ListSourceType_VALUELIST
920 RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE_TYPE );
923 if (m_nIncludeDatabase & DA_LIST_SOURCE)
925 exportListSourceAsAttribute();
926 RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE );
929 #if OSL_DEBUG_LEVEL > 0
930 OSL_ENSURE(0 == nIncludeDatabase,
931 "OControlExport::exportDatabaseAttributes: forgot some flags!");
932 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
933 // be 0 now ...
934 #endif
937 //---------------------------------------------------------------------
938 void OControlExport::exportBindingAtributes()
940 #if OSL_DEBUG_LEVEL > 0
941 sal_Int32 nIncludeBinding = m_nIncludeBindings;
942 #endif
944 // ....................................................
945 if ( m_nIncludeBindings & BA_LINKED_CELL )
947 exportCellBindingAttributes( ( m_nIncludeBindings & BA_LIST_LINKING_TYPE ) != 0 );
948 #if OSL_DEBUG_LEVEL > 0
949 // reset the bit for later checking
950 nIncludeBinding = nIncludeBinding & ~( BA_LINKED_CELL | BA_LIST_LINKING_TYPE );
951 #endif
954 // ....................................................
955 if ( m_nIncludeBindings & BA_LIST_CELL_RANGE )
957 exportCellListSourceRange();
958 #if OSL_DEBUG_LEVEL > 0
959 // reset the bit for later checking
960 nIncludeBinding = nIncludeBinding & ~BA_LIST_CELL_RANGE;
961 #endif
964 if ( m_nIncludeBindings & BA_XFORMS_BIND )
966 exportXFormsBindAttributes();
967 #if OSL_DEBUG_LEVEL > 0
968 // reset the bit for later checking
969 nIncludeBinding = nIncludeBinding & ~BA_XFORMS_BIND;
970 #endif
973 if ( m_nIncludeBindings & BA_XFORMS_LISTBIND )
975 exportXFormsListAttributes();
976 #if OSL_DEBUG_LEVEL > 0
977 // reset the bit for later checking
978 nIncludeBinding = nIncludeBinding & ~BA_XFORMS_LISTBIND;
979 #endif
982 if ( m_nIncludeBindings & BA_XFORMS_SUBMISSION )
984 exportXFormsSubmissionAttributes();
985 #if OSL_DEBUG_LEVEL > 0
986 // reset the bit for later checking
987 nIncludeBinding = nIncludeBinding & ~BA_XFORMS_SUBMISSION;
988 #endif
991 OSL_ENSURE( 0 == nIncludeBinding,
992 "OControlExport::exportBindingAtributes: forgot some flags!");
993 // in the debug version, we should have removed every bit we handled from the mask, so it should
994 // be 0 now ...
997 void OControlExport::exportSpecialAttributes()
999 sal_Int32 i=0;
1001 // the boolean properties
1003 static const sal_Int32 nBooleanPropertyAttributeIds[] =
1004 { // attribute flags
1005 SCA_VALIDATION, SCA_MULTI_LINE, SCA_AUTOMATIC_COMPLETION, SCA_MULTIPLE, SCA_DEFAULT_BUTTON, SCA_IS_TRISTATE,
1006 SCA_TOGGLE, SCA_FOCUS_ON_CLICK
1008 static const OUString pBooleanPropertyNames[] =
1009 { // property names
1010 OUString(PROPERTY_STRICTFORMAT), OUString(PROPERTY_MULTILINE),
1011 OUString(PROPERTY_AUTOCOMPLETE),
1012 OUString(PROPERTY_MULTISELECTION),
1013 OUString(PROPERTY_DEFAULTBUTTON), OUString(PROPERTY_TRISTATE),
1014 OUString(PROPERTY_TOGGLE), OUString(PROPERTY_FOCUS_ON_CLICK)
1016 sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
1017 #if OSL_DEBUG_LEVEL > 0
1018 sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
1019 OSL_ENSURE((nIdCount == nNameCount),
1020 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
1021 #endif
1022 const sal_Int32* pAttributeId = nBooleanPropertyAttributeIds;
1023 for ( i = 0; i < nIdCount; ++i, ++pAttributeId )
1025 if ( *pAttributeId & m_nIncludeSpecial)
1027 exportBooleanPropertyAttribute(
1028 OAttributeMetaData::getSpecialAttributeNamespace( *pAttributeId ),
1029 OAttributeMetaData::getSpecialAttributeName( *pAttributeId ),
1030 pBooleanPropertyNames[i],
1031 ( *pAttributeId == SCA_FOCUS_ON_CLICK ) ? BOOLATTR_DEFAULT_TRUE : BOOLATTR_DEFAULT_FALSE
1033 #if OSL_DEBUG_LEVEL > 0
1034 // reset the bit for later checking
1035 m_nIncludeSpecial = m_nIncludeSpecial & ~*pAttributeId;
1036 #endif
1041 // the integer properties
1043 static sal_Int32 nIntegerPropertyAttributeIds[] =
1044 { // attribute flags
1045 SCA_PAGE_STEP_SIZE
1047 static const OUString pIntegerPropertyNames[] =
1048 { // property names
1049 OUString(PROPERTY_BLOCK_INCREMENT)
1051 static const sal_Int32 nIntegerPropertyAttrDefaults[] =
1052 { // attribute defaults (XML defaults, not runtime defaults!)
1056 sal_Int32 nIdCount = sizeof( nIntegerPropertyAttributeIds ) / sizeof( nIntegerPropertyAttributeIds[0] );
1057 #if OSL_DEBUG_LEVEL > 0
1058 sal_Int32 nNameCount = sizeof( pIntegerPropertyNames ) / sizeof( pIntegerPropertyNames[0] );
1059 OSL_ENSURE( ( nIdCount == nNameCount ),
1060 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1061 sal_Int32 nDefaultCount = sizeof( nIntegerPropertyAttrDefaults ) / sizeof( nIntegerPropertyAttrDefaults[0] );
1062 OSL_ENSURE( ( nIdCount == nDefaultCount ),
1063 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
1064 #endif
1065 for ( i = 0; i < nIdCount; ++i )
1066 if ( nIntegerPropertyAttributeIds[i] & m_nIncludeSpecial )
1068 exportInt32PropertyAttribute(
1069 OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds[i] ),
1070 OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds[i] ),
1071 pIntegerPropertyNames[i],
1072 nIntegerPropertyAttrDefaults[i]
1074 #if OSL_DEBUG_LEVEL > 0
1075 // reset the bit for later checking
1076 m_nIncludeSpecial = m_nIncludeSpecial & ~nIntegerPropertyAttributeIds[i];
1077 #endif
1080 if ( SCA_STEP_SIZE & m_nIncludeSpecial )
1082 OUString sPropertyName;
1083 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1084 sPropertyName = PROPERTY_LINE_INCREMENT;
1085 else if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1086 sPropertyName = PROPERTY_SPIN_INCREMENT;
1087 else
1088 OSL_FAIL( "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1090 if ( !sPropertyName.isEmpty() )
1091 exportInt32PropertyAttribute(
1092 OAttributeMetaData::getSpecialAttributeNamespace( SCA_STEP_SIZE ),
1093 OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ),
1094 sPropertyName,
1098 #if OSL_DEBUG_LEVEL > 0
1099 // reset the bit for later checking
1100 m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STEP_SIZE;
1101 #endif
1106 // -------------------
1107 // the enum properties
1109 if (SCA_STATE & m_nIncludeSpecial)
1111 exportEnumPropertyAttribute(
1112 OAttributeMetaData::getSpecialAttributeNamespace(SCA_STATE),
1113 OAttributeMetaData::getSpecialAttributeName(SCA_STATE),
1114 PROPERTY_DEFAULT_STATE,
1115 OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1116 STATE_NOCHECK);
1117 #if OSL_DEBUG_LEVEL > 0
1118 // reset the bit for later checking
1119 m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STATE;
1120 #endif
1123 if (SCA_CURRENT_STATE & m_nIncludeSpecial)
1125 exportEnumPropertyAttribute(
1126 OAttributeMetaData::getSpecialAttributeNamespace(SCA_CURRENT_STATE),
1127 OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE),
1128 PROPERTY_STATE,
1129 OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1130 STATE_NOCHECK);
1131 #if OSL_DEBUG_LEVEL > 0
1132 // reset the bit for later checking
1133 m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_CURRENT_STATE;
1134 #endif
1138 // --------------------------------------------------------------------
1139 // some properties which require a special handling
1140 // the repeat delay
1142 if ( m_nIncludeSpecial & SCA_REPEAT_DELAY )
1144 DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY, sal_Int32 );
1146 sal_Int32 nRepeatDelay = 0;
1147 m_xProps->getPropertyValue( PROPERTY_REPEAT_DELAY ) >>= nRepeatDelay;
1148 Time aTime( Time::SYSTEM );
1149 aTime.MakeTimeFromMS( nRepeatDelay );
1150 util::Duration aDuration;
1151 aDuration.Hours = aTime.GetHour();
1152 aDuration.Minutes = aTime.GetMin();
1153 aDuration.Seconds = aTime.GetSec();
1154 aDuration.NanoSeconds = (nRepeatDelay % 1000) * 1000000;
1156 OUStringBuffer buf;
1157 ::sax::Converter::convertDuration(buf, aDuration);
1158 AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCA_REPEAT_DELAY )
1159 ,OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY )
1160 ,buf.makeStringAndClear());
1162 exportedProperty( PROPERTY_REPEAT_DELAY );
1164 #if OSL_DEBUG_LEVEL > 0
1165 // reset the bit for later checking
1166 m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_REPEAT_DELAY;
1167 #endif
1171 // ----------------------------------
1172 // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1174 if (SCA_ECHO_CHAR & m_nIncludeSpecial)
1176 DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
1177 sal_Int16 nValue(0);
1178 m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue;
1179 if (nValue)
1181 OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
1182 AddAttribute(
1183 OAttributeMetaData::getSpecialAttributeNamespace(SCA_ECHO_CHAR),
1184 OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR),
1185 sCharacter);
1187 exportedProperty(PROPERTY_ECHO_CHAR);
1188 #if OSL_DEBUG_LEVEL > 0
1189 // reset the bit for later checking
1190 m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_ECHO_CHAR;
1191 #endif
1195 // ----------------------------------
1196 // the string properties
1198 static sal_Int32 nStringPropertyAttributeIds[] =
1199 { // attribute flags
1200 SCA_GROUP_NAME
1202 static const OUString pStringPropertyNames[] =
1203 { // property names
1204 OUString(PROPERTY_GROUP_NAME)
1207 sal_Int32 nIdCount = sizeof( nStringPropertyAttributeIds ) / sizeof( nStringPropertyAttributeIds[0] );
1208 #if OSL_DEBUG_LEVEL > 0
1209 sal_Int32 nNameCount = sizeof( pStringPropertyNames ) / sizeof( pStringPropertyNames[0] );
1210 OSL_ENSURE( ( nIdCount == nNameCount ),
1211 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1212 #endif
1213 for ( i = 0; i < nIdCount; ++i )
1214 if ( nStringPropertyAttributeIds[i] & m_nIncludeSpecial )
1216 exportStringPropertyAttribute(
1217 OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ),
1218 OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ),
1219 pStringPropertyNames[i]
1221 #if OSL_DEBUG_LEVEL > 0
1222 // reset the bit for later checking
1223 m_nIncludeSpecial = m_nIncludeSpecial & ~nStringPropertyAttributeIds[i];
1224 #endif
1228 // ----------------------------------
1229 if ((SCA_MIN_VALUE | SCA_MAX_VALUE) & m_nIncludeSpecial)
1231 // need to export the min value and the max value as attributes
1232 // It depends on the real type (FormComponentType) of the control, which properties hold these
1233 // values
1234 const sal_Char* pMinValuePropertyName = NULL;
1235 const sal_Char* pMaxValuePropertyName = NULL;
1236 getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
1238 OSL_ENSURE((NULL == pMinValuePropertyName) == (0 == (SCA_MIN_VALUE & m_nIncludeSpecial)),
1239 "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1240 OSL_ENSURE((NULL == pMaxValuePropertyName) == (0 == (SCA_MAX_VALUE & m_nIncludeSpecial)),
1241 "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1243 // add the two attributes
1244 static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE);
1245 static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE);
1246 static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MIN_VALUE);
1247 static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MAX_VALUE);
1249 if (pMinValuePropertyName && (SCA_MIN_VALUE & m_nIncludeSpecial))
1250 exportGenericPropertyAttribute(
1251 nMinValueNamespaceKey,
1252 pMinValueAttributeName,
1253 pMinValuePropertyName);
1255 if (pMaxValuePropertyName && (SCA_MAX_VALUE & m_nIncludeSpecial))
1256 exportGenericPropertyAttribute(
1257 nMaxValueNamespaceKey,
1258 pMaxValueAttributeName,
1259 pMaxValuePropertyName);
1260 #if OSL_DEBUG_LEVEL > 0
1261 // reset the bit for later checking
1262 m_nIncludeSpecial = m_nIncludeSpecial & ~(SCA_MIN_VALUE | SCA_MAX_VALUE);
1263 #endif
1266 // ----------------------------------
1267 if ( SCA_IMAGE_POSITION & m_nIncludeSpecial )
1269 exportImagePositionAttributes();
1270 RESET_BIT( m_nIncludeSpecial, SCA_IMAGE_POSITION );
1273 OSL_ENSURE(0 == m_nIncludeSpecial,
1274 "OControlExport::exportSpecialAttributes: forgot some flags!");
1275 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1276 // be 0 now ...
1279 //---------------------------------------------------------------------
1280 OUString OControlExport::getScalarListSourceValue() const
1282 OUString sListSource;
1283 Any aListSource = m_xProps->getPropertyValue( PROPERTY_LISTSOURCE );
1284 if ( !( aListSource >>= sListSource ) )
1286 Sequence< OUString > aListSourceSequence;
1287 aListSource >>= aListSourceSequence;
1288 if ( aListSourceSequence.getLength() )
1289 sListSource = aListSourceSequence[ 0 ];
1291 return sListSource;
1294 //---------------------------------------------------------------------
1295 void OControlExport::exportListSourceAsAttribute()
1297 // DA_LIST_SOURCE needs some special handling
1298 DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE );
1300 OUString sListSource = getScalarListSourceValue();
1301 if ( !sListSource.isEmpty() )
1302 { // the ListSource property needs to be exported as attribute, and it is not empty
1303 AddAttribute(
1304 OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE),
1305 OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE),
1306 sListSource);
1309 exportedProperty( PROPERTY_LISTSOURCE );
1312 //---------------------------------------------------------------------
1313 void OControlExport::getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut)
1315 Sequence< sal_Int16 > aValueSequence;
1316 DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
1317 m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
1319 const sal_Int16* pValues = aValueSequence.getConstArray();
1320 for (sal_Int32 i=0; i<aValueSequence.getLength(); ++i, ++pValues)
1321 _rOut.insert(*pValues);
1324 //---------------------------------------------------------------------
1325 void OControlExport::exportListSourceAsElements()
1327 // the string lists
1328 Sequence< OUString > aItems, aValues;
1329 DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< OUString > );
1330 m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
1332 DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE, Sequence< OUString > );
1333 if ( 0 == ( m_nIncludeDatabase & DA_LIST_SOURCE ) )
1334 m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
1335 // if we exported the list source as attribute, we do not repeat it as sub elements
1337 // the selection lists
1338 Int16Set aSelection, aDefaultSelection;
1339 getSequenceInt16PropertyAsSet(PROPERTY_SELECT_SEQ, aSelection);
1340 getSequenceInt16PropertyAsSet(PROPERTY_DEFAULT_SELECT_SEQ, aDefaultSelection);
1342 // the string for "true"
1343 OUString sTrue;
1344 OUStringBuffer sBuffer;
1345 ::sax::Converter::convertBool(sBuffer, true);
1346 sTrue = sBuffer.makeStringAndClear();
1348 // loop through both lists ('til the maximum of both lengths)
1349 const OUString* pItems = aItems.getConstArray();
1350 const OUString* pValues = aValues.getConstArray();
1352 sal_Int32 nItems = aItems.getLength();
1353 sal_Int32 nValues = aValues.getLength();
1355 sal_Int16 nMaxLen = (sal_Int16)std::max(nItems, nValues);
1357 for (sal_Int16 i=0; i<nMaxLen; ++i )
1359 m_rContext.getGlobalContext().ClearAttrList();
1360 if (i < nItems)
1362 // there is an item at this position
1363 AddAttribute(
1364 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
1365 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
1366 *pItems);
1367 ++pItems;
1369 if (i < nValues)
1371 // there is an value at this position
1372 AddAttribute(
1373 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE),
1374 OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE),
1375 *pValues);
1376 ++pValues;
1379 Int16SetIterator aSelectedPos = aSelection.find(i);
1380 if (aSelection.end() != aSelectedPos)
1381 { // the item at this position is selected
1382 AddAttribute(
1383 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1384 OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1385 sTrue
1387 aSelection.erase(aSelectedPos);
1390 Int16SetIterator aDefaultSelectedPos = aDefaultSelection.find(i);
1391 if (aDefaultSelection.end() != aDefaultSelectedPos)
1392 { // the item at this position is selected as default
1393 AddAttribute(
1394 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1395 OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1396 sTrue
1398 aDefaultSelection.erase(aDefaultSelectedPos);
1400 SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", sal_True, sal_True);
1403 // There may be more "selected" or "default-selected" items than there are in the lists in real,
1404 // so we need to store some additional "form:option" items which have no name and no label, but
1405 // one or both of the selected flags.
1406 // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1408 if ( !aSelection.empty() || !aDefaultSelection.empty() )
1410 sal_Int16 nLastSelected = -1;
1411 if ( !aSelection.empty() )
1412 nLastSelected = *(--aSelection.end());
1414 sal_Int16 nLastDefaultSelected = -1;
1415 if ( !aDefaultSelection.empty() )
1416 nLastDefaultSelected = *(--aDefaultSelection.end());
1418 // the maximum element in both sets
1419 sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
1420 OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!");
1421 // if the maximum (selected or default selected) entry number is less than the maximum item count
1422 // in both lists, the entry number should have been removed from the set
1424 for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
1426 if (aSelection.end() != aSelection.find(i))
1427 { // the (not existent) item at this position is selected
1428 AddAttribute(
1429 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1430 OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1431 sTrue
1435 if (aDefaultSelection.end() != aDefaultSelection.find(i))
1436 { // the (not existent) item at this position is selected as default
1437 AddAttribute(
1438 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1439 OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1440 sTrue
1443 SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", sal_True, sal_True);
1448 //---------------------------------------------------------------------
1449 void OControlExport::implStartElement(const sal_Char* _pName)
1451 // before we let the base class start it's outer element, we add a wrapper element
1452 const sal_Char *pOuterElementName = getOuterXMLElementName();
1453 m_pOuterElement = pOuterElementName
1454 ? new SvXMLElementExport(
1455 m_rContext.getGlobalContext(),
1456 XML_NAMESPACE_FORM,
1457 pOuterElementName, sal_True,
1458 sal_True)
1459 : 0;
1461 // add the attributes for the inner element
1462 exportInnerAttributes();
1464 // and start the inner element
1465 OElementExport::implStartElement(_pName);
1468 //---------------------------------------------------------------------
1469 void OControlExport::implEndElement()
1471 // end the inner element
1472 OElementExport::implEndElement();
1474 // end the outer element if it exists
1475 delete m_pOuterElement;
1476 m_pOuterElement = NULL;
1479 //---------------------------------------------------------------------
1480 const sal_Char* OControlExport::getOuterXMLElementName() const
1482 return 0;
1485 //---------------------------------------------------------------------
1486 const sal_Char* OControlExport::getXMLElementName() const
1488 return getElementName(m_eType);
1491 //---------------------------------------------------------------------
1492 void OControlExport::examine()
1494 OSL_ENSURE( ( m_nIncludeCommon == 0 ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == 0 )
1495 && ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == 0),
1496 "OControlExport::examine: called me twice? Not initialized?" );
1498 // get the class id to decide which kind of element we need in the XML stream
1499 m_nClassId = FormComponentType::CONTROL;
1500 DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
1501 m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId;
1502 bool knownType = false;
1503 switch (m_nClassId)
1505 case FormComponentType::DATEFIELD:
1506 m_eType = DATE;
1507 knownType = true;
1508 // NO BREAK
1509 case FormComponentType::TIMEFIELD:
1510 if ( !knownType )
1512 m_eType = TIME;
1513 knownType = true;
1515 m_nIncludeSpecial |= SCA_VALIDATION;
1516 // NO BREAK
1517 case FormComponentType::NUMERICFIELD:
1518 case FormComponentType::CURRENCYFIELD:
1519 case FormComponentType::PATTERNFIELD:
1520 if ( !knownType )
1522 m_eType = FORMATTED_TEXT;
1523 knownType = true;
1525 // NO BREAK
1526 case FormComponentType::TEXTFIELD:
1527 { // it's some kind of edit. To know which type we need further investigation
1529 if ( !knownType )
1531 // check if it's a formatted field
1532 if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
1534 m_eType = FORMATTED_TEXT;
1536 else
1538 // all other controls are represented by an ordinary edit control, but which XML control type
1539 // it is depends on the current values of some properties
1541 // if the EchoChar string is not empty, it is a password field
1542 sal_Int16 nEchoChar = 0;
1543 if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR))
1544 // grid columns do not have this property ....
1545 m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar;
1546 if (nEchoChar)
1548 m_eType = PASSWORD;
1549 m_nIncludeSpecial |= SCA_ECHO_CHAR;
1551 else
1553 // if the MultiLine property is sal_True, it is a TextArea
1554 sal_Bool bMultiLine = sal_False;
1555 if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE))
1556 // grid columns do not have this property ....
1557 bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
1559 if ( bMultiLine )
1560 m_eType = TEXT_AREA;
1561 else
1562 // the only case left is represented by a Text element
1563 m_eType = TEXT;
1566 knownType = true;
1569 // attributes which are common to all the types:
1570 // common attributes
1571 m_nIncludeCommon =
1572 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED |
1573 CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1575 if ( ( m_nClassId != FormComponentType::DATEFIELD )
1576 && ( m_nClassId != FormComponentType::TIMEFIELD )
1578 // date and time field values are handled differently nowadays
1579 m_nIncludeCommon |= CCA_VALUE;
1581 // database attributes
1582 m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1584 // event attributes
1585 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1587 // only text and pattern fields have a ConvertEmptyToNull property
1588 if ( ( m_nClassId == FormComponentType::TEXTFIELD )
1589 || ( m_nClassId == FormComponentType::PATTERNFIELD )
1591 m_nIncludeDatabase |= DA_CONVERT_EMPTY;
1593 // all controls but the file control fields have a readonly property
1594 if ( m_nClassId != FormComponentType::FILECONTROL )
1595 m_nIncludeCommon |= CCA_READONLY;
1597 // a text field has a max text len
1598 if ( m_nClassId == FormComponentType::TEXTFIELD )
1599 m_nIncludeCommon |= CCA_MAX_LENGTH;
1601 // max and min values and validation:
1602 if (FORMATTED_TEXT == m_eType)
1603 { // in general all controls represented as formatted-text have these props
1604 if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField
1605 m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE;
1607 if (FormComponentType::TEXTFIELD != m_nClassId)
1608 // and the FormattedField does not have a validation flag
1609 m_nIncludeSpecial |= SCA_VALIDATION;
1612 // if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1613 if ( ( PASSWORD != m_eType )
1614 && ( DATE != m_eType )
1615 && ( TIME != m_eType )
1618 m_nIncludeCommon |= CCA_CURRENT_VALUE;
1621 break;
1623 case FormComponentType::FILECONTROL:
1624 m_eType = FILE;
1625 m_nIncludeCommon =
1626 CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE | CCA_DISABLED |
1627 CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE |
1628 CCA_VALUE;
1629 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1630 break;
1632 case FormComponentType::FIXEDTEXT:
1633 m_eType = FIXED_TEXT;
1634 m_nIncludeCommon =
1635 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1636 CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1637 m_nIncludeSpecial = SCA_MULTI_LINE;
1638 m_nIncludeEvents = EA_CONTROL_EVENTS;
1639 break;
1641 case FormComponentType::COMBOBOX:
1642 m_eType = COMBOBOX;
1643 m_nIncludeCommon =
1644 CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE |
1645 CCA_DISABLED | CCA_DROPDOWN | CCA_MAX_LENGTH | CCA_PRINTABLE | CCA_READONLY | CCA_SIZE |
1646 CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE;
1647 m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION;
1648 m_nIncludeDatabase = DA_CONVERT_EMPTY | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE | DA_LIST_SOURCE_TYPE;
1649 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1650 break;
1652 case FormComponentType::LISTBOX:
1653 m_eType = LISTBOX;
1654 m_nIncludeCommon =
1655 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_DROPDOWN |
1656 CCA_PRINTABLE | CCA_SIZE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1657 m_nIncludeSpecial = SCA_MULTIPLE;
1658 m_nIncludeDatabase = DA_BOUND_COLUMN | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE_TYPE;
1659 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_CLICK | EA_ON_DBLCLICK;
1660 // check if we need to export the ListSource as attribute
1662 // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1663 // a sequence of pairs which is build from the StringItemList and the ValueList
1664 ListSourceType eListSourceType = ListSourceType_VALUELIST;
1665 #if OSL_DEBUG_LEVEL > 0
1666 sal_Bool bSuccess =
1667 #endif
1668 m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType;
1669 OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1670 if (ListSourceType_VALUELIST != eListSourceType)
1672 m_nIncludeDatabase |= DA_LIST_SOURCE;
1676 break;
1678 case FormComponentType::COMMANDBUTTON:
1679 m_eType = BUTTON;
1680 m_nIncludeCommon |= CCA_TAB_STOP | CCA_LABEL;
1681 m_nIncludeSpecial = SCA_DEFAULT_BUTTON | SCA_TOGGLE | SCA_FOCUS_ON_CLICK | SCA_IMAGE_POSITION | SCA_REPEAT_DELAY;
1682 // NO BREAK !
1683 case FormComponentType::IMAGEBUTTON:
1684 if (BUTTON != m_eType)
1686 // not coming from the previous case
1687 m_eType = IMAGE;
1689 m_nIncludeCommon |=
1690 CCA_NAME | CCA_SERVICE_NAME | CCA_BUTTON_TYPE | CCA_DISABLED |
1691 CCA_IMAGE_DATA | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TARGET_FRAME |
1692 CCA_TARGET_LOCATION | CCA_TITLE;
1693 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CLICK | EA_ON_DBLCLICK;
1694 break;
1696 case FormComponentType::CHECKBOX:
1697 m_eType = CHECKBOX;
1698 m_nIncludeSpecial = SCA_CURRENT_STATE | SCA_IS_TRISTATE | SCA_STATE;
1699 // NO BREAK !
1700 case FormComponentType::RADIOBUTTON:
1701 m_nIncludeCommon =
1702 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE |
1703 CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE | CCA_VISUAL_EFFECT;
1704 if (CHECKBOX != m_eType)
1705 { // not coming from the previous case
1706 m_eType = RADIO;
1707 m_nIncludeCommon |= CCA_CURRENT_SELECTED | CCA_SELECTED;
1709 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) )
1710 m_nIncludeSpecial |= SCA_IMAGE_POSITION;
1711 if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) )
1712 m_nIncludeSpecial |= SCA_GROUP_NAME;
1713 m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1714 m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE;
1715 break;
1717 case FormComponentType::GROUPBOX:
1718 m_eType = FRAME;
1719 m_nIncludeCommon =
1720 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1721 CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1722 m_nIncludeEvents = EA_CONTROL_EVENTS;
1723 break;
1725 case FormComponentType::IMAGECONTROL:
1726 m_eType = IMAGE_FRAME;
1727 m_nIncludeCommon =
1728 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_IMAGE_DATA |
1729 CCA_PRINTABLE | CCA_READONLY | CCA_TITLE;
1730 m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1731 m_nIncludeEvents = EA_CONTROL_EVENTS;
1732 break;
1734 case FormComponentType::HIDDENCONTROL:
1735 m_eType = HIDDEN;
1736 m_nIncludeCommon =
1737 CCA_NAME | CCA_SERVICE_NAME | CCA_VALUE;
1738 break;
1740 case FormComponentType::GRIDCONTROL:
1741 m_eType = GRID;
1742 m_nIncludeCommon =
1743 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1744 CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1745 m_nIncludeEvents = EA_CONTROL_EVENTS;
1746 break;
1748 case FormComponentType::SCROLLBAR:
1749 case FormComponentType::SPINBUTTON:
1750 m_eType = VALUERANGE;
1751 m_nIncludeCommon =
1752 CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1753 CCA_TITLE | CCA_CURRENT_VALUE | CCA_VALUE | CCA_ORIENTATION;
1754 m_nIncludeSpecial = SCA_MAX_VALUE | SCA_STEP_SIZE | SCA_MIN_VALUE | SCA_REPEAT_DELAY;
1756 if ( m_nClassId == FormComponentType::SCROLLBAR )
1757 m_nIncludeSpecial |= SCA_PAGE_STEP_SIZE ;
1759 m_nIncludeEvents = EA_CONTROL_EVENTS;
1760 break;
1762 default:
1763 OSL_FAIL("OControlExport::examineControl: unknown control type (class id)!");
1764 // NO break!
1766 case FormComponentType::NAVIGATIONBAR:
1767 // TODO: should we have an own file format for this?
1768 // NO break
1770 case FormComponentType::CONTROL:
1771 m_eType = GENERIC_CONTROL;
1772 // unknown control type
1773 m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME;
1774 // at least a name should be there, 'cause without a name the control could never have been
1775 // inserted into it's parent container
1776 // In addition, the service name is absolutely necessary to create the control upon reading.
1777 m_nIncludeEvents = EA_CONTROL_EVENTS;
1778 // we always should be able to export events - this is not control type dependent
1779 break;
1782 // in general, all control types need to export the control id
1783 m_nIncludeCommon |= CCA_CONTROL_ID;
1785 // is is a control bound to a calc cell?
1786 if ( FormCellBindingHelper::livesInSpreadsheetDocument( m_xProps ) )
1788 FormCellBindingHelper aHelper( m_xProps, NULL );
1790 if ( aHelper.isCellBinding( aHelper.getCurrentBinding( ) ) )
1792 m_nIncludeBindings |= BA_LINKED_CELL;
1793 if ( m_nClassId == FormComponentType::LISTBOX )
1794 m_nIncludeBindings |= BA_LIST_LINKING_TYPE;
1798 // is it a list-like control which uses a calc cell range as list source?
1800 if ( aHelper.isCellRangeListSource( aHelper.getCurrentListSource( ) ) )
1801 m_nIncludeBindings |= BA_LIST_CELL_RANGE;
1805 // is control bound to XForms?
1806 if( !getXFormsBindName( m_xProps ).isEmpty() )
1808 m_nIncludeBindings |= BA_XFORMS_BIND;
1811 // is (list-)control bound to XForms list?
1812 if( !getXFormsListBindName( m_xProps ).isEmpty() )
1814 m_nIncludeBindings |= BA_XFORMS_LISTBIND;
1817 // does the control have an XForms submission?
1818 if( !getXFormsSubmissionName( m_xProps ).isEmpty() )
1820 m_nIncludeBindings |= BA_XFORMS_SUBMISSION;
1824 //---------------------------------------------------------------------
1825 void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType )
1829 FormCellBindingHelper aHelper( m_xProps, NULL );
1830 Reference< XValueBinding > xBinding( aHelper.getCurrentBinding() );
1831 OSL_ENSURE( xBinding.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1832 if ( xBinding.is() )
1834 // ....................................................
1835 AddAttribute(
1836 OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL ),
1837 OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL ),
1838 aHelper.getStringAddressFromCellBinding( xBinding )
1841 // ....................................................
1842 if ( _bIncludeListLinkageType )
1844 sal_Int16 nLinkageType = aHelper.isCellIntegerBinding( xBinding ) ? 1 : 0;
1846 OUStringBuffer sBuffer;
1847 m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(
1848 sBuffer,
1849 (sal_uInt16)nLinkageType,
1850 OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType )
1853 AddAttribute(
1854 OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE ),
1855 OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ),
1856 sBuffer.makeStringAndClear()
1862 catch( const Exception& )
1864 OSL_FAIL( "OControlExport::exportCellBindingAttributes: caught an exception!" );
1868 //---------------------------------------------------------------------
1869 void OControlExport::exportXFormsBindAttributes()
1871 OUString sBindName = getXFormsBindName( m_xProps );
1872 AddAttribute( XML_NAMESPACE_XFORMS, XML_BIND, sBindName );
1874 //---------------------------------------------------------------------
1875 void OControlExport::exportXFormsListAttributes()
1877 OUString sBindName = getXFormsListBindName( m_xProps );
1878 AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_LIST_SOURCE, sBindName );
1880 //---------------------------------------------------------------------
1881 void OControlExport::exportXFormsSubmissionAttributes()
1883 OUString sSubmission = getXFormsSubmissionName( m_xProps );
1884 AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_SUBMISSION, sSubmission );
1886 //---------------------------------------------------------------------
1887 void OControlExport::exportCellListSourceRange( )
1891 Reference< XListEntrySink > xSink( m_xProps, UNO_QUERY );
1892 Reference< XListEntrySource > xSource;
1893 if ( xSink.is() )
1894 xSource = xSource.query( xSink->getListEntrySource() );
1895 OSL_ENSURE( xSource.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1896 if ( xSource.is() )
1898 FormCellBindingHelper aHelper( m_xProps, NULL );
1900 AddAttribute(
1901 OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE ),
1902 OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ),
1903 aHelper.getStringAddressFromCellListSource( xSource )
1907 catch( const Exception& )
1909 OSL_FAIL( "OControlExport::exportCellListSourceRange: caught an exception!" );
1913 //---------------------------------------------------------------------
1914 void OControlExport::exportImagePositionAttributes()
1918 sal_Int16 nImagePosition = ImagePosition::Centered;
1919 OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_IMAGE_POSITION ) >>= nImagePosition );
1920 OSL_ENSURE( ( nImagePosition >= ImagePosition::LeftTop ) && ( nImagePosition <= ImagePosition::Centered ),
1921 "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1923 if ( ( nImagePosition < ImagePosition::LeftTop ) || ( nImagePosition > ImagePosition::Centered ) )
1924 // this is important to prevent potential buffer overflows below, so don't optimize
1925 nImagePosition = ImagePosition::Centered;
1927 if ( nImagePosition == ImagePosition::Centered )
1929 AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( XML_CENTER ) );
1931 else
1933 XMLTokenEnum eXmlImagePositions[] =
1935 XML_START, XML_END, XML_TOP, XML_BOTTOM
1937 XMLTokenEnum eXmlImageAligns[] =
1939 XML_START, XML_CENTER, XML_END
1942 XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ nImagePosition / 3 ];
1943 XMLTokenEnum eXmlImageAlign = eXmlImageAligns [ nImagePosition % 3 ];
1945 AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( eXmlImagePosition ) );
1946 AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_ALIGN ), GetXMLToken( eXmlImageAlign ) );
1949 exportedProperty( PROPERTY_IMAGE_POSITION );
1950 // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1951 // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1952 // we don't need to export ImageAlign anymore
1953 exportedProperty( PROPERTY_IMAGE_ALIGN );
1955 catch( const Exception& )
1957 DBG_UNHANDLED_EXCEPTION();
1961 //---------------------------------------------------------------------
1962 bool OControlExport::controlHasActiveDataBinding() const
1966 // currently exchanging the data with a database column?
1967 OUString sBoundFieldPropertyName( "BoundField" );
1968 if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( sBoundFieldPropertyName ) )
1970 Reference< XPropertySet > xBoundField;
1971 m_xProps->getPropertyValue( sBoundFieldPropertyName ) >>= xBoundField;
1972 if ( xBoundField.is() )
1973 return true;
1976 // currently exchanging data with an external binding?
1977 Reference< XBindableValue > xBindable( m_xProps, UNO_QUERY );
1978 if ( xBindable.is() && xBindable->getValueBinding().is() )
1979 return true;
1981 catch( const Exception& )
1983 OSL_FAIL( "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
1986 return false;
1989 //---------------------------------------------------------------------
1990 bool OControlExport::controlHasUserSuppliedListEntries() const
1994 // an external list source?
1995 Reference< XListEntrySink > xEntrySink( m_xProps, UNO_QUERY );
1996 if ( xEntrySink.is() && xEntrySink->getListEntrySource().is() )
1997 return false;
1999 if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( PROPERTY_LISTSOURCETYPE ) )
2001 ListSourceType eListSourceType = ListSourceType_VALUELIST;
2002 OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eListSourceType );
2003 if ( eListSourceType == ListSourceType_VALUELIST )
2004 // for value lists, the list entries as entered by the user are used
2005 return true;
2007 // for every other type, the list entries are filled with some data obtained
2008 // from a database - if and only if the ListSource property is not empty
2009 return getScalarListSourceValue().isEmpty();
2012 catch( const Exception& )
2014 OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: caught an exception!" );
2017 OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
2018 // this method should be called for list and combo boxes only
2019 return true;
2022 //=====================================================================
2023 //= OColumnExport
2024 //=====================================================================
2025 //---------------------------------------------------------------------
2026 OColumnExport::OColumnExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl, const OUString& _rControlId,
2027 const Sequence< ScriptEventDescriptor >& _rEvents)
2028 :OControlExport(_rContext, _rxControl, _rControlId, OUString(), _rEvents)
2032 //---------------------------------------------------------------------
2033 OColumnExport::~OColumnExport()
2035 implEndElement();
2038 //---------------------------------------------------------------------
2039 void OColumnExport::exportServiceNameAttribute()
2041 // the attribute "service name" (which has a slightly different meaning for columns
2042 DBG_CHECK_PROPERTY( PROPERTY_COLUMNSERVICENAME, OUString );
2043 OUString sColumnServiceName;
2044 m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName;
2045 // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
2046 // real service name for the column (for use with the XGridColumnFactory) is only the last
2047 // token of this complete name.
2048 sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.');
2049 OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!");
2050 sColumnServiceName = sColumnServiceName.copy(nLastSep + 1);
2051 sColumnServiceName =
2052 m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
2053 XML_NAMESPACE_OOO, sColumnServiceName );
2054 // add the attribute
2055 AddAttribute( OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME)
2056 , OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME)
2057 , sColumnServiceName);
2058 // flag the property as "handled"
2059 exportedProperty(PROPERTY_COLUMNSERVICENAME);
2063 //---------------------------------------------------------------------
2064 const sal_Char* OColumnExport::getOuterXMLElementName() const
2066 return "column";
2069 //---------------------------------------------------------------------
2070 void OColumnExport::exportAttributes()
2072 OControlExport::exportAttributes();
2074 // the attribute "label"
2075 exportStringPropertyAttribute(
2076 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
2077 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
2078 PROPERTY_LABEL);
2080 // the style attribute
2081 OUString sStyleName = m_rContext.getObjectStyleName( m_xProps );
2082 if ( !sStyleName.isEmpty() )
2084 AddAttribute(
2085 OAttributeMetaData::getSpecialAttributeNamespace( SCA_COLUMN_STYLE_NAME ),
2086 OAttributeMetaData::getSpecialAttributeName( SCA_COLUMN_STYLE_NAME ),
2087 sStyleName
2092 //---------------------------------------------------------------------
2093 void OColumnExport::examine()
2095 OControlExport::examine();
2097 // grid columns miss some properties of the controls they're representing
2098 m_nIncludeCommon &= ~(CCA_FOR | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_LABEL);
2099 m_nIncludeSpecial &= ~(SCA_ECHO_CHAR | SCA_AUTOMATIC_COMPLETION | SCA_MULTIPLE | SCA_MULTI_LINE);
2101 if (FormComponentType::DATEFIELD != m_nClassId)
2102 // except date fields, no column has the DropDown property
2103 m_nIncludeCommon &= ~CCA_DROPDOWN;
2106 //=====================================================================
2107 //= OFormExport
2108 //=====================================================================
2109 //---------------------------------------------------------------------
2110 OFormExport::OFormExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxForm,
2111 const Sequence< ScriptEventDescriptor >& _rEvents)
2112 :OElementExport(_rContext, _rxForm, _rEvents)
2113 ,m_bCreateConnectionResourceElement(sal_False)
2115 OSL_ENSURE(m_xProps.is(), "OFormExport::OFormExport: invalid arguments!");
2118 //---------------------------------------------------------------------
2119 const sal_Char* OFormExport::getXMLElementName() const
2121 return "form";
2124 //---------------------------------------------------------------------
2125 void OFormExport::exportSubTags()
2127 if ( m_bCreateConnectionResourceElement && m_xProps.is() )
2129 m_rContext.getGlobalContext().ClearAttrList();
2130 OUString sPropValue;
2131 m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; // if set it is a file url
2132 if ( sPropValue.isEmpty() )
2133 m_xProps->getPropertyValue( PROPERTY_URL ) >>= sPropValue;
2134 if ( !sPropValue.isEmpty() )
2135 AddAttribute(
2136 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_LOCATION),
2137 OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION),
2138 sPropValue);
2139 if ( m_rContext.getGlobalContext().GetAttrList().getLength() )
2141 SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, xmloff::token::XML_CONNECTION_RESOURCE, sal_True, sal_True);
2145 // let the base class export the remaining properties and the events
2146 OElementExport::exportSubTags();
2147 // loop through all children
2148 Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY);
2149 OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspic�ous!");
2151 if (xCollection.is())
2152 m_rContext.exportCollectionElements(xCollection);
2155 //---------------------------------------------------------------------
2156 void OFormExport::exportAttributes()
2158 sal_Int32 i=0;
2160 // ---------------------
2161 // the string properties
2163 static FormAttributes eStringPropertyIds[] =
2165 faName, /*faAction,*/ faCommand, faFilter, faOrder
2167 static OUString aStringPropertyNames[] =
2169 OUString(PROPERTY_NAME), /*OUString(PROPERTY_TARGETURL),*/ OUString(PROPERTY_COMMAND), OUString(PROPERTY_FILTER), OUString(PROPERTY_ORDER)
2171 sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]);
2172 #if OSL_DEBUG_LEVEL > 0
2173 sal_Int32 nNameCount = sizeof(aStringPropertyNames) / sizeof(aStringPropertyNames[0]);
2174 OSL_ENSURE((nIdCount == nNameCount),
2175 "OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2176 #endif
2177 for (i=0; i<nIdCount; ++i)
2178 exportStringPropertyAttribute(
2179 OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]),
2180 OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]),
2181 aStringPropertyNames[i]);
2183 // #i112082# xlink:type is added as part of exportTargetLocationAttribute
2185 // now export the data source name or databaselocation or connection resource
2186 OUString sPropValue;
2187 m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue;
2188 m_bCreateConnectionResourceElement = sPropValue.isEmpty();
2189 if ( !m_bCreateConnectionResourceElement )
2191 INetURLObject aURL(sPropValue);
2192 m_bCreateConnectionResourceElement = ( aURL.GetProtocol() == INET_PROT_FILE );
2193 if ( !m_bCreateConnectionResourceElement )
2194 exportStringPropertyAttribute(
2195 OAttributeMetaData::getFormAttributeNamespace(faDatasource),
2196 OAttributeMetaData::getFormAttributeName(faDatasource),
2197 PROPERTY_DATASOURCENAME);
2199 else
2200 exportedProperty(PROPERTY_URL);
2201 if ( m_bCreateConnectionResourceElement )
2202 exportedProperty(PROPERTY_DATASOURCENAME);
2205 // the boolean properties
2207 static FormAttributes eBooleanPropertyIds[] =
2209 faAllowDeletes, faAllowInserts, faAllowUpdates, faApplyFilter, faEscapeProcessing, faIgnoreResult
2211 static const OUString pBooleanPropertyNames[] =
2213 OUString(PROPERTY_ALLOWDELETES),
2214 OUString(PROPERTY_ALLOWINSERTS),
2215 OUString(PROPERTY_ALLOWUPDATES),
2216 OUString(PROPERTY_APPLYFILTER),
2217 OUString(PROPERTY_ESCAPEPROCESSING),
2218 OUString(PROPERTY_IGNORERESULT)
2220 static sal_Int8 nBooleanPropertyAttrFlags[] =
2222 BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE
2224 sal_Int32 nIdCount = sizeof(eBooleanPropertyIds) / sizeof(eBooleanPropertyIds[0]);
2225 #if OSL_DEBUG_LEVEL > 0
2226 sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
2227 sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
2228 OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
2229 "OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2230 #endif
2231 for (i=0; i<nIdCount; ++i)
2232 exportBooleanPropertyAttribute(
2233 OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds[i]),
2234 OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds[i]),
2235 pBooleanPropertyNames[i],
2236 nBooleanPropertyAttrFlags[i]
2240 // the enum properties
2242 static FormAttributes eEnumPropertyIds[] =
2244 faEnctype, faMethod, faCommandType, faNavigationMode, faTabbingCycle
2246 static const OUString pEnumPropertyNames[] =
2248 OUString(PROPERTY_SUBMIT_ENCODING), OUString(PROPERTY_SUBMIT_METHOD), OUString(PROPERTY_COMMAND_TYPE), OUString(PROPERTY_NAVIGATION), OUString(PROPERTY_CYCLE)
2250 static OEnumMapper::EnumProperties eEnumPropertyMaps[] =
2252 OEnumMapper::epSubmitEncoding, OEnumMapper::epSubmitMethod, OEnumMapper::epCommandType, OEnumMapper::epNavigationType, OEnumMapper::epTabCyle
2254 static sal_Int32 nEnumPropertyAttrDefaults[] =
2256 FormSubmitEncoding_URL, FormSubmitMethod_GET, CommandType::COMMAND, NavigationBarMode_CURRENT, TabulatorCycle_RECORDS
2258 static sal_Bool nEnumPropertyAttrDefaultFlags[] =
2260 sal_False, sal_False, sal_False, sal_False, sal_True
2262 sal_Int32 nIdCount = sizeof(eEnumPropertyIds) / sizeof(eEnumPropertyIds[0]);
2263 #if OSL_DEBUG_LEVEL > 0
2264 sal_Int32 nNameCount = sizeof(pEnumPropertyNames) / sizeof(pEnumPropertyNames[0]);
2265 sal_Int32 nDefaultCount = sizeof(nEnumPropertyAttrDefaults) / sizeof(nEnumPropertyAttrDefaults[0]);
2266 sal_Int32 nDefaultFlagCount = sizeof(nEnumPropertyAttrDefaultFlags) / sizeof(nEnumPropertyAttrDefaultFlags[0]);
2267 sal_Int32 nMapCount = sizeof(eEnumPropertyMaps) / sizeof(eEnumPropertyMaps[0]);
2268 OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount) && (nDefaultCount == nDefaultFlagCount) && (nDefaultFlagCount == nMapCount),
2269 "OFormExport::exportAttributes: somebody tampered with the maps (3)!");
2270 #endif
2271 for (i=0; i<nIdCount; ++i)
2272 exportEnumPropertyAttribute(
2273 OAttributeMetaData::getFormAttributeNamespace(eEnumPropertyIds[i]),
2274 OAttributeMetaData::getFormAttributeName(eEnumPropertyIds[i]),
2275 pEnumPropertyNames[i],
2276 OEnumMapper::getEnumMap(eEnumPropertyMaps[i]),
2277 nEnumPropertyAttrDefaults[i],
2278 nEnumPropertyAttrDefaultFlags[i]
2282 // the service name
2283 exportServiceNameAttribute();
2284 // the target frame
2285 exportTargetFrameAttribute();
2286 // the target URL
2287 exportTargetLocationAttribute(true); // #i110911# add type attribute (for form, but not for control)
2289 // master fields
2290 exportStringSequenceAttribute(
2291 OAttributeMetaData::getFormAttributeNamespace(faMasterFields),
2292 OAttributeMetaData::getFormAttributeName(faMasterFields),
2293 PROPERTY_MASTERFIELDS);
2294 // detail fields
2295 exportStringSequenceAttribute(
2296 OAttributeMetaData::getFormAttributeNamespace(faDetailFiels),
2297 OAttributeMetaData::getFormAttributeName(faDetailFiels),
2298 PROPERTY_DETAILFIELDS);
2300 //.........................................................................
2301 } // namespace xmloff
2302 //.........................................................................
2304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */