1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: elementexport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include "elementexport.hxx"
35 #include "strings.hxx"
36 #include "xmlnmspe.hxx"
37 #include "eventexport.hxx"
38 #include "formenums.hxx"
39 #include "formcellbinding.hxx"
40 #include "formcellbinding.hxx"
41 #include "xformsexport.hxx"
43 /** === begin UNO includes === **/
44 #include <com/sun/star/text/XText.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/io/XPersistObject.hpp>
47 #include <com/sun/star/form/FormComponentType.hpp>
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
49 #include <com/sun/star/form/FormSubmitEncoding.hpp>
50 #include <com/sun/star/form/FormSubmitMethod.hpp>
51 #include <com/sun/star/sdb/CommandType.hpp>
52 #include <com/sun/star/form/NavigationBarMode.hpp>
53 #include <com/sun/star/form/TabulatorCycle.hpp>
54 #include <com/sun/star/form/FormButtonType.hpp>
55 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
56 #include <com/sun/star/awt/VisualEffect.hpp>
57 #include <com/sun/star/form/ListSourceType.hpp>
58 #include <com/sun/star/awt/ImagePosition.hpp>
59 /** === end UNO includes === **/
61 #include <vcl/wintypes.hxx> // for check states
62 #include <xmloff/txtprmap.hxx>
63 #include <com/sun/star/form/binding/XBindableValue.hpp>
64 #include <com/sun/star/form/binding/XListEntrySink.hpp>
65 #include <tools/urlobj.hxx>
66 #include <xmloff/xmlexp.hxx>
67 #include <xmloff/nmspmap.hxx>
68 #include <vcl/wintypes.hxx> // for check states
69 #include <xmloff/XMLEventExport.hxx>
70 #include <xmloff/xmluconv.hxx>
71 #include <xmloff/xmltoken.hxx>
72 #include <tools/time.hxx>
73 #include <tools/diagnose_ex.h>
74 #include <comphelper/extract.hxx>
79 //.........................................................................
82 //.........................................................................
84 #if OSL_DEBUG_LEVEL > 0
85 #define RESET_BIT( bitfield, bit ) \
86 bitfield = bitfield & ~bit
88 #define RESET_BIT( bitfield, bit )
91 using namespace ::xmloff::token
;
92 using namespace ::com::sun::star::uno
;
93 using namespace ::com::sun::star::sdb
;
94 using namespace ::com::sun::star::awt
;
95 using namespace ::com::sun::star::form
;
96 using namespace ::com::sun::star::lang
;
97 using namespace ::com::sun::star::lang
;
98 using namespace ::com::sun::star::beans
;
99 using namespace ::com::sun::star::container
;
100 using namespace ::com::sun::star::script
;
101 using namespace ::com::sun::star::io
;
102 using namespace ::com::sun::star::table
;
103 using namespace ::com::sun::star::text
;
104 using namespace ::com::sun::star::form::binding
;
106 //=====================================================================
108 //=====================================================================
109 OElementExport::OElementExport(IFormsExportContext
& _rContext
, const Reference
< XPropertySet
>& _rxProps
,
110 const Sequence
< ScriptEventDescriptor
>& _rEvents
)
111 :OPropertyExport(_rContext
, _rxProps
)
117 //---------------------------------------------------------------------
118 OElementExport::~OElementExport()
123 //---------------------------------------------------------------------
124 void OElementExport::doExport()
126 // collect some general information about the element
129 // first add the attributes necessary for the element
130 m_rContext
.getGlobalContext().ClearAttrList();
132 // add the attributes
135 // start the XML element
136 implStartElement(getXMLElementName());
138 // the sub elements (mostly control type dependent)
144 //---------------------------------------------------------------------
145 void OElementExport::examine()
147 // nothing to do here
150 //---------------------------------------------------------------------
151 void OElementExport::exportAttributes()
153 // nothing to do here
156 //---------------------------------------------------------------------
157 void OElementExport::exportSubTags()
159 // the properties which where not exported 'til now
160 exportRemainingProperties();
162 // the script:events sub tags
166 //---------------------------------------------------------------------
167 void OElementExport::implStartElement(const sal_Char
* _pName
)
169 m_pXMLElement
= new SvXMLElementExport(m_rContext
.getGlobalContext(), XML_NAMESPACE_FORM
, _pName
, sal_True
, sal_True
);
172 //---------------------------------------------------------------------
173 void OElementExport::implEndElement()
175 delete m_pXMLElement
;
176 m_pXMLElement
= NULL
;
179 //---------------------------------------------------------------------
180 void OElementExport::exportServiceNameAttribute()
182 Reference
< XPersistObject
> xPersistence(m_xProps
, UNO_QUERY
);
183 if (!xPersistence
.is())
185 OSL_ENSURE(sal_False
, "OElementExport::exportServiceNameAttribute: no XPersistObject!");
189 ::rtl::OUString sServiceName
= xPersistence
->getServiceName();
190 // we don't want to write the old service name directly: it's a name used for compatibility reasons, but
191 // as we start some kind of new file format here (with this xml export), we don't care about
193 // So we translate the old persistence service name into new ones, if possible
195 ::rtl::OUString sToWriteServiceName
= sServiceName
;
196 #define CHECK_N_TRANSLATE( name ) \
197 else if (0 == sServiceName.compareToAscii(SERVICE_PERSISTENT_COMPONENT_##name)) \
198 sToWriteServiceName = SERVICE_##name
202 CHECK_N_TRANSLATE( FORM
);
203 CHECK_N_TRANSLATE( FORM
);
204 CHECK_N_TRANSLATE( LISTBOX
);
205 CHECK_N_TRANSLATE( COMBOBOX
);
206 CHECK_N_TRANSLATE( RADIOBUTTON
);
207 CHECK_N_TRANSLATE( GROUPBOX
);
208 CHECK_N_TRANSLATE( FIXEDTEXT
);
209 CHECK_N_TRANSLATE( COMMANDBUTTON
);
210 CHECK_N_TRANSLATE( CHECKBOX
);
211 CHECK_N_TRANSLATE( GRID
);
212 CHECK_N_TRANSLATE( IMAGEBUTTON
);
213 CHECK_N_TRANSLATE( FILECONTROL
);
214 CHECK_N_TRANSLATE( TIMEFIELD
);
215 CHECK_N_TRANSLATE( DATEFIELD
);
216 CHECK_N_TRANSLATE( NUMERICFIELD
);
217 CHECK_N_TRANSLATE( CURRENCYFIELD
);
218 CHECK_N_TRANSLATE( PATTERNFIELD
);
219 CHECK_N_TRANSLATE( HIDDENCONTROL
);
220 CHECK_N_TRANSLATE( IMAGECONTROL
);
221 CHECK_N_TRANSLATE( FORMATTEDFIELD
);
222 else if (0 == sServiceName
.compareToAscii(SERVICE_PERSISTENT_COMPONENT_EDIT
))
223 { // special handling for the edit field: we have two controls using this as persistence service name
224 sToWriteServiceName
= SERVICE_EDIT
;
225 Reference
< XServiceInfo
> xSI(m_xProps
, UNO_QUERY
);
226 if (xSI
.is() && xSI
->supportsService(SERVICE_FORMATTEDFIELD
))
227 sToWriteServiceName
= SERVICE_FORMATTEDFIELD
;
229 #if OSL_DEBUG_LEVEL > 0
230 Reference
< XServiceInfo
> xSI(m_xProps
, UNO_QUERY
);
231 OSL_ENSURE(xSI
.is() && xSI
->supportsService(sToWriteServiceName
),
232 "OElementExport::exportServiceNameAttribute: wrong service name translation!");
235 sToWriteServiceName
=
236 m_rContext
.getGlobalContext().GetNamespaceMap().GetQNameByKey(
237 XML_NAMESPACE_OOO
, sToWriteServiceName
);
241 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME
),
242 OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME
),
243 sToWriteServiceName
);
246 //---------------------------------------------------------------------
247 void OElementExport::exportEvents()
249 if (!m_aEvents
.getLength())
253 Reference
< XNameReplace
> xWrapper
= new OEventDescriptorMapper(m_aEvents
);
254 m_rContext
.getGlobalContext().GetEventExport().Export(xWrapper
);
257 //=====================================================================
259 //=====================================================================
260 //---------------------------------------------------------------------
261 OControlExport::OControlExport(IFormsExportContext
& _rContext
, const Reference
< XPropertySet
>& _rxControl
,
262 const ::rtl::OUString
& _rControlId
, const ::rtl::OUString
& _rReferringControls
,
263 const Sequence
< ScriptEventDescriptor
>& _rEvents
)
264 :OElementExport(_rContext
, _rxControl
, _rEvents
)
265 ,m_sControlId(_rControlId
)
266 ,m_sReferringControls(_rReferringControls
)
267 ,m_nClassId(FormComponentType::CONTROL
)
270 ,m_nIncludeDatabase(0)
271 ,m_nIncludeSpecial(0)
273 ,m_nIncludeBindings(0)
274 ,m_pOuterElement(NULL
)
276 OSL_ENSURE(m_xProps
.is(), "OControlExport::OControlExport: invalid arguments!");
279 //---------------------------------------------------------------------
280 OControlExport::~OControlExport()
285 //---------------------------------------------------------------------
286 void OControlExport::exportOuterAttributes()
289 if (CCA_NAME
& m_nIncludeCommon
)
291 exportStringPropertyAttribute(
292 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_NAME
),
293 OAttributeMetaData::getCommonControlAttributeName(CCA_NAME
),
296 #if OSL_DEBUG_LEVEL > 0
297 // reset the bit for later checking
298 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_NAME
;
303 if (m_nIncludeCommon
& CCA_SERVICE_NAME
)
305 exportServiceNameAttribute();
306 #if OSL_DEBUG_LEVEL > 0
307 // reset the bit for later checking
308 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_SERVICE_NAME
;
313 //---------------------------------------------------------------------
314 void OControlExport::exportInnerAttributes()
317 if (CCA_CONTROL_ID
& m_nIncludeCommon
)
319 OSL_ENSURE(m_sControlId
.getLength(), "OControlExport::exportInnerAttributes: have no control id for the control!");
321 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CONTROL_ID
),
322 OAttributeMetaData::getCommonControlAttributeName(CCA_CONTROL_ID
),
324 #if OSL_DEBUG_LEVEL > 0
325 // reset the bit for later checking
326 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_CONTROL_ID
;
330 // common control attributes
331 exportCommonControlAttributes();
333 // common database attributes
334 exportDatabaseAttributes();
336 // attributes related to external bindings
337 exportBindingAtributes();
339 // attributes special to the respective control type
340 exportSpecialAttributes();
342 // add the style references to the attributes
343 flagStyleProperties();
346 //---------------------------------------------------------------------
347 void OControlExport::exportAttributes()
349 exportOuterAttributes();
352 //---------------------------------------------------------------------
353 void OControlExport::exportSubTags() throw (Exception
)
355 // for the upcoming exportRemainingProperties:
356 // if a control has the LabelControl property, this is not stored with the control itself, but instead with
357 // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
358 // know anything about this, we need to prevent that it tries to export this property
359 exportedProperty(PROPERTY_CONTROLLABEL
);
361 // if it's a control supporting XText, then we need to declare all text-related properties
362 // as "already exported". This prevents them from being exported as generic "form:property"-tags.
363 // *If* we would export them this way, they would be completely superfluous, and sometimes even
364 // disastrous, since they may, at import time, override paragraph properties which already have
366 Reference
< XText
> xControlText( m_xProps
, UNO_QUERY
);
367 if ( xControlText
.is() )
369 const XMLPropertyMapEntry
* pCharAttributeProperties
= XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_TEXT
);
370 while ( pCharAttributeProperties
->msApiName
)
372 exportedProperty( ::rtl::OUString::createFromAscii( pCharAttributeProperties
->msApiName
) );
373 ++pCharAttributeProperties
;
376 const XMLPropertyMapEntry
* pParaAttributeProperties
= XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_SHAPE_PARA
);
377 while ( pParaAttributeProperties
->msApiName
)
379 exportedProperty( ::rtl::OUString::createFromAscii( pParaAttributeProperties
->msApiName
) );
380 ++pParaAttributeProperties
;
383 // the RichText property is not exported. The presence of the text:p element
384 // will be used - upon reading - as indicator for the value of the RichText property
385 exportedProperty( PROPERTY_RICH_TEXT
);
387 // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
388 // The former is a short/enum value, the latter a boolean. The former has a real meaning
389 // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
390 // later on imported, it overwrites anything which has previously been imported for
392 // 2004-04-14 - #i27729# - fs@openoffice.org
393 exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharCrossedOut" ) ) );
396 if ( m_eType
== LISTBOX
)
398 // will be exported in exportListSourceAsElements:
399 if ( controlHasUserSuppliedListEntries() )
400 exportedProperty( PROPERTY_DEFAULT_SELECT_SEQ
);
402 // will not be exported in a generic way. Either exportListSourceAsElements cares
403 // for them, or we don't need them
404 exportedProperty( PROPERTY_STRING_ITEM_LIST
);
405 exportedProperty( PROPERTY_VALUE_SEQ
);
406 exportedProperty( PROPERTY_SELECT_SEQ
);
407 exportedProperty( PROPERTY_LISTSOURCE
);
409 if ( m_eType
== COMBOBOX
)
410 exportedProperty( PROPERTY_STRING_ITEM_LIST
);
412 // let the base class export the remaining properties and the events
413 OElementExport::exportSubTags();
415 // special sub tags for some controls
419 // don't export the list entries if the are not provided by the user, but obtained implicitly
420 // from other sources
421 // #i26944# - 2004-05-17 - fs@openoffice.org
422 if ( controlHasUserSuppliedListEntries() )
423 exportListSourceAsElements();
426 { // a grid control requires us to store all columns as sub elements
427 Reference
< XIndexAccess
> xColumnContainer(m_xProps
, UNO_QUERY
);
428 OSL_ENSURE(xColumnContainer
.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
429 if (xColumnContainer
.is())
430 m_rContext
.exportCollectionElements(xColumnContainer
);
434 { // a combox box description has sub elements: the items
435 DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST
, Sequence
< ::rtl::OUString
> );
437 // don't export the list entries if the are not provided by the user, but obtained implicitly
438 // from other sources
439 // #i26944# - 2004-05-17 - fs@openoffice.org
440 if ( controlHasUserSuppliedListEntries() )
443 Sequence
< ::rtl::OUString
> aListItems
;
444 m_xProps
->getPropertyValue(PROPERTY_STRING_ITEM_LIST
) >>= aListItems
;
445 // loop through it and write the sub elements
446 const ::rtl::OUString
* pListItems
= aListItems
.getConstArray();
447 for (sal_Int32 i
=0; i
<aListItems
.getLength(); ++i
, ++pListItems
)
449 m_rContext
.getGlobalContext().ClearAttrList();
451 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL
),
452 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL
),
454 SvXMLElementExport
aFormElement(m_rContext
.getGlobalContext(), XML_NAMESPACE_FORM
, "item", sal_True
, sal_True
);
462 // if we act as rich text control, we need to export some text:p elements
463 if ( xControlText
.is() )
465 sal_Bool bActingAsRichText
= sal_False
;
466 if ( m_xPropertyInfo
->hasPropertyByName( PROPERTY_RICH_TEXT
) )
468 OSL_VERIFY(m_xProps
->getPropertyValue( PROPERTY_RICH_TEXT
) >>= bActingAsRichText
);
471 if ( bActingAsRichText
)
472 m_rContext
.getGlobalContext().GetTextParagraphExport()->exportText( xControlText
);
482 //---------------------------------------------------------------------
483 void OControlExport::exportCommonControlAttributes()
487 // I decided to handle all the properties here with some static arrays describing the property-attribute
488 // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
489 // would require maps and O(log n) searches, which seems somewhat expensive as this code is used
492 // the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
493 // map identifiers from the wrong block
495 // --------------------------------------------------------------------
496 // some string properties
498 // the attribute ids of all properties which are expected to be of type string
499 static sal_Int32 nStringPropertyAttributeIds
[] =
503 // the names of all properties which are expected to be of type string
504 static ::rtl::OUString aStringPropertyNames
[] =
506 PROPERTY_LABEL
, PROPERTY_TITLE
508 OSL_ENSURE( sizeof(aStringPropertyNames
)/sizeof(aStringPropertyNames
[0]) ==
509 sizeof(nStringPropertyAttributeIds
)/sizeof(nStringPropertyAttributeIds
[0]),
510 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
512 for (i
=0; i
<sizeof(nStringPropertyAttributeIds
)/sizeof(nStringPropertyAttributeIds
[0]); ++i
)
513 if (nStringPropertyAttributeIds
[i
] & m_nIncludeCommon
)
515 exportStringPropertyAttribute(
516 OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds
[i
]),
517 OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds
[i
]),
518 aStringPropertyNames
[i
]
520 #if OSL_DEBUG_LEVEL > 0
521 // reset the bit for later checking
522 m_nIncludeCommon
= m_nIncludeCommon
& ~nStringPropertyAttributeIds
[i
];
527 // --------------------------------------------------------------------
528 // some boolean properties
530 static sal_Int32 nBooleanPropertyAttributeIds
[] =
532 CCA_CURRENT_SELECTED
, CCA_DISABLED
, CCA_DROPDOWN
, CCA_PRINTABLE
, CCA_READONLY
, CCA_SELECTED
, CCA_TAB_STOP
, CCA_ENABLEVISIBLE
534 static const ::rtl::OUString
* pBooleanPropertyNames
[] =
536 &PROPERTY_STATE
, &PROPERTY_ENABLED
, &PROPERTY_DROPDOWN
, &PROPERTY_PRINTABLE
, &PROPERTY_READONLY
, &PROPERTY_DEFAULT_STATE
, &PROPERTY_TABSTOP
, &PROPERTY_ENABLEVISIBLE
538 static sal_Bool nBooleanPropertyAttrFlags
[] =
539 { // attribute defaults
540 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
542 #if OSL_DEBUG_LEVEL > 0
543 sal_Int32 nIdCount
= sizeof(nBooleanPropertyAttributeIds
) / sizeof(nBooleanPropertyAttributeIds
[0]);
544 sal_Int32 nNameCount
= sizeof(pBooleanPropertyNames
) / sizeof(pBooleanPropertyNames
[0]);
545 sal_Int32 nFlagsCount
= sizeof(nBooleanPropertyAttrFlags
) / sizeof(nBooleanPropertyAttrFlags
[0]);
546 OSL_ENSURE((nIdCount
== nNameCount
) && (nNameCount
== nFlagsCount
),
547 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
549 for (i
=0; i
<sizeof(nBooleanPropertyAttributeIds
)/sizeof(nBooleanPropertyAttributeIds
[0]); ++i
)
550 if (nBooleanPropertyAttributeIds
[i
] & m_nIncludeCommon
)
552 exportBooleanPropertyAttribute(
553 OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds
[i
]),
554 OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds
[i
]),
555 *(pBooleanPropertyNames
[i
]),
556 nBooleanPropertyAttrFlags
[i
]);
557 #if OSL_DEBUG_LEVEL > 0
558 // reset the bit for later checking
559 m_nIncludeCommon
= m_nIncludeCommon
& ~nBooleanPropertyAttributeIds
[i
];
565 // --------------------------------------------------------------------
566 // some integer properties
568 // now the common handling
569 static sal_Int32 nIntegerPropertyAttributeIds
[] =
571 CCA_SIZE
, CCA_TAB_INDEX
573 static const ::rtl::OUString
* pIntegerPropertyNames
[] =
575 &PROPERTY_LINECOUNT
, &PROPERTY_TABINDEX
577 static const sal_Int16 nIntegerPropertyAttrDefaults
[] =
578 { // attribute defaults
582 if ( m_nIncludeCommon
& CCA_MAX_LENGTH
)
583 exportedProperty(PROPERTY_MAXTEXTLENGTH
);
585 #if OSL_DEBUG_LEVEL > 0
586 sal_Int32 nIdCount
= sizeof(nIntegerPropertyAttributeIds
) / sizeof(nIntegerPropertyAttributeIds
[0]);
587 sal_Int32 nNameCount
= sizeof(pIntegerPropertyNames
) / sizeof(pIntegerPropertyNames
[0]);
588 sal_Int32 nDefaultCount
= sizeof(nIntegerPropertyAttrDefaults
) / sizeof(nIntegerPropertyAttrDefaults
[0]);
589 OSL_ENSURE((nIdCount
== nNameCount
) && (nNameCount
== nDefaultCount
),
590 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
592 for (i
=0; i
<sizeof(nIntegerPropertyAttributeIds
)/sizeof(nIntegerPropertyAttributeIds
[0]); ++i
)
593 if (nIntegerPropertyAttributeIds
[i
] & m_nIncludeCommon
)
595 exportInt16PropertyAttribute(
596 OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds
[i
]),
597 OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds
[i
]),
598 *(pIntegerPropertyNames
[i
]),
599 nIntegerPropertyAttrDefaults
[i
]);
600 #if OSL_DEBUG_LEVEL > 0
601 // reset the bit for later checking
602 m_nIncludeCommon
= m_nIncludeCommon
& ~nIntegerPropertyAttributeIds
[i
];
609 // --------------------------------------------------------------------
610 // some enum properties
612 if (m_nIncludeCommon
& CCA_BUTTON_TYPE
)
614 exportEnumPropertyAttribute(
615 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_BUTTON_TYPE
),
616 OAttributeMetaData::getCommonControlAttributeName(CCA_BUTTON_TYPE
),
618 OEnumMapper::getEnumMap(OEnumMapper::epButtonType
),
619 FormButtonType_PUSH
);
620 #if OSL_DEBUG_LEVEL > 0
621 // reset the bit for later checking
622 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_BUTTON_TYPE
;
625 if ( m_nIncludeCommon
& CCA_ORIENTATION
)
627 exportEnumPropertyAttribute(
628 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_ORIENTATION
),
629 OAttributeMetaData::getCommonControlAttributeName( CCA_ORIENTATION
),
630 PROPERTY_ORIENTATION
,
631 OEnumMapper::getEnumMap( OEnumMapper::epOrientation
),
632 ScrollBarOrientation::HORIZONTAL
634 #if OSL_DEBUG_LEVEL > 0
635 // reset the bit for later checking
636 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_ORIENTATION
;
640 if ( m_nIncludeCommon
& CCA_VISUAL_EFFECT
)
642 exportEnumPropertyAttribute(
643 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_VISUAL_EFFECT
),
644 OAttributeMetaData::getCommonControlAttributeName( CCA_VISUAL_EFFECT
),
645 PROPERTY_VISUAL_EFFECT
,
646 OEnumMapper::getEnumMap( OEnumMapper::epVisualEffect
),
649 #if OSL_DEBUG_LEVEL > 0
650 // reset the bit for later checking
651 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_VISUAL_EFFECT
;
656 // --------------------------------------------------------------------
657 // some properties which require a special handling
660 if (m_nIncludeCommon
& CCA_TARGET_FRAME
)
662 exportTargetFrameAttribute();
663 #if OSL_DEBUG_LEVEL > 0
664 // reset the bit for later checking
665 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_TARGET_FRAME
;
670 if ( m_nIncludeCommon
& CCA_MAX_LENGTH
)
672 // normally, the respective property would be "MaxTextLen"
673 // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
675 // determine the name of the property to export
676 ::rtl::OUString
sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH
);
677 if ( m_xPropertyInfo
->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH
) )
678 sTextLenPropertyName
= PROPERTY_PERSISTENCE_MAXTEXTLENGTH
;
681 exportInt16PropertyAttribute(
682 OAttributeMetaData::getCommonControlAttributeNamespace( CCA_MAX_LENGTH
),
683 OAttributeMetaData::getCommonControlAttributeName( CCA_MAX_LENGTH
),
684 sTextLenPropertyName
,
688 // in either way, both properties count as "exported"
689 exportedProperty( PROPERTY_MAXTEXTLENGTH
);
690 exportedProperty( PROPERTY_PERSISTENCE_MAXTEXTLENGTH
);
692 #if OSL_DEBUG_LEVEL > 0
693 // reset the bit for later checking
694 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_MAX_LENGTH
;
698 if (m_nIncludeCommon
& CCA_TARGET_LOCATION
)
700 exportTargetLocationAttribute();
701 #if OSL_DEBUG_LEVEL > 0
702 // reset the bit for later checking
703 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_TARGET_LOCATION
;
708 if (m_nIncludeCommon
& CCA_IMAGE_DATA
)
710 exportImageDataAttribute();
711 #if OSL_DEBUG_LEVEL > 0
712 // reset the bit for later checking
713 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_IMAGE_DATA
;
719 if (m_nIncludeCommon
& CCA_FOR
)
721 if (m_sReferringControls
.getLength())
722 { // there is at least one control referring to the one we're handling currently
724 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_FOR
),
725 OAttributeMetaData::getCommonControlAttributeName(CCA_FOR
),
726 m_sReferringControls
);
728 #if OSL_DEBUG_LEVEL > 0
729 // reset the bit for later checking
730 m_nIncludeCommon
= m_nIncludeCommon
& ~CCA_FOR
;
734 if ((CCA_CURRENT_VALUE
| CCA_VALUE
) & m_nIncludeCommon
)
736 const sal_Char
* pCurrentValuePropertyName
= NULL
;
737 const sal_Char
* pValuePropertyName
= NULL
;
739 // get the property names
740 getValuePropertyNames(m_eType
, m_nClassId
, pCurrentValuePropertyName
, pValuePropertyName
);
742 static const sal_Char
* pCurrentValueAttributeName
= OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE
);
743 static const sal_Char
* pValueAttributeName
= OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE
);
744 static const sal_uInt16 nCurrentValueAttributeNamespaceKey
= OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_VALUE
);
745 static const sal_uInt16 nValueAttributeNamespaceKey
= OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE
);
747 // add the atrtributes if necessary and possible
748 if (pCurrentValuePropertyName
&& (CCA_CURRENT_VALUE
& m_nIncludeCommon
))
750 // don't export the current-value if this value originates from a data binding
751 // #i26944# - 2004-05-17 - fs@openoffice.org
752 if ( controlHasActiveDataBinding() )
753 exportedProperty( ::rtl::OUString::createFromAscii( pCurrentValuePropertyName
) );
755 exportGenericPropertyAttribute(
756 nCurrentValueAttributeNamespaceKey
,
757 pCurrentValueAttributeName
,
758 pCurrentValuePropertyName
762 if (pValuePropertyName
&& (CCA_VALUE
& m_nIncludeCommon
))
763 exportGenericPropertyAttribute(
764 nValueAttributeNamespaceKey
,
768 OSL_ENSURE((NULL
== pValuePropertyName
) == (0 == (CCA_VALUE
& m_nIncludeCommon
)),
769 "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
770 OSL_ENSURE((NULL
== pCurrentValuePropertyName
) == (0 == (CCA_CURRENT_VALUE
& m_nIncludeCommon
)),
771 "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
773 #if OSL_DEBUG_LEVEL > 0
774 // reset the bit for later checking
775 m_nIncludeCommon
= m_nIncludeCommon
& ~(CCA_CURRENT_VALUE
| CCA_VALUE
);
779 OSL_ENSURE(0 == m_nIncludeCommon
,
780 "OControlExport::exportCommonControlAttributes: forgot some flags!");
781 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
785 //---------------------------------------------------------------------
786 void OControlExport::exportDatabaseAttributes()
788 #if OSL_DEBUG_LEVEL > 0
789 sal_Int32 nIncludeDatabase
= m_nIncludeDatabase
;
791 // the only string property: DataField
792 if (DA_DATA_FIELD
& m_nIncludeDatabase
)
794 exportStringPropertyAttribute(
795 OAttributeMetaData::getDatabaseAttributeNamespace(DA_DATA_FIELD
),
796 OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD
),
798 RESET_BIT( nIncludeDatabase
, DA_DATA_FIELD
);
802 if ( DA_INPUT_REQUIRED
& m_nIncludeDatabase
)
804 exportBooleanPropertyAttribute(
805 OAttributeMetaData::getDatabaseAttributeNamespace( DA_INPUT_REQUIRED
),
806 OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED
),
807 PROPERTY_INPUT_REQUIRED
,
808 BOOLATTR_DEFAULT_TRUE
810 RESET_BIT( nIncludeDatabase
, DA_INPUT_REQUIRED
);
813 // the only int16 property: BoundColumn
814 if (DA_BOUND_COLUMN
& m_nIncludeDatabase
)
816 exportInt16PropertyAttribute(
817 OAttributeMetaData::getDatabaseAttributeNamespace(DA_BOUND_COLUMN
),
818 OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN
),
819 PROPERTY_BOUNDCOLUMN
,
821 RESET_BIT( nIncludeDatabase
, DA_BOUND_COLUMN
);
824 // ConvertEmptyToNull
825 if (DA_CONVERT_EMPTY
& m_nIncludeDatabase
)
827 exportBooleanPropertyAttribute(
828 OAttributeMetaData::getDatabaseAttributeNamespace(DA_CONVERT_EMPTY
),
829 OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY
),
830 PROPERTY_EMPTY_IS_NULL
,
831 BOOLATTR_DEFAULT_FALSE
833 RESET_BIT( nIncludeDatabase
, DA_CONVERT_EMPTY
);
836 // the only enum property: ListSourceType
837 if (DA_LIST_SOURCE_TYPE
& m_nIncludeDatabase
)
839 exportEnumPropertyAttribute(
840 OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE_TYPE
),
841 OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE
),
842 PROPERTY_LISTSOURCETYPE
,
843 OEnumMapper::getEnumMap(OEnumMapper::epListSourceType
),
844 ListSourceType_VALUELIST
846 RESET_BIT( nIncludeDatabase
, DA_LIST_SOURCE_TYPE
);
849 if (m_nIncludeDatabase
& DA_LIST_SOURCE
)
851 exportListSourceAsAttribute();
852 RESET_BIT( nIncludeDatabase
, DA_LIST_SOURCE
);
855 #if OSL_DEBUG_LEVEL > 0
856 OSL_ENSURE(0 == nIncludeDatabase
,
857 "OControlExport::exportDatabaseAttributes: forgot some flags!");
858 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
863 //---------------------------------------------------------------------
864 void OControlExport::exportBindingAtributes()
866 #if OSL_DEBUG_LEVEL > 0
867 sal_Int32 nIncludeBinding
= m_nIncludeBindings
;
870 // ....................................................
871 if ( m_nIncludeBindings
& BA_LINKED_CELL
)
873 exportCellBindingAttributes( ( m_nIncludeBindings
& BA_LIST_LINKING_TYPE
) != 0 );
874 #if OSL_DEBUG_LEVEL > 0
875 // reset the bit for later checking
876 nIncludeBinding
= nIncludeBinding
& ~( BA_LINKED_CELL
| BA_LIST_LINKING_TYPE
);
880 // ....................................................
881 if ( m_nIncludeBindings
& BA_LIST_CELL_RANGE
)
883 exportCellListSourceRange();
884 #if OSL_DEBUG_LEVEL > 0
885 // reset the bit for later checking
886 nIncludeBinding
= nIncludeBinding
& ~BA_LIST_CELL_RANGE
;
890 if ( m_nIncludeBindings
& BA_XFORMS_BIND
)
892 exportXFormsBindAttributes();
893 #if OSL_DEBUG_LEVEL > 0
894 // reset the bit for later checking
895 nIncludeBinding
= nIncludeBinding
& ~BA_XFORMS_BIND
;
899 if ( m_nIncludeBindings
& BA_XFORMS_LISTBIND
)
901 exportXFormsListAttributes();
902 #if OSL_DEBUG_LEVEL > 0
903 // reset the bit for later checking
904 nIncludeBinding
= nIncludeBinding
& ~BA_XFORMS_LISTBIND
;
908 if ( m_nIncludeBindings
& BA_XFORMS_SUBMISSION
)
910 exportXFormsSubmissionAttributes();
911 #if OSL_DEBUG_LEVEL > 0
912 // reset the bit for later checking
913 nIncludeBinding
= nIncludeBinding
& ~BA_XFORMS_SUBMISSION
;
917 OSL_ENSURE( 0 == nIncludeBinding
,
918 "OControlExport::exportBindingAtributes: forgot some flags!");
919 // in the debug version, we should have removed every bit we handled from the mask, so it should
923 //---------------------------------------------------------------------
924 void OControlExport::exportSpecialAttributes()
928 // ----------------------
929 // the boolean properties
931 static const sal_Int32 nBooleanPropertyAttributeIds
[] =
933 SCA_VALIDATION
, SCA_MULTI_LINE
, SCA_AUTOMATIC_COMPLETION
, SCA_MULTIPLE
, SCA_DEFAULT_BUTTON
, SCA_IS_TRISTATE
,
934 SCA_TOGGLE
, SCA_FOCUS_ON_CLICK
936 static const ::rtl::OUString
* pBooleanPropertyNames
[] =
938 &PROPERTY_STRICTFORMAT
, &PROPERTY_MULTILINE
, &PROPERTY_AUTOCOMPLETE
, &PROPERTY_MULTISELECTION
, &PROPERTY_DEFAULTBUTTON
, &PROPERTY_TRISTATE
,
939 &PROPERTY_TOGGLE
, &PROPERTY_FOCUS_ON_CLICK
941 sal_Int32 nIdCount
= sizeof(nBooleanPropertyAttributeIds
) / sizeof(nBooleanPropertyAttributeIds
[0]);
942 #if OSL_DEBUG_LEVEL > 0
943 sal_Int32 nNameCount
= sizeof(pBooleanPropertyNames
) / sizeof(pBooleanPropertyNames
[0]);
944 OSL_ENSURE((nIdCount
== nNameCount
),
945 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
947 const sal_Int32
* pAttributeId
= nBooleanPropertyAttributeIds
;
948 const ::rtl::OUString
** pPropertyName
= pBooleanPropertyNames
;
949 for ( i
= 0; i
< nIdCount
; ++i
, ++pAttributeId
, ++pPropertyName
)
951 if ( *pAttributeId
& m_nIncludeSpecial
)
953 exportBooleanPropertyAttribute(
954 OAttributeMetaData::getSpecialAttributeNamespace( *pAttributeId
),
955 OAttributeMetaData::getSpecialAttributeName( *pAttributeId
),
957 ( *pAttributeId
== SCA_FOCUS_ON_CLICK
) ? BOOLATTR_DEFAULT_TRUE
: BOOLATTR_DEFAULT_FALSE
959 #if OSL_DEBUG_LEVEL > 0
960 // reset the bit for later checking
961 m_nIncludeSpecial
= m_nIncludeSpecial
& ~*pAttributeId
;
967 // ----------------------
968 // the integer properties
970 static sal_Int32 nIntegerPropertyAttributeIds
[] =
974 static const ::rtl::OUString
* pIntegerPropertyNames
[] =
976 &PROPERTY_BLOCK_INCREMENT
978 static const sal_Int32 nIntegerPropertyAttrDefaults
[] =
979 { // attribute defaults (XML defaults, not runtime defaults!)
983 sal_Int32 nIdCount
= sizeof( nIntegerPropertyAttributeIds
) / sizeof( nIntegerPropertyAttributeIds
[0] );
984 #if OSL_DEBUG_LEVEL > 0
985 sal_Int32 nNameCount
= sizeof( pIntegerPropertyNames
) / sizeof( pIntegerPropertyNames
[0] );
986 OSL_ENSURE( ( nIdCount
== nNameCount
),
987 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
988 sal_Int32 nDefaultCount
= sizeof( nIntegerPropertyAttrDefaults
) / sizeof( nIntegerPropertyAttrDefaults
[0] );
989 OSL_ENSURE( ( nIdCount
== nDefaultCount
),
990 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
992 for ( i
= 0; i
< nIdCount
; ++i
)
993 if ( nIntegerPropertyAttributeIds
[i
] & m_nIncludeSpecial
)
995 exportInt32PropertyAttribute(
996 OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds
[i
] ),
997 OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds
[i
] ),
998 *( pIntegerPropertyNames
[i
] ),
999 nIntegerPropertyAttrDefaults
[i
]
1001 #if OSL_DEBUG_LEVEL > 0
1002 // reset the bit for later checking
1003 m_nIncludeSpecial
= m_nIncludeSpecial
& ~nIntegerPropertyAttributeIds
[i
];
1007 if ( SCA_STEP_SIZE
& m_nIncludeSpecial
)
1009 ::rtl::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
;
1015 OSL_ENSURE( sal_False
, "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1017 if ( sPropertyName
.getLength() )
1018 exportInt32PropertyAttribute(
1019 OAttributeMetaData::getSpecialAttributeNamespace( SCA_STEP_SIZE
),
1020 OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE
),
1025 #if OSL_DEBUG_LEVEL > 0
1026 // reset the bit for later checking
1027 m_nIncludeSpecial
= m_nIncludeSpecial
& ~SCA_STEP_SIZE
;
1033 // -------------------
1034 // the enum properties
1036 if (SCA_STATE
& m_nIncludeSpecial
)
1038 exportEnumPropertyAttribute(
1039 OAttributeMetaData::getSpecialAttributeNamespace(SCA_STATE
),
1040 OAttributeMetaData::getSpecialAttributeName(SCA_STATE
),
1041 PROPERTY_DEFAULT_STATE
,
1042 OEnumMapper::getEnumMap(OEnumMapper::epCheckState
),
1044 #if OSL_DEBUG_LEVEL > 0
1045 // reset the bit for later checking
1046 m_nIncludeSpecial
= m_nIncludeSpecial
& ~SCA_STATE
;
1050 if (SCA_CURRENT_STATE
& m_nIncludeSpecial
)
1052 exportEnumPropertyAttribute(
1053 OAttributeMetaData::getSpecialAttributeNamespace(SCA_CURRENT_STATE
),
1054 OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE
),
1056 OEnumMapper::getEnumMap(OEnumMapper::epCheckState
),
1058 #if OSL_DEBUG_LEVEL > 0
1059 // reset the bit for later checking
1060 m_nIncludeSpecial
= m_nIncludeSpecial
& ~SCA_CURRENT_STATE
;
1065 // --------------------------------------------------------------------
1066 // some properties which require a special handling
1069 if ( m_nIncludeSpecial
& SCA_REPEAT_DELAY
)
1071 DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY
, sal_Int32
);
1073 sal_Int32 nRepeatDelay
= 0;
1074 m_xProps
->getPropertyValue( PROPERTY_REPEAT_DELAY
) >>= nRepeatDelay
;
1076 aTime
.MakeTimeFromMS( nRepeatDelay
);
1078 AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCA_REPEAT_DELAY
)
1079 ,OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY
)
1080 ,SvXMLUnitConverter::convertTimeDuration( aTime
, nRepeatDelay
% 1000 ) );
1082 exportedProperty( PROPERTY_REPEAT_DELAY
);
1084 #if OSL_DEBUG_LEVEL > 0
1085 // reset the bit for later checking
1086 m_nIncludeSpecial
= m_nIncludeSpecial
& ~SCA_REPEAT_DELAY
;
1091 // ----------------------------------
1092 // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1094 if (SCA_ECHO_CHAR
& m_nIncludeSpecial
)
1096 DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR
, sal_Int16
);
1097 sal_Int16
nValue(0);
1098 m_xProps
->getPropertyValue(PROPERTY_ECHO_CHAR
) >>= nValue
;
1101 ::rtl::OUString
sCharacter(reinterpret_cast<const sal_Unicode
*>(&nValue
), 1);
1103 OAttributeMetaData::getSpecialAttributeNamespace(SCA_ECHO_CHAR
),
1104 OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR
),
1107 exportedProperty(PROPERTY_ECHO_CHAR
);
1108 #if OSL_DEBUG_LEVEL > 0
1109 // reset the bit for later checking
1110 m_nIncludeSpecial
= m_nIncludeSpecial
& ~SCA_ECHO_CHAR
;
1115 // ----------------------------------
1116 // the string properties
1118 static sal_Int32 nStringPropertyAttributeIds
[] =
1119 { // attribute flags
1122 static const ::rtl::OUString
* pStringPropertyNames
[] =
1124 &PROPERTY_GROUP_NAME
1127 sal_Int32 nIdCount
= sizeof( nStringPropertyAttributeIds
) / sizeof( nStringPropertyAttributeIds
[0] );
1128 #if OSL_DEBUG_LEVEL > 0
1129 sal_Int32 nNameCount
= sizeof( pStringPropertyNames
) / sizeof( pStringPropertyNames
[0] );
1130 OSL_ENSURE( ( nIdCount
== nNameCount
),
1131 "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1133 for ( i
= 0; i
< nIdCount
; ++i
)
1134 if ( nStringPropertyAttributeIds
[i
] & m_nIncludeSpecial
)
1136 exportStringPropertyAttribute(
1137 OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds
[i
] ),
1138 OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds
[i
] ),
1139 *( pStringPropertyNames
[i
] )
1141 #if OSL_DEBUG_LEVEL > 0
1142 // reset the bit for later checking
1143 m_nIncludeSpecial
= m_nIncludeSpecial
& ~nStringPropertyAttributeIds
[i
];
1148 // ----------------------------------
1149 if ((SCA_MIN_VALUE
| SCA_MAX_VALUE
) & m_nIncludeSpecial
)
1151 // need to export the min value and the max value as attributes
1152 // It depends on the real type (FormComponentType) of the control, which properties hold these
1154 const sal_Char
* pMinValuePropertyName
= NULL
;
1155 const sal_Char
* pMaxValuePropertyName
= NULL
;
1156 getValueLimitPropertyNames(m_nClassId
, pMinValuePropertyName
, pMaxValuePropertyName
);
1158 OSL_ENSURE((NULL
== pMinValuePropertyName
) == (0 == (SCA_MIN_VALUE
& m_nIncludeSpecial
)),
1159 "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1160 OSL_ENSURE((NULL
== pMaxValuePropertyName
) == (0 == (SCA_MAX_VALUE
& m_nIncludeSpecial
)),
1161 "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1163 // add the two attributes
1164 static const sal_Char
* pMinValueAttributeName
= OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE
);
1165 static const sal_Char
* pMaxValueAttributeName
= OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE
);
1166 static const sal_uInt16 nMinValueNamespaceKey
= OAttributeMetaData::getSpecialAttributeNamespace(SCA_MIN_VALUE
);
1167 static const sal_uInt16 nMaxValueNamespaceKey
= OAttributeMetaData::getSpecialAttributeNamespace(SCA_MAX_VALUE
);
1169 if (pMinValuePropertyName
&& (SCA_MIN_VALUE
& m_nIncludeSpecial
))
1170 exportGenericPropertyAttribute(
1171 nMinValueNamespaceKey
,
1172 pMinValueAttributeName
,
1173 pMinValuePropertyName
);
1175 if (pMaxValuePropertyName
&& (SCA_MAX_VALUE
& m_nIncludeSpecial
))
1176 exportGenericPropertyAttribute(
1177 nMaxValueNamespaceKey
,
1178 pMaxValueAttributeName
,
1179 pMaxValuePropertyName
);
1180 #if OSL_DEBUG_LEVEL > 0
1181 // reset the bit for later checking
1182 m_nIncludeSpecial
= m_nIncludeSpecial
& ~(SCA_MIN_VALUE
| SCA_MAX_VALUE
);
1186 // ----------------------------------
1187 if ( SCA_IMAGE_POSITION
& m_nIncludeSpecial
)
1189 exportImagePositionAttributes();
1190 RESET_BIT( m_nIncludeSpecial
, SCA_IMAGE_POSITION
);
1193 OSL_ENSURE(0 == m_nIncludeSpecial
,
1194 "OControlExport::exportSpecialAttributes: forgot some flags!");
1195 // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1199 //---------------------------------------------------------------------
1200 ::rtl::OUString
OControlExport::getScalarListSourceValue() const
1202 ::rtl::OUString sListSource
;
1203 Any aListSource
= m_xProps
->getPropertyValue( PROPERTY_LISTSOURCE
);
1204 if ( !( aListSource
>>= sListSource
) )
1206 Sequence
< ::rtl::OUString
> aListSourceSequence
;
1207 aListSource
>>= aListSourceSequence
;
1208 if ( aListSourceSequence
.getLength() )
1209 sListSource
= aListSourceSequence
[ 0 ];
1214 //---------------------------------------------------------------------
1215 void OControlExport::exportListSourceAsAttribute()
1217 // DA_LIST_SOURCE needs some special handling
1218 DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE
);
1220 ::rtl::OUString sListSource
= getScalarListSourceValue();
1221 if ( sListSource
.getLength() )
1222 { // the ListSource property needs to be exported as attribute, and it is not empty
1224 OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE
),
1225 OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE
),
1229 exportedProperty( PROPERTY_LISTSOURCE
);
1232 //---------------------------------------------------------------------
1233 void OControlExport::getSequenceInt16PropertyAsSet(const ::rtl::OUString
& _rPropertyName
, Int16Set
& _rOut
)
1235 Sequence
< sal_Int16
> aValueSequence
;
1236 DBG_CHECK_PROPERTY(_rPropertyName
, Sequence
< sal_Int16
>);
1237 m_xProps
->getPropertyValue(_rPropertyName
) >>= aValueSequence
;
1239 const sal_Int16
* pValues
= aValueSequence
.getConstArray();
1240 for (sal_Int32 i
=0; i
<aValueSequence
.getLength(); ++i
, ++pValues
)
1241 _rOut
.insert(*pValues
);
1244 //---------------------------------------------------------------------
1245 void OControlExport::exportListSourceAsElements()
1248 Sequence
< ::rtl::OUString
> aItems
, aValues
;
1249 DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST
, Sequence
< ::rtl::OUString
> );
1250 m_xProps
->getPropertyValue(PROPERTY_STRING_ITEM_LIST
) >>= aItems
;
1252 DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE
, Sequence
< ::rtl::OUString
> );
1253 if ( 0 == ( m_nIncludeDatabase
& DA_LIST_SOURCE
) )
1254 m_xProps
->getPropertyValue(PROPERTY_LISTSOURCE
) >>= aValues
;
1255 // if we exported the list source as attribute, we do not repeat it as sub elements
1257 // the selection lists
1258 Int16Set aSelection
, aDefaultSelection
;
1259 getSequenceInt16PropertyAsSet(PROPERTY_SELECT_SEQ
, aSelection
);
1260 getSequenceInt16PropertyAsSet(PROPERTY_DEFAULT_SELECT_SEQ
, aDefaultSelection
);
1262 // the string for "true"
1263 ::rtl::OUString sTrue
;
1264 ::rtl::OUStringBuffer sBuffer
;
1265 m_rContext
.getGlobalContext().GetMM100UnitConverter().convertBool(sBuffer
, sal_True
);
1266 sTrue
= sBuffer
.makeStringAndClear();
1268 // loop through both lists ('til the maximum of both lengths)
1269 const ::rtl::OUString
* pItems
= aItems
.getConstArray();
1270 const ::rtl::OUString
* pValues
= aValues
.getConstArray();
1272 sal_Int32 nItems
= aItems
.getLength();
1273 sal_Int32 nValues
= aValues
.getLength();
1275 sal_Int16 nMaxLen
= (sal_Int16
)std::max(nItems
, nValues
);
1277 for (sal_Int16 i
=0; i
<nMaxLen
; ++i
)
1279 m_rContext
.getGlobalContext().ClearAttrList();
1282 // there is an item at this position
1284 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL
),
1285 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL
),
1291 // there is an value at this position
1293 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE
),
1294 OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE
),
1299 Int16SetIterator aSelectedPos
= aSelection
.find(i
);
1300 if (aSelection
.end() != aSelectedPos
)
1301 { // the item at this position is selected
1303 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED
),
1304 OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED
),
1307 aSelection
.erase(aSelectedPos
);
1310 Int16SetIterator aDefaultSelectedPos
= aDefaultSelection
.find(i
);
1311 if (aDefaultSelection
.end() != aDefaultSelectedPos
)
1312 { // the item at this position is selected as default
1314 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED
),
1315 OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED
),
1318 aDefaultSelection
.erase(aDefaultSelectedPos
);
1320 SvXMLElementExport
aFormElement(m_rContext
.getGlobalContext(), XML_NAMESPACE_FORM
, "option", sal_True
, sal_True
);
1323 // There may be more "selected" or "default-selected" items than there are in the lists in real,
1324 // so we need to store some additional "form:option" items which have no name and no label, but
1325 // one or both of the selected flags.
1326 // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1328 if ( !aSelection
.empty() || !aDefaultSelection
.empty() )
1330 sal_Int16 nLastSelected
= -1;
1331 if ( !aSelection
.empty() )
1332 nLastSelected
= *(--aSelection
.end());
1334 sal_Int16 nLastDefaultSelected
= -1;
1335 if ( !aDefaultSelection
.empty() )
1336 nLastDefaultSelected
= *(--aDefaultSelection
.end());
1338 // the maximum element in both sets
1339 sal_Int16 nLastReferredEntry
= std::max(nLastSelected
, nLastDefaultSelected
);
1340 OSL_ENSURE(nLastReferredEntry
>= nMaxLen
, "OControlExport::exportListSourceAsElements: inconsistence!");
1341 // if the maximum (selected or default selected) entry number is less than the maximum item count
1342 // in both lists, the entry number should have been removed from the set
1344 for (sal_Int16 i
=nMaxLen
; i
<=nLastReferredEntry
; ++i
)
1346 if (aSelection
.end() != aSelection
.find(i
))
1347 { // the (not existent) item at this position is selected
1349 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED
),
1350 OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED
),
1355 if (aDefaultSelection
.end() != aDefaultSelection
.find(i
))
1356 { // the (not existent) item at this position is selected as default
1358 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED
),
1359 OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED
),
1363 SvXMLElementExport
aFormElement(m_rContext
.getGlobalContext(), XML_NAMESPACE_FORM
, "option", sal_True
, sal_True
);
1368 //---------------------------------------------------------------------
1369 void OControlExport::implStartElement(const sal_Char
* _pName
)
1371 // before we let the base class start it's outer element, we add a wrapper element
1372 const sal_Char
*pOuterElementName
= getOuterXMLElementName();
1373 m_pOuterElement
= pOuterElementName
1374 ? new SvXMLElementExport(
1375 m_rContext
.getGlobalContext(),
1377 pOuterElementName
, sal_True
,
1381 // add the attributes for the inner element
1382 exportInnerAttributes();
1384 // and start the inner element
1385 OElementExport::implStartElement(_pName
);
1388 //---------------------------------------------------------------------
1389 void OControlExport::implEndElement()
1391 // end the inner element
1392 OElementExport::implEndElement();
1394 // end the outer element if it exists
1395 delete m_pOuterElement
;
1396 m_pOuterElement
= NULL
;
1399 //---------------------------------------------------------------------
1400 const sal_Char
* OControlExport::getOuterXMLElementName() const
1405 //---------------------------------------------------------------------
1406 const sal_Char
* OControlExport::getXMLElementName() const
1408 return getElementName(m_eType
);
1411 //---------------------------------------------------------------------
1412 void OControlExport::examine()
1414 OSL_ENSURE( ( m_nIncludeCommon
== 0 ) && ( m_nIncludeSpecial
== 0 ) && ( m_nIncludeDatabase
== 0 )
1415 && ( m_nIncludeEvents
== 0 ) && ( m_nIncludeBindings
== 0),
1416 "OControlExport::examine: called me twice? Not initialized?" );
1418 // get the class id to decide which kind of element we need in the XML stream
1419 m_nClassId
= FormComponentType::CONTROL
;
1420 DBG_CHECK_PROPERTY( PROPERTY_CLASSID
, sal_Int16
);
1421 m_xProps
->getPropertyValue(PROPERTY_CLASSID
) >>= m_nClassId
;
1424 case FormComponentType::DATEFIELD
:
1425 case FormComponentType::TIMEFIELD
:
1426 case FormComponentType::NUMERICFIELD
:
1427 case FormComponentType::CURRENCYFIELD
:
1428 case FormComponentType::PATTERNFIELD
:
1429 m_eType
= FORMATTED_TEXT
;
1431 case FormComponentType::TEXTFIELD
:
1432 { // it's some kind of edit. To know which type we need further investigation
1434 if (FORMATTED_TEXT
!= m_eType
)
1435 { // not coming from the previous cases which had a class id .ne. TEXTFIELD
1437 // check if it's a formatted field
1438 if (m_xPropertyInfo
->hasPropertyByName(PROPERTY_FORMATKEY
))
1440 m_eType
= FORMATTED_TEXT
;
1444 // all other controls are represented by an ordinary edit control, but which XML control type
1445 // it is depends on the current values of some properties
1447 // if the EchoChar string is not empty, it is a password field
1448 sal_Int16 nEchoChar
= 0;
1449 if (m_xPropertyInfo
->hasPropertyByName(PROPERTY_ECHOCHAR
))
1450 // grid columns do not have this property ....
1451 m_xProps
->getPropertyValue(PROPERTY_ECHOCHAR
) >>= nEchoChar
;
1455 m_nIncludeSpecial
|= SCA_ECHO_CHAR
;
1459 // if the MultiLine property is sal_True, it is a TextArea
1460 sal_Bool bMultiLine
= sal_False
;
1461 if (m_xPropertyInfo
->hasPropertyByName(PROPERTY_MULTILINE
))
1462 // grid columns do not have this property ....
1463 bMultiLine
= ::cppu::any2bool(m_xProps
->getPropertyValue(PROPERTY_MULTILINE
));
1466 m_eType
= TEXT_AREA
;
1468 // the only case left is represented by a Text element
1474 // attributes which are common to all the four types:
1475 // common attributes
1477 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_VALUE
|
1478 CCA_PRINTABLE
| CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
;
1480 // database attributes
1481 m_nIncludeDatabase
= DA_DATA_FIELD
| DA_INPUT_REQUIRED
;
1484 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CHANGE
| EA_ON_SELECT
;
1486 // only text and pattern fields have a ConvertEmptyToNull property
1487 if ( ( m_nClassId
== FormComponentType::TEXTFIELD
)
1488 || ( m_nClassId
== FormComponentType::PATTERNFIELD
)
1490 m_nIncludeDatabase
|= DA_CONVERT_EMPTY
;
1492 // all controls but the file control fields have a readonly property
1493 if ( m_nClassId
!= FormComponentType::FILECONTROL
)
1494 m_nIncludeCommon
|= CCA_READONLY
;
1496 // a text field has a max text len
1497 if ( m_nClassId
== FormComponentType::TEXTFIELD
)
1498 m_nIncludeCommon
|= CCA_MAX_LENGTH
;
1500 // max and min values and validation:
1501 if (FORMATTED_TEXT
== m_eType
)
1502 { // in general all controls represented as formatted-text have these props
1503 if (FormComponentType::PATTERNFIELD
!= m_nClassId
)
1504 // but the PatternField does not have value limits
1505 m_nIncludeSpecial
|= SCA_MAX_VALUE
| SCA_MIN_VALUE
;
1507 if (FormComponentType::TEXTFIELD
!= m_nClassId
)
1508 // and the FormattedField does not have a validation flag
1509 m_nIncludeSpecial
|= SCA_VALIDATION
;
1512 // if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1513 if ( PASSWORD
!= m_eType
)
1514 m_nIncludeCommon
|= CCA_CURRENT_VALUE
;
1518 case FormComponentType::FILECONTROL
:
1521 CCA_NAME
| CCA_SERVICE_NAME
| CCA_CURRENT_VALUE
| CCA_DISABLED
|
1522 CCA_PRINTABLE
| CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
|
1524 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CHANGE
| EA_ON_SELECT
;
1527 case FormComponentType::FIXEDTEXT
:
1528 m_eType
= FIXED_TEXT
;
1530 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_LABEL
|
1531 CCA_PRINTABLE
| CCA_TITLE
| CCA_FOR
;
1532 m_nIncludeSpecial
= SCA_MULTI_LINE
;
1533 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1536 case FormComponentType::COMBOBOX
:
1539 CCA_NAME
| CCA_SERVICE_NAME
| CCA_CURRENT_VALUE
|
1540 CCA_DISABLED
| CCA_DROPDOWN
| CCA_MAX_LENGTH
| CCA_PRINTABLE
| CCA_READONLY
| CCA_SIZE
|
1541 CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
| CCA_VALUE
;
1542 m_nIncludeSpecial
= SCA_AUTOMATIC_COMPLETION
;
1543 m_nIncludeDatabase
= DA_CONVERT_EMPTY
| DA_DATA_FIELD
| DA_INPUT_REQUIRED
| DA_LIST_SOURCE
| DA_LIST_SOURCE_TYPE
;
1544 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CHANGE
| EA_ON_SELECT
;
1547 case FormComponentType::LISTBOX
:
1550 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_DROPDOWN
|
1551 CCA_PRINTABLE
| CCA_SIZE
| CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
;
1552 m_nIncludeSpecial
= SCA_MULTIPLE
;
1553 m_nIncludeDatabase
= DA_BOUND_COLUMN
| DA_DATA_FIELD
| DA_INPUT_REQUIRED
| DA_LIST_SOURCE_TYPE
;
1554 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CHANGE
| EA_ON_CLICK
| EA_ON_DBLCLICK
;
1555 // check if we need to export the ListSource as attribute
1557 // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1558 // a sequence of pairs which is build from the StringItemList and the ValueList
1559 ListSourceType eListSourceType
= ListSourceType_VALUELIST
;
1560 #if OSL_DEBUG_LEVEL > 0
1563 m_xProps
->getPropertyValue(PROPERTY_LISTSOURCETYPE
) >>= eListSourceType
;
1564 OSL_ENSURE(bSuccess
, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1565 if (ListSourceType_VALUELIST
!= eListSourceType
)
1567 m_nIncludeDatabase
|= DA_LIST_SOURCE
;
1573 case FormComponentType::COMMANDBUTTON
:
1575 m_nIncludeCommon
|= CCA_TAB_STOP
| CCA_LABEL
;
1576 m_nIncludeSpecial
= SCA_DEFAULT_BUTTON
| SCA_TOGGLE
| SCA_FOCUS_ON_CLICK
| SCA_IMAGE_POSITION
| SCA_REPEAT_DELAY
;
1578 case FormComponentType::IMAGEBUTTON
:
1579 if (BUTTON
!= m_eType
)
1581 // not coming from the previous case
1585 CCA_NAME
| CCA_SERVICE_NAME
| CCA_BUTTON_TYPE
| CCA_DISABLED
|
1586 CCA_IMAGE_DATA
| CCA_PRINTABLE
| CCA_TAB_INDEX
| CCA_TARGET_FRAME
|
1587 CCA_TARGET_LOCATION
| CCA_TITLE
;
1588 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CLICK
| EA_ON_DBLCLICK
;
1591 case FormComponentType::CHECKBOX
:
1593 m_nIncludeSpecial
= SCA_CURRENT_STATE
| SCA_IS_TRISTATE
| SCA_STATE
;
1595 case FormComponentType::RADIOBUTTON
:
1597 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_LABEL
| CCA_PRINTABLE
|
1598 CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
| CCA_VALUE
| CCA_VISUAL_EFFECT
;
1599 if (CHECKBOX
!= m_eType
)
1600 { // not coming from the previous case
1602 m_nIncludeCommon
|= CCA_CURRENT_SELECTED
| CCA_SELECTED
;
1604 if ( m_xPropertyInfo
->hasPropertyByName( PROPERTY_IMAGE_POSITION
) )
1605 m_nIncludeSpecial
|= SCA_IMAGE_POSITION
;
1606 if ( m_xPropertyInfo
->hasPropertyByName( PROPERTY_GROUP_NAME
) )
1607 m_nIncludeSpecial
|= SCA_GROUP_NAME
;
1608 m_nIncludeDatabase
= DA_DATA_FIELD
| DA_INPUT_REQUIRED
;
1609 m_nIncludeEvents
= EA_CONTROL_EVENTS
| EA_ON_CHANGE
;
1612 case FormComponentType::GROUPBOX
:
1615 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_LABEL
|
1616 CCA_PRINTABLE
| CCA_TITLE
| CCA_FOR
;
1617 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1620 case FormComponentType::IMAGECONTROL
:
1621 m_eType
= IMAGE_FRAME
;
1623 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_IMAGE_DATA
|
1624 CCA_PRINTABLE
| CCA_READONLY
| CCA_TITLE
;
1625 m_nIncludeDatabase
= DA_DATA_FIELD
| DA_INPUT_REQUIRED
;
1626 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1629 case FormComponentType::HIDDENCONTROL
:
1632 CCA_NAME
| CCA_SERVICE_NAME
| CCA_VALUE
;
1635 case FormComponentType::GRIDCONTROL
:
1638 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_PRINTABLE
|
1639 CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_TITLE
;
1640 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1643 case FormComponentType::SCROLLBAR
:
1644 case FormComponentType::SPINBUTTON
:
1645 m_eType
= VALUERANGE
;
1647 CCA_NAME
| CCA_SERVICE_NAME
| CCA_DISABLED
| CCA_PRINTABLE
|
1648 CCA_TITLE
| CCA_CURRENT_VALUE
| CCA_VALUE
| CCA_ORIENTATION
;
1649 m_nIncludeSpecial
= SCA_MAX_VALUE
| SCA_STEP_SIZE
| SCA_MIN_VALUE
| SCA_REPEAT_DELAY
;
1651 if ( m_nClassId
== FormComponentType::SCROLLBAR
)
1652 m_nIncludeSpecial
|= SCA_PAGE_STEP_SIZE
;
1654 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1658 OSL_ENSURE(sal_False
, "OControlExport::examineControl: unknown control type (class id)!");
1661 case FormComponentType::NAVIGATIONBAR
:
1662 // TODO: should we have an own file format for this?
1665 case FormComponentType::CONTROL
:
1666 m_eType
= GENERIC_CONTROL
;
1667 // unknown control type
1668 m_nIncludeCommon
= CCA_NAME
| CCA_SERVICE_NAME
;
1669 // at least a name should be there, 'cause without a name the control could never have been
1670 // inserted into it's parent container
1671 // In addition, the service name is absolutely necessary to create the control upon reading.
1672 m_nIncludeEvents
= EA_CONTROL_EVENTS
;
1673 // we always should be able to export events - this is not control type dependent
1677 // in general, all control types need to export the control id
1678 m_nIncludeCommon
|= CCA_CONTROL_ID
;
1680 // is is a control bound to a calc cell?
1681 if ( FormCellBindingHelper::livesInSpreadsheetDocument( m_xProps
) )
1683 FormCellBindingHelper
aHelper( m_xProps
, NULL
);
1685 if ( aHelper
.isCellBinding( aHelper
.getCurrentBinding( ) ) )
1687 m_nIncludeBindings
|= BA_LINKED_CELL
;
1688 if ( m_nClassId
== FormComponentType::LISTBOX
)
1689 m_nIncludeBindings
|= BA_LIST_LINKING_TYPE
;
1693 // is it a list-like control which uses a calc cell range as list source?
1695 if ( aHelper
.isCellRangeListSource( aHelper
.getCurrentListSource( ) ) )
1696 m_nIncludeBindings
|= BA_LIST_CELL_RANGE
;
1700 // is control bound to XForms?
1701 if( getXFormsBindName( m_xProps
).getLength() > 0 )
1703 m_nIncludeBindings
|= BA_XFORMS_BIND
;
1706 // is (list-)control bound to XForms list?
1707 if( getXFormsListBindName( m_xProps
).getLength() > 0 )
1709 m_nIncludeBindings
|= BA_XFORMS_LISTBIND
;
1712 // does the control have an XForms submission?
1713 if( getXFormsSubmissionName( m_xProps
).getLength() > 0 )
1715 m_nIncludeBindings
|= BA_XFORMS_SUBMISSION
;
1719 //---------------------------------------------------------------------
1720 void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType
)
1724 FormCellBindingHelper
aHelper( m_xProps
, NULL
);
1725 Reference
< XValueBinding
> xBinding( aHelper
.getCurrentBinding() );
1726 OSL_ENSURE( xBinding
.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1727 if ( xBinding
.is() )
1729 // ....................................................
1731 OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL
),
1732 OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL
),
1733 aHelper
.getStringAddressFromCellBinding( xBinding
)
1736 // ....................................................
1737 if ( _bIncludeListLinkageType
)
1739 sal_Int16 nLinkageType
= aHelper
.isCellIntegerBinding( xBinding
) ? 1 : 0;
1741 ::rtl::OUStringBuffer sBuffer
;
1742 m_rContext
.getGlobalContext().GetMM100UnitConverter().convertEnum(
1744 (sal_uInt16
)nLinkageType
,
1745 OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType
)
1749 OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE
),
1750 OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE
),
1751 sBuffer
.makeStringAndClear()
1757 catch( const Exception
& )
1759 OSL_ENSURE( sal_False
, "OControlExport::exportCellBindingAttributes: caught an exception!" );
1763 //---------------------------------------------------------------------
1764 void OControlExport::exportXFormsBindAttributes()
1766 rtl::OUString sBindName
= getXFormsBindName( m_xProps
);
1767 AddAttribute( XML_NAMESPACE_XFORMS
, XML_BIND
, sBindName
);
1769 //---------------------------------------------------------------------
1770 void OControlExport::exportXFormsListAttributes()
1772 rtl::OUString sBindName
= getXFormsListBindName( m_xProps
);
1773 AddAttribute( XML_NAMESPACE_FORM
, XML_XFORMS_LIST_SOURCE
, sBindName
);
1775 //---------------------------------------------------------------------
1776 void OControlExport::exportXFormsSubmissionAttributes()
1778 rtl::OUString sSubmission
= getXFormsSubmissionName( m_xProps
);
1779 AddAttribute( XML_NAMESPACE_FORM
, XML_XFORMS_SUBMISSION
, sSubmission
);
1781 //---------------------------------------------------------------------
1782 void OControlExport::exportCellListSourceRange( )
1786 Reference
< XListEntrySink
> xSink( m_xProps
, UNO_QUERY
);
1787 Reference
< XListEntrySource
> xSource
;
1789 xSource
= xSource
.query( xSink
->getListEntrySource() );
1790 OSL_ENSURE( xSource
.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1793 FormCellBindingHelper
aHelper( m_xProps
, NULL
);
1796 OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE
),
1797 OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE
),
1798 aHelper
.getStringAddressFromCellListSource( xSource
)
1802 catch( const Exception
& )
1804 OSL_ENSURE( sal_False
, "OControlExport::exportCellListSourceRange: caught an exception!" );
1808 //---------------------------------------------------------------------
1809 void OControlExport::exportImagePositionAttributes()
1813 sal_Int16 nImagePosition
= ImagePosition::Centered
;
1814 OSL_VERIFY( m_xProps
->getPropertyValue( PROPERTY_IMAGE_POSITION
) >>= nImagePosition
);
1815 OSL_ENSURE( ( nImagePosition
>= ImagePosition::LeftTop
) && ( nImagePosition
<= ImagePosition::Centered
),
1816 "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1818 if ( ( nImagePosition
< ImagePosition::LeftTop
) || ( nImagePosition
> ImagePosition::Centered
) )
1819 // this is important to prevent potential buffer overflows below, so don't optimize
1820 nImagePosition
= ImagePosition::Centered
;
1822 if ( nImagePosition
== ImagePosition::Centered
)
1824 AddAttribute( XML_NAMESPACE_FORM
, GetXMLToken( XML_IMAGE_POSITION
), GetXMLToken( XML_CENTER
) );
1828 XMLTokenEnum eXmlImagePositions
[] =
1830 XML_START
, XML_END
, XML_TOP
, XML_BOTTOM
1832 XMLTokenEnum eXmlImageAligns
[] =
1834 XML_START
, XML_CENTER
, XML_END
1837 XMLTokenEnum eXmlImagePosition
= eXmlImagePositions
[ nImagePosition
/ 3 ];
1838 XMLTokenEnum eXmlImageAlign
= eXmlImageAligns
[ nImagePosition
% 3 ];
1840 AddAttribute( XML_NAMESPACE_FORM
, GetXMLToken( XML_IMAGE_POSITION
), GetXMLToken( eXmlImagePosition
) );
1841 AddAttribute( XML_NAMESPACE_FORM
, GetXMLToken( XML_IMAGE_ALIGN
), GetXMLToken( eXmlImageAlign
) );
1844 exportedProperty( PROPERTY_IMAGE_POSITION
);
1845 // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1846 // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1847 // we don't need to export ImageAlign anymore
1848 exportedProperty( PROPERTY_IMAGE_ALIGN
);
1850 catch( const Exception
& )
1852 DBG_UNHANDLED_EXCEPTION();
1856 //---------------------------------------------------------------------
1857 bool OControlExport::controlHasActiveDataBinding() const
1861 // currently exchanging the data with a database column?
1862 ::rtl::OUString
sBoundFieldPropertyName( RTL_CONSTASCII_USTRINGPARAM( "BoundField" ) );
1863 if ( m_xPropertyInfo
.is() && m_xPropertyInfo
->hasPropertyByName( sBoundFieldPropertyName
) )
1865 Reference
< XPropertySet
> xBoundField
;
1866 m_xProps
->getPropertyValue( sBoundFieldPropertyName
) >>= xBoundField
;
1867 if ( xBoundField
.is() )
1871 // currently exchanging data with an external binding?
1872 Reference
< XBindableValue
> xBindable( m_xProps
, UNO_QUERY
);
1873 if ( xBindable
.is() && xBindable
->getValueBinding().is() )
1876 catch( const Exception
& )
1878 OSL_ENSURE( sal_False
, "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
1884 //---------------------------------------------------------------------
1885 bool OControlExport::controlHasUserSuppliedListEntries() const
1889 // an external list source?
1890 Reference
< XListEntrySink
> xEntrySink( m_xProps
, UNO_QUERY
);
1891 if ( xEntrySink
.is() && xEntrySink
->getListEntrySource().is() )
1894 if ( m_xPropertyInfo
.is() && m_xPropertyInfo
->hasPropertyByName( PROPERTY_LISTSOURCETYPE
) )
1896 ListSourceType eListSourceType
= ListSourceType_VALUELIST
;
1897 OSL_VERIFY( m_xProps
->getPropertyValue( PROPERTY_LISTSOURCETYPE
) >>= eListSourceType
);
1898 if ( eListSourceType
== ListSourceType_VALUELIST
)
1899 // for value lists, the list entries as entered by the user are used
1902 // for every other type, the list entries are filled with some data obtained
1903 // from a database - if and only if the ListSource property is not empty
1904 return ( 0 == getScalarListSourceValue().getLength() );
1907 catch( const Exception
& )
1909 OSL_ENSURE( sal_False
, "OControlExport::controlHasUserSuppliedListEntries: caught an exception!" );
1912 OSL_ENSURE( sal_False
, "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
1913 // this method should be called for list and combo boxes only
1917 //=====================================================================
1919 //=====================================================================
1920 //---------------------------------------------------------------------
1921 OColumnExport::OColumnExport(IFormsExportContext
& _rContext
, const Reference
< XPropertySet
>& _rxControl
, const ::rtl::OUString
& _rControlId
,
1922 const Sequence
< ScriptEventDescriptor
>& _rEvents
)
1923 :OControlExport(_rContext
, _rxControl
, _rControlId
, ::rtl::OUString(), _rEvents
)
1927 //---------------------------------------------------------------------
1928 OColumnExport::~OColumnExport()
1933 //---------------------------------------------------------------------
1934 void OColumnExport::exportServiceNameAttribute()
1936 // the attribute "service name" (which has a slightly different meaning for columns
1937 DBG_CHECK_PROPERTY( PROPERTY_COLUMNSERVICENAME
, ::rtl::OUString
);
1938 ::rtl::OUString sColumnServiceName
;
1939 m_xProps
->getPropertyValue(PROPERTY_COLUMNSERVICENAME
) >>= sColumnServiceName
;
1940 // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
1941 // real service name for the column (for use with the XGridColumnFactory) is only the last
1942 // token of this complete name.
1943 sal_Int32 nLastSep
= sColumnServiceName
.lastIndexOf('.');
1944 OSL_ENSURE(-1 != nLastSep
, "OColumnExport::startExportElement: invalid service name!");
1945 sColumnServiceName
= sColumnServiceName
.copy(nLastSep
+ 1);
1946 sColumnServiceName
=
1947 m_rContext
.getGlobalContext().GetNamespaceMap().GetQNameByKey(
1948 XML_NAMESPACE_OOO
, sColumnServiceName
);
1949 // add the attribute
1950 AddAttribute( OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME
)
1951 , OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME
)
1952 , sColumnServiceName
);
1953 // flag the property as "handled"
1954 exportedProperty(PROPERTY_COLUMNSERVICENAME
);
1958 //---------------------------------------------------------------------
1959 const sal_Char
* OColumnExport::getOuterXMLElementName() const
1964 //---------------------------------------------------------------------
1965 void OColumnExport::exportAttributes()
1967 OControlExport::exportAttributes();
1969 // the attribute "label"
1970 exportStringPropertyAttribute(
1971 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL
),
1972 OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL
),
1975 // the style attribute
1976 ::rtl::OUString sStyleName
= m_rContext
.getObjectStyleName( m_xProps
);
1977 if ( sStyleName
.getLength() )
1980 OAttributeMetaData::getSpecialAttributeNamespace( SCA_COLUMN_STYLE_NAME
),
1981 OAttributeMetaData::getSpecialAttributeName( SCA_COLUMN_STYLE_NAME
),
1987 //---------------------------------------------------------------------
1988 void OColumnExport::examine()
1990 OControlExport::examine();
1992 // grid columns miss some properties of the controls they're representing
1993 m_nIncludeCommon
&= ~(CCA_FOR
| CCA_PRINTABLE
| CCA_TAB_INDEX
| CCA_TAB_STOP
| CCA_LABEL
);
1994 m_nIncludeSpecial
&= ~(SCA_ECHO_CHAR
| SCA_AUTOMATIC_COMPLETION
| SCA_MULTIPLE
| SCA_MULTI_LINE
);
1996 if (FormComponentType::DATEFIELD
!= m_nClassId
)
1997 // except date fields, no column has the DropDown property
1998 m_nIncludeCommon
&= ~CCA_DROPDOWN
;
2001 //=====================================================================
2003 //=====================================================================
2004 //---------------------------------------------------------------------
2005 OFormExport::OFormExport(IFormsExportContext
& _rContext
, const Reference
< XPropertySet
>& _rxForm
,
2006 const Sequence
< ScriptEventDescriptor
>& _rEvents
)
2007 :OElementExport(_rContext
, _rxForm
, _rEvents
)
2008 ,m_bCreateConnectionResourceElement(sal_False
)
2010 OSL_ENSURE(m_xProps
.is(), "OFormExport::OFormExport: invalid arguments!");
2013 //---------------------------------------------------------------------
2014 const sal_Char
* OFormExport::getXMLElementName() const
2019 //---------------------------------------------------------------------
2020 void OFormExport::exportSubTags()
2022 if ( m_bCreateConnectionResourceElement
&& m_xProps
.is() )
2024 m_rContext
.getGlobalContext().ClearAttrList();
2025 ::rtl::OUString sPropValue
;
2026 m_xProps
->getPropertyValue( PROPERTY_DATASOURCENAME
) >>= sPropValue
; // if set it is a file url
2027 if ( !sPropValue
.getLength() )
2028 m_xProps
->getPropertyValue( PROPERTY_URL
) >>= sPropValue
;
2029 if ( sPropValue
.getLength() )
2031 OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_LOCATION
),
2032 OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION
),
2034 if ( m_rContext
.getGlobalContext().GetAttrList().getLength() )
2036 SvXMLElementExport
aFormElement(m_rContext
.getGlobalContext(), XML_NAMESPACE_FORM
, xmloff::token::XML_CONNECTION_RESOURCE
, sal_True
, sal_True
);
2040 // let the base class export the remaining properties and the events
2041 OElementExport::exportSubTags();
2042 // loop through all children
2043 Reference
< XIndexAccess
> xCollection(m_xProps
, UNO_QUERY
);
2044 OSL_ENSURE(xCollection
.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspic�ous!");
2046 if (xCollection
.is())
2047 m_rContext
.exportCollectionElements(xCollection
);
2050 //---------------------------------------------------------------------
2051 void OFormExport::exportAttributes()
2055 // ---------------------
2056 // the string properties
2058 static FormAttributes eStringPropertyIds
[] =
2060 faName
, /*faAction,*/ faCommand
, faFilter
, faOrder
2062 static ::rtl::OUString aStringPropertyNames
[] =
2064 PROPERTY_NAME
, /*PROPERTY_TARGETURL,*/ PROPERTY_COMMAND
, PROPERTY_FILTER
, PROPERTY_ORDER
2066 sal_Int32 nIdCount
= sizeof(eStringPropertyIds
) / sizeof(eStringPropertyIds
[0]);
2067 #if OSL_DEBUG_LEVEL > 0
2068 sal_Int32 nNameCount
= sizeof(aStringPropertyNames
) / sizeof(aStringPropertyNames
[0]);
2069 OSL_ENSURE((nIdCount
== nNameCount
),
2070 "OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2072 for (i
=0; i
<nIdCount
; ++i
)
2073 exportStringPropertyAttribute(
2074 OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds
[i
]),
2075 OAttributeMetaData::getFormAttributeName(eStringPropertyIds
[i
]),
2076 aStringPropertyNames
[i
]);
2077 // now export the data source name or databaselocation or connection resource
2078 ::rtl::OUString sPropValue
;
2079 m_xProps
->getPropertyValue( PROPERTY_DATASOURCENAME
) >>= sPropValue
;
2080 m_bCreateConnectionResourceElement
= !sPropValue
.getLength();
2081 if ( !m_bCreateConnectionResourceElement
)
2083 INetURLObject
aURL(sPropValue
);
2084 m_bCreateConnectionResourceElement
= ( aURL
.GetProtocol() == INET_PROT_FILE
);
2085 if ( !m_bCreateConnectionResourceElement
)
2086 exportStringPropertyAttribute(
2087 OAttributeMetaData::getFormAttributeNamespace(faDatasource
),
2088 OAttributeMetaData::getFormAttributeName(faDatasource
),
2089 PROPERTY_DATASOURCENAME
);
2092 exportedProperty(PROPERTY_URL
);
2093 if ( m_bCreateConnectionResourceElement
)
2094 exportedProperty(PROPERTY_DATASOURCENAME
);
2097 // ----------------------
2098 // the boolean properties
2100 static FormAttributes eBooleanPropertyIds
[] =
2102 faAllowDeletes
, faAllowInserts
, faAllowUpdates
, faApplyFilter
, faEscapeProcessing
, faIgnoreResult
2104 static const ::rtl::OUString
* pBooleanPropertyNames
[] =
2106 &PROPERTY_ALLOWDELETES
, &PROPERTY_ALLOWINSERTS
, &PROPERTY_ALLOWUPDATES
, &PROPERTY_APPLYFILTER
, &PROPERTY_ESCAPEPROCESSING
, &PROPERTY_IGNORERESULT
2108 static sal_Int8 nBooleanPropertyAttrFlags
[] =
2110 BOOLATTR_DEFAULT_TRUE
, BOOLATTR_DEFAULT_TRUE
, BOOLATTR_DEFAULT_TRUE
, BOOLATTR_DEFAULT_FALSE
, BOOLATTR_DEFAULT_TRUE
, BOOLATTR_DEFAULT_FALSE
2112 sal_Int32 nIdCount
= sizeof(eBooleanPropertyIds
) / sizeof(eBooleanPropertyIds
[0]);
2113 #if OSL_DEBUG_LEVEL > 0
2114 sal_Int32 nNameCount
= sizeof(pBooleanPropertyNames
) / sizeof(pBooleanPropertyNames
[0]);
2115 sal_Int32 nFlagsCount
= sizeof(nBooleanPropertyAttrFlags
) / sizeof(nBooleanPropertyAttrFlags
[0]);
2116 OSL_ENSURE((nIdCount
== nNameCount
) && (nNameCount
== nFlagsCount
),
2117 "OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2119 for (i
=0; i
<nIdCount
; ++i
)
2120 exportBooleanPropertyAttribute(
2121 OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds
[i
]),
2122 OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds
[i
]),
2123 *(pBooleanPropertyNames
[i
]),
2124 nBooleanPropertyAttrFlags
[i
]
2128 // -------------------
2129 // the enum properties
2131 static FormAttributes eEnumPropertyIds
[] =
2133 faEnctype
, faMethod
, faCommandType
, faNavigationMode
, faTabbingCycle
2135 static const sal_Char
* pEnumPropertyNames
[] =
2137 PROPERTY_SUBMIT_ENCODING
, PROPERTY_SUBMIT_METHOD
, PROPERTY_COMMAND_TYPE
, PROPERTY_NAVIGATION
, PROPERTY_CYCLE
2139 static OEnumMapper::EnumProperties eEnumPropertyMaps
[] =
2141 OEnumMapper::epSubmitEncoding
, OEnumMapper::epSubmitMethod
, OEnumMapper::epCommandType
, OEnumMapper::epNavigationType
, OEnumMapper::epTabCyle
2143 static sal_Int32 nEnumPropertyAttrDefaults
[] =
2145 FormSubmitEncoding_URL
, FormSubmitMethod_GET
, CommandType::COMMAND
, NavigationBarMode_CURRENT
, TabulatorCycle_RECORDS
2147 static sal_Bool nEnumPropertyAttrDefaultFlags
[] =
2149 sal_False
, sal_False
, sal_False
, sal_False
, sal_True
2151 sal_Int32 nIdCount
= sizeof(eEnumPropertyIds
) / sizeof(eEnumPropertyIds
[0]);
2152 #if OSL_DEBUG_LEVEL > 0
2153 sal_Int32 nNameCount
= sizeof(pEnumPropertyNames
) / sizeof(pEnumPropertyNames
[0]);
2154 sal_Int32 nDefaultCount
= sizeof(nEnumPropertyAttrDefaults
) / sizeof(nEnumPropertyAttrDefaults
[0]);
2155 sal_Int32 nDefaultFlagCount
= sizeof(nEnumPropertyAttrDefaultFlags
) / sizeof(nEnumPropertyAttrDefaultFlags
[0]);
2156 sal_Int32 nMapCount
= sizeof(eEnumPropertyMaps
) / sizeof(eEnumPropertyMaps
[0]);
2157 OSL_ENSURE((nIdCount
== nNameCount
) && (nNameCount
== nDefaultCount
) && (nDefaultCount
== nDefaultFlagCount
) && (nDefaultFlagCount
== nMapCount
),
2158 "OFormExport::exportAttributes: somebody tampered with the maps (3)!");
2160 for (i
=0; i
<nIdCount
; ++i
)
2161 exportEnumPropertyAttribute(
2162 OAttributeMetaData::getFormAttributeNamespace(eEnumPropertyIds
[i
]),
2163 OAttributeMetaData::getFormAttributeName(eEnumPropertyIds
[i
]),
2164 pEnumPropertyNames
[i
],
2165 OEnumMapper::getEnumMap(eEnumPropertyMaps
[i
]),
2166 nEnumPropertyAttrDefaults
[i
],
2167 nEnumPropertyAttrDefaultFlags
[i
]
2172 exportServiceNameAttribute();
2174 exportTargetFrameAttribute();
2176 exportTargetLocationAttribute();
2179 exportStringSequenceAttribute(
2180 OAttributeMetaData::getFormAttributeNamespace(faMasterFields
),
2181 OAttributeMetaData::getFormAttributeName(faMasterFields
),
2182 PROPERTY_MASTERFIELDS
);
2184 exportStringSequenceAttribute(
2185 OAttributeMetaData::getFormAttributeNamespace(faDetailFiels
),
2186 OAttributeMetaData::getFormAttributeName(faDetailFiels
),
2187 PROPERTY_DETAILFIELDS
);
2189 //.........................................................................
2190 } // namespace xmloff
2191 //.........................................................................