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