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