Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "elementexport.hxx"
21 : #include "strings.hxx"
22 : #include <xmloff/xmlnmspe.hxx>
23 : #include "eventexport.hxx"
24 : #include "formenums.hxx"
25 : #include "formcellbinding.hxx"
26 : #include <xmloff/xformsexport.hxx>
27 : #include "property_meta_data.hxx"
28 :
29 : #include <com/sun/star/text/XText.hpp>
30 : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : #include <com/sun/star/io/XPersistObject.hpp>
32 : #include <com/sun/star/util/Duration.hpp>
33 : #include <com/sun/star/form/FormComponentType.hpp>
34 : #include <com/sun/star/beans/PropertyAttribute.hpp>
35 : #include <com/sun/star/form/FormSubmitEncoding.hpp>
36 : #include <com/sun/star/form/FormSubmitMethod.hpp>
37 : #include <com/sun/star/sdb/CommandType.hpp>
38 : #include <com/sun/star/form/NavigationBarMode.hpp>
39 : #include <com/sun/star/form/TabulatorCycle.hpp>
40 : #include <com/sun/star/form/FormButtonType.hpp>
41 : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
42 : #include <com/sun/star/awt/VisualEffect.hpp>
43 : #include <com/sun/star/form/ListSourceType.hpp>
44 : #include <com/sun/star/awt/ImagePosition.hpp>
45 :
46 : #include <sax/tools/converter.hxx>
47 : #include <tools/gen.hxx>
48 : #include <xmloff/txtprmap.hxx>
49 : #include <com/sun/star/form/binding/XBindableValue.hpp>
50 : #include <com/sun/star/form/binding/XListEntrySink.hpp>
51 : #include <tools/urlobj.hxx>
52 : #include <xmloff/xmlexp.hxx>
53 : #include <xmloff/nmspmap.hxx>
54 : #include <xmloff/XMLEventExport.hxx>
55 : #include <xmloff/xmluconv.hxx>
56 : #include <xmloff/xmltoken.hxx>
57 : #include <tools/time.hxx>
58 : #include <tools/diagnose_ex.h>
59 : #include <comphelper/extract.hxx>
60 : #include <sal/macros.h>
61 :
62 : #include <stdio.h>
63 : #include <algorithm>
64 :
65 : namespace xmloff
66 : {
67 :
68 : #if OSL_DEBUG_LEVEL > 0
69 : #define RESET_BIT( bitfield, bit ) \
70 : bitfield = bitfield & ~bit
71 : #else
72 : #define RESET_BIT( bitfield, bit )
73 : #endif
74 :
75 : using namespace ::xmloff::token;
76 : using namespace ::com::sun::star;
77 : using namespace ::com::sun::star::uno;
78 : using namespace ::com::sun::star::sdb;
79 : using namespace ::com::sun::star::awt;
80 : using namespace ::com::sun::star::form;
81 : using namespace ::com::sun::star::lang;
82 : using namespace ::com::sun::star::beans;
83 : using namespace ::com::sun::star::container;
84 : using namespace ::com::sun::star::script;
85 : using namespace ::com::sun::star::io;
86 : using namespace ::com::sun::star::table;
87 : using namespace ::com::sun::star::text;
88 : using namespace ::com::sun::star::form::binding;
89 :
90 : //= OElementExport
91 0 : OElementExport::OElementExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps,
92 : const Sequence< ScriptEventDescriptor >& _rEvents)
93 : :OPropertyExport(_rContext, _rxProps)
94 : ,m_aEvents(_rEvents)
95 0 : ,m_pXMLElement(NULL)
96 : {
97 0 : }
98 :
99 0 : OElementExport::~OElementExport()
100 : {
101 0 : implEndElement();
102 0 : }
103 :
104 0 : void OElementExport::doExport()
105 : {
106 : // collect some general information about the element
107 0 : examine();
108 :
109 : // first add the attributes necessary for the element
110 0 : m_rContext.getGlobalContext().ClearAttrList();
111 :
112 : // add the attributes
113 0 : exportAttributes();
114 :
115 : // start the XML element
116 0 : implStartElement(getXMLElementName());
117 :
118 : // the sub elements (mostly control type dependent)
119 0 : exportSubTags();
120 :
121 0 : implEndElement();
122 0 : }
123 :
124 0 : void OElementExport::examine()
125 : {
126 : // nothing to do here
127 0 : }
128 :
129 0 : void OElementExport::exportAttributes()
130 : {
131 : // nothing to do here
132 0 : }
133 :
134 0 : void OElementExport::exportSubTags()
135 : {
136 : // the properties which where not exported 'til now
137 0 : exportRemainingProperties();
138 :
139 : // the script:events sub tags
140 0 : exportEvents();
141 0 : }
142 :
143 0 : void OElementExport::implStartElement(const sal_Char* _pName)
144 : {
145 0 : m_pXMLElement = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, true, true);
146 0 : }
147 :
148 0 : void OElementExport::implEndElement()
149 : {
150 0 : delete m_pXMLElement;
151 0 : m_pXMLElement = NULL;
152 0 : }
153 :
154 0 : void OElementExport::exportServiceNameAttribute()
155 : {
156 0 : Reference< XPersistObject > xPersistence(m_xProps, UNO_QUERY);
157 0 : if (!xPersistence.is())
158 : {
159 : OSL_FAIL("OElementExport::exportServiceNameAttribute: no XPersistObject!");
160 0 : return;
161 : }
162 :
163 0 : OUString sServiceName = xPersistence->getServiceName();
164 : // we don't want to write the old service name directly: it's a name used for compatibility reasons, but
165 : // as we start some kind of new file format here (with this xml export), we don't care about
166 : // compatibility ...
167 : // So we translate the old persistence service name into new ones, if possible
168 :
169 0 : OUString sToWriteServiceName = sServiceName;
170 : #define CHECK_N_TRANSLATE( name ) \
171 : else if (sServiceName.equals(SERVICE_PERSISTENT_COMPONENT_##name)) \
172 : sToWriteServiceName = SERVICE_##name
173 :
174 : if (false)
175 : ;
176 0 : CHECK_N_TRANSLATE( FORM );
177 0 : CHECK_N_TRANSLATE( FORM );
178 0 : CHECK_N_TRANSLATE( LISTBOX );
179 0 : CHECK_N_TRANSLATE( COMBOBOX );
180 0 : CHECK_N_TRANSLATE( RADIOBUTTON );
181 0 : CHECK_N_TRANSLATE( GROUPBOX );
182 0 : CHECK_N_TRANSLATE( FIXEDTEXT );
183 0 : CHECK_N_TRANSLATE( COMMANDBUTTON );
184 0 : CHECK_N_TRANSLATE( CHECKBOX );
185 0 : CHECK_N_TRANSLATE( GRID );
186 0 : CHECK_N_TRANSLATE( IMAGEBUTTON );
187 0 : CHECK_N_TRANSLATE( FILECONTROL );
188 0 : CHECK_N_TRANSLATE( TIMEFIELD );
189 0 : CHECK_N_TRANSLATE( DATEFIELD );
190 0 : CHECK_N_TRANSLATE( NUMERICFIELD );
191 0 : CHECK_N_TRANSLATE( CURRENCYFIELD );
192 0 : CHECK_N_TRANSLATE( PATTERNFIELD );
193 0 : CHECK_N_TRANSLATE( HIDDENCONTROL );
194 0 : CHECK_N_TRANSLATE( IMAGECONTROL );
195 0 : CHECK_N_TRANSLATE( FORMATTEDFIELD );
196 0 : else if (sServiceName.equals(SERVICE_PERSISTENT_COMPONENT_EDIT))
197 : {
198 : // special handling for the edit field: we have two controls using this as persistence service name
199 0 : sToWriteServiceName = SERVICE_EDIT;
200 0 : Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
201 0 : if (xSI.is() && xSI->supportsService(SERVICE_FORMATTEDFIELD))
202 0 : sToWriteServiceName = SERVICE_FORMATTEDFIELD;
203 : }
204 : #if OSL_DEBUG_LEVEL > 0
205 : Reference< XServiceInfo > xSI(m_xProps, UNO_QUERY);
206 : OSL_ENSURE(xSI.is() && xSI->supportsService(sToWriteServiceName),
207 : "OElementExport::exportServiceNameAttribute: wrong service name translation!");
208 :
209 : #endif
210 0 : sToWriteServiceName =
211 0 : m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
212 0 : XML_NAMESPACE_OOO, sToWriteServiceName );
213 :
214 : // now write this
215 : AddAttribute(
216 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME),
217 : OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME),
218 0 : sToWriteServiceName);
219 : }
220 :
221 0 : void OElementExport::exportEvents()
222 : {
223 0 : if (!m_aEvents.getLength())
224 : // nothing to do
225 0 : return;
226 :
227 0 : Reference< XNameReplace > xWrapper = new OEventDescriptorMapper(m_aEvents);
228 0 : m_rContext.getGlobalContext().GetEventExport().Export(xWrapper);
229 : }
230 :
231 : //= OControlExport
232 0 : OControlExport::OControlExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl,
233 : const OUString& _rControlId, const OUString& _rReferringControls,
234 : const Sequence< ScriptEventDescriptor >& _rEvents)
235 : :OElementExport(_rContext, _rxControl, _rEvents)
236 : ,m_sControlId(_rControlId)
237 : ,m_sReferringControls(_rReferringControls)
238 : ,m_nClassId(FormComponentType::CONTROL)
239 : ,m_eType( UNKNOWN )
240 : ,m_nIncludeCommon(0)
241 : ,m_nIncludeDatabase(0)
242 : ,m_nIncludeSpecial(0)
243 : ,m_nIncludeEvents(0)
244 : ,m_nIncludeBindings(0)
245 0 : ,m_pOuterElement(NULL)
246 : {
247 : OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
248 0 : }
249 :
250 0 : OControlExport::~OControlExport()
251 : {
252 0 : implEndElement();
253 0 : }
254 :
255 0 : void OControlExport::exportOuterAttributes()
256 : {
257 : // the control id
258 0 : if (CCA_NAME & m_nIncludeCommon)
259 : {
260 : exportStringPropertyAttribute(
261 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_NAME),
262 : OAttributeMetaData::getCommonControlAttributeName(CCA_NAME),
263 : PROPERTY_NAME
264 0 : );
265 : #if OSL_DEBUG_LEVEL > 0
266 : // reset the bit for later checking
267 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_NAME;
268 : #endif
269 : }
270 :
271 : // the service name
272 0 : if (m_nIncludeCommon & CCA_SERVICE_NAME)
273 : {
274 0 : exportServiceNameAttribute();
275 : #if OSL_DEBUG_LEVEL > 0
276 : // reset the bit for later checking
277 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_SERVICE_NAME;
278 : #endif
279 : }
280 0 : }
281 :
282 0 : void OControlExport::exportInnerAttributes()
283 : {
284 : // the control id
285 0 : if (CCA_CONTROL_ID & m_nIncludeCommon)
286 : {
287 : OSL_ENSURE(!m_sControlId.isEmpty(), "OControlExport::exportInnerAttributes: have no control id for the control!");
288 0 : m_rContext.getGlobalContext().AddAttributeIdLegacy(
289 0 : XML_NAMESPACE_FORM, m_sControlId);
290 : #if OSL_DEBUG_LEVEL > 0
291 : // reset the bit for later checking
292 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_CONTROL_ID;
293 : #endif
294 : }
295 :
296 : // "new-style" properties ...
297 0 : exportGenericHandlerAttributes();
298 :
299 : // common control attributes
300 0 : exportCommonControlAttributes();
301 :
302 : // common database attributes
303 0 : exportDatabaseAttributes();
304 :
305 : // attributes related to external bindings
306 0 : exportBindingAtributes();
307 :
308 : // attributes special to the respective control type
309 0 : exportSpecialAttributes();
310 :
311 : // add the style references to the attributes
312 0 : flagStyleProperties();
313 0 : }
314 :
315 0 : void OControlExport::exportAttributes()
316 : {
317 0 : exportOuterAttributes();
318 0 : }
319 :
320 0 : void OControlExport::exportSubTags() throw (Exception)
321 : {
322 : // for the upcoming exportRemainingProperties:
323 : // if a control has the LabelControl property, this is not stored with the control itself, but instead with
324 : // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't
325 : // know anything about this, we need to prevent that it tries to export this property
326 0 : exportedProperty(PROPERTY_CONTROLLABEL);
327 :
328 : // if it's a control supporting XText, then we need to declare all text-related properties
329 : // as "already exported". This prevents them from being exported as generic "form:property"-tags.
330 : // *If* we would export them this way, they would be completely superfluous, and sometimes even
331 : // disastrous, since they may, at import time, override paragraph properties which already have
332 : // been set before
333 0 : Reference< XText > xControlText( m_xProps, UNO_QUERY );
334 0 : if ( xControlText.is() )
335 : {
336 0 : const XMLPropertyMapEntry* pCharAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_TEXT );
337 0 : while ( pCharAttributeProperties->msApiName )
338 : {
339 0 : exportedProperty( OUString::createFromAscii( pCharAttributeProperties->msApiName ) );
340 0 : ++pCharAttributeProperties;
341 : }
342 :
343 0 : const XMLPropertyMapEntry* pParaAttributeProperties = XMLTextPropertySetMapper::getPropertyMapForType( TEXT_PROP_MAP_SHAPE_PARA );
344 0 : while ( pParaAttributeProperties->msApiName )
345 : {
346 0 : exportedProperty( OUString::createFromAscii( pParaAttributeProperties->msApiName ) );
347 0 : ++pParaAttributeProperties;
348 : }
349 :
350 : // the RichText property is not exported. The presence of the text:p element
351 : // will be used - upon reading - as indicator for the value of the RichText property
352 0 : exportedProperty( PROPERTY_RICH_TEXT );
353 :
354 : // strange thing: paragraphs support both a CharStrikeout and a CharCrossedOut property
355 : // The former is a short/enum value, the latter a boolean. The former has a real meaning
356 : // (the strikeout type), the latter hasn't. But, when the CharCrossedOut is exported and
357 : // later on imported, it overwrites anything which has previously been imported for
358 : // CharStrikeout.
359 : // #i27729#
360 0 : exportedProperty( OUString( "CharCrossedOut" ) );
361 : }
362 :
363 0 : if ( m_eType == LISTBOX )
364 : {
365 : // will be exported in exportListSourceAsElements:
366 0 : if ( controlHasUserSuppliedListEntries() )
367 0 : exportedProperty( PROPERTY_DEFAULT_SELECT_SEQ );
368 :
369 : // will not be exported in a generic way. Either exportListSourceAsElements cares
370 : // for them, or we don't need them
371 0 : exportedProperty( PROPERTY_STRING_ITEM_LIST );
372 0 : exportedProperty( PROPERTY_VALUE_SEQ );
373 0 : exportedProperty( PROPERTY_SELECT_SEQ );
374 0 : exportedProperty( PROPERTY_LISTSOURCE );
375 : }
376 0 : if ( m_eType == COMBOBOX )
377 0 : exportedProperty( PROPERTY_STRING_ITEM_LIST );
378 :
379 : // let the base class export the remaining properties and the events
380 0 : OElementExport::exportSubTags();
381 :
382 : // special sub tags for some controls
383 0 : switch (m_eType)
384 : {
385 : case LISTBOX:
386 : // don't export the list entries if the are not provided by the user, but obtained implicitly
387 : // from other sources
388 : // #i26944#
389 0 : if ( controlHasUserSuppliedListEntries() )
390 0 : exportListSourceAsElements();
391 0 : break;
392 : case GRID:
393 : { // a grid control requires us to store all columns as sub elements
394 0 : Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY);
395 : OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!");
396 0 : if (xColumnContainer.is())
397 0 : m_rContext.exportCollectionElements(xColumnContainer);
398 : }
399 0 : break;
400 : case COMBOBOX:
401 : { // a combox box description has sub elements: the items
402 : DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< OUString > );
403 :
404 : // don't export the list entries if the are not provided by the user, but obtained implicitly
405 : // from other sources
406 : // #i26944#
407 0 : if ( controlHasUserSuppliedListEntries() )
408 : {
409 : // get the item list
410 0 : Sequence< OUString > aListItems;
411 0 : m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
412 : // loop through it and write the sub elements
413 0 : const OUString* pListItems = aListItems.getConstArray();
414 0 : for (sal_Int32 i=0; i<aListItems.getLength(); ++i, ++pListItems)
415 : {
416 0 : m_rContext.getGlobalContext().ClearAttrList();
417 : AddAttribute(
418 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
419 : OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
420 0 : *pListItems);
421 0 : SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", true, true);
422 0 : }
423 : }
424 : }
425 0 : break;
426 :
427 : case TEXT_AREA:
428 : {
429 : // if we act as rich text control, we need to export some text:p elements
430 0 : if ( xControlText.is() )
431 : {
432 0 : sal_Bool bActingAsRichText = sal_False;
433 0 : if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_RICH_TEXT ) )
434 : {
435 0 : OSL_VERIFY(m_xProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bActingAsRichText );
436 : }
437 :
438 0 : if ( bActingAsRichText )
439 0 : m_rContext.getGlobalContext().GetTextParagraphExport()->exportText( xControlText );
440 : }
441 : }
442 0 : break;
443 : default:
444 : // nothing do to
445 0 : break;
446 0 : }
447 0 : }
448 :
449 0 : void OControlExport::exportGenericHandlerAttributes()
450 : {
451 0 : const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
452 0 : for ( const Property* prop = aProperties.getConstArray();
453 0 : prop != aProperties.getConstArray() + aProperties.getLength();
454 : ++prop
455 : )
456 : {
457 : try
458 : {
459 : // see if this property can already be handled with an IPropertyHandler (which, on the long
460 : // term, should be the case for most, if not all, properties)
461 0 : const PropertyDescription* propDescription = metadata::getPropertyDescription( prop->Name );
462 0 : if ( propDescription == NULL )
463 0 : continue;
464 :
465 : // let the factory provide the concrete handler. Note that caching, if desired, is the task
466 : // of the factory
467 0 : PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId );
468 0 : if ( !handler.get() )
469 : {
470 : SAL_WARN( "xmloff.forms", "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" );
471 0 : continue;
472 : }
473 :
474 0 : OUString attributeValue;
475 0 : if ( propDescription->propertyGroup == NO_GROUP )
476 : {
477 : // that's a property which has a direct mapping to an attribute
478 0 : if ( !shouldExportProperty( prop->Name ) )
479 : // TODO: in the future, we surely need a more sophisticated approach to this, involving the property
480 : // handler, or the property description
481 : {
482 0 : exportedProperty( prop->Name );
483 0 : continue;
484 : }
485 :
486 0 : const Any propValue = m_xProps->getPropertyValue( prop->Name );
487 0 : attributeValue = handler->getAttributeValue( propValue );
488 : }
489 : else
490 : {
491 : // that's a property which is part of a group of properties, whose values, in their entity, comprise
492 : // a single attribute value
493 :
494 : // retrieve the descriptions of all other properties which add to the attribute value
495 0 : PropertyDescriptionList descriptions;
496 0 : metadata::getPropertyGroup( propDescription->propertyGroup, descriptions );
497 :
498 : // retrieve the values for all those properties
499 0 : PropertyValues aValues;
500 0 : for ( PropertyDescriptionList::iterator desc = descriptions.begin();
501 0 : desc != descriptions.end();
502 : ++desc
503 : )
504 : {
505 : // TODO: XMultiPropertySet?
506 0 : const Any propValue = m_xProps->getPropertyValue( (*desc)->propertyName );
507 0 : aValues[ (*desc)->propertyId ] = propValue;
508 0 : }
509 :
510 : // let the handler translate into an XML attribute value
511 0 : attributeValue = handler->getAttributeValue( aValues );
512 : }
513 :
514 : AddAttribute(
515 : propDescription->attribute.namespacePrefix,
516 0 : token::GetXMLToken( propDescription->attribute.attributeToken ),
517 : attributeValue
518 0 : );
519 :
520 0 : exportedProperty( prop->Name );
521 : }
522 0 : catch( const Exception& )
523 : {
524 : DBG_UNHANDLED_EXCEPTION();
525 : }
526 0 : }
527 0 : }
528 :
529 0 : void OControlExport::exportCommonControlAttributes()
530 : {
531 0 : size_t i=0;
532 :
533 : // I decided to handle all the properties here with some static arrays describing the property-attribute
534 : // relations. This leads to somewhat ugly code :), but the only alternative I can think of right now
535 : // would require maps and O(log n) searches, which seems somewhat expensive as this code is used
536 : // very frequently.
537 :
538 : // the extra indents for the respective blocks are to ensure that there is no copy'n'paste error, using
539 : // map identifiers from the wrong block
540 :
541 : // some string properties
542 : {
543 : // the attribute ids of all properties which are expected to be of type string
544 : static const sal_Int32 nStringPropertyAttributeIds[] =
545 : {
546 : CCA_LABEL, CCA_TITLE
547 : };
548 : // the names of all properties which are expected to be of type string
549 : static const OUString aStringPropertyNames[] =
550 : {
551 : OUString(PROPERTY_LABEL), OUString(PROPERTY_TITLE)
552 0 : };
553 : OSL_ENSURE( sizeof(aStringPropertyNames)/sizeof(aStringPropertyNames[0]) ==
554 : sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]),
555 : "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
556 :
557 0 : for (i=0; i<sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]); ++i)
558 0 : if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
559 : {
560 : exportStringPropertyAttribute(
561 0 : OAttributeMetaData::getCommonControlAttributeNamespace(nStringPropertyAttributeIds[i]),
562 0 : OAttributeMetaData::getCommonControlAttributeName(nStringPropertyAttributeIds[i]),
563 : aStringPropertyNames[i]
564 0 : );
565 : #if OSL_DEBUG_LEVEL > 0
566 : // reset the bit for later checking
567 : m_nIncludeCommon = m_nIncludeCommon & ~nStringPropertyAttributeIds[i];
568 : #endif
569 : }
570 : }
571 :
572 : // some boolean properties
573 : {
574 : static const sal_Int32 nBooleanPropertyAttributeIds[] =
575 : { // attribute flags
576 : CCA_CURRENT_SELECTED, CCA_DISABLED, CCA_DROPDOWN, CCA_PRINTABLE, CCA_READONLY, CCA_SELECTED, CCA_TAB_STOP, CCA_ENABLEVISIBLE
577 : };
578 : static const OUString pBooleanPropertyNames[] =
579 : { // property names
580 : OUString(PROPERTY_STATE), OUString(PROPERTY_ENABLED),
581 : OUString(PROPERTY_DROPDOWN), OUString(PROPERTY_PRINTABLE),
582 : OUString(PROPERTY_READONLY), OUString(PROPERTY_DEFAULT_STATE),
583 : OUString(PROPERTY_TABSTOP), OUString(PROPERTY_ENABLEVISIBLE)
584 0 : };
585 : static const sal_Bool nBooleanPropertyAttrFlags[] =
586 : { // attribute defaults
587 : 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
588 : };
589 : #if OSL_DEBUG_LEVEL > 0
590 : static const sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
591 : static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
592 : static const sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
593 : OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
594 : "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
595 : #endif
596 0 : for (i=0; i<sizeof(nBooleanPropertyAttributeIds)/sizeof(nBooleanPropertyAttributeIds[0]); ++i)
597 0 : if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
598 : {
599 : exportBooleanPropertyAttribute(
600 0 : OAttributeMetaData::getCommonControlAttributeNamespace(nBooleanPropertyAttributeIds[i]),
601 0 : OAttributeMetaData::getCommonControlAttributeName(nBooleanPropertyAttributeIds[i]),
602 : pBooleanPropertyNames[i],
603 0 : nBooleanPropertyAttrFlags[i]);
604 : #if OSL_DEBUG_LEVEL > 0
605 : // reset the bit for later checking
606 : m_nIncludeCommon = m_nIncludeCommon & ~nBooleanPropertyAttributeIds[i];
607 : #endif
608 : }
609 : }
610 :
611 : // some integer properties
612 : {
613 : // now the common handling
614 : static sal_Int32 nIntegerPropertyAttributeIds[] =
615 : { // attribute flags
616 : CCA_SIZE, CCA_TAB_INDEX
617 : };
618 : static const OUString pIntegerPropertyNames[] =
619 : { // property names
620 : OUString(PROPERTY_LINECOUNT), OUString(PROPERTY_TABINDEX)
621 0 : };
622 : static const sal_Int16 nIntegerPropertyAttrDefaults[] =
623 : { // attribute defaults
624 : 5, 0
625 : };
626 :
627 0 : if ( m_nIncludeCommon & CCA_MAX_LENGTH )
628 0 : exportedProperty(PROPERTY_MAXTEXTLENGTH);
629 :
630 : #if OSL_DEBUG_LEVEL > 0
631 : static const sal_Int32 nIdCount = sizeof(nIntegerPropertyAttributeIds) / sizeof(nIntegerPropertyAttributeIds[0]);
632 : static const sal_Int32 nNameCount = sizeof(pIntegerPropertyNames) / sizeof(pIntegerPropertyNames[0]);
633 : static const sal_Int32 nDefaultCount = sizeof(nIntegerPropertyAttrDefaults) / sizeof(nIntegerPropertyAttrDefaults[0]);
634 : OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
635 : "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
636 : #endif
637 0 : for (i=0; i<sizeof(nIntegerPropertyAttributeIds)/sizeof(nIntegerPropertyAttributeIds[0]); ++i)
638 0 : if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
639 : {
640 : exportInt16PropertyAttribute(
641 0 : OAttributeMetaData::getCommonControlAttributeNamespace(nIntegerPropertyAttributeIds[i]),
642 : OAttributeMetaData::getCommonControlAttributeName(nIntegerPropertyAttributeIds[i]),
643 : pIntegerPropertyNames[i],
644 0 : nIntegerPropertyAttrDefaults[i]);
645 : #if OSL_DEBUG_LEVEL > 0
646 : // reset the bit for later checking
647 : m_nIncludeCommon = m_nIncludeCommon & ~nIntegerPropertyAttributeIds[i];
648 : #endif
649 : }
650 :
651 : }
652 :
653 : // some enum properties
654 : {
655 0 : if (m_nIncludeCommon & CCA_BUTTON_TYPE)
656 : {
657 : exportEnumPropertyAttribute(
658 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_BUTTON_TYPE),
659 : OAttributeMetaData::getCommonControlAttributeName(CCA_BUTTON_TYPE),
660 : PROPERTY_BUTTONTYPE,
661 : OEnumMapper::getEnumMap(OEnumMapper::epButtonType),
662 0 : FormButtonType_PUSH);
663 : #if OSL_DEBUG_LEVEL > 0
664 : // reset the bit for later checking
665 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_BUTTON_TYPE;
666 : #endif
667 : }
668 0 : if ( m_nIncludeCommon & CCA_ORIENTATION )
669 : {
670 : exportEnumPropertyAttribute(
671 0 : OAttributeMetaData::getCommonControlAttributeNamespace( CCA_ORIENTATION ),
672 : OAttributeMetaData::getCommonControlAttributeName( CCA_ORIENTATION ),
673 : PROPERTY_ORIENTATION,
674 : OEnumMapper::getEnumMap( OEnumMapper::epOrientation ),
675 : ScrollBarOrientation::HORIZONTAL
676 0 : );
677 : #if OSL_DEBUG_LEVEL > 0
678 : // reset the bit for later checking
679 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_ORIENTATION;
680 : #endif
681 : }
682 :
683 0 : if ( m_nIncludeCommon & CCA_VISUAL_EFFECT )
684 : {
685 : exportEnumPropertyAttribute(
686 0 : OAttributeMetaData::getCommonControlAttributeNamespace( CCA_VISUAL_EFFECT ),
687 : OAttributeMetaData::getCommonControlAttributeName( CCA_VISUAL_EFFECT ),
688 : PROPERTY_VISUAL_EFFECT,
689 : OEnumMapper::getEnumMap( OEnumMapper::epVisualEffect ),
690 : VisualEffect::LOOK3D
691 0 : );
692 : #if OSL_DEBUG_LEVEL > 0
693 : // reset the bit for later checking
694 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_VISUAL_EFFECT;
695 : #endif
696 : }
697 : }
698 :
699 : // some properties which require a special handling
700 :
701 : // the target frame
702 0 : if (m_nIncludeCommon & CCA_TARGET_FRAME)
703 : {
704 0 : exportTargetFrameAttribute();
705 : #if OSL_DEBUG_LEVEL > 0
706 : // reset the bit for later checking
707 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_FRAME;
708 : #endif
709 : }
710 :
711 : // max text length
712 0 : if ( m_nIncludeCommon & CCA_MAX_LENGTH )
713 : {
714 : // normally, the respective property would be "MaxTextLen"
715 : // However, if the model has a property "PersistenceMaxTextLength", then we prefer this
716 :
717 : // determine the name of the property to export
718 0 : OUString sTextLenPropertyName( PROPERTY_MAXTEXTLENGTH );
719 0 : if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_PERSISTENCE_MAXTEXTLENGTH ) )
720 0 : sTextLenPropertyName = PROPERTY_PERSISTENCE_MAXTEXTLENGTH;
721 :
722 : // export it
723 : exportInt16PropertyAttribute(
724 0 : OAttributeMetaData::getCommonControlAttributeNamespace( CCA_MAX_LENGTH ),
725 : OAttributeMetaData::getCommonControlAttributeName( CCA_MAX_LENGTH ),
726 : sTextLenPropertyName,
727 : 0
728 0 : );
729 :
730 : // in either way, both properties count as "exported"
731 0 : exportedProperty( PROPERTY_MAXTEXTLENGTH );
732 0 : exportedProperty( PROPERTY_PERSISTENCE_MAXTEXTLENGTH );
733 :
734 : #if OSL_DEBUG_LEVEL > 0
735 : // reset the bit for later checking
736 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_MAX_LENGTH;
737 : #endif
738 : }
739 :
740 0 : if (m_nIncludeCommon & CCA_TARGET_LOCATION)
741 : {
742 0 : exportTargetLocationAttribute(false);
743 : #if OSL_DEBUG_LEVEL > 0
744 : // reset the bit for later checking
745 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_LOCATION;
746 : #endif
747 : }
748 :
749 : // OJ #99721#
750 0 : if (m_nIncludeCommon & CCA_IMAGE_DATA)
751 : {
752 0 : exportImageDataAttribute();
753 : #if OSL_DEBUG_LEVEL > 0
754 : // reset the bit for later checking
755 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_IMAGE_DATA;
756 : #endif
757 : }
758 :
759 : // the for attribute
760 : // the target frame
761 0 : if (m_nIncludeCommon & CCA_FOR)
762 : {
763 0 : if (!m_sReferringControls.isEmpty())
764 : { // there is at least one control referring to the one we're handling currently
765 : AddAttribute(
766 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_FOR),
767 : OAttributeMetaData::getCommonControlAttributeName(CCA_FOR),
768 0 : m_sReferringControls);
769 : }
770 : #if OSL_DEBUG_LEVEL > 0
771 : // reset the bit for later checking
772 : m_nIncludeCommon = m_nIncludeCommon & ~CCA_FOR;
773 : #endif
774 : }
775 :
776 0 : if ((CCA_CURRENT_VALUE | CCA_VALUE) & m_nIncludeCommon)
777 : {
778 0 : const sal_Char* pCurrentValuePropertyName = NULL;
779 0 : const sal_Char* pValuePropertyName = NULL;
780 :
781 : // get the property names
782 0 : getValuePropertyNames(m_eType, m_nClassId, pCurrentValuePropertyName, pValuePropertyName);
783 :
784 0 : static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE);
785 0 : static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE);
786 0 : static const sal_uInt16 nCurrentValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_VALUE);
787 0 : static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE);
788 :
789 : // add the atrtributes if necessary and possible
790 0 : if (pCurrentValuePropertyName && (CCA_CURRENT_VALUE & m_nIncludeCommon))
791 : {
792 : // don't export the current-value if this value originates from a data binding
793 : // #i26944#
794 0 : if ( controlHasActiveDataBinding() )
795 0 : exportedProperty( OUString::createFromAscii( pCurrentValuePropertyName ) );
796 : else
797 : exportGenericPropertyAttribute(
798 : nCurrentValueAttributeNamespaceKey,
799 : pCurrentValueAttributeName,
800 : pCurrentValuePropertyName
801 0 : );
802 : }
803 :
804 0 : if (pValuePropertyName && (CCA_VALUE & m_nIncludeCommon))
805 : exportGenericPropertyAttribute(
806 : nValueAttributeNamespaceKey,
807 : pValueAttributeName,
808 0 : pValuePropertyName);
809 :
810 : OSL_ENSURE((NULL == pValuePropertyName) == (0 == (CCA_VALUE & m_nIncludeCommon)),
811 : "OControlExport::exportCommonControlAttributes: no property found for the value attribute!");
812 : OSL_ENSURE((NULL == pCurrentValuePropertyName ) == (0 == (CCA_CURRENT_VALUE & m_nIncludeCommon)),
813 : "OControlExport::exportCommonControlAttributes: no property found for the current-value attribute!");
814 :
815 : #if OSL_DEBUG_LEVEL > 0
816 : // reset the bit for later checking
817 : m_nIncludeCommon = m_nIncludeCommon & ~(CCA_CURRENT_VALUE | CCA_VALUE);
818 : #endif
819 : }
820 :
821 : OSL_ENSURE(0 == m_nIncludeCommon,
822 : "OControlExport::exportCommonControlAttributes: forgot some flags!");
823 : // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
824 : // be 0 now ...
825 0 : }
826 :
827 0 : void OControlExport::exportDatabaseAttributes()
828 : {
829 : #if OSL_DEBUG_LEVEL > 0
830 : sal_Int32 nIncludeDatabase = m_nIncludeDatabase;
831 : #endif
832 : // the only string property: DataField
833 0 : if (DA_DATA_FIELD & m_nIncludeDatabase)
834 : {
835 : exportStringPropertyAttribute(
836 0 : OAttributeMetaData::getDatabaseAttributeNamespace(DA_DATA_FIELD),
837 : OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD),
838 0 : PROPERTY_DATAFIELD);
839 : RESET_BIT( nIncludeDatabase, DA_DATA_FIELD );
840 : }
841 :
842 : // InputRequired
843 0 : if ( DA_INPUT_REQUIRED & m_nIncludeDatabase )
844 : {
845 : exportBooleanPropertyAttribute(
846 0 : OAttributeMetaData::getDatabaseAttributeNamespace( DA_INPUT_REQUIRED ),
847 : OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ),
848 : PROPERTY_INPUT_REQUIRED,
849 : BOOLATTR_DEFAULT_TRUE
850 0 : );
851 : RESET_BIT( nIncludeDatabase, DA_INPUT_REQUIRED );
852 : }
853 :
854 : // the only int16 property: BoundColumn
855 0 : if (DA_BOUND_COLUMN & m_nIncludeDatabase)
856 : {
857 : exportInt16PropertyAttribute(
858 0 : OAttributeMetaData::getDatabaseAttributeNamespace(DA_BOUND_COLUMN),
859 : OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN),
860 : PROPERTY_BOUNDCOLUMN,
861 : 0,
862 0 : true);
863 : RESET_BIT( nIncludeDatabase, DA_BOUND_COLUMN );
864 : }
865 :
866 : // ConvertEmptyToNull
867 0 : if (DA_CONVERT_EMPTY & m_nIncludeDatabase)
868 : {
869 : exportBooleanPropertyAttribute(
870 0 : OAttributeMetaData::getDatabaseAttributeNamespace(DA_CONVERT_EMPTY),
871 : OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY),
872 : PROPERTY_EMPTY_IS_NULL,
873 : BOOLATTR_DEFAULT_FALSE
874 0 : );
875 : RESET_BIT( nIncludeDatabase, DA_CONVERT_EMPTY );
876 : }
877 :
878 : // the only enum property: ListSourceType
879 0 : if (DA_LIST_SOURCE_TYPE & m_nIncludeDatabase)
880 : {
881 : exportEnumPropertyAttribute(
882 0 : OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE_TYPE),
883 : OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE),
884 : PROPERTY_LISTSOURCETYPE,
885 : OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
886 : ListSourceType_VALUELIST
887 0 : );
888 : RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE_TYPE );
889 : }
890 :
891 0 : if (m_nIncludeDatabase & DA_LIST_SOURCE)
892 : {
893 0 : exportListSourceAsAttribute();
894 : RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE );
895 : }
896 :
897 : #if OSL_DEBUG_LEVEL > 0
898 : OSL_ENSURE(0 == nIncludeDatabase,
899 : "OControlExport::exportDatabaseAttributes: forgot some flags!");
900 : // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
901 : // be 0 now ...
902 : #endif
903 0 : }
904 :
905 0 : void OControlExport::exportBindingAtributes()
906 : {
907 : #if OSL_DEBUG_LEVEL > 0
908 : sal_Int32 nIncludeBinding = m_nIncludeBindings;
909 : #endif
910 :
911 0 : if ( m_nIncludeBindings & BA_LINKED_CELL )
912 : {
913 0 : exportCellBindingAttributes( ( m_nIncludeBindings & BA_LIST_LINKING_TYPE ) != 0 );
914 : #if OSL_DEBUG_LEVEL > 0
915 : // reset the bit for later checking
916 : nIncludeBinding = nIncludeBinding & ~( BA_LINKED_CELL | BA_LIST_LINKING_TYPE );
917 : #endif
918 : }
919 :
920 0 : if ( m_nIncludeBindings & BA_LIST_CELL_RANGE )
921 : {
922 0 : exportCellListSourceRange();
923 : #if OSL_DEBUG_LEVEL > 0
924 : // reset the bit for later checking
925 : nIncludeBinding = nIncludeBinding & ~BA_LIST_CELL_RANGE;
926 : #endif
927 : }
928 :
929 0 : if ( m_nIncludeBindings & BA_XFORMS_BIND )
930 : {
931 0 : exportXFormsBindAttributes();
932 : #if OSL_DEBUG_LEVEL > 0
933 : // reset the bit for later checking
934 : nIncludeBinding = nIncludeBinding & ~BA_XFORMS_BIND;
935 : #endif
936 : }
937 :
938 0 : if ( m_nIncludeBindings & BA_XFORMS_LISTBIND )
939 : {
940 0 : exportXFormsListAttributes();
941 : #if OSL_DEBUG_LEVEL > 0
942 : // reset the bit for later checking
943 : nIncludeBinding = nIncludeBinding & ~BA_XFORMS_LISTBIND;
944 : #endif
945 : }
946 :
947 0 : if ( m_nIncludeBindings & BA_XFORMS_SUBMISSION )
948 : {
949 0 : exportXFormsSubmissionAttributes();
950 : #if OSL_DEBUG_LEVEL > 0
951 : // reset the bit for later checking
952 : nIncludeBinding = nIncludeBinding & ~BA_XFORMS_SUBMISSION;
953 : #endif
954 : }
955 :
956 : OSL_ENSURE( 0 == nIncludeBinding,
957 : "OControlExport::exportBindingAtributes: forgot some flags!");
958 : // in the debug version, we should have removed every bit we handled from the mask, so it should
959 : // be 0 now ...
960 0 : }
961 :
962 0 : void OControlExport::exportSpecialAttributes()
963 : {
964 0 : sal_Int32 i=0;
965 :
966 : // the boolean properties
967 : {
968 : static const sal_Int32 nBooleanPropertyAttributeIds[] =
969 : { // attribute flags
970 : SCA_VALIDATION, SCA_MULTI_LINE, SCA_AUTOMATIC_COMPLETION, SCA_MULTIPLE, SCA_DEFAULT_BUTTON, SCA_IS_TRISTATE,
971 : SCA_TOGGLE, SCA_FOCUS_ON_CLICK
972 : };
973 : static const OUString pBooleanPropertyNames[] =
974 : { // property names
975 : OUString(PROPERTY_STRICTFORMAT), OUString(PROPERTY_MULTILINE),
976 : OUString(PROPERTY_AUTOCOMPLETE),
977 : OUString(PROPERTY_MULTISELECTION),
978 : OUString(PROPERTY_DEFAULTBUTTON), OUString(PROPERTY_TRISTATE),
979 : OUString(PROPERTY_TOGGLE), OUString(PROPERTY_FOCUS_ON_CLICK)
980 0 : };
981 : static const sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
982 : #if OSL_DEBUG_LEVEL > 0
983 : static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
984 : OSL_ENSURE((nIdCount == nNameCount),
985 : "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!");
986 : #endif
987 0 : const sal_Int32* pAttributeId = nBooleanPropertyAttributeIds;
988 0 : for ( i = 0; i < nIdCount; ++i, ++pAttributeId )
989 : {
990 0 : if ( *pAttributeId & m_nIncludeSpecial)
991 : {
992 : exportBooleanPropertyAttribute(
993 0 : OAttributeMetaData::getSpecialAttributeNamespace( *pAttributeId ),
994 : OAttributeMetaData::getSpecialAttributeName( *pAttributeId ),
995 : pBooleanPropertyNames[i],
996 0 : ( *pAttributeId == SCA_FOCUS_ON_CLICK ) ? BOOLATTR_DEFAULT_TRUE : BOOLATTR_DEFAULT_FALSE
997 0 : );
998 : #if OSL_DEBUG_LEVEL > 0
999 : // reset the bit for later checking
1000 : m_nIncludeSpecial = m_nIncludeSpecial & ~*pAttributeId;
1001 : #endif
1002 : }
1003 : }
1004 : }
1005 :
1006 : // the integer properties
1007 : {
1008 : static sal_Int32 nIntegerPropertyAttributeIds[] =
1009 : { // attribute flags
1010 : SCA_PAGE_STEP_SIZE
1011 : };
1012 : static const OUString pIntegerPropertyNames[] =
1013 : { // property names
1014 : OUString(PROPERTY_BLOCK_INCREMENT)
1015 0 : };
1016 : static const sal_Int32 nIntegerPropertyAttrDefaults[] =
1017 : { // attribute defaults (XML defaults, not runtime defaults!)
1018 : 10
1019 : };
1020 :
1021 : static const sal_Int32 nIdCount = sizeof( nIntegerPropertyAttributeIds ) / sizeof( nIntegerPropertyAttributeIds[0] );
1022 : #if OSL_DEBUG_LEVEL > 0
1023 : static const sal_Int32 nNameCount = sizeof( pIntegerPropertyNames ) / sizeof( pIntegerPropertyNames[0] );
1024 : OSL_ENSURE( ( nIdCount == nNameCount ),
1025 : "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1026 : static const sal_Int32 nDefaultCount = sizeof( nIntegerPropertyAttrDefaults ) / sizeof( nIntegerPropertyAttrDefaults[0] );
1027 : OSL_ENSURE( ( nIdCount == nDefaultCount ),
1028 : "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" );
1029 : #endif
1030 0 : for ( i = 0; i < nIdCount; ++i )
1031 0 : if ( nIntegerPropertyAttributeIds[i] & m_nIncludeSpecial )
1032 : {
1033 : exportInt32PropertyAttribute(
1034 0 : OAttributeMetaData::getSpecialAttributeNamespace( nIntegerPropertyAttributeIds[i] ),
1035 : OAttributeMetaData::getSpecialAttributeName( nIntegerPropertyAttributeIds[i] ),
1036 : pIntegerPropertyNames[i],
1037 0 : nIntegerPropertyAttrDefaults[i]
1038 0 : );
1039 : #if OSL_DEBUG_LEVEL > 0
1040 : // reset the bit for later checking
1041 : m_nIncludeSpecial = m_nIncludeSpecial & ~nIntegerPropertyAttributeIds[i];
1042 : #endif
1043 : }
1044 :
1045 0 : if ( SCA_STEP_SIZE & m_nIncludeSpecial )
1046 : {
1047 0 : OUString sPropertyName;
1048 0 : if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
1049 0 : sPropertyName = PROPERTY_LINE_INCREMENT;
1050 0 : else if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
1051 0 : sPropertyName = PROPERTY_SPIN_INCREMENT;
1052 : else
1053 : OSL_FAIL( "OControlExport::exportSpecialAttributes: not property which can be mapped to step-size attribute!" );
1054 :
1055 0 : if ( !sPropertyName.isEmpty() )
1056 : exportInt32PropertyAttribute(
1057 0 : OAttributeMetaData::getSpecialAttributeNamespace( SCA_STEP_SIZE ),
1058 : OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ),
1059 : sPropertyName,
1060 : 1
1061 0 : );
1062 :
1063 : #if OSL_DEBUG_LEVEL > 0
1064 : // reset the bit for later checking
1065 : m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STEP_SIZE;
1066 : #endif
1067 : }
1068 :
1069 : }
1070 :
1071 : // the enum properties
1072 : {
1073 0 : if (SCA_STATE & m_nIncludeSpecial)
1074 : {
1075 : exportEnumPropertyAttribute(
1076 0 : OAttributeMetaData::getSpecialAttributeNamespace(SCA_STATE),
1077 : OAttributeMetaData::getSpecialAttributeName(SCA_STATE),
1078 : PROPERTY_DEFAULT_STATE,
1079 : OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1080 0 : TRISTATE_FALSE);
1081 : #if OSL_DEBUG_LEVEL > 0
1082 : // reset the bit for later checking
1083 : m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STATE;
1084 : #endif
1085 : }
1086 :
1087 0 : if (SCA_CURRENT_STATE & m_nIncludeSpecial)
1088 : {
1089 : exportEnumPropertyAttribute(
1090 0 : OAttributeMetaData::getSpecialAttributeNamespace(SCA_CURRENT_STATE),
1091 : OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE),
1092 : PROPERTY_STATE,
1093 : OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
1094 0 : TRISTATE_FALSE);
1095 : #if OSL_DEBUG_LEVEL > 0
1096 : // reset the bit for later checking
1097 : m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_CURRENT_STATE;
1098 : #endif
1099 : }
1100 : }
1101 :
1102 : // some properties which require a special handling
1103 : // the repeat delay
1104 : {
1105 0 : if ( m_nIncludeSpecial & SCA_REPEAT_DELAY )
1106 : {
1107 : DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY, sal_Int32 );
1108 :
1109 0 : sal_Int32 nRepeatDelay = 0;
1110 0 : m_xProps->getPropertyValue( PROPERTY_REPEAT_DELAY ) >>= nRepeatDelay;
1111 0 : Time aTime( Time::SYSTEM );
1112 0 : aTime.MakeTimeFromMS( nRepeatDelay );
1113 0 : util::Duration aDuration;
1114 0 : aDuration.Hours = aTime.GetHour();
1115 0 : aDuration.Minutes = aTime.GetMin();
1116 0 : aDuration.Seconds = aTime.GetSec();
1117 0 : aDuration.NanoSeconds = (nRepeatDelay % 1000) * 1000000;
1118 :
1119 0 : OUStringBuffer buf;
1120 0 : ::sax::Converter::convertDuration(buf, aDuration);
1121 0 : AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCA_REPEAT_DELAY )
1122 : ,OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY )
1123 0 : ,buf.makeStringAndClear());
1124 :
1125 0 : exportedProperty( PROPERTY_REPEAT_DELAY );
1126 :
1127 : #if OSL_DEBUG_LEVEL > 0
1128 : // reset the bit for later checking
1129 : m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_REPEAT_DELAY;
1130 : #endif
1131 : }
1132 : }
1133 :
1134 : // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string
1135 : {
1136 0 : if (SCA_ECHO_CHAR & m_nIncludeSpecial)
1137 : {
1138 : DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 );
1139 0 : sal_Int16 nValue(0);
1140 0 : m_xProps->getPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue;
1141 0 : if (nValue)
1142 : {
1143 0 : OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1);
1144 : AddAttribute(
1145 0 : OAttributeMetaData::getSpecialAttributeNamespace(SCA_ECHO_CHAR),
1146 : OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR),
1147 0 : sCharacter);
1148 : }
1149 0 : exportedProperty(PROPERTY_ECHO_CHAR);
1150 : #if OSL_DEBUG_LEVEL > 0
1151 : // reset the bit for later checking
1152 : m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_ECHO_CHAR;
1153 : #endif
1154 : }
1155 : }
1156 :
1157 : // the string properties
1158 : {
1159 : static const sal_Int32 nStringPropertyAttributeIds[] =
1160 : { // attribute flags
1161 : SCA_GROUP_NAME
1162 : };
1163 : static const OUString pStringPropertyNames[] =
1164 : { // property names
1165 : OUString(PROPERTY_GROUP_NAME)
1166 0 : };
1167 :
1168 : static const sal_Int32 nIdCount = sizeof( nStringPropertyAttributeIds ) / sizeof( nStringPropertyAttributeIds[0] );
1169 : #if OSL_DEBUG_LEVEL > 0
1170 : static const sal_Int32 nNameCount = sizeof( pStringPropertyNames ) / sizeof( pStringPropertyNames[0] );
1171 : OSL_ENSURE( ( nIdCount == nNameCount ),
1172 : "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" );
1173 : #endif
1174 0 : for ( i = 0; i < nIdCount; ++i )
1175 0 : if ( nStringPropertyAttributeIds[i] & m_nIncludeSpecial )
1176 : {
1177 : exportStringPropertyAttribute(
1178 0 : OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ),
1179 0 : OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ),
1180 : pStringPropertyNames[i]
1181 0 : );
1182 : #if OSL_DEBUG_LEVEL > 0
1183 : // reset the bit for later checking
1184 : m_nIncludeSpecial = m_nIncludeSpecial & ~nStringPropertyAttributeIds[i];
1185 : #endif
1186 : }
1187 : }
1188 :
1189 0 : if ((SCA_MIN_VALUE | SCA_MAX_VALUE) & m_nIncludeSpecial)
1190 : {
1191 : // need to export the min value and the max value as attributes
1192 : // It depends on the real type (FormComponentType) of the control, which properties hold these
1193 : // values
1194 0 : const sal_Char* pMinValuePropertyName = NULL;
1195 0 : const sal_Char* pMaxValuePropertyName = NULL;
1196 0 : getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName);
1197 :
1198 : OSL_ENSURE((NULL == pMinValuePropertyName) == (0 == (SCA_MIN_VALUE & m_nIncludeSpecial)),
1199 : "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!");
1200 : OSL_ENSURE((NULL == pMaxValuePropertyName) == (0 == (SCA_MAX_VALUE & m_nIncludeSpecial)),
1201 : "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!");
1202 :
1203 : // add the two attributes
1204 0 : static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE);
1205 0 : static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE);
1206 0 : static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MIN_VALUE);
1207 0 : static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MAX_VALUE);
1208 :
1209 0 : if (pMinValuePropertyName && (SCA_MIN_VALUE & m_nIncludeSpecial))
1210 : exportGenericPropertyAttribute(
1211 : nMinValueNamespaceKey,
1212 : pMinValueAttributeName,
1213 0 : pMinValuePropertyName);
1214 :
1215 0 : if (pMaxValuePropertyName && (SCA_MAX_VALUE & m_nIncludeSpecial))
1216 : exportGenericPropertyAttribute(
1217 : nMaxValueNamespaceKey,
1218 : pMaxValueAttributeName,
1219 0 : pMaxValuePropertyName);
1220 : #if OSL_DEBUG_LEVEL > 0
1221 : // reset the bit for later checking
1222 : m_nIncludeSpecial = m_nIncludeSpecial & ~(SCA_MIN_VALUE | SCA_MAX_VALUE);
1223 : #endif
1224 : }
1225 :
1226 0 : if ( SCA_IMAGE_POSITION & m_nIncludeSpecial )
1227 : {
1228 0 : exportImagePositionAttributes();
1229 : RESET_BIT( m_nIncludeSpecial, SCA_IMAGE_POSITION );
1230 : }
1231 :
1232 : OSL_ENSURE(0 == m_nIncludeSpecial,
1233 : "OControlExport::exportSpecialAttributes: forgot some flags!");
1234 : // in the dbg_util version, we should have removed every bit we handled from the mask, so it should
1235 : // be 0 now ...
1236 0 : }
1237 :
1238 0 : OUString OControlExport::getScalarListSourceValue() const
1239 : {
1240 0 : OUString sListSource;
1241 0 : Any aListSource = m_xProps->getPropertyValue( PROPERTY_LISTSOURCE );
1242 0 : if ( !( aListSource >>= sListSource ) )
1243 : {
1244 0 : Sequence< OUString > aListSourceSequence;
1245 0 : aListSource >>= aListSourceSequence;
1246 0 : if ( aListSourceSequence.getLength() )
1247 0 : sListSource = aListSourceSequence[ 0 ];
1248 : }
1249 0 : return sListSource;
1250 : }
1251 :
1252 0 : void OControlExport::exportListSourceAsAttribute()
1253 : {
1254 : // DA_LIST_SOURCE needs some special handling
1255 : DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE );
1256 :
1257 0 : OUString sListSource = getScalarListSourceValue();
1258 0 : if ( !sListSource.isEmpty() )
1259 : { // the ListSource property needs to be exported as attribute, and it is not empty
1260 : AddAttribute(
1261 0 : OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE),
1262 : OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE),
1263 0 : sListSource);
1264 : }
1265 :
1266 0 : exportedProperty( PROPERTY_LISTSOURCE );
1267 0 : }
1268 :
1269 0 : void OControlExport::getSequenceInt16PropertyAsSet(const OUString& _rPropertyName, Int16Set& _rOut)
1270 : {
1271 0 : Sequence< sal_Int16 > aValueSequence;
1272 : DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
1273 0 : m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
1274 :
1275 0 : const sal_Int16* pValues = aValueSequence.getConstArray();
1276 0 : for (sal_Int32 i=0; i<aValueSequence.getLength(); ++i, ++pValues)
1277 0 : _rOut.insert(*pValues);
1278 0 : }
1279 :
1280 0 : void OControlExport::exportListSourceAsElements()
1281 : {
1282 : // the string lists
1283 0 : Sequence< OUString > aItems, aValues;
1284 : DBG_CHECK_PROPERTY( PROPERTY_STRING_ITEM_LIST, Sequence< OUString > );
1285 0 : m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
1286 :
1287 : DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE, Sequence< OUString > );
1288 0 : if ( 0 == ( m_nIncludeDatabase & DA_LIST_SOURCE ) )
1289 0 : m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
1290 : // if we exported the list source as attribute, we do not repeat it as sub elements
1291 :
1292 : // the selection lists
1293 0 : Int16Set aSelection, aDefaultSelection;
1294 0 : getSequenceInt16PropertyAsSet(PROPERTY_SELECT_SEQ, aSelection);
1295 0 : getSequenceInt16PropertyAsSet(PROPERTY_DEFAULT_SELECT_SEQ, aDefaultSelection);
1296 :
1297 : // the string for "true"
1298 0 : OUString sTrue;
1299 0 : OUStringBuffer sBuffer;
1300 0 : ::sax::Converter::convertBool(sBuffer, true);
1301 0 : sTrue = sBuffer.makeStringAndClear();
1302 :
1303 : // loop through both lists ('til the maximum of both lengths)
1304 0 : const OUString* pItems = aItems.getConstArray();
1305 0 : const OUString* pValues = aValues.getConstArray();
1306 :
1307 0 : sal_Int32 nItems = aItems.getLength();
1308 0 : sal_Int32 nValues = aValues.getLength();
1309 :
1310 0 : sal_Int16 nMaxLen = (sal_Int16)std::max(nItems, nValues);
1311 :
1312 0 : for (sal_Int16 i=0; i<nMaxLen; ++i )
1313 : {
1314 0 : m_rContext.getGlobalContext().ClearAttrList();
1315 0 : if (i < nItems)
1316 : {
1317 : // there is an item at this position
1318 : AddAttribute(
1319 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
1320 : OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
1321 0 : *pItems);
1322 0 : ++pItems;
1323 : }
1324 0 : if (i < nValues)
1325 : {
1326 : // there is an value at this position
1327 : AddAttribute(
1328 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_VALUE),
1329 : OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE),
1330 0 : *pValues);
1331 0 : ++pValues;
1332 : }
1333 :
1334 0 : Int16Set::iterator aSelectedPos = aSelection.find(i);
1335 0 : if (aSelection.end() != aSelectedPos)
1336 : { // the item at this position is selected
1337 : AddAttribute(
1338 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1339 : OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1340 : sTrue
1341 0 : );
1342 0 : aSelection.erase(aSelectedPos);
1343 : }
1344 :
1345 0 : Int16Set::iterator aDefaultSelectedPos = aDefaultSelection.find(i);
1346 0 : if (aDefaultSelection.end() != aDefaultSelectedPos)
1347 : { // the item at this position is selected as default
1348 : AddAttribute(
1349 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1350 : OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1351 : sTrue
1352 0 : );
1353 0 : aDefaultSelection.erase(aDefaultSelectedPos);
1354 : }
1355 0 : SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1356 0 : }
1357 :
1358 : // There may be more "selected" or "default-selected" items than there are in the lists in real,
1359 : // so we need to store some additional "form:option" items which have no name and no label, but
1360 : // one or both of the selected flags.
1361 : // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com
1362 :
1363 0 : if ( !aSelection.empty() || !aDefaultSelection.empty() )
1364 : {
1365 0 : sal_Int16 nLastSelected = -1;
1366 0 : if ( !aSelection.empty() )
1367 0 : nLastSelected = *(--aSelection.end());
1368 :
1369 0 : sal_Int16 nLastDefaultSelected = -1;
1370 0 : if ( !aDefaultSelection.empty() )
1371 0 : nLastDefaultSelected = *(--aDefaultSelection.end());
1372 :
1373 : // the maximum element in both sets
1374 0 : sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected);
1375 : OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!");
1376 : // if the maximum (selected or default selected) entry number is less than the maximum item count
1377 : // in both lists, the entry number should have been removed from the set
1378 :
1379 0 : for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i)
1380 : {
1381 0 : if (aSelection.end() != aSelection.find(i))
1382 : { // the (not existent) item at this position is selected
1383 : AddAttribute(
1384 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CURRENT_SELECTED),
1385 : OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED),
1386 : sTrue
1387 0 : );
1388 : }
1389 :
1390 0 : if (aDefaultSelection.end() != aDefaultSelection.find(i))
1391 : { // the (not existent) item at this position is selected as default
1392 : AddAttribute(
1393 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SELECTED),
1394 : OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED),
1395 : sTrue
1396 0 : );
1397 : }
1398 0 : SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true);
1399 0 : }
1400 0 : }
1401 0 : }
1402 :
1403 0 : void OControlExport::implStartElement(const sal_Char* _pName)
1404 : {
1405 : // before we let the base class start it's outer element, we add a wrapper element
1406 0 : const sal_Char *pOuterElementName = getOuterXMLElementName();
1407 : m_pOuterElement = pOuterElementName
1408 : ? new SvXMLElementExport(
1409 0 : m_rContext.getGlobalContext(),
1410 : XML_NAMESPACE_FORM,
1411 : pOuterElementName, true,
1412 0 : true)
1413 0 : : 0;
1414 :
1415 : // add the attributes for the inner element
1416 0 : exportInnerAttributes();
1417 :
1418 : // and start the inner element
1419 0 : OElementExport::implStartElement(_pName);
1420 0 : }
1421 :
1422 0 : void OControlExport::implEndElement()
1423 : {
1424 : // end the inner element
1425 0 : OElementExport::implEndElement();
1426 :
1427 : // end the outer element if it exists
1428 0 : delete m_pOuterElement;
1429 0 : m_pOuterElement = NULL;
1430 0 : }
1431 :
1432 0 : const sal_Char* OControlExport::getOuterXMLElementName() const
1433 : {
1434 0 : return 0;
1435 : }
1436 :
1437 0 : const sal_Char* OControlExport::getXMLElementName() const
1438 : {
1439 0 : return getElementName(m_eType);
1440 : }
1441 :
1442 0 : void OControlExport::examine()
1443 : {
1444 : OSL_ENSURE( ( m_nIncludeCommon == 0 ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == 0 )
1445 : && ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == 0),
1446 : "OControlExport::examine: called me twice? Not initialized?" );
1447 :
1448 : // get the class id to decide which kind of element we need in the XML stream
1449 0 : m_nClassId = FormComponentType::CONTROL;
1450 : DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 );
1451 0 : m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId;
1452 0 : bool knownType = false;
1453 0 : switch (m_nClassId)
1454 : {
1455 : case FormComponentType::DATEFIELD:
1456 0 : m_eType = DATE;
1457 0 : knownType = true;
1458 : // NO BREAK
1459 : case FormComponentType::TIMEFIELD:
1460 0 : if ( !knownType )
1461 : {
1462 0 : m_eType = TIME;
1463 0 : knownType = true;
1464 : }
1465 0 : m_nIncludeSpecial |= SCA_VALIDATION;
1466 : // NO BREAK
1467 : case FormComponentType::NUMERICFIELD:
1468 : case FormComponentType::CURRENCYFIELD:
1469 : case FormComponentType::PATTERNFIELD:
1470 0 : if ( !knownType )
1471 : {
1472 0 : m_eType = FORMATTED_TEXT;
1473 0 : knownType = true;
1474 : }
1475 : // NO BREAK
1476 : case FormComponentType::TEXTFIELD:
1477 : { // it's some kind of edit. To know which type we need further investigation
1478 :
1479 0 : if ( !knownType )
1480 : {
1481 : // check if it's a formatted field
1482 0 : if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY))
1483 : {
1484 0 : m_eType = FORMATTED_TEXT;
1485 : }
1486 : else
1487 : {
1488 : // all other controls are represented by an ordinary edit control, but which XML control type
1489 : // it is depends on the current values of some properties
1490 :
1491 : // if the EchoChar string is not empty, it is a password field
1492 0 : sal_Int16 nEchoChar = 0;
1493 0 : if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR))
1494 : // grid columns do not have this property ....
1495 0 : m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar;
1496 0 : if (nEchoChar)
1497 : {
1498 0 : m_eType = PASSWORD;
1499 0 : m_nIncludeSpecial |= SCA_ECHO_CHAR;
1500 : }
1501 : else
1502 : {
1503 : // if the MultiLine property is sal_True, it is a TextArea
1504 0 : sal_Bool bMultiLine = sal_False;
1505 0 : if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE))
1506 : // grid columns do not have this property ....
1507 0 : bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE));
1508 :
1509 0 : if ( bMultiLine )
1510 0 : m_eType = TEXT_AREA;
1511 : else
1512 : // the only case left is represented by a Text element
1513 0 : m_eType = TEXT;
1514 : }
1515 : }
1516 0 : knownType = true;
1517 : }
1518 :
1519 : // attributes which are common to all the types:
1520 : // common attributes
1521 : m_nIncludeCommon =
1522 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED |
1523 0 : CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1524 :
1525 0 : if ( ( m_nClassId != FormComponentType::DATEFIELD )
1526 0 : && ( m_nClassId != FormComponentType::TIMEFIELD )
1527 : )
1528 : // date and time field values are handled differently nowadays
1529 0 : m_nIncludeCommon |= CCA_VALUE;
1530 :
1531 : // database attributes
1532 0 : m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1533 :
1534 : // event attributes
1535 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1536 :
1537 : // only text and pattern fields have a ConvertEmptyToNull property
1538 0 : if ( ( m_nClassId == FormComponentType::TEXTFIELD )
1539 0 : || ( m_nClassId == FormComponentType::PATTERNFIELD )
1540 : )
1541 0 : m_nIncludeDatabase |= DA_CONVERT_EMPTY;
1542 :
1543 : // all controls but the file control fields have a readonly property
1544 0 : if ( m_nClassId != FormComponentType::FILECONTROL )
1545 0 : m_nIncludeCommon |= CCA_READONLY;
1546 :
1547 : // a text field has a max text len
1548 0 : if ( m_nClassId == FormComponentType::TEXTFIELD )
1549 0 : m_nIncludeCommon |= CCA_MAX_LENGTH;
1550 :
1551 : // max and min values and validation:
1552 0 : if (FORMATTED_TEXT == m_eType)
1553 : { // in general all controls represented as formatted-text have these props
1554 0 : if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField
1555 0 : m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE;
1556 :
1557 0 : if (FormComponentType::TEXTFIELD != m_nClassId)
1558 : // and the FormattedField does not have a validation flag
1559 0 : m_nIncludeSpecial |= SCA_VALIDATION;
1560 : }
1561 :
1562 : // if it's not a password field or rich text control, the CurrentValue needs to be stored, too
1563 0 : if ( ( PASSWORD != m_eType )
1564 0 : && ( DATE != m_eType )
1565 0 : && ( TIME != m_eType )
1566 : )
1567 : {
1568 0 : m_nIncludeCommon |= CCA_CURRENT_VALUE;
1569 : }
1570 : }
1571 0 : break;
1572 :
1573 : case FormComponentType::FILECONTROL:
1574 0 : m_eType = FILE;
1575 : m_nIncludeCommon =
1576 : CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE | CCA_DISABLED |
1577 : CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE |
1578 0 : CCA_VALUE;
1579 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1580 0 : break;
1581 :
1582 : case FormComponentType::FIXEDTEXT:
1583 0 : m_eType = FIXED_TEXT;
1584 : m_nIncludeCommon =
1585 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1586 0 : CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1587 0 : m_nIncludeSpecial = SCA_MULTI_LINE;
1588 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1589 0 : break;
1590 :
1591 : case FormComponentType::COMBOBOX:
1592 0 : m_eType = COMBOBOX;
1593 : m_nIncludeCommon =
1594 : CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE |
1595 : CCA_DISABLED | CCA_DROPDOWN | CCA_MAX_LENGTH | CCA_PRINTABLE | CCA_READONLY | CCA_SIZE |
1596 0 : CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE;
1597 0 : m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION;
1598 0 : m_nIncludeDatabase = DA_CONVERT_EMPTY | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE | DA_LIST_SOURCE_TYPE;
1599 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
1600 0 : break;
1601 :
1602 : case FormComponentType::LISTBOX:
1603 0 : m_eType = LISTBOX;
1604 : m_nIncludeCommon =
1605 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_DROPDOWN |
1606 0 : CCA_PRINTABLE | CCA_SIZE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1607 0 : m_nIncludeSpecial = SCA_MULTIPLE;
1608 0 : m_nIncludeDatabase = DA_BOUND_COLUMN | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE_TYPE;
1609 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_CLICK | EA_ON_DBLCLICK;
1610 : // check if we need to export the ListSource as attribute
1611 : {
1612 : // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead
1613 : // a sequence of pairs which is build from the StringItemList and the ValueList
1614 0 : ListSourceType eListSourceType = ListSourceType_VALUELIST;
1615 : #if OSL_DEBUG_LEVEL > 0
1616 : sal_Bool bSuccess =
1617 : #endif
1618 0 : m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType;
1619 : OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
1620 0 : if (ListSourceType_VALUELIST != eListSourceType)
1621 : {
1622 0 : m_nIncludeDatabase |= DA_LIST_SOURCE;
1623 : }
1624 : }
1625 :
1626 0 : break;
1627 :
1628 : case FormComponentType::COMMANDBUTTON:
1629 0 : m_eType = BUTTON;
1630 0 : m_nIncludeCommon |= CCA_TAB_STOP | CCA_LABEL;
1631 0 : m_nIncludeSpecial = SCA_DEFAULT_BUTTON | SCA_TOGGLE | SCA_FOCUS_ON_CLICK | SCA_IMAGE_POSITION | SCA_REPEAT_DELAY;
1632 : // NO BREAK !
1633 : case FormComponentType::IMAGEBUTTON:
1634 0 : if (BUTTON != m_eType)
1635 : {
1636 : // not coming from the previous case
1637 0 : m_eType = IMAGE;
1638 : }
1639 : m_nIncludeCommon |=
1640 : CCA_NAME | CCA_SERVICE_NAME | CCA_BUTTON_TYPE | CCA_DISABLED |
1641 : CCA_IMAGE_DATA | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TARGET_FRAME |
1642 0 : CCA_TARGET_LOCATION | CCA_TITLE;
1643 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CLICK | EA_ON_DBLCLICK;
1644 0 : break;
1645 :
1646 : case FormComponentType::CHECKBOX:
1647 0 : m_eType = CHECKBOX;
1648 0 : m_nIncludeSpecial = SCA_CURRENT_STATE | SCA_IS_TRISTATE | SCA_STATE;
1649 : // NO BREAK !
1650 : case FormComponentType::RADIOBUTTON:
1651 : m_nIncludeCommon =
1652 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE |
1653 0 : CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE | CCA_VISUAL_EFFECT;
1654 0 : if (CHECKBOX != m_eType)
1655 : { // not coming from the previous case
1656 0 : m_eType = RADIO;
1657 0 : m_nIncludeCommon |= CCA_CURRENT_SELECTED | CCA_SELECTED;
1658 : }
1659 0 : if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) )
1660 0 : m_nIncludeSpecial |= SCA_IMAGE_POSITION;
1661 0 : if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) )
1662 0 : m_nIncludeSpecial |= SCA_GROUP_NAME;
1663 0 : m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1664 0 : m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE;
1665 0 : break;
1666 :
1667 : case FormComponentType::GROUPBOX:
1668 0 : m_eType = FRAME;
1669 : m_nIncludeCommon =
1670 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL |
1671 0 : CCA_PRINTABLE | CCA_TITLE | CCA_FOR;
1672 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1673 0 : break;
1674 :
1675 : case FormComponentType::IMAGECONTROL:
1676 0 : m_eType = IMAGE_FRAME;
1677 : m_nIncludeCommon =
1678 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_IMAGE_DATA |
1679 0 : CCA_PRINTABLE | CCA_READONLY | CCA_TITLE;
1680 0 : m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
1681 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1682 0 : break;
1683 :
1684 : case FormComponentType::HIDDENCONTROL:
1685 0 : m_eType = HIDDEN;
1686 : m_nIncludeCommon =
1687 0 : CCA_NAME | CCA_SERVICE_NAME | CCA_VALUE;
1688 0 : break;
1689 :
1690 : case FormComponentType::GRIDCONTROL:
1691 0 : m_eType = GRID;
1692 : m_nIncludeCommon =
1693 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1694 0 : CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE;
1695 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1696 0 : break;
1697 :
1698 : case FormComponentType::SCROLLBAR:
1699 : case FormComponentType::SPINBUTTON:
1700 0 : m_eType = VALUERANGE;
1701 : m_nIncludeCommon =
1702 : CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE |
1703 0 : CCA_TITLE | CCA_CURRENT_VALUE | CCA_VALUE | CCA_ORIENTATION;
1704 0 : m_nIncludeSpecial = SCA_MAX_VALUE | SCA_STEP_SIZE | SCA_MIN_VALUE | SCA_REPEAT_DELAY;
1705 :
1706 0 : if ( m_nClassId == FormComponentType::SCROLLBAR )
1707 0 : m_nIncludeSpecial |= SCA_PAGE_STEP_SIZE ;
1708 :
1709 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1710 0 : break;
1711 :
1712 : default:
1713 : OSL_FAIL("OControlExport::examineControl: unknown control type (class id)!");
1714 : // NO break!
1715 :
1716 : case FormComponentType::NAVIGATIONBAR:
1717 : // TODO: should we have an own file format for this?
1718 : // NO break
1719 :
1720 : case FormComponentType::CONTROL:
1721 0 : m_eType = GENERIC_CONTROL;
1722 : // unknown control type
1723 0 : m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME;
1724 : // at least a name should be there, 'cause without a name the control could never have been
1725 : // inserted into its parent container
1726 : // In addition, the service name is absolutely necessary to create the control upon reading.
1727 0 : m_nIncludeEvents = EA_CONTROL_EVENTS;
1728 : // we always should be able to export events - this is not control type dependent
1729 0 : break;
1730 : }
1731 :
1732 : // in general, all control types need to export the control id
1733 0 : m_nIncludeCommon |= CCA_CONTROL_ID;
1734 :
1735 : // is is a control bound to a calc cell?
1736 0 : if ( FormCellBindingHelper::livesInSpreadsheetDocument( m_xProps ) )
1737 : {
1738 0 : FormCellBindingHelper aHelper( m_xProps, NULL );
1739 : {
1740 0 : if ( aHelper.isCellBinding( aHelper.getCurrentBinding( ) ) )
1741 : {
1742 0 : m_nIncludeBindings |= BA_LINKED_CELL;
1743 0 : if ( m_nClassId == FormComponentType::LISTBOX )
1744 0 : m_nIncludeBindings |= BA_LIST_LINKING_TYPE;
1745 : }
1746 : }
1747 :
1748 : // is it a list-like control which uses a calc cell range as list source?
1749 : {
1750 0 : if ( aHelper.isCellRangeListSource( aHelper.getCurrentListSource( ) ) )
1751 0 : m_nIncludeBindings |= BA_LIST_CELL_RANGE;
1752 0 : }
1753 : }
1754 :
1755 : // is control bound to XForms?
1756 0 : if( !getXFormsBindName( m_xProps ).isEmpty() )
1757 : {
1758 0 : m_nIncludeBindings |= BA_XFORMS_BIND;
1759 : }
1760 :
1761 : // is (list-)control bound to XForms list?
1762 0 : if( !getXFormsListBindName( m_xProps ).isEmpty() )
1763 : {
1764 0 : m_nIncludeBindings |= BA_XFORMS_LISTBIND;
1765 : }
1766 :
1767 : // does the control have an XForms submission?
1768 0 : if( !getXFormsSubmissionName( m_xProps ).isEmpty() )
1769 : {
1770 0 : m_nIncludeBindings |= BA_XFORMS_SUBMISSION;
1771 : }
1772 0 : }
1773 :
1774 0 : void OControlExport::exportCellBindingAttributes( bool _bIncludeListLinkageType )
1775 : {
1776 : try
1777 : {
1778 0 : FormCellBindingHelper aHelper( m_xProps, NULL );
1779 0 : Reference< XValueBinding > xBinding( aHelper.getCurrentBinding() );
1780 : OSL_ENSURE( xBinding.is(), "OControlExport::exportCellBindingAttributes: invalid bindable or invalid binding!" );
1781 0 : if ( xBinding.is() )
1782 : {
1783 : AddAttribute(
1784 0 : OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL ),
1785 : OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL ),
1786 : aHelper.getStringAddressFromCellBinding( xBinding )
1787 0 : );
1788 :
1789 0 : if ( _bIncludeListLinkageType )
1790 : {
1791 0 : sal_Int16 nLinkageType = aHelper.isCellIntegerBinding( xBinding ) ? 1 : 0;
1792 :
1793 0 : OUStringBuffer sBuffer;
1794 0 : m_rContext.getGlobalContext().GetMM100UnitConverter().convertEnum(
1795 : sBuffer,
1796 : (sal_uInt16)nLinkageType,
1797 : OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType )
1798 0 : );
1799 :
1800 : AddAttribute(
1801 0 : OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE ),
1802 : OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ),
1803 : sBuffer.makeStringAndClear()
1804 0 : );
1805 : }
1806 :
1807 0 : }
1808 : }
1809 0 : catch( const Exception& )
1810 : {
1811 : OSL_FAIL( "OControlExport::exportCellBindingAttributes: caught an exception!" );
1812 : DBG_UNHANDLED_EXCEPTION();
1813 : }
1814 0 : }
1815 :
1816 0 : void OControlExport::exportXFormsBindAttributes()
1817 : {
1818 0 : OUString sBindName = getXFormsBindName( m_xProps );
1819 0 : AddAttribute( XML_NAMESPACE_XFORMS, XML_BIND, sBindName );
1820 0 : }
1821 0 : void OControlExport::exportXFormsListAttributes()
1822 : {
1823 0 : OUString sBindName = getXFormsListBindName( m_xProps );
1824 0 : AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_LIST_SOURCE, sBindName );
1825 0 : }
1826 0 : void OControlExport::exportXFormsSubmissionAttributes()
1827 : {
1828 0 : OUString sSubmission = getXFormsSubmissionName( m_xProps );
1829 0 : AddAttribute( XML_NAMESPACE_FORM, XML_XFORMS_SUBMISSION, sSubmission );
1830 0 : }
1831 0 : void OControlExport::exportCellListSourceRange( )
1832 : {
1833 : try
1834 : {
1835 0 : Reference< XListEntrySink > xSink( m_xProps, UNO_QUERY );
1836 0 : Reference< XListEntrySource > xSource;
1837 0 : if ( xSink.is() )
1838 0 : xSource = xSource.query( xSink->getListEntrySource() );
1839 : OSL_ENSURE( xSource.is(), "OControlExport::exportCellListSourceRange: list source or sink!" );
1840 0 : if ( xSource.is() )
1841 : {
1842 0 : FormCellBindingHelper aHelper( m_xProps, NULL );
1843 :
1844 : AddAttribute(
1845 0 : OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE ),
1846 : OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ),
1847 : aHelper.getStringAddressFromCellListSource( xSource )
1848 0 : );
1849 0 : }
1850 : }
1851 0 : catch( const Exception& )
1852 : {
1853 : OSL_FAIL( "OControlExport::exportCellListSourceRange: caught an exception!" );
1854 : DBG_UNHANDLED_EXCEPTION();
1855 : }
1856 0 : }
1857 :
1858 0 : void OControlExport::exportImagePositionAttributes()
1859 : {
1860 : try
1861 : {
1862 0 : sal_Int16 nImagePosition = ImagePosition::Centered;
1863 0 : OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_IMAGE_POSITION ) >>= nImagePosition );
1864 : OSL_ENSURE( ( nImagePosition >= ImagePosition::LeftTop ) && ( nImagePosition <= ImagePosition::Centered ),
1865 : "OControlExport::exportImagePositionAttributes: don't know this image position!" );
1866 :
1867 0 : if ( ( nImagePosition < ImagePosition::LeftTop ) || ( nImagePosition > ImagePosition::Centered ) )
1868 : // this is important to prevent potential buffer overflows below, so don't optimize
1869 0 : nImagePosition = ImagePosition::Centered;
1870 :
1871 0 : if ( nImagePosition == ImagePosition::Centered )
1872 : {
1873 0 : AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( XML_CENTER ) );
1874 : }
1875 : else
1876 : {
1877 : XMLTokenEnum eXmlImagePositions[] =
1878 : {
1879 : XML_START, XML_END, XML_TOP, XML_BOTTOM
1880 0 : };
1881 : XMLTokenEnum eXmlImageAligns[] =
1882 : {
1883 : XML_START, XML_CENTER, XML_END
1884 0 : };
1885 :
1886 0 : XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ nImagePosition / 3 ];
1887 0 : XMLTokenEnum eXmlImageAlign = eXmlImageAligns [ nImagePosition % 3 ];
1888 :
1889 0 : AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_POSITION ), GetXMLToken( eXmlImagePosition ) );
1890 0 : AddAttribute( XML_NAMESPACE_FORM, GetXMLToken( XML_IMAGE_ALIGN ), GetXMLToken( eXmlImageAlign ) );
1891 : }
1892 :
1893 0 : exportedProperty( PROPERTY_IMAGE_POSITION );
1894 : // some of the controls which have an ImagePosition also have an ImageAlign for compatibility
1895 : // reasons. Since the ImageAlign values simply represent a sub set of the ImagePosition values,
1896 : // we don't need to export ImageAlign anymore
1897 0 : exportedProperty( PROPERTY_IMAGE_ALIGN );
1898 : }
1899 0 : catch( const Exception& )
1900 : {
1901 : DBG_UNHANDLED_EXCEPTION();
1902 : }
1903 0 : }
1904 :
1905 0 : bool OControlExport::controlHasActiveDataBinding() const
1906 : {
1907 : try
1908 : {
1909 : // currently exchanging the data with a database column?
1910 0 : OUString sBoundFieldPropertyName( "BoundField" );
1911 0 : if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( sBoundFieldPropertyName ) )
1912 : {
1913 0 : Reference< XPropertySet > xBoundField;
1914 0 : m_xProps->getPropertyValue( sBoundFieldPropertyName ) >>= xBoundField;
1915 0 : if ( xBoundField.is() )
1916 0 : return true;
1917 : }
1918 :
1919 : // currently exchanging data with an external binding?
1920 0 : Reference< XBindableValue > xBindable( m_xProps, UNO_QUERY );
1921 0 : if ( xBindable.is() && xBindable->getValueBinding().is() )
1922 0 : return true;
1923 : }
1924 0 : catch( const Exception& )
1925 : {
1926 : OSL_FAIL( "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
1927 : DBG_UNHANDLED_EXCEPTION();
1928 : }
1929 :
1930 0 : return false;
1931 : }
1932 :
1933 0 : bool OControlExport::controlHasUserSuppliedListEntries() const
1934 : {
1935 : try
1936 : {
1937 : // an external list source?
1938 0 : Reference< XListEntrySink > xEntrySink( m_xProps, UNO_QUERY );
1939 0 : if ( xEntrySink.is() && xEntrySink->getListEntrySource().is() )
1940 0 : return false;
1941 :
1942 0 : if ( m_xPropertyInfo.is() && m_xPropertyInfo->hasPropertyByName( PROPERTY_LISTSOURCETYPE ) )
1943 : {
1944 0 : ListSourceType eListSourceType = ListSourceType_VALUELIST;
1945 0 : OSL_VERIFY( m_xProps->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eListSourceType );
1946 0 : if ( eListSourceType == ListSourceType_VALUELIST )
1947 : // for value lists, the list entries as entered by the user are used
1948 0 : return true;
1949 :
1950 : // for every other type, the list entries are filled with some data obtained
1951 : // from a database - if and only if the ListSource property is not empty
1952 0 : return getScalarListSourceValue().isEmpty();
1953 0 : }
1954 : }
1955 0 : catch( const Exception& )
1956 : {
1957 : OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: caught an exception!" );
1958 : DBG_UNHANDLED_EXCEPTION();
1959 : }
1960 :
1961 : OSL_FAIL( "OControlExport::controlHasUserSuppliedListEntries: unreachable code!" );
1962 : // this method should be called for list and combo boxes only
1963 0 : return true;
1964 : }
1965 :
1966 : //= OColumnExport
1967 0 : OColumnExport::OColumnExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxControl, const OUString& _rControlId,
1968 : const Sequence< ScriptEventDescriptor >& _rEvents)
1969 0 : :OControlExport(_rContext, _rxControl, _rControlId, OUString(), _rEvents)
1970 : {
1971 0 : }
1972 :
1973 0 : OColumnExport::~OColumnExport()
1974 : {
1975 0 : implEndElement();
1976 0 : }
1977 :
1978 0 : void OColumnExport::exportServiceNameAttribute()
1979 : {
1980 : // the attribute "service name" (which has a slightly different meaning for columns
1981 : DBG_CHECK_PROPERTY( PROPERTY_COLUMNSERVICENAME, OUString );
1982 0 : OUString sColumnServiceName;
1983 0 : m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName;
1984 : // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the
1985 : // real service name for the column (for use with the XGridColumnFactory) is only the last
1986 : // token of this complete name.
1987 0 : sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.');
1988 : OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!");
1989 0 : sColumnServiceName = sColumnServiceName.copy(nLastSep + 1);
1990 0 : sColumnServiceName =
1991 0 : m_rContext.getGlobalContext().GetNamespaceMap().GetQNameByKey(
1992 0 : XML_NAMESPACE_OOO, sColumnServiceName );
1993 : // add the attribute
1994 0 : AddAttribute( OAttributeMetaData::getCommonControlAttributeNamespace(CCA_SERVICE_NAME)
1995 : , OAttributeMetaData::getCommonControlAttributeName(CCA_SERVICE_NAME)
1996 0 : , sColumnServiceName);
1997 : // flag the property as "handled"
1998 0 : exportedProperty(PROPERTY_COLUMNSERVICENAME);
1999 :
2000 0 : }
2001 :
2002 0 : const sal_Char* OColumnExport::getOuterXMLElementName() const
2003 : {
2004 0 : return "column";
2005 : }
2006 :
2007 0 : void OColumnExport::exportAttributes()
2008 : {
2009 0 : OControlExport::exportAttributes();
2010 :
2011 : // the attribute "label"
2012 : exportStringPropertyAttribute(
2013 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_LABEL),
2014 : OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL),
2015 0 : PROPERTY_LABEL);
2016 :
2017 : // the style attribute
2018 0 : OUString sStyleName = m_rContext.getObjectStyleName( m_xProps );
2019 0 : if ( !sStyleName.isEmpty() )
2020 : {
2021 : AddAttribute(
2022 0 : OAttributeMetaData::getSpecialAttributeNamespace( SCA_COLUMN_STYLE_NAME ),
2023 : OAttributeMetaData::getSpecialAttributeName( SCA_COLUMN_STYLE_NAME ),
2024 : sStyleName
2025 0 : );
2026 0 : }
2027 0 : }
2028 :
2029 0 : void OColumnExport::examine()
2030 : {
2031 0 : OControlExport::examine();
2032 :
2033 : // grid columns miss some properties of the controls they're representing
2034 0 : m_nIncludeCommon &= ~(CCA_FOR | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_LABEL);
2035 0 : m_nIncludeSpecial &= ~(SCA_ECHO_CHAR | SCA_AUTOMATIC_COMPLETION | SCA_MULTIPLE | SCA_MULTI_LINE);
2036 :
2037 0 : if (FormComponentType::DATEFIELD != m_nClassId)
2038 : // except date fields, no column has the DropDown property
2039 0 : m_nIncludeCommon &= ~CCA_DROPDOWN;
2040 0 : }
2041 :
2042 : //= OFormExport
2043 0 : OFormExport::OFormExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxForm,
2044 : const Sequence< ScriptEventDescriptor >& _rEvents)
2045 : :OElementExport(_rContext, _rxForm, _rEvents)
2046 0 : ,m_bCreateConnectionResourceElement(sal_False)
2047 : {
2048 : OSL_ENSURE(m_xProps.is(), "OFormExport::OFormExport: invalid arguments!");
2049 0 : }
2050 :
2051 0 : const sal_Char* OFormExport::getXMLElementName() const
2052 : {
2053 0 : return "form";
2054 : }
2055 :
2056 0 : void OFormExport::exportSubTags()
2057 : {
2058 0 : if ( m_bCreateConnectionResourceElement && m_xProps.is() )
2059 : {
2060 0 : m_rContext.getGlobalContext().ClearAttrList();
2061 0 : OUString sPropValue;
2062 0 : m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; // if set it is a file url
2063 0 : if ( sPropValue.isEmpty() )
2064 0 : m_xProps->getPropertyValue( PROPERTY_URL ) >>= sPropValue;
2065 0 : if ( !sPropValue.isEmpty() )
2066 : AddAttribute(
2067 0 : OAttributeMetaData::getCommonControlAttributeNamespace(CCA_TARGET_LOCATION),
2068 : OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION),
2069 0 : sPropValue);
2070 0 : if ( m_rContext.getGlobalContext().GetAttrList().getLength() )
2071 : {
2072 0 : SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, xmloff::token::XML_CONNECTION_RESOURCE, true, true);
2073 0 : }
2074 : }
2075 :
2076 : // let the base class export the remaining properties and the events
2077 0 : OElementExport::exportSubTags();
2078 : // loop through all children
2079 0 : Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY);
2080 : OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspic�ous!");
2081 :
2082 0 : if (xCollection.is())
2083 0 : m_rContext.exportCollectionElements(xCollection);
2084 0 : }
2085 :
2086 0 : void OFormExport::exportAttributes()
2087 : {
2088 0 : sal_Int32 i=0;
2089 :
2090 : // the string properties
2091 : {
2092 : static const FormAttributes eStringPropertyIds[] =
2093 : {
2094 : faName, /*faAction,*/ faCommand, faFilter, faOrder
2095 : };
2096 : static const OUString aStringPropertyNames[] =
2097 : {
2098 : OUString(PROPERTY_NAME), /*OUString(PROPERTY_TARGETURL),*/ OUString(PROPERTY_COMMAND), OUString(PROPERTY_FILTER), OUString(PROPERTY_ORDER)
2099 0 : };
2100 : static const sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]);
2101 : #if OSL_DEBUG_LEVEL > 0
2102 : static const sal_Int32 nNameCount = sizeof(aStringPropertyNames) / sizeof(aStringPropertyNames[0]);
2103 : OSL_ENSURE((nIdCount == nNameCount),
2104 : "OFormExport::exportAttributes: somebody tampered with the maps (1)!");
2105 : #endif
2106 0 : for (i=0; i<nIdCount; ++i)
2107 : exportStringPropertyAttribute(
2108 0 : OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]),
2109 0 : OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]),
2110 0 : aStringPropertyNames[i]);
2111 :
2112 : // #i112082# xlink:type is added as part of exportTargetLocationAttribute
2113 :
2114 : // now export the data source name or databaselocation or connection resource
2115 0 : OUString sPropValue;
2116 0 : m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue;
2117 0 : m_bCreateConnectionResourceElement = sPropValue.isEmpty();
2118 0 : if ( !m_bCreateConnectionResourceElement )
2119 : {
2120 0 : INetURLObject aURL(sPropValue);
2121 0 : m_bCreateConnectionResourceElement = ( aURL.GetProtocol() == INET_PROT_FILE );
2122 0 : if ( !m_bCreateConnectionResourceElement )
2123 : exportStringPropertyAttribute(
2124 0 : OAttributeMetaData::getFormAttributeNamespace(faDatasource),
2125 : OAttributeMetaData::getFormAttributeName(faDatasource),
2126 0 : PROPERTY_DATASOURCENAME);
2127 : }
2128 : else
2129 0 : exportedProperty(PROPERTY_URL);
2130 0 : if ( m_bCreateConnectionResourceElement )
2131 0 : exportedProperty(PROPERTY_DATASOURCENAME);
2132 : }
2133 :
2134 : // the boolean properties
2135 : {
2136 : static const FormAttributes eBooleanPropertyIds[] =
2137 : {
2138 : faAllowDeletes, faAllowInserts, faAllowUpdates, faApplyFilter, faEscapeProcessing, faIgnoreResult
2139 : };
2140 : static const OUString pBooleanPropertyNames[] =
2141 : {
2142 : OUString(PROPERTY_ALLOWDELETES),
2143 : OUString(PROPERTY_ALLOWINSERTS),
2144 : OUString(PROPERTY_ALLOWUPDATES),
2145 : OUString(PROPERTY_APPLYFILTER),
2146 : OUString(PROPERTY_ESCAPEPROCESSING),
2147 : OUString(PROPERTY_IGNORERESULT)
2148 0 : };
2149 : static const sal_Int8 nBooleanPropertyAttrFlags[] =
2150 : {
2151 : BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE
2152 : };
2153 : static const sal_Int32 nIdCount = sizeof(eBooleanPropertyIds) / sizeof(eBooleanPropertyIds[0]);
2154 : #if OSL_DEBUG_LEVEL > 0
2155 : static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]);
2156 : static const sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]);
2157 : OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
2158 : "OFormExport::exportAttributes: somebody tampered with the maps (2)!");
2159 : #endif
2160 0 : for (i=0; i<nIdCount; ++i)
2161 : exportBooleanPropertyAttribute(
2162 0 : OAttributeMetaData::getFormAttributeNamespace(eBooleanPropertyIds[i]),
2163 0 : OAttributeMetaData::getFormAttributeName(eBooleanPropertyIds[i]),
2164 : pBooleanPropertyNames[i],
2165 0 : nBooleanPropertyAttrFlags[i]
2166 0 : );
2167 : }
2168 :
2169 : // the enum properties
2170 : {
2171 : static const FormAttributes eEnumPropertyIds[] =
2172 : {
2173 : faEnctype, faMethod, faCommandType, faNavigationMode, faTabbingCycle
2174 : };
2175 : static const OUString pEnumPropertyNames[] =
2176 : {
2177 : OUString(PROPERTY_SUBMIT_ENCODING), OUString(PROPERTY_SUBMIT_METHOD), OUString(PROPERTY_COMMAND_TYPE), OUString(PROPERTY_NAVIGATION), OUString(PROPERTY_CYCLE)
2178 0 : };
2179 : static const OEnumMapper::EnumProperties eEnumPropertyMaps[] =
2180 : {
2181 : OEnumMapper::epSubmitEncoding, OEnumMapper::epSubmitMethod, OEnumMapper::epCommandType, OEnumMapper::epNavigationType, OEnumMapper::epTabCyle
2182 : };
2183 : static const sal_Int32 nEnumPropertyAttrDefaults[] =
2184 : {
2185 : FormSubmitEncoding_URL, FormSubmitMethod_GET, CommandType::COMMAND, NavigationBarMode_CURRENT, TabulatorCycle_RECORDS
2186 : };
2187 : static const sal_Bool nEnumPropertyAttrDefaultFlags[] =
2188 : {
2189 : sal_False, sal_False, sal_False, sal_False, sal_True
2190 : };
2191 : static const sal_Int32 nIdCount = sizeof(eEnumPropertyIds) / sizeof(eEnumPropertyIds[0]);
2192 : #if OSL_DEBUG_LEVEL > 0
2193 : static const sal_Int32 nNameCount = sizeof(pEnumPropertyNames) / sizeof(pEnumPropertyNames[0]);
2194 : static const sal_Int32 nDefaultCount = sizeof(nEnumPropertyAttrDefaults) / sizeof(nEnumPropertyAttrDefaults[0]);
2195 : static const sal_Int32 nDefaultFlagCount = sizeof(nEnumPropertyAttrDefaultFlags) / sizeof(nEnumPropertyAttrDefaultFlags[0]);
2196 : static const sal_Int32 nMapCount = sizeof(eEnumPropertyMaps) / sizeof(eEnumPropertyMaps[0]);
2197 : OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount) && (nDefaultCount == nDefaultFlagCount) && (nDefaultFlagCount == nMapCount),
2198 : "OFormExport::exportAttributes: somebody tampered with the maps (3)!");
2199 : #endif
2200 0 : for (i=0; i<nIdCount; ++i)
2201 : exportEnumPropertyAttribute(
2202 0 : OAttributeMetaData::getFormAttributeNamespace(eEnumPropertyIds[i]),
2203 0 : OAttributeMetaData::getFormAttributeName(eEnumPropertyIds[i]),
2204 : pEnumPropertyNames[i],
2205 0 : OEnumMapper::getEnumMap(eEnumPropertyMaps[i]),
2206 0 : nEnumPropertyAttrDefaults[i],
2207 0 : nEnumPropertyAttrDefaultFlags[i]
2208 0 : );
2209 : }
2210 :
2211 : // the service name
2212 0 : exportServiceNameAttribute();
2213 : // the target frame
2214 0 : exportTargetFrameAttribute();
2215 : // the target URL
2216 0 : exportTargetLocationAttribute(true); // #i110911# add type attribute (for form, but not for control)
2217 :
2218 : // master fields
2219 : exportStringSequenceAttribute(
2220 0 : OAttributeMetaData::getFormAttributeNamespace(faMasterFields),
2221 : OAttributeMetaData::getFormAttributeName(faMasterFields),
2222 0 : PROPERTY_MASTERFIELDS);
2223 : // detail fields
2224 : exportStringSequenceAttribute(
2225 0 : OAttributeMetaData::getFormAttributeNamespace(faDetailFiels),
2226 : OAttributeMetaData::getFormAttributeName(faDetailFiels),
2227 0 : PROPERTY_DETAILFIELDS);
2228 0 : }
2229 : } // namespace xmloff
2230 :
2231 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|