LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/forms - elementimport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 879 0.2 %
Date: 2012-12-27 Functions: 2 96 2.1 %
Legend: Lines: hit not hit

          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 "elementimport.hxx"
      22             : #include "xmloff/xmlimp.hxx"
      23             : #include "xmloff/nmspmap.hxx"
      24             : #include "strings.hxx"
      25             : #include "callbacks.hxx"
      26             : #include "attriblistmerge.hxx"
      27             : #include "xmloff/xmlnmspe.hxx"
      28             : #include "eventimport.hxx"
      29             : #include "xmloff/txtstyli.hxx"
      30             : #include "formenums.hxx"
      31             : #include "xmloff/xmltoken.hxx"
      32             : #include "gridcolumnproptranslator.hxx"
      33             : #include "property_description.hxx"
      34             : #include "property_meta_data.hxx"
      35             : 
      36             : #include <com/sun/star/text/XText.hpp>
      37             : #include <com/sun/star/util/XCloneable.hpp>
      38             : #include <com/sun/star/util/Duration.hpp>
      39             : #include <com/sun/star/form/FormComponentType.hpp>
      40             : #include <com/sun/star/awt/ImagePosition.hpp>
      41             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      42             : #include <com/sun/star/beans/XPropertyContainer.hpp>
      43             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      44             : 
      45             : #include <sax/tools/converter.hxx>
      46             : #include <tools/urlobj.hxx>
      47             : #include <tools/diagnose_ex.h>
      48             : #include <rtl/logfile.hxx>
      49             : #include <rtl/strbuf.hxx>
      50             : #include <comphelper/extract.hxx>
      51             : #include <comphelper/types.hxx>
      52             : 
      53             : #include <algorithm>
      54             : #include <functional>
      55             : 
      56             : //.........................................................................
      57             : namespace xmloff
      58             : {
      59             : //.........................................................................
      60             : 
      61             :     using namespace ::xmloff::token;
      62             :     using namespace ::com::sun::star;
      63             :     using namespace ::com::sun::star::uno;
      64             :     using namespace ::com::sun::star::awt;
      65             :     using namespace ::com::sun::star::container;
      66             :     using namespace ::com::sun::star::beans;
      67             :     using namespace ::com::sun::star::script;
      68             :     using namespace ::com::sun::star::lang;
      69             :     using namespace ::com::sun::star::form;
      70             :     using namespace ::com::sun::star::xml;
      71             :     using namespace ::com::sun::star::util;
      72             :     using namespace ::com::sun::star::text;
      73             :     using namespace ::comphelper;
      74             :     using ::com::sun::star::xml::sax::XAttributeList;
      75             : 
      76             : #define PROPID_VALUE            1
      77             : #define PROPID_CURRENT_VALUE    2
      78             : #define PROPID_MIN_VALUE        3
      79             : #define PROPID_MAX_VALUE        4
      80             : 
      81             :     //=====================================================================
      82             :     struct PropertyValueLess
      83             :     {
      84           0 :         sal_Bool operator()(const PropertyValue& _rLeft, const PropertyValue& _rRight)
      85             :         {
      86           0 :             return _rLeft.Name < _rRight.Name;
      87             :         }
      88             :     };
      89             : 
      90             :     //=====================================================================
      91             :     struct PropertyValueCompare : public ::std::binary_function< PropertyValue, ::rtl::OUString, bool>
      92             :     {
      93             :         bool operator() (const PropertyValue& lhs, const ::rtl::OUString& rhs) const
      94             :         {
      95             :             return lhs.Name == rhs;
      96             :         }
      97             :         bool operator() (const ::rtl::OUString& lhs, const PropertyValue& rhs) const
      98             :         {
      99             :             return lhs == rhs.Name;
     100             :         }
     101             :     };
     102             : 
     103             :     //=====================================================================
     104             :     template <class ELEMENT>
     105           0 :     void pushBackSequenceElement(Sequence< ELEMENT >& _rContainer, const ELEMENT& _rElement)
     106             :     {
     107           0 :         sal_Int32 nLen = _rContainer.getLength();
     108           0 :         _rContainer.realloc(nLen + 1);
     109           0 :         _rContainer[nLen] = _rElement;
     110           0 :     }
     111             : 
     112             :     //=====================================================================
     113             :     //= OElementNameMap
     114             :     //=====================================================================
     115             :     //---------------------------------------------------------------------
     116          24 :     OElementNameMap::MapString2Element  OElementNameMap::s_sElementTranslations;
     117             : 
     118             :     //---------------------------------------------------------------------
     119           0 :     const OControlElement::ElementType& operator ++(OControlElement::ElementType& _e)
     120             :     {
     121           0 :         OControlElement::ElementType e = _e;
     122           0 :         sal_Int32 nAsInt = static_cast<sal_Int32>(e);
     123           0 :         _e = static_cast<OControlElement::ElementType>( ++nAsInt );
     124           0 :         return _e;
     125             :     }
     126             : 
     127             :     //---------------------------------------------------------------------
     128           0 :     OControlElement::ElementType OElementNameMap::getElementType(const ::rtl::OUString& _rName)
     129             :     {
     130           0 :         if ( s_sElementTranslations.empty() )
     131             :         {   // initialize
     132           0 :             for (ElementType eType=(ElementType)0; eType<UNKNOWN; ++eType)
     133           0 :                 s_sElementTranslations[::rtl::OUString::createFromAscii(getElementName(eType))] = eType;
     134             :         }
     135           0 :         ConstMapString2ElementIterator aPos = s_sElementTranslations.find(_rName);
     136           0 :         if (s_sElementTranslations.end() != aPos)
     137           0 :             return aPos->second;
     138             : 
     139           0 :         return UNKNOWN;
     140             :     }
     141             : 
     142             :     //=====================================================================
     143             :     //= OElementImport
     144             :     //=====================================================================
     145             :     //---------------------------------------------------------------------
     146           0 :     OElementImport::OElementImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
     147             :             const Reference< XNameContainer >& _rxParentContainer)
     148             :         :OPropertyImport(_rImport, _nPrefix, _rName)
     149             :         ,m_rFormImport(_rImport)
     150             :         ,m_rEventManager(_rEventManager)
     151             :         ,m_pStyleElement( NULL )
     152             :         ,m_xParentContainer(_rxParentContainer)
     153           0 :         ,m_bImplicitGenericAttributeHandling( true )
     154             :     {
     155             :         OSL_ENSURE(m_xParentContainer.is(), "OElementImport::OElementImport: invalid parent container!");
     156           0 :     }
     157             : 
     158             :     //---------------------------------------------------------------------
     159           0 :     OElementImport::~OElementImport()
     160             :     {
     161           0 :     }
     162             : 
     163             :     //---------------------------------------------------------------------
     164           0 :     ::rtl::OUString OElementImport::determineDefaultServiceName() const
     165             :     {
     166           0 :         return ::rtl::OUString();
     167             :     }
     168             : 
     169             :     //---------------------------------------------------------------------
     170           0 :     void OElementImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
     171             :     {
     172             :         ENTER_LOG_CONTEXT( "xmloff::OElementImport - importing one element" );
     173             : 
     174           0 :         const SvXMLNamespaceMap& rMap = m_rContext.getGlobalContext().GetNamespaceMap();
     175           0 :         const ::rtl::OUString sImplNameAttribute = rMap.GetQNameByKey( XML_NAMESPACE_FORM, GetXMLToken( XML_CONTROL_IMPLEMENTATION ) );
     176           0 :         const ::rtl::OUString sControlImplementation = _rxAttrList->getValueByName( sImplNameAttribute );
     177             : 
     178             :         // retrieve the service name
     179           0 :         if ( !sControlImplementation.isEmpty() )
     180             :         {
     181           0 :             ::rtl::OUString sOOoImplementationName;
     182           0 :             const sal_uInt16 nImplPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sControlImplementation, &sOOoImplementationName );
     183           0 :             m_sServiceName = ( nImplPrefix == XML_NAMESPACE_OOO ) ? sOOoImplementationName : sControlImplementation;
     184             :         }
     185             : 
     186           0 :         if ( m_sServiceName.isEmpty() )
     187           0 :             determineDefaultServiceName();
     188             : 
     189             :         // create the object *now*. This allows setting properties in the various handleAttribute methods.
     190             :         // (Though currently not all code is migrated to this pattern, most attributes are still handled
     191             :         // by remembering the value (via implPushBackPropertyValue), and setting the correct property value
     192             :         // later (in OControlImport::StartElement).)
     193           0 :         m_xElement = createElement();
     194           0 :         if ( m_xElement.is() )
     195           0 :             m_xInfo = m_xElement->getPropertySetInfo();
     196             : 
     197             :         // call the base class
     198           0 :         OPropertyImport::StartElement( _rxAttrList );
     199           0 :     }
     200             : 
     201             :     //---------------------------------------------------------------------
     202           0 :     SvXMLImportContext* OElementImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
     203             :         const Reference< XAttributeList >& _rxAttrList)
     204             :     {
     205           0 :         if( token::IsXMLToken(_rLocalName, token::XML_EVENT_LISTENERS) && (XML_NAMESPACE_OFFICE == _nPrefix))
     206           0 :             return new OFormEventsImportContext(m_rFormImport.getGlobalContext(), _nPrefix, _rLocalName, *this);
     207             : 
     208           0 :         return OPropertyImport::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
     209             :     }
     210             : 
     211             :     //---------------------------------------------------------------------
     212           0 :     void OElementImport::EndElement()
     213             :     {
     214             :         OSL_ENSURE(m_xElement.is(), "OElementImport::EndElement: invalid element created!");
     215           0 :         if (!m_xElement.is())
     216           0 :             return;
     217             : 
     218             :         // apply the non-generic properties
     219           0 :         implApplySpecificProperties();
     220             : 
     221             :         // set the generic properties
     222           0 :         implApplyGenericProperties();
     223             : 
     224             :         // set the style properties
     225           0 :         if ( m_pStyleElement && m_xElement.is() )
     226             :         {
     227             :             Reference< XPropertySet > xPropTranslation =
     228           0 :                 new OGridColumnPropertyTranslator( Reference< XMultiPropertySet >( m_xElement, UNO_QUERY ) );
     229           0 :             const_cast< XMLTextStyleContext* >( m_pStyleElement )->FillPropertySet( xPropTranslation );
     230             : 
     231           0 :             const ::rtl::OUString sNumberStyleName = const_cast< XMLTextStyleContext* >( m_pStyleElement )->GetDataStyleName( );
     232           0 :             if ( !sNumberStyleName.isEmpty() )
     233             :                 // the style also has a number (sub) style
     234           0 :                 m_rContext.applyControlNumberStyle( m_xElement, sNumberStyleName );
     235             :         }
     236             : 
     237             :         // insert the element into the parent container
     238           0 :         if (m_sName.isEmpty())
     239             :         {
     240             :             OSL_FAIL("OElementImport::EndElement: did not find a name attribute!");
     241           0 :             m_sName = implGetDefaultName();
     242             :         }
     243             : 
     244           0 :         if (m_xParentContainer.is())
     245           0 :             m_xParentContainer->insertByName(m_sName, makeAny(m_xElement));
     246             : 
     247             :         LEAVE_LOG_CONTEXT( );
     248             :     }
     249             : 
     250             :     //---------------------------------------------------------------------
     251           0 :     void OElementImport::implApplySpecificProperties()
     252             :     {
     253           0 :         if ( m_aValues.empty() )
     254           0 :             return;
     255             : 
     256             :         // set all the properties we collected
     257             : #if OSL_DEBUG_LEVEL > 0
     258             :         // check if the object has all the properties
     259             :         // (We do this in the non-pro version only. Doing it all the time would be much to expensive)
     260             :         if ( m_xInfo.is() )
     261             :         {
     262             :             PropertyValueArray::const_iterator aEnd = m_aValues.end();
     263             :             for (   PropertyValueArray::iterator aCheck = m_aValues.begin();
     264             :                     aCheck != aEnd;
     265             :                     ++aCheck
     266             :                 )
     267             :             {
     268             :                 OSL_ENSURE(m_xInfo->hasPropertyByName(aCheck->Name),
     269             :                         ::rtl::OStringBuffer("OElementImport::implApplySpecificProperties: read a property (").
     270             :                     append(rtl::OUStringToOString(aCheck->Name, RTL_TEXTENCODING_ASCII_US)).
     271             :                     append(") which does not exist on the element!").getStr());
     272             :             }
     273             :         }
     274             : #endif
     275             : 
     276             :         // set the properties
     277           0 :         const Reference< XMultiPropertySet > xMultiProps(m_xElement, UNO_QUERY);
     278           0 :         sal_Bool bSuccess = sal_False;
     279           0 :         if (xMultiProps.is())
     280             :         {
     281             :             // translate our properties so that the XMultiPropertySet can handle them
     282             : 
     283             :             // sort our property value array so that we can use it in a setPropertyValues
     284           0 :             ::std::sort( m_aValues.begin(), m_aValues.end(), PropertyValueLess());
     285             : 
     286             :             // the names
     287           0 :             Sequence< ::rtl::OUString > aNames(m_aValues.size());
     288           0 :             ::rtl::OUString* pNames = aNames.getArray();
     289             :             // the values
     290           0 :             Sequence< Any > aValues(m_aValues.size());
     291           0 :             Any* pValues = aValues.getArray();
     292             :             // copy
     293             : 
     294           0 :             PropertyValueArray::iterator aEnd = m_aValues.end();
     295           0 :             for (   PropertyValueArray::iterator aPropValues = m_aValues.begin();
     296             :                     aPropValues != aEnd;
     297             :                     ++aPropValues, ++pNames, ++pValues
     298             :                 )
     299             :             {
     300           0 :                 *pNames = aPropValues->Name;
     301           0 :                 *pValues = aPropValues->Value;
     302             :             }
     303             : 
     304             :             try
     305             :             {
     306           0 :                 xMultiProps->setPropertyValues(aNames, aValues);
     307           0 :                 bSuccess = sal_True;
     308             :             }
     309           0 :             catch(Exception&)
     310             :             {
     311             :                 OSL_FAIL("OElementImport::implApplySpecificProperties: could not set the properties (using the XMultiPropertySet)!");
     312           0 :             }
     313             :         }
     314             : 
     315           0 :         if (!bSuccess)
     316             :         {   // no XMultiPropertySet or setting all properties at once failed
     317           0 :             PropertyValueArray::iterator aEnd = m_aValues.end();
     318           0 :             for (   PropertyValueArray::iterator aPropValues = m_aValues.begin();
     319             :                     aPropValues != aEnd;
     320             :                     ++aPropValues
     321             :                 )
     322             :             {
     323             :                 // this try/catch here is expensive, but because this is just a fallback which should normally not be
     324             :                 // used it's acceptable this way ...
     325             :                 try
     326             :                 {
     327           0 :                     m_xElement->setPropertyValue(aPropValues->Name, aPropValues->Value);
     328             :                 }
     329           0 :                 catch(Exception&)
     330             :                 {
     331             :                     OSL_FAIL(::rtl::OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \"").
     332             :                         append(rtl::OUStringToOString(aPropValues->Name, RTL_TEXTENCODING_ASCII_US)).
     333             :                         append("\"!").getStr());
     334             :                 }
     335             :             }
     336           0 :         }
     337             :     }
     338             : 
     339             :     //---------------------------------------------------------------------
     340           0 :     void OElementImport::implApplyGenericProperties()
     341             :     {
     342           0 :         if ( m_aGenericValues.empty() )
     343           0 :             return;
     344             : 
     345           0 :         Reference< XPropertyContainer > xDynamicProperties( m_xElement, UNO_QUERY );
     346             : 
     347           0 :         PropertyValueArray::iterator aEnd = m_aGenericValues.end();
     348           0 :         for (   PropertyValueArray::iterator aPropValues =
     349           0 :                 m_aGenericValues.begin();
     350             :                 aPropValues != aEnd;
     351             :                 ++aPropValues
     352             :             )
     353             :         {
     354             :             // check property type for numeric types before setting
     355             :             // the property
     356             :             try
     357             :             {
     358             :                 // if such a property does not yet exist at the element, create it if necessary
     359           0 :                 const bool bExistentProperty = m_xInfo->hasPropertyByName( aPropValues->Name );
     360           0 :                 if ( !bExistentProperty )
     361             :                 {
     362           0 :                     if ( !xDynamicProperties.is() )
     363             :                     {
     364             :                     #if OSL_DEBUG_LEVEL > 0
     365             :                         ::rtl::OString aMessage( "OElementImport::implApplyGenericProperties: encountered an unknown property (" );
     366             :                         aMessage += ::rtl::OUStringToOString( aPropValues->Name, RTL_TEXTENCODING_ASCII_US );
     367             :                         aMessage += "), but component is no PropertyBag!";
     368             :                         OSL_FAIL( aMessage.getStr() );
     369             :                     #endif
     370           0 :                         continue;
     371             :                     }
     372             : 
     373           0 :                     xDynamicProperties->addProperty(
     374           0 :                         aPropValues->Name,
     375             :                         PropertyAttribute::BOUND | PropertyAttribute::REMOVEABLE,
     376           0 :                         aPropValues->Value
     377           0 :                     );
     378             : 
     379             :                     // re-fetch the PropertySetInfo
     380           0 :                     m_xInfo = m_xElement->getPropertySetInfo();
     381             :                 }
     382             : 
     383             :                 // determine the type of the value (source for the following conversion)
     384           0 :                 TypeClass eValueTypeClass = aPropValues->Value.getValueTypeClass();
     385           0 :                 const sal_Bool bValueIsSequence = TypeClass_SEQUENCE == eValueTypeClass;
     386           0 :                 if ( bValueIsSequence )
     387             :                 {
     388           0 :                     uno::Type aSimpleType( getSequenceElementType( aPropValues->Value.getValueType() ) );
     389           0 :                     eValueTypeClass = aSimpleType.getTypeClass();
     390             :                 }
     391             : 
     392             :                 // determine the type of the property (target for the following conversion)
     393           0 :                 const Property aProperty( m_xInfo->getPropertyByName( aPropValues->Name ) );
     394           0 :                 TypeClass ePropTypeClass = aProperty.Type.getTypeClass();
     395           0 :                 const sal_Bool bPropIsSequence = TypeClass_SEQUENCE == ePropTypeClass;
     396           0 :                 if( bPropIsSequence )
     397             :                 {
     398           0 :                     uno::Type aSimpleType( ::comphelper::getSequenceElementType( aProperty.Type ) );
     399           0 :                     ePropTypeClass = aSimpleType.getTypeClass();
     400             :                 }
     401             : 
     402           0 :                 if ( bPropIsSequence != bValueIsSequence )
     403             :                 {
     404             :                     OSL_FAIL( "OElementImport::implImportGenericProperties: either both value and property should be a sequence, or none of them!" );
     405           0 :                     continue;
     406             :                 }
     407             : 
     408           0 :                 if ( bValueIsSequence )
     409             :                 {
     410             :                     OSL_ENSURE( eValueTypeClass == TypeClass_ANY,
     411             :                         "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" );
     412             :                         // (OPropertyImport should produce only Sequencer< Any >, since it cannot know the real type
     413             : 
     414             :                     OSL_ENSURE( ePropTypeClass == TypeClass_SHORT,
     415             :                         "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" );
     416             : 
     417           0 :                     Sequence< Any > aXMLValueList;
     418           0 :                     aPropValues->Value >>= aXMLValueList;
     419           0 :                     Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() );
     420             : 
     421           0 :                     const Any*       pXMLValue = aXMLValueList.getConstArray();
     422           0 :                           sal_Int16* pPropValue = aPropertyValueList.getArray();
     423             : 
     424           0 :                     for ( sal_Int32 i=0; i<aXMLValueList.getLength(); ++i, ++pXMLValue, ++pPropValue )
     425             :                     {
     426             :                         // only value sequences of numeric types implemented so far.
     427           0 :                         double nVal( 0 );
     428           0 :                         OSL_VERIFY( *pXMLValue >>= nVal );
     429           0 :                         *pPropValue = static_cast< sal_Int16 >( nVal );
     430             :                     }
     431             : 
     432           0 :                     aPropValues->Value <<= aPropertyValueList;
     433             :                 }
     434           0 :                 else if ( ePropTypeClass != eValueTypeClass )
     435             :                 {
     436           0 :                     switch ( eValueTypeClass )
     437             :                     {
     438             :                     case TypeClass_DOUBLE:
     439             :                     {
     440           0 :                         double nVal = 0;
     441           0 :                         aPropValues->Value >>= nVal;
     442           0 :                         switch( ePropTypeClass )
     443             :                         {
     444             :                         case TypeClass_BYTE:
     445           0 :                             aPropValues->Value <<= static_cast< sal_Int8 >( nVal );
     446           0 :                             break;
     447             :                         case TypeClass_SHORT:
     448           0 :                             aPropValues->Value <<= static_cast< sal_Int16 >( nVal );
     449           0 :                             break;
     450             :                         case TypeClass_LONG:
     451             :                         case TypeClass_ENUM:
     452           0 :                             aPropValues->Value <<= static_cast< sal_Int32 >( nVal );
     453           0 :                             break;
     454             :                         case TypeClass_HYPER:
     455           0 :                             aPropValues->Value <<= static_cast< sal_Int64 >( nVal );
     456           0 :                             break;
     457             :                         default:
     458             :                             OSL_FAIL( "OElementImport::implImportGenericProperties: unsupported value type!" );
     459           0 :                             break;
     460             :                         }
     461             :                     }
     462           0 :                     break;
     463             :                     default:
     464             :                         OSL_FAIL( "OElementImport::implImportGenericProperties: non-double values not supported!" );
     465           0 :                         break;
     466             :                     }
     467             :                 }
     468             : 
     469           0 :                 m_xElement->setPropertyValue( aPropValues->Name, aPropValues->Value );
     470             :             }
     471           0 :             catch(Exception&)
     472             :             {
     473             :                 OSL_FAIL(::rtl::OStringBuffer("OElementImport::EndElement: could not set the property \"").
     474             :                     append(::rtl::OUStringToOString(aPropValues->Name, RTL_TEXTENCODING_ASCII_US)).
     475             :                     append("\"!").getStr());
     476             :             }
     477           0 :         }
     478             :     }
     479             : 
     480             :     //---------------------------------------------------------------------
     481           0 :     ::rtl::OUString OElementImport::implGetDefaultName() const
     482             :     {
     483             :         // no optimization here. If this method gets called, the XML stream did not contain a name for the
     484             :         // element, which is a heavy error. So in this case we don't care for performance
     485           0 :         static const ::rtl::OUString sUnnamedName("unnamed");
     486             :         OSL_ENSURE(m_xParentContainer.is(), "OElementImport::implGetDefaultName: no parent container!");
     487           0 :         if (!m_xParentContainer.is())
     488           0 :             return sUnnamedName;
     489           0 :         Sequence< ::rtl::OUString > aNames = m_xParentContainer->getElementNames();
     490             : 
     491           0 :         ::rtl::OUString sReturn;
     492           0 :         const ::rtl::OUString* pNames = NULL;
     493           0 :         const ::rtl::OUString* pNamesEnd = aNames.getConstArray() + aNames.getLength();
     494           0 :         for (sal_Int32 i=0; i<32768; ++i)   // the limit is nearly arbitrary ...
     495             :         {
     496             :             // assemble the new name (suggestion)
     497           0 :             sReturn = sUnnamedName;
     498           0 :             sReturn += ::rtl::OUString::valueOf(i);
     499             :             // check the existence (this is the bad performance part ....)
     500           0 :             for (pNames = aNames.getConstArray(); pNames<pNamesEnd; ++pNames)
     501             :             {
     502           0 :                 if (*pNames == sReturn)
     503             :                 {
     504           0 :                     break;
     505             :                 }
     506             :             }
     507           0 :             if (pNames<pNamesEnd)
     508             :                 // found the name
     509           0 :                 continue;
     510           0 :             return sReturn;
     511             :         }
     512             :         OSL_FAIL("OElementImport::implGetDefaultName: did not find a free name!");
     513           0 :         return sUnnamedName;
     514             :     }
     515             : 
     516             :     //---------------------------------------------------------------------
     517           0 :     PropertyGroups::const_iterator OElementImport::impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const
     518             :     {
     519           0 :         ENSURE_OR_RETURN( m_xInfo.is(), "OElementImport::impl_matchPropertyGroup: no property set info!", i_propertyGroups.end() );
     520             : 
     521           0 :         for (   PropertyGroups::const_iterator group = i_propertyGroups.begin();
     522           0 :                 group != i_propertyGroups.end();
     523             :                 ++group
     524             :             )
     525             :         {
     526           0 :             bool missingProp = false;
     527           0 :             for (   PropertyDescriptionList::const_iterator prop = group->begin();
     528           0 :                     prop != group->end();
     529             :                     ++prop
     530             :                 )
     531             :             {
     532           0 :                 if ( !m_xInfo->hasPropertyByName( (*prop)->propertyName ) )
     533             :                 {
     534           0 :                     missingProp = true;
     535           0 :                     break;
     536             :                 }
     537             :             }
     538             : 
     539           0 :             if ( missingProp )
     540             :                 // try next group
     541           0 :                 continue;
     542             : 
     543           0 :             return group;
     544             :         }
     545             : 
     546           0 :         return i_propertyGroups.end();
     547             :     }
     548             : 
     549             :     //---------------------------------------------------------------------
     550           0 :     bool OElementImport::tryGenericAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue )
     551             :     {
     552             :         // the generic approach (which I hope all props will be migrated to, on the medium term): property handlers
     553           0 :         const AttributeDescription attribute( metadata::getAttributeDescription( _nNamespaceKey, _rLocalName ) );
     554           0 :         if ( attribute.attributeToken != XML_TOKEN_INVALID )
     555             :         {
     556           0 :             PropertyGroups propertyGroups;
     557           0 :             metadata::getPropertyGroupList( attribute, propertyGroups );
     558           0 :             const PropertyGroups::const_iterator pos = impl_matchPropertyGroup( propertyGroups );
     559           0 :             if ( pos == propertyGroups.end() )
     560           0 :                 return false;
     561             : 
     562             :             do
     563             :             {
     564           0 :                 const PropertyDescriptionList& rProperties( *pos );
     565           0 :                 const PropertyDescription* first = *rProperties.begin();
     566           0 :                 if ( !first )
     567             :                 {
     568             :                     SAL_WARN( "xmloff.forms", "OElementImport::handleAttribute: invalid property description!" );
     569             :                     break;
     570             :                 }
     571             : 
     572           0 :                 const PPropertyHandler handler = (*first->factory)( first->propertyId );
     573           0 :                 if ( !handler.get() )
     574             :                 {
     575             :                     SAL_WARN( "xmloff.forms", "OElementImport::handleAttribute: invalid property handler!" );
     576             :                     break;
     577             :                 }
     578             : 
     579           0 :                 PropertyValues aValues;
     580           0 :                 for (   PropertyDescriptionList::const_iterator propDesc = rProperties.begin();
     581           0 :                         propDesc != rProperties.end();
     582             :                         ++propDesc
     583             :                     )
     584             :                 {
     585           0 :                     aValues[ (*propDesc)->propertyId ] = Any();
     586             :                 }
     587           0 :                 if ( handler->getPropertyValues( _rValue, aValues ) )
     588             :                 {
     589           0 :                     for (   PropertyDescriptionList::const_iterator propDesc = rProperties.begin();
     590           0 :                             propDesc != rProperties.end();
     591             :                             ++propDesc
     592             :                         )
     593             :                     {
     594           0 :                         implPushBackPropertyValue( (*propDesc)->propertyName, aValues[ (*propDesc)->propertyId ] );
     595             :                     }
     596           0 :                 }
     597             :             }
     598             :             while ( false );
     599             : 
     600             :             // handled
     601           0 :             return true;
     602             :         }
     603           0 :         return false;
     604             :     }
     605             : 
     606             :     //---------------------------------------------------------------------
     607           0 :     bool OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
     608             :     {
     609           0 :         if ( token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION ) )
     610             :             // ignore this, it has already been handled in OElementImport::StartElement
     611           0 :             return true;
     612             : 
     613           0 :         if ( token::IsXMLToken( _rLocalName, token::XML_NAME ) )
     614             :         {
     615           0 :             if ( m_sName.isEmpty() )
     616             :                 // remember the name for later use in EndElement
     617           0 :                 m_sName = _rValue;
     618           0 :             return true;
     619             :         }
     620             : 
     621             :         // maybe it's the style attribute?
     622           0 :         if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) )
     623             :         {
     624           0 :             const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue );
     625             :             OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" );
     626             :             // remember the element for later usage.
     627           0 :             m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext );
     628           0 :             return true;
     629             :         }
     630             : 
     631           0 :         if ( m_bImplicitGenericAttributeHandling )
     632           0 :             if ( tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) )
     633           0 :                 return true;
     634             : 
     635             :         // let the base class handle it
     636           0 :         return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
     637             :     }
     638             : 
     639             :     //---------------------------------------------------------------------
     640           0 :     Reference< XPropertySet > OElementImport::createElement()
     641             :     {
     642           0 :         Reference< XPropertySet > xReturn;
     643           0 :         if (!m_sServiceName.isEmpty())
     644             :         {
     645           0 :             Reference< XInterface > xPure = m_rFormImport.getGlobalContext().getServiceFactory()->createInstance(m_sServiceName);
     646             :             OSL_ENSURE(xPure.is(),
     647             :                         ::rtl::OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: ").append(rtl::OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US)).append(")!").getStr());
     648           0 :             xReturn = Reference< XPropertySet >(xPure, UNO_QUERY);
     649             :         }
     650             :         else
     651             :             OSL_FAIL("OElementImport::createElement: no service name to create an element!");
     652             : 
     653           0 :         return xReturn;
     654             :     }
     655             : 
     656             :     //---------------------------------------------------------------------
     657           0 :     void OElementImport::registerEvents(const Sequence< ScriptEventDescriptor >& _rEvents)
     658             :     {
     659             :         OSL_ENSURE(m_xElement.is(), "OElementImport::registerEvents: no element to register events for!");
     660           0 :         m_rEventManager.registerEvents(m_xElement, _rEvents);
     661           0 :     }
     662             : 
     663             :     //---------------------------------------------------------------------
     664           0 :     void OElementImport::simulateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault)
     665             :     {
     666             :         OSL_ENSURE( m_xInfo.is(), "OPropertyImport::simulateDefaultedAttribute: the component should be more gossipy about it's properties!" );
     667             : 
     668           0 :         if ( !m_xInfo.is() || m_xInfo->hasPropertyByName( _rPropertyName ) )
     669             :         {
     670           0 :             ::rtl::OUString sLocalAttrName = ::rtl::OUString::createFromAscii(_pAttributeName);
     671           0 :             if ( !encounteredAttribute( sLocalAttrName ) )
     672           0 :                 OSL_VERIFY( handleAttribute( XML_NAMESPACE_FORM, sLocalAttrName, ::rtl::OUString::createFromAscii( _pAttributeDefault ) ) );
     673             :         }
     674           0 :     }
     675             : 
     676             :     //=====================================================================
     677             :     //= OControlImport
     678             :     //=====================================================================
     679             :     //---------------------------------------------------------------------
     680           0 :     OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
     681             :             const Reference< XNameContainer >& _rxParentContainer)
     682             :         :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer)
     683           0 :         ,m_eElementType(OControlElement::UNKNOWN)
     684             :     {
     685           0 :         disableImplicitGenericAttributeHandling();
     686           0 :     }
     687             : 
     688             :     //---------------------------------------------------------------------
     689           0 :     OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
     690             :             const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
     691             :         :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer)
     692           0 :         ,m_eElementType(_eType)
     693             :     {
     694           0 :         disableImplicitGenericAttributeHandling();
     695           0 :     }
     696             : 
     697             :     //---------------------------------------------------------------------
     698           0 :     ::rtl::OUString OControlImport::determineDefaultServiceName() const
     699             :     {
     700           0 :         const sal_Char* pServiceName = NULL;
     701           0 :         switch ( m_eElementType )
     702             :         {
     703             :         case OControlElement::TEXT:
     704             :         case OControlElement::TEXT_AREA:
     705           0 :         case OControlElement::PASSWORD:          pServiceName = "com.sun.star.form.component.TextField"; break;
     706           0 :         case OControlElement::FILE:              pServiceName = "com.sun.star.form.component.FileControl"; break;
     707           0 :         case OControlElement::FORMATTED_TEXT:    pServiceName = "com.sun.star.form.component.FormattedField"; break;
     708           0 :         case OControlElement::FIXED_TEXT:        pServiceName = "com.sun.star.form.component.FixedText"; break;
     709           0 :         case OControlElement::COMBOBOX:          pServiceName = "com.sun.star.form.component.ComboBox"; break;
     710           0 :         case OControlElement::LISTBOX:           pServiceName = "com.sun.star.form.component.ListBox"; break;
     711           0 :         case OControlElement::BUTTON:            pServiceName = "com.sun.star.form.component.CommandButton"; break;
     712           0 :         case OControlElement::IMAGE:             pServiceName = "com.sun.star.form.component.ImageButton"; break;
     713           0 :         case OControlElement::CHECKBOX:          pServiceName = "com.sun.star.form.component.CheckBox"; break;
     714           0 :         case OControlElement::RADIO:             pServiceName = "com.sun.star.form.component.RadioButton"; break;
     715           0 :         case OControlElement::FRAME:             pServiceName = "com.sun.star.form.component.GroupBox"; break;
     716           0 :         case OControlElement::IMAGE_FRAME:       pServiceName = "com.sun.star.form.component.DatabaseImageControl"; break;
     717           0 :         case OControlElement::HIDDEN:            pServiceName = "com.sun.star.form.component.HiddenControl"; break;
     718           0 :         case OControlElement::GRID:              pServiceName = "com.sun.star.form.component.GridControl"; break;
     719           0 :         case OControlElement::TIME:              pServiceName = "com.sun.star.form.component.DateField"; break;
     720           0 :         case OControlElement::DATE:              pServiceName = "com.sun.star.form.component.TimeField"; break;
     721           0 :         default:                                 break;
     722             :         }
     723           0 :         if ( pServiceName != NULL )
     724           0 :             return ::rtl::OUString::createFromAscii( pServiceName );
     725           0 :         return ::rtl::OUString();
     726             :     }
     727             : 
     728             :     //---------------------------------------------------------------------
     729           0 :     void OControlImport::addOuterAttributes(const Reference< XAttributeList >& _rxOuterAttribs)
     730             :     {
     731             :         OSL_ENSURE(!m_xOuterAttributes.is(), "OControlImport::addOuterAttributes: already have these attributes!");
     732           0 :         m_xOuterAttributes = _rxOuterAttribs;
     733           0 :     }
     734             : 
     735             :     //---------------------------------------------------------------------
     736           0 :     bool OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
     737             :     {
     738           0 :         static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL);
     739             : 
     740           0 :         if (IsXMLToken(_rLocalName, XML_ID))
     741             :         {   // it's the control id
     742           0 :             if (XML_NAMESPACE_XML == _nNamespaceKey)
     743             :             {
     744           0 :                 m_sControlId = _rValue;
     745             :             }
     746           0 :             else if (XML_NAMESPACE_FORM == _nNamespaceKey)
     747             :             {
     748           0 :                 if (m_sControlId.isEmpty())
     749             :                 {
     750           0 :                     m_sControlId = _rValue;
     751             :                 }
     752             :             }
     753           0 :             return true;
     754             :         }
     755             : 
     756           0 :         if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) )
     757             :         {   // it's the address of a spreadsheet cell
     758           0 :             m_sBoundCellAddress = _rValue;
     759           0 :             return true;
     760             :         }
     761             : 
     762           0 :         if ( _nNamespaceKey == XML_NAMESPACE_XFORMS && IsXMLToken( _rLocalName, XML_BIND ) )
     763             :         {
     764           0 :             m_sBindingID = _rValue;
     765           0 :             return true;
     766             :         }
     767             : 
     768           0 :         if ( _nNamespaceKey == XML_NAMESPACE_FORM && IsXMLToken( _rLocalName, XML_XFORMS_LIST_SOURCE )  )
     769             :         {
     770           0 :             m_sListBindingID = _rValue;
     771           0 :             return true;
     772             :         }
     773             : 
     774           0 :         if  (   (   ( _nNamespaceKey == XML_NAMESPACE_FORM )
     775           0 :                 &&  IsXMLToken( _rLocalName, XML_XFORMS_SUBMISSION )
     776             :                 )
     777             :             ||  (   ( _nNamespaceKey == XML_NAMESPACE_XFORMS )
     778           0 :                 &&  IsXMLToken( _rLocalName, XML_SUBMISSION )
     779             :                 )
     780             :             )
     781             :         {
     782           0 :             m_sSubmissionID = _rValue;
     783           0 :             return true;
     784             :         }
     785             : 
     786           0 :         if ( OElementImport::tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) )
     787           0 :             return true;
     788             : 
     789           0 :         static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE);
     790           0 :         static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE);
     791           0 :         static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE);
     792           0 :         static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE);
     793           0 :         static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY );
     794             : 
     795           0 :         sal_Int32 nHandle = -1;
     796           0 :         if ( _rLocalName.equalsAscii( pValueAttributeName ) )
     797           0 :             nHandle = PROPID_VALUE;
     798           0 :         else if ( _rLocalName.equalsAscii( pCurrentValueAttributeName ) )
     799           0 :             nHandle = PROPID_CURRENT_VALUE;
     800           0 :         else if ( _rLocalName.equalsAscii( pMinValueAttributeName ) )
     801           0 :             nHandle = PROPID_MIN_VALUE;
     802           0 :         else if ( _rLocalName.equalsAscii( pMaxValueAttributeName ) )
     803           0 :             nHandle = PROPID_MAX_VALUE;
     804           0 :         if ( nHandle != -1 )
     805             :         {
     806             :             // for the moment, simply remember the name and the value
     807           0 :             PropertyValue aProp;
     808           0 :             aProp.Name = _rLocalName;
     809           0 :             aProp.Handle = nHandle;
     810           0 :             aProp.Value <<= _rValue;
     811           0 :             m_aValueProperties.push_back(aProp);
     812           0 :             return true;
     813             :         }
     814             : 
     815           0 :         if ( _rLocalName.equalsAscii( pRepeatDelayAttributeName ) )
     816             :         {
     817           0 :             util::Duration aDuration;
     818           0 :             if (::sax::Converter::convertDuration(aDuration, _rValue))
     819             :             {
     820           0 :                 PropertyValue aProp;
     821           0 :                 aProp.Name = PROPERTY_REPEAT_DELAY;
     822             :                 sal_Int32 const nMS =
     823             :                     ((aDuration.Hours * 60 + aDuration.Minutes) * 60
     824           0 :                      + aDuration.Seconds) * 1000 + aDuration.MilliSeconds;
     825           0 :                 aProp.Value <<= nMS;
     826             : 
     827           0 :                 implPushBackPropertyValue(aProp);
     828             :             }
     829           0 :             return true;
     830             :         }
     831             : 
     832           0 :         return OElementImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
     833             :     }
     834             : 
     835             :     //---------------------------------------------------------------------
     836           0 :     void OControlImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
     837             :     {
     838           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttributes;
     839           0 :         if( m_xOuterAttributes.is() )
     840             :         {
     841             :             // merge the attribute lists
     842           0 :             OAttribListMerger* pMerger = new OAttribListMerger;
     843             :             // our own one
     844           0 :             pMerger->addList(_rxAttrList);
     845             :             // and the ones of our enclosing element
     846           0 :             pMerger->addList(m_xOuterAttributes);
     847           0 :             xAttributes = pMerger;
     848             :         }
     849             :         else
     850             :         {
     851           0 :             xAttributes = _rxAttrList;
     852             :         }
     853             : 
     854             :         // let the base class handle all the attributes
     855           0 :         OElementImport::StartElement(xAttributes);
     856             : 
     857           0 :         if ( !m_aValueProperties.empty() && m_xElement.is())
     858             :         {
     859             :             // get the property set info
     860           0 :             if (!m_xInfo.is())
     861             :             {
     862             :                 OSL_FAIL("OControlImport::StartElement: no PropertySetInfo!");
     863           0 :                 return;
     864             :             }
     865             : 
     866           0 :             const sal_Char* pValueProperty = NULL;
     867           0 :             const sal_Char* pCurrentValueProperty = NULL;
     868           0 :             const sal_Char* pMinValueProperty = NULL;
     869           0 :             const sal_Char* pMaxValueProperty = NULL;
     870             : 
     871           0 :             sal_Bool bRetrievedValues = sal_False;
     872           0 :             sal_Bool bRetrievedValueLimits = sal_False;
     873             : 
     874             :             // get the class id of our element
     875           0 :             sal_Int16 nClassId = FormComponentType::CONTROL;
     876           0 :             m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
     877             : 
     878             :             // translate the value properties we collected in handleAttributes
     879           0 :             PropertyValueArray::iterator aEnd = m_aValueProperties.end();
     880           0 :             for (   PropertyValueArray::iterator aValueProps = m_aValueProperties.begin();
     881             :                     aValueProps != aEnd;
     882             :                     ++aValueProps
     883             :                 )
     884             :             {
     885           0 :                 bool bSuccess = false;
     886           0 :                 switch (aValueProps->Handle)
     887             :                 {
     888             :                     case PROPID_VALUE:
     889             :                     case PROPID_CURRENT_VALUE:
     890             :                     {
     891             :                         // get the property names
     892           0 :                         if (!bRetrievedValues)
     893             :                         {
     894           0 :                             getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty);
     895           0 :                             if ( !pCurrentValueProperty && !pValueProperty )
     896             :                             {
     897             :                                 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value property names!" );
     898           0 :                                 break;
     899             :                             }
     900             : 
     901           0 :                             bRetrievedValues = sal_True;
     902             :                         }
     903           0 :                         if ( PROPID_VALUE == aValueProps->Handle && !pValueProperty )
     904             :                         {
     905             :                             SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a value property!");
     906           0 :                             break;
     907             :                         }
     908             : 
     909           0 :                         if ( PROPID_CURRENT_VALUE == aValueProps->Handle && !pCurrentValueProperty )
     910             :                         {
     911             :                             SAL_WARN( "xmloff.forms", "OControlImport::StartElement: the control does not have a current-value property!");
     912           0 :                             break;
     913             :                         }
     914             : 
     915             :                         // transfer the name
     916           0 :                         if (PROPID_VALUE == aValueProps->Handle)
     917           0 :                             aValueProps->Name = ::rtl::OUString::createFromAscii(pValueProperty);
     918             :                         else
     919           0 :                             aValueProps->Name = ::rtl::OUString::createFromAscii(pCurrentValueProperty);
     920           0 :                         bSuccess = true;
     921             :                     }
     922           0 :                     break;
     923             :                     case PROPID_MIN_VALUE:
     924             :                     case PROPID_MAX_VALUE:
     925             :                     {
     926             :                         // get the property names
     927           0 :                         if (!bRetrievedValueLimits)
     928             :                         {
     929           0 :                             getValueLimitPropertyNames(nClassId, pMinValueProperty, pMaxValueProperty);
     930           0 :                             if ( !pMinValueProperty || !pMaxValueProperty )
     931             :                             {
     932             :                                 SAL_WARN( "xmloff.forms", "OControlImport::StartElement: illegal value limit property names!" );
     933           0 :                                 break;
     934             :                             }
     935             : 
     936           0 :                             bRetrievedValueLimits = sal_True;
     937             :                         }
     938             :                         OSL_ENSURE((PROPID_MIN_VALUE != aValueProps->Handle) || pMinValueProperty,
     939             :                             "OControlImport::StartElement: the control does not have a value property!");
     940             :                         OSL_ENSURE((PROPID_MAX_VALUE != aValueProps->Handle) || pMaxValueProperty,
     941             :                             "OControlImport::StartElement: the control does not have a current-value property!");
     942             : 
     943             :                         // transfer the name
     944           0 :                         if (PROPID_MIN_VALUE == aValueProps->Handle)
     945           0 :                             aValueProps->Name = ::rtl::OUString::createFromAscii(pMinValueProperty);
     946             :                         else
     947           0 :                             aValueProps->Name = ::rtl::OUString::createFromAscii(pMaxValueProperty);
     948           0 :                         bSuccess = true;
     949             :                     }
     950           0 :                     break;
     951             :                 }
     952             : 
     953           0 :                 if ( !bSuccess )
     954           0 :                     continue;
     955             : 
     956             :                 // translate the value
     957           0 :                 implTranslateValueProperty(m_xInfo, *aValueProps);
     958             :                 // add the property to the base class' array
     959           0 :                 implPushBackPropertyValue(*aValueProps);
     960             :             }
     961           0 :         }
     962             :     }
     963             : 
     964             :     //---------------------------------------------------------------------
     965           0 :     void OControlImport::implTranslateValueProperty(const Reference< XPropertySetInfo >& _rxPropInfo,
     966             :         PropertyValue& _rPropValue)
     967             :     {
     968             :         OSL_ENSURE(_rxPropInfo->hasPropertyByName(_rPropValue.Name),
     969             :             "OControlImport::implTranslateValueProperty: invalid property name!");
     970             : 
     971             :         // retrieve the type of the property
     972           0 :         Property aProp = _rxPropInfo->getPropertyByName(_rPropValue.Name);
     973             :         // the untranslated string value as read in handleAttribute
     974           0 :         ::rtl::OUString sValue;
     975             :     #if OSL_DEBUG_LEVEL > 0
     976             :         sal_Bool bSuccess =
     977             :     #endif
     978           0 :         _rPropValue.Value >>= sValue;
     979             :         OSL_ENSURE(bSuccess, "OControlImport::implTranslateValueProperty: supposed to be called with non-translated string values!");
     980             : 
     981           0 :         if (TypeClass_ANY == aProp.Type.getTypeClass())
     982             :         {
     983             :             // we have exactly 2 properties where this type class is allowed:
     984             :             OSL_ENSURE(
     985             :                     (0 == _rPropValue.Name.equalsAsciiL(PROPERTY_EFFECTIVE_VALUE.ascii, PROPERTY_EFFECTIVE_VALUE.length))
     986             :                 ||  (0 == _rPropValue.Name.equalsAsciiL(PROPERTY_EFFECTIVE_DEFAULT.ascii, PROPERTY_EFFECTIVE_DEFAULT.length)),
     987             :                 "OControlImport::implTranslateValueProperty: invalid property type/name combination!");
     988             : 
     989             :             // Both properties are allowed to have a double or a string value,
     990             :             // so first try to convert the string into a number
     991             :             double nValue;
     992           0 :             if (::sax::Converter::convertDouble(nValue, sValue))
     993           0 :                 _rPropValue.Value <<= nValue;
     994             :             else
     995           0 :                 _rPropValue.Value <<= sValue;
     996             :         }
     997             :         else
     998           0 :             _rPropValue.Value = PropertyConversion::convertString(GetImport(), aProp.Type, sValue);
     999           0 :     }
    1000             : 
    1001             :     //---------------------------------------------------------------------
    1002           0 :     void OControlImport::EndElement()
    1003             :     {
    1004             :         OSL_ENSURE(m_xElement.is(), "OControlImport::EndElement: invalid control!");
    1005           0 :         if ( !m_xElement.is() )
    1006           0 :             return;
    1007             : 
    1008             :         // register our control with it's id
    1009           0 :         if (!m_sControlId.isEmpty())
    1010           0 :             m_rFormImport.registerControlId(m_xElement, m_sControlId);
    1011             :         // it's allowed to have no control id. In this case we're importing a column
    1012             : 
    1013             :         // one more pre-work to do:
    1014             :         // when we set default values, then by definition the respective value is set
    1015             :         // to this default value, too. This means if the sequence contains for example
    1016             :         // a DefaultText value, then the Text will be affected by this, too.
    1017             :         // In case the Text is not part of the property sequence (or occurs _before_
    1018             :         // the DefaultText, which can happen for other value/default-value property names),
    1019             :         // this means that the Text (the value property) is incorrectly imported.
    1020             : 
    1021           0 :         sal_Bool bRestoreValuePropertyValue = sal_False;
    1022           0 :         Any aValuePropertyValue;
    1023             : 
    1024           0 :         sal_Int16 nClassId = FormComponentType::CONTROL;
    1025             :         try
    1026             :         {
    1027             :             // get the class id of our element
    1028           0 :             m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
    1029             :         }
    1030           0 :         catch( const Exception& )
    1031             :         {
    1032             :             OSL_FAIL( "OControlImport::EndElement: caught an exception while retrieving the class id!" );
    1033             :         }
    1034             : 
    1035           0 :         const sal_Char* pValueProperty = NULL;
    1036           0 :         const sal_Char* pDefaultValueProperty = NULL;
    1037           0 :         getRuntimeValuePropertyNames(m_eElementType, nClassId, pValueProperty, pDefaultValueProperty);
    1038           0 :         if ( pDefaultValueProperty && pValueProperty )
    1039             :         {
    1040           0 :             sal_Bool bNonDefaultValuePropertyValue = sal_False;
    1041             :                 // is the "value property" part of the sequence?
    1042             : 
    1043             :             // look up this property in our sequence
    1044           0 :             PropertyValueArray::iterator aEnd = m_aValues.end();
    1045           0 :             for (   PropertyValueArray::iterator aCheck = m_aValues.begin();
    1046             :                     ( aCheck != aEnd );
    1047             :                     ++aCheck
    1048             :                 )
    1049             :             {
    1050           0 :                 if ( aCheck->Name.equalsAscii( pDefaultValueProperty ) )
    1051           0 :                     bRestoreValuePropertyValue = sal_True;
    1052           0 :                 else if ( aCheck->Name.equalsAscii( pValueProperty ) )
    1053             :                 {
    1054           0 :                     bNonDefaultValuePropertyValue = sal_True;
    1055             :                     // we need to restore the value property we found here, nothing else
    1056           0 :                     aValuePropertyValue = aCheck->Value;
    1057             :                 }
    1058             :             }
    1059             : 
    1060           0 :             if ( bRestoreValuePropertyValue && !bNonDefaultValuePropertyValue )
    1061             :             {
    1062             :                 // found it -> need to remember (and restore) the "value property value", which is not set explicitly
    1063             :                 try
    1064             :                 {
    1065           0 :                     aValuePropertyValue = m_xElement->getPropertyValue( ::rtl::OUString::createFromAscii( pValueProperty ) );
    1066             :                 }
    1067           0 :                 catch( const Exception& )
    1068             :                 {
    1069             :                     OSL_FAIL( "OControlImport::EndElement: caught an exception while retrieving the current value property!" );
    1070             :                 }
    1071             :             }
    1072             :         }
    1073             : 
    1074             :         // let the base class set all the values
    1075           0 :         OElementImport::EndElement();
    1076             : 
    1077             :         // restore the "value property value", if necessary
    1078           0 :         if ( bRestoreValuePropertyValue && pValueProperty )
    1079             :         {
    1080             :             try
    1081             :             {
    1082           0 :                 m_xElement->setPropertyValue( ::rtl::OUString::createFromAscii( pValueProperty ), aValuePropertyValue );
    1083             :             }
    1084           0 :             catch( const Exception& )
    1085             :             {
    1086             :                 OSL_FAIL( "OControlImport::EndElement: caught an exception while restoring the value property!" );
    1087             :             }
    1088             :         }
    1089             : 
    1090             :         // the external cell binding, if applicable
    1091           0 :         if ( m_xElement.is() && !m_sBoundCellAddress.isEmpty() )
    1092           0 :             doRegisterCellValueBinding( m_sBoundCellAddress );
    1093             : 
    1094             :         // XForms binding, if applicable
    1095           0 :         if ( m_xElement.is() && !m_sBindingID.isEmpty() )
    1096           0 :             doRegisterXFormsValueBinding( m_sBindingID );
    1097             : 
    1098             :         // XForms list binding, if applicable
    1099           0 :         if ( m_xElement.is() && !m_sListBindingID.isEmpty() )
    1100           0 :             doRegisterXFormsListBinding( m_sListBindingID );
    1101             : 
    1102             :         // XForms submission, if applicable
    1103           0 :         if ( m_xElement.is() && !m_sSubmissionID.isEmpty() )
    1104           0 :             doRegisterXFormsSubmission( m_sSubmissionID );
    1105             :     }
    1106             : 
    1107             :     //---------------------------------------------------------------------
    1108           0 :     void OControlImport::doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress )
    1109             :     {
    1110             :         OSL_PRECOND( m_xElement.is(), "OControlImport::doRegisterCellValueBinding: invalid element!" );
    1111             :         OSL_PRECOND( !_rBoundCellAddress.isEmpty(),
    1112             :             "OControlImport::doRegisterCellValueBinding: invalid address!" );
    1113             : 
    1114           0 :         m_rContext.registerCellValueBinding( m_xElement, _rBoundCellAddress );
    1115           0 :     }
    1116             : 
    1117             :     //---------------------------------------------------------------------
    1118           0 :     void OControlImport::doRegisterXFormsValueBinding( const ::rtl::OUString& _rBindingID )
    1119             :     {
    1120             :         OSL_PRECOND( m_xElement.is(), "need element" );
    1121             :         OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
    1122             : 
    1123           0 :         m_rContext.registerXFormsValueBinding( m_xElement, _rBindingID );
    1124           0 :     }
    1125             : 
    1126             :     //---------------------------------------------------------------------
    1127           0 :     void OControlImport::doRegisterXFormsListBinding( const ::rtl::OUString& _rBindingID )
    1128             :     {
    1129             :         OSL_PRECOND( m_xElement.is(), "need element" );
    1130             :         OSL_PRECOND( !_rBindingID.isEmpty(), "binding ID is not valid" );
    1131             : 
    1132           0 :         m_rContext.registerXFormsListBinding( m_xElement, _rBindingID );
    1133           0 :     }
    1134             : 
    1135             :     //---------------------------------------------------------------------
    1136           0 :     void OControlImport::doRegisterXFormsSubmission( const ::rtl::OUString& _rSubmissionID )
    1137             :     {
    1138             :         OSL_PRECOND( m_xElement.is(), "need element" );
    1139             :         OSL_PRECOND( !_rSubmissionID.isEmpty(), "binding ID is not valid" );
    1140             : 
    1141           0 :         m_rContext.registerXFormsSubmission( m_xElement, _rSubmissionID );
    1142           0 :     }
    1143             : 
    1144             :     //---------------------------------------------------------------------
    1145             : 
    1146           0 :     Reference< XPropertySet > OControlImport::createElement()
    1147             :     {
    1148           0 :         const Reference<XPropertySet> xPropSet = OElementImport::createElement();
    1149           0 :         if ( xPropSet.is() )
    1150             :         {
    1151           0 :             m_xInfo = xPropSet->getPropertySetInfo();
    1152           0 :             if ( m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_ALIGN) )
    1153             :             {
    1154           0 :                 Any aValue;
    1155           0 :                 xPropSet->setPropertyValue(PROPERTY_ALIGN,aValue);
    1156             :             }
    1157             :         }
    1158           0 :         return xPropSet;
    1159             :     }
    1160             : 
    1161             :     //=====================================================================
    1162             :     //= OImagePositionImport
    1163             :     //=====================================================================
    1164             :     //---------------------------------------------------------------------
    1165           0 :     OImagePositionImport::OImagePositionImport( OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager,
    1166             :         sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const Reference< XNameContainer >& _rxParentContainer,
    1167             :         OControlElement::ElementType _eType )
    1168             :         :OControlImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType )
    1169             :         ,m_nImagePosition( -1 )
    1170             :         ,m_nImageAlign( 0 )
    1171           0 :         ,m_bHaveImagePosition( sal_False )
    1172             :     {
    1173           0 :     }
    1174             : 
    1175             :     //---------------------------------------------------------------------
    1176           0 :     bool OImagePositionImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName,
    1177             :         const ::rtl::OUString& _rValue )
    1178             :     {
    1179           0 :         if ( _rLocalName == GetXMLToken( XML_IMAGE_POSITION ) )
    1180             :         {
    1181           0 :             OSL_VERIFY( PropertyConversion::convertString(
    1182             :                 m_rContext.getGlobalContext(), ::getCppuType( &m_nImagePosition ),
    1183             :                 _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImagePosition )
    1184             :             ) >>= m_nImagePosition );
    1185           0 :             m_bHaveImagePosition = sal_True;
    1186           0 :             return true;
    1187             :         }
    1188             : 
    1189           0 :         if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) )
    1190             :         {
    1191           0 :             OSL_VERIFY( PropertyConversion::convertString(
    1192             :                 m_rContext.getGlobalContext(), ::getCppuType( &m_nImageAlign ),
    1193             :                 _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImageAlign )
    1194             :             ) >>= m_nImageAlign );
    1195           0 :             return true;
    1196             :         }
    1197             : 
    1198           0 :         return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
    1199             :     }
    1200             : 
    1201             :     //---------------------------------------------------------------------
    1202           0 :     void OImagePositionImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1203             :     {
    1204           0 :         OControlImport::StartElement( _rxAttrList );
    1205             : 
    1206           0 :         if ( m_bHaveImagePosition )
    1207             :         {
    1208           0 :             sal_Int16 nUnoImagePosition = ImagePosition::Centered;
    1209           0 :             if ( m_nImagePosition >= 0 )
    1210             :             {
    1211             :                 OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ),
    1212             :                     "OImagePositionImport::StartElement: unknown image align and/or position!" );
    1213           0 :                 nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign;
    1214             :             }
    1215             : 
    1216           0 :             PropertyValue aImagePosition;
    1217           0 :             aImagePosition.Name = PROPERTY_IMAGE_POSITION;
    1218           0 :             aImagePosition.Value <<= nUnoImagePosition;
    1219           0 :             implPushBackPropertyValue( aImagePosition );
    1220             :         }
    1221           0 :     }
    1222             : 
    1223             :     //=====================================================================
    1224             :     //= OReferredControlImport
    1225             :     //=====================================================================
    1226             :     //---------------------------------------------------------------------
    1227           0 :     OReferredControlImport::OReferredControlImport(
    1228             :             OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1229             :             const Reference< XNameContainer >& _rxParentContainer,
    1230             :             OControlElement::ElementType )
    1231           0 :         :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer)
    1232             :     {
    1233           0 :     }
    1234             : 
    1235             :     //---------------------------------------------------------------------
    1236           0 :     void OReferredControlImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1237             :     {
    1238           0 :         OControlImport::StartElement(_rxAttrList);
    1239             : 
    1240             :         // the base class should have created the control, so we can register it
    1241           0 :         if ( !m_sReferringControls.isEmpty() )
    1242           0 :             m_rFormImport.registerControlReferences(m_xElement, m_sReferringControls);
    1243           0 :     }
    1244             : 
    1245             :     //---------------------------------------------------------------------
    1246           0 :     bool OReferredControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName,
    1247             :         const ::rtl::OUString& _rValue)
    1248             :     {
    1249           0 :         static const ::rtl::OUString s_sReferenceAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_FOR));
    1250           0 :         if (_rLocalName == s_sReferenceAttributeName)
    1251             :         {
    1252           0 :             m_sReferringControls = _rValue;
    1253           0 :             return true;
    1254             :         }
    1255           0 :         return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
    1256             :     }
    1257             : 
    1258             :     //=====================================================================
    1259             :     //= OPasswordImport
    1260             :     //=====================================================================
    1261             :     //---------------------------------------------------------------------
    1262           0 :     OPasswordImport::OPasswordImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1263             :             const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
    1264           0 :         :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
    1265             :     {
    1266           0 :     }
    1267             : 
    1268             :     //---------------------------------------------------------------------
    1269           0 :     bool OPasswordImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
    1270             :     {
    1271           0 :         static const ::rtl::OUString s_sEchoCharAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR));
    1272           0 :         if (_rLocalName == s_sEchoCharAttributeName)
    1273             :         {
    1274             :             // need a special handling for the EchoChar property
    1275           0 :             PropertyValue aEchoChar;
    1276           0 :             aEchoChar.Name = PROPERTY_ECHOCHAR;
    1277             :             OSL_ENSURE(_rValue.getLength() == 1, "OPasswordImport::handleAttribute: invalid echo char attribute!");
    1278             :                 // we ourself should not have written values other than of length 1
    1279           0 :             if (_rValue.getLength() >= 1)
    1280           0 :                 aEchoChar.Value <<= (sal_Int16)_rValue.getStr()[0];
    1281             :             else
    1282           0 :                 aEchoChar.Value <<= (sal_Int16)0;
    1283           0 :             implPushBackPropertyValue(aEchoChar);
    1284           0 :             return true;
    1285             :         }
    1286           0 :         return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
    1287             :     }
    1288             : 
    1289             :     //=====================================================================
    1290             :     //= ORadioImport
    1291             :     //=====================================================================
    1292             :     //---------------------------------------------------------------------
    1293           0 :     ORadioImport::ORadioImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1294             :             const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType)
    1295           0 :         :OImagePositionImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType )
    1296             :     {
    1297           0 :     }
    1298             : 
    1299             :     //---------------------------------------------------------------------
    1300           0 :     bool ORadioImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
    1301             :     {
    1302             :         // need special handling for the State & CurrentState properties:
    1303             :         // they're stored as booleans, but expected to be int16 properties
    1304           0 :         static const sal_Char* pCurrentSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED);
    1305           0 :         static const sal_Char* pSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED);
    1306           0 :         if  (  _rLocalName.equalsAscii( pCurrentSelectedAttributeName )
    1307           0 :             || _rLocalName.equalsAscii( pSelectedAttributeName )
    1308             :             )
    1309             :         {
    1310           0 :             const OAttribute2Property::AttributeAssignment* pProperty = m_rContext.getAttributeMap().getAttributeTranslation(_rLocalName);
    1311             :             OSL_ENSURE(pProperty, "ORadioImport::handleAttribute: invalid property map!");
    1312           0 :             if (pProperty)
    1313             :             {
    1314           0 :                 const Any aBooleanValue( PropertyConversion::convertString(m_rContext.getGlobalContext(), pProperty->aPropertyType, _rValue, pProperty->pEnumMap) );
    1315             : 
    1316             :                 // create and store a new PropertyValue
    1317           0 :                 PropertyValue aNewValue;
    1318           0 :                 aNewValue.Name = pProperty->sPropertyName;
    1319           0 :                 aNewValue.Value <<= (sal_Int16)::cppu::any2bool(aBooleanValue);
    1320             : 
    1321           0 :                 implPushBackPropertyValue(aNewValue);
    1322             :             }
    1323           0 :             return true;
    1324             :         }
    1325           0 :         return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
    1326             :     }
    1327             : 
    1328             :     //=====================================================================
    1329             :     //= OURLReferenceImport
    1330             :     //=====================================================================
    1331           0 :     OURLReferenceImport::OURLReferenceImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1332             :             const Reference< XNameContainer >& _rxParentContainer,
    1333             :             OControlElement::ElementType _eType)
    1334           0 :         :OImagePositionImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
    1335             :     {
    1336           0 :     }
    1337             : 
    1338             :     //---------------------------------------------------------------------
    1339           0 :     bool OURLReferenceImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
    1340             :     {
    1341           0 :         static const sal_Char* s_pTargetLocationAttributeName   = OAttributeMetaData::getCommonControlAttributeName( CCA_TARGET_LOCATION );
    1342           0 :         static const sal_Char* s_pImageDataAttributeName        = OAttributeMetaData::getCommonControlAttributeName( CCA_IMAGE_DATA );
    1343             : 
    1344             :         // need to make the URL absolute if
    1345             :         // * it's the image-data attribute
    1346             :         // * it's the target-location attribute, and we're dealign with an object which has the respective property
    1347             :         sal_Bool bMakeAbsolute =
    1348           0 :                 ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) )
    1349           0 :             ||  (   ( 0 == _rLocalName.compareToAscii( s_pTargetLocationAttributeName ) )
    1350             :                 &&  (   ( OControlElement::BUTTON == m_eElementType )
    1351             :                     ||  ( OControlElement::IMAGE == m_eElementType )
    1352             :                     )
    1353           0 :                 );
    1354             : 
    1355           0 :         if ( bMakeAbsolute && !_rValue.isEmpty() )
    1356             :         {
    1357             :             // make a global URL out of the local one
    1358           0 :             ::rtl::OUString sAdjustedValue;
    1359             :             // only resolve image related url
    1360             :             // we don't want say form url targets to be resolved
    1361             :             // using ResolveGraphicObjectURL
    1362           0 :             if ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) )
    1363           0 :                 sAdjustedValue = m_rContext.getGlobalContext().ResolveGraphicObjectURL( _rValue, sal_False );
    1364             :             else
    1365           0 :                 sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue );
    1366           0 :             return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue );
    1367             :         }
    1368             : 
    1369           0 :         return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
    1370             :     }
    1371             : 
    1372             :     //=====================================================================
    1373             :     //= OButtonImport
    1374             :     //=====================================================================
    1375             :     //---------------------------------------------------------------------
    1376           0 :     OButtonImport::OButtonImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1377             :             const Reference< XNameContainer >& _rxParentContainer,
    1378             :             OControlElement::ElementType _eType)
    1379           0 :         :OURLReferenceImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
    1380             :     {
    1381           0 :         enableTrackAttributes();
    1382           0 :     }
    1383             : 
    1384             :     //---------------------------------------------------------------------
    1385           0 :     void OButtonImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1386             :     {
    1387           0 :         OURLReferenceImport::StartElement(_rxAttrList);
    1388             : 
    1389             :         // handle the target-frame attribute
    1390           0 :         simulateDefaultedAttribute(OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank");
    1391           0 :     }
    1392             : 
    1393             :     //=====================================================================
    1394             :     //= OValueRangeImport
    1395             :     //=====================================================================
    1396             :     //---------------------------------------------------------------------
    1397           0 :     OValueRangeImport::OValueRangeImport( OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1398             :             const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType )
    1399             :         :OControlImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType )
    1400           0 :         ,m_nStepSizeValue( 1 )
    1401             :     {
    1402             : 
    1403           0 :     }
    1404             : 
    1405             :     //---------------------------------------------------------------------
    1406           0 :     bool OValueRangeImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue )
    1407             :     {
    1408           0 :         if ( _rLocalName.equalsAscii( OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ) ) )
    1409             :         {
    1410           0 :             ::sax::Converter::convertNumber( m_nStepSizeValue, _rValue );
    1411           0 :             return true;
    1412             :         }
    1413           0 :         return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue );
    1414             :     }
    1415             : 
    1416             :     //---------------------------------------------------------------------
    1417           0 :     void OValueRangeImport::StartElement( const Reference< XAttributeList >& _rxAttrList )
    1418             :     {
    1419           0 :         OControlImport::StartElement( _rxAttrList );
    1420             : 
    1421           0 :         if ( m_xInfo.is() )
    1422             :         {
    1423           0 :             if ( m_xInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) )
    1424           0 :                 m_xElement->setPropertyValue( PROPERTY_SPIN_INCREMENT, makeAny( m_nStepSizeValue ) );
    1425           0 :             else if ( m_xInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) )
    1426           0 :                 m_xElement->setPropertyValue( PROPERTY_LINE_INCREMENT, makeAny( m_nStepSizeValue ) );
    1427             :         }
    1428           0 :     }
    1429             : 
    1430             :     //=====================================================================
    1431             :     //= OTextLikeImport
    1432             :     //=====================================================================
    1433             :     //---------------------------------------------------------------------
    1434           0 :     OTextLikeImport::OTextLikeImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1435             :             const Reference< XNameContainer >& _rxParentContainer,
    1436             :             OControlElement::ElementType _eType)
    1437             :         :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
    1438           0 :         ,m_bEncounteredTextPara( false )
    1439             :     {
    1440           0 :         enableTrackAttributes();
    1441           0 :     }
    1442             : 
    1443             :     //---------------------------------------------------------------------
    1444           0 :     SvXMLImportContext* OTextLikeImport::CreateChildContext( sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    1445             :         const Reference< XAttributeList >& _rxAttrList )
    1446             :     {
    1447           0 :         if ( ( XML_NAMESPACE_TEXT == _nPrefix ) && _rLocalName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("p")) )
    1448             :         {
    1449             :             OSL_ENSURE( m_eElementType == OControlElement::TEXT_AREA,
    1450             :                 "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" );
    1451             : 
    1452           0 :             if ( m_eElementType == OControlElement::TEXT_AREA )
    1453             :             {
    1454           0 :                 Reference< XText > xTextElement( m_xElement, UNO_QUERY );
    1455           0 :                 if ( xTextElement.is() )
    1456             :                 {
    1457           0 :                     UniReference < XMLTextImportHelper > xTextImportHelper( m_rContext.getGlobalContext().GetTextImport() );
    1458             : 
    1459           0 :                     if ( !m_xCursor.is() )
    1460             :                     {
    1461           0 :                         m_xOldCursor = xTextImportHelper->GetCursor();
    1462           0 :                         m_xCursor = xTextElement->createTextCursor();
    1463             : 
    1464           0 :                         if ( m_xCursor.is() )
    1465           0 :                             xTextImportHelper->SetCursor( m_xCursor );
    1466             :                     }
    1467           0 :                     if ( m_xCursor.is() )
    1468             :                     {
    1469           0 :                         m_bEncounteredTextPara = true;
    1470           0 :                         return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), _nPrefix, _rLocalName, _rxAttrList );
    1471           0 :                     }
    1472             :                 }
    1473             :                 else
    1474             :                 {
    1475             :                     // in theory, we could accumulate all the text portions (without formatting),
    1476             :                     // and set it as Text property at the model ...
    1477           0 :                 }
    1478             :             }
    1479             :         }
    1480             : 
    1481           0 :         return OControlImport::CreateChildContext( _nPrefix, _rLocalName, _rxAttrList );
    1482             :     }
    1483             : 
    1484             :     //---------------------------------------------------------------------
    1485           0 :     void OTextLikeImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1486             :     {
    1487           0 :         OControlImport::StartElement(_rxAttrList);
    1488             : 
    1489             :         // handle the convert-empty-to-null attribute, whose default is different from the property default
    1490             :         // unfortunately, different classes are imported by this class ('cause they're represented by the
    1491             :         // same XML element), though not all of them know this property.
    1492             :         // So we have to do a check ...
    1493           0 :         if (m_xElement.is() && m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_EMPTY_IS_NULL) )
    1494           0 :             simulateDefaultedAttribute(OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY), PROPERTY_EMPTY_IS_NULL, "false");
    1495           0 :     }
    1496             : 
    1497             :     //---------------------------------------------------------------------
    1498             :     struct EqualHandle : public ::std::unary_function< PropertyValue, bool >
    1499             :     {
    1500             :         const sal_Int32 m_nHandle;
    1501           0 :         EqualHandle( sal_Int32 _nHandle ) : m_nHandle( _nHandle ) { }
    1502             : 
    1503           0 :         inline bool operator()( const PropertyValue& _rProp )
    1504             :         {
    1505           0 :             return _rProp.Handle == m_nHandle;
    1506             :         }
    1507             :     };
    1508             : 
    1509             :     //---------------------------------------------------------------------
    1510           0 :     void OTextLikeImport::removeRedundantCurrentValue()
    1511             :     {
    1512           0 :         if ( m_bEncounteredTextPara )
    1513             :         {
    1514             :             // In case the text is written in the text:p elements, we need to ignore what we read as
    1515             :             // current-value attribute, since it's redundant.
    1516             :             // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE
    1517             :             // handle, so we do not need to determine the name of our value property here
    1518             :             // (normally, it should be "Text", since no other controls than the edit field should
    1519             :             // have the text:p elements)
    1520             :             PropertyValueArray::iterator aValuePropertyPos = ::std::find_if(
    1521             :                 m_aValues.begin(),
    1522             :                 m_aValues.end(),
    1523             :                 EqualHandle( PROPID_CURRENT_VALUE )
    1524           0 :             );
    1525           0 :             if ( aValuePropertyPos != m_aValues.end() )
    1526             :             {
    1527             :                 OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" );
    1528           0 :                 if ( aValuePropertyPos->Name == PROPERTY_TEXT )
    1529             :                 {
    1530             :                     ::std::copy(
    1531             :                         aValuePropertyPos + 1,
    1532             :                         m_aValues.end(),
    1533             :                         aValuePropertyPos
    1534           0 :                     );
    1535           0 :                     m_aValues.resize( m_aValues.size() - 1 );
    1536             :                 }
    1537             :             }
    1538             : 
    1539             :             // additionally, we need to set the "RichText" property of our element to sal_True
    1540             :             // (the presence of the text:p is used as indicator for the value of the RichText property)
    1541           0 :             sal_Bool bHasRichTextProperty = sal_False;
    1542           0 :             if ( m_xInfo.is() )
    1543           0 :                 bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT );
    1544             :             OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" );
    1545           0 :             if ( bHasRichTextProperty )
    1546           0 :                 m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, makeAny( (sal_Bool)sal_True ) );
    1547             :         }
    1548             :         // Note that we do *not* set the RichText property (in case our element has one) to sal_False here
    1549             :         // since this is the default of this property, anyway.
    1550           0 :     }
    1551             : 
    1552             :     //---------------------------------------------------------------------
    1553           0 :     struct EqualName : public ::std::unary_function< PropertyValue, bool >
    1554             :     {
    1555             :         const ::rtl::OUString m_sName;
    1556           0 :         EqualName( const ::rtl::OUString& _rName ) : m_sName( _rName ) { }
    1557             : 
    1558           0 :         inline bool operator()( const PropertyValue& _rProp )
    1559             :         {
    1560           0 :             return _rProp.Name == m_sName;
    1561             :         }
    1562             :     };
    1563             : 
    1564             :     //---------------------------------------------------------------------
    1565           0 :     void OTextLikeImport::adjustDefaultControlProperty()
    1566             :     {
    1567             :         // In OpenOffice.org 2.0, we changed the implementation of the css.form.component.TextField (the model of a text field control),
    1568             :         // so that it now uses another default control. So if we encounter a text field where the *old* default
    1569             :         // control property is writting, we are not allowed to use it
    1570             :         PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if(
    1571             :             m_aValues.begin(),
    1572             :             m_aValues.end(),
    1573             :             EqualName( ::rtl::OUString( "DefaultControl"  ) )
    1574           0 :         );
    1575           0 :         if ( aDefaultControlPropertyPos != m_aValues.end() )
    1576             :         {
    1577           0 :             ::rtl::OUString sDefaultControl;
    1578           0 :             OSL_VERIFY( aDefaultControlPropertyPos->Value >>= sDefaultControl );
    1579           0 :             if ( sDefaultControl == "stardiv.one.form.control.Edit" )
    1580             :             {
    1581             :                 // complete remove this property value from the array. Today's "default value" of the "DefaultControl"
    1582             :                 // property is sufficient
    1583             :                 ::std::copy(
    1584             :                     aDefaultControlPropertyPos + 1,
    1585             :                     m_aValues.end(),
    1586             :                     aDefaultControlPropertyPos
    1587           0 :                 );
    1588           0 :                 m_aValues.resize( m_aValues.size() - 1 );
    1589           0 :             }
    1590             :         }
    1591           0 :     }
    1592             : 
    1593             :     //---------------------------------------------------------------------
    1594           0 :     void OTextLikeImport::EndElement()
    1595             :     {
    1596           0 :         removeRedundantCurrentValue();
    1597           0 :         adjustDefaultControlProperty();
    1598             : 
    1599             :         // let the base class do the stuff
    1600           0 :         OControlImport::EndElement();
    1601             : 
    1602             :         // some cleanups
    1603           0 :         UniReference < XMLTextImportHelper > xTextImportHelper( m_rContext.getGlobalContext().GetTextImport() );
    1604           0 :         if ( m_xCursor.is() )
    1605             :         {
    1606             :             // delete the newline which has been imported errornously
    1607             :             // TODO (fs): stole this code somewhere - why don't we fix the text import??
    1608           0 :             m_xCursor->gotoEnd( sal_False );
    1609           0 :             m_xCursor->goLeft( 1, sal_True );
    1610           0 :             m_xCursor->setString( ::rtl::OUString() );
    1611             : 
    1612             :             // reset cursor
    1613           0 :             xTextImportHelper->ResetCursor();
    1614             :         }
    1615             : 
    1616           0 :         if ( m_xOldCursor.is() )
    1617           0 :             xTextImportHelper->SetCursor( m_xOldCursor );
    1618             : 
    1619           0 :     }
    1620             : 
    1621             :     //=====================================================================
    1622             :     //= OListAndComboImport
    1623             :     //=====================================================================
    1624             :     //---------------------------------------------------------------------
    1625           0 :     OListAndComboImport::OListAndComboImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1626             :             const Reference< XNameContainer >& _rxParentContainer,
    1627             :             OControlElement::ElementType _eType)
    1628             :         :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
    1629             :         ,m_nEmptyListItems( 0 )
    1630             :         ,m_nEmptyValueItems( 0 )
    1631             :         ,m_bEncounteredLSAttrib( sal_False )
    1632           0 :         ,m_bLinkWithIndexes( sal_False )
    1633             :     {
    1634           0 :         if (OControlElement::COMBOBOX == m_eElementType)
    1635           0 :             enableTrackAttributes();
    1636           0 :     }
    1637             : 
    1638             :     //---------------------------------------------------------------------
    1639           0 :     SvXMLImportContext* OListAndComboImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    1640             :             const Reference< XAttributeList >& _rxAttrList)
    1641             :     {
    1642             :         // is it the "option" sub tag of a listbox ?
    1643           0 :         static const ::rtl::OUString s_sOptionElementName("option");
    1644           0 :         if (s_sOptionElementName == _rLocalName)
    1645           0 :             return new OListOptionImport(GetImport(), _nPrefix, _rLocalName, this);
    1646             : 
    1647             :         // is it the "item" sub tag of a combobox ?
    1648           0 :         static const ::rtl::OUString s_sItemElementName("item");
    1649           0 :         if (s_sItemElementName == _rLocalName)
    1650           0 :             return new OComboItemImport(GetImport(), _nPrefix, _rLocalName, this);
    1651             : 
    1652             :         // everything else
    1653           0 :         return OControlImport::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
    1654             :     }
    1655             : 
    1656             :     //---------------------------------------------------------------------
    1657           0 :     void OListAndComboImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1658             :     {
    1659           0 :         m_bLinkWithIndexes = sal_False;
    1660             : 
    1661           0 :         OControlImport::StartElement(_rxAttrList);
    1662             : 
    1663           0 :         if (OControlElement::COMBOBOX == m_eElementType)
    1664             :         {
    1665             :             // for the auto-completion
    1666             :             // the attribute default does not equal the property default, so in case we did not read this attribute,
    1667             :             // we have to simulate it
    1668           0 :             simulateDefaultedAttribute( OAttributeMetaData::getSpecialAttributeName( SCA_AUTOMATIC_COMPLETION ), PROPERTY_AUTOCOMPLETE, "false");
    1669             : 
    1670             :             // same for the convert-empty-to-null attribute, which's default is different from the property default
    1671           0 :             simulateDefaultedAttribute( OAttributeMetaData::getDatabaseAttributeName( DA_CONVERT_EMPTY ), PROPERTY_EMPTY_IS_NULL, "false");
    1672             :         }
    1673           0 :     }
    1674             : 
    1675             :     //---------------------------------------------------------------------
    1676           0 :     void OListAndComboImport::EndElement()
    1677             :     {
    1678             :         // append the list source property the the properties sequence of our importer
    1679             :         // the string item list
    1680           0 :         PropertyValue aItemList;
    1681           0 :         aItemList.Name = PROPERTY_STRING_ITEM_LIST;
    1682           0 :         aItemList.Value <<= m_aListSource;
    1683           0 :         implPushBackPropertyValue(aItemList);
    1684             : 
    1685           0 :         if (OControlElement::LISTBOX == m_eElementType)
    1686             :         {
    1687             :             OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
    1688             :                 "OListAndComboImport::EndElement: inconsistence between labels and values!");
    1689             : 
    1690           0 :             if ( !m_bEncounteredLSAttrib )
    1691             :             {
    1692             :                 // the value sequence
    1693           0 :                 PropertyValue aValueList;
    1694           0 :                 aValueList.Name = PROPERTY_LISTSOURCE;
    1695           0 :                 aValueList.Value <<= m_aValueList;
    1696           0 :                 implPushBackPropertyValue(aValueList);
    1697             :             }
    1698             : 
    1699             :             // the select sequence
    1700           0 :             PropertyValue aSelected;
    1701           0 :             aSelected.Name = PROPERTY_SELECT_SEQ;
    1702           0 :             aSelected.Value <<= m_aSelectedSeq;
    1703           0 :             implPushBackPropertyValue(aSelected);
    1704             : 
    1705             :             // the default select sequence
    1706           0 :             PropertyValue aDefaultSelected;
    1707           0 :             aDefaultSelected.Name = PROPERTY_DEFAULT_SELECT_SEQ;
    1708           0 :             aDefaultSelected.Value <<= m_aDefaultSelectedSeq;
    1709           0 :             implPushBackPropertyValue(aDefaultSelected);
    1710             :         }
    1711             : 
    1712           0 :         OControlImport::EndElement();
    1713             : 
    1714             :         // the external list source, if applicable
    1715           0 :         if ( m_xElement.is() && !m_sCellListSource.isEmpty() )
    1716           0 :             m_rContext.registerCellRangeListSource( m_xElement, m_sCellListSource );
    1717           0 :     }
    1718             : 
    1719             :     //---------------------------------------------------------------------
    1720           0 :     void OListAndComboImport::doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress )
    1721             :     {
    1722           0 :         ::rtl::OUString sBoundCellAddress( _rBoundCellAddress );
    1723           0 :         if ( m_bLinkWithIndexes )
    1724             :         {
    1725             :             // This is a HACK. We register a string which is no valid address, but allows
    1726             :             // (somewhere else) to determine that a non-standard binding should be created.
    1727             :             // This hack is acceptable for OOo 1.1.1, since the file format for value
    1728             :             // bindings of form controls is to be changed afterwards, anyway.
    1729           0 :             sBoundCellAddress += ::rtl::OUString( ":index"  );
    1730             :         }
    1731             : 
    1732           0 :         OControlImport::doRegisterCellValueBinding( sBoundCellAddress );
    1733           0 :     }
    1734             : 
    1735             :     //---------------------------------------------------------------------
    1736           0 :     bool OListAndComboImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
    1737             :     {
    1738           0 :         static const sal_Char* pListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE);
    1739           0 :         if ( _rLocalName.equalsAscii(pListSourceAttributeName) )
    1740             :         {
    1741           0 :             PropertyValue aListSource;
    1742           0 :             aListSource.Name = PROPERTY_LISTSOURCE;
    1743             : 
    1744             :             // it's the ListSource attribute
    1745           0 :             m_bEncounteredLSAttrib = sal_True;
    1746           0 :             if ( OControlElement::COMBOBOX == m_eElementType )
    1747             :             {
    1748           0 :                 aListSource.Value <<= _rValue;
    1749             :             }
    1750             :             else
    1751             :             {
    1752             :                 // a listbox which has a list-source attribute must have a list-source-type of something
    1753             :                 // not equal to ValueList.
    1754             :                 // In this case, the list-source value is simply the one and only element of the ListSource property.
    1755           0 :                 Sequence< ::rtl::OUString > aListSourcePropValue( 1 );
    1756           0 :                 aListSourcePropValue[0] = _rValue;
    1757           0 :                 aListSource.Value <<= aListSourcePropValue;
    1758             :             }
    1759             : 
    1760           0 :             implPushBackPropertyValue( aListSource );
    1761           0 :             return true;
    1762             :         }
    1763             : 
    1764           0 :         if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) )
    1765             :         {
    1766           0 :             m_sCellListSource = _rValue;
    1767           0 :             return true;
    1768             :         }
    1769             : 
    1770           0 :         if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) )
    1771             :         {
    1772           0 :             sal_Int16 nLinkageType = 0;
    1773             :             PropertyConversion::convertString(
    1774           0 :                 m_rContext.getGlobalContext(),
    1775           0 :                 ::getCppuType( static_cast< sal_Int16* >( NULL ) ),
    1776             :                 _rValue,
    1777             :                 OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType )
    1778           0 :             ) >>= nLinkageType;
    1779             : 
    1780           0 :             m_bLinkWithIndexes = ( nLinkageType != 0 );
    1781           0 :             return true;
    1782             :         }
    1783             : 
    1784           0 :         return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
    1785             :     }
    1786             : 
    1787             :     //---------------------------------------------------------------------
    1788           0 :     void OListAndComboImport::implPushBackLabel(const ::rtl::OUString& _rLabel)
    1789             :     {
    1790             :         OSL_ENSURE(!m_nEmptyListItems, "OListAndComboImport::implPushBackValue: label list is already done!");
    1791           0 :         if (!m_nEmptyListItems)
    1792           0 :             pushBackSequenceElement(m_aListSource, _rLabel);
    1793           0 :     }
    1794             : 
    1795             :     //---------------------------------------------------------------------
    1796           0 :     void OListAndComboImport::implPushBackValue(const ::rtl::OUString& _rValue)
    1797             :     {
    1798             :         OSL_ENSURE(!m_nEmptyValueItems, "OListAndComboImport::implPushBackValue: value list is already done!");
    1799           0 :         if (!m_nEmptyValueItems)
    1800             :         {
    1801             :             OSL_ENSURE( !m_bEncounteredLSAttrib, "OListAndComboImport::implPushBackValue: invalid structure! Did you save this document with a version prior SRC641 m?" );
    1802             :                 // We already had the list-source attribute, which means that the ListSourceType is
    1803             :                 // not ValueList, which means that the ListSource should contain only one string in
    1804             :                 // the first element of the sequence
    1805             :                 // All other values in the file are invalid
    1806             : 
    1807           0 :             pushBackSequenceElement( m_aValueList, _rValue );
    1808             :         }
    1809           0 :     }
    1810             : 
    1811             :     //---------------------------------------------------------------------
    1812           0 :     void OListAndComboImport::implEmptyLabelFound()
    1813             :     {
    1814           0 :         ++m_nEmptyListItems;
    1815           0 :     }
    1816             : 
    1817             :     //---------------------------------------------------------------------
    1818           0 :     void OListAndComboImport::implEmptyValueFound()
    1819             :     {
    1820           0 :         ++m_nEmptyValueItems;
    1821           0 :     }
    1822             : 
    1823             :     //---------------------------------------------------------------------
    1824           0 :     void OListAndComboImport::implSelectCurrentItem()
    1825             :     {
    1826             :         OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
    1827             :             "OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!");
    1828             : 
    1829           0 :         sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems);
    1830           0 :         pushBackSequenceElement(m_aSelectedSeq, nItemNumber);
    1831           0 :     }
    1832             : 
    1833             :     //---------------------------------------------------------------------
    1834           0 :     void OListAndComboImport::implDefaultSelectCurrentItem()
    1835             :     {
    1836             :         OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems),
    1837             :             "OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!");
    1838             : 
    1839           0 :         sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems);
    1840           0 :         pushBackSequenceElement(m_aDefaultSelectedSeq, nItemNumber);
    1841           0 :     }
    1842             : 
    1843             :     //=====================================================================
    1844             :     //= OListOptionImport
    1845             :     //=====================================================================
    1846             :     //---------------------------------------------------------------------
    1847           0 :     OListOptionImport::OListOptionImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1848             :             const OListAndComboImportRef& _rListBox)
    1849             :         :SvXMLImportContext(_rImport, _nPrefix, _rName)
    1850           0 :         ,m_xListBoxImport(_rListBox)
    1851             :     {
    1852           0 :     }
    1853             : 
    1854             :     //---------------------------------------------------------------------
    1855           0 :     void OListOptionImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1856             :     {
    1857             :         // the label and the value
    1858           0 :         const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
    1859             :         const ::rtl::OUString sLabelAttribute = rMap.GetQNameByKey(
    1860           0 :             GetPrefix(), ::rtl::OUString("label"));
    1861             :         const ::rtl::OUString sValueAttribute = rMap.GetQNameByKey(
    1862           0 :             GetPrefix(), ::rtl::OUString("value"));
    1863             : 
    1864             :         // -------------------
    1865             :         // the label attribute
    1866           0 :         ::rtl::OUString sValue = _rxAttrList->getValueByName(sLabelAttribute);
    1867           0 :         sal_Bool bNonexistentAttribute = sal_False;
    1868           0 :         if (sValue.isEmpty())
    1869           0 :             if (_rxAttrList->getTypeByName(sLabelAttribute).isEmpty())
    1870             :                 // this attribute does not really exist
    1871           0 :                 bNonexistentAttribute = sal_True;
    1872             : 
    1873           0 :         if (bNonexistentAttribute)
    1874           0 :             m_xListBoxImport->implEmptyLabelFound();
    1875             :         else
    1876           0 :             m_xListBoxImport->implPushBackLabel( sValue );
    1877             : 
    1878             :         // -------------------
    1879             :         // the value attribute
    1880           0 :         sValue = _rxAttrList->getValueByName(sValueAttribute);
    1881           0 :         bNonexistentAttribute = sal_False;
    1882           0 :         if (sValue.isEmpty())
    1883           0 :             if (_rxAttrList->getTypeByName(sValueAttribute).isEmpty())
    1884             :                 // this attribute does not really exist
    1885           0 :                 bNonexistentAttribute = sal_True;
    1886             : 
    1887           0 :         if (bNonexistentAttribute)
    1888           0 :             m_xListBoxImport->implEmptyValueFound();
    1889             :         else
    1890           0 :             m_xListBoxImport->implPushBackValue( sValue );
    1891             : 
    1892             :         // the current-selected and selected
    1893             :         const ::rtl::OUString sSelectedAttribute = rMap.GetQNameByKey(
    1894           0 :             GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED)));
    1895             :         const ::rtl::OUString sDefaultSelectedAttribute = rMap.GetQNameByKey(
    1896           0 :             GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED)));
    1897             : 
    1898             :         // propagate the selected flag
    1899           0 :         bool bSelected(false);
    1900             :         ::sax::Converter::convertBool(bSelected,
    1901           0 :             _rxAttrList->getValueByName(sSelectedAttribute));
    1902           0 :         if (bSelected)
    1903           0 :             m_xListBoxImport->implSelectCurrentItem();
    1904             : 
    1905             :         // same for the default selected
    1906           0 :         bool bDefaultSelected(false);
    1907             :         ::sax::Converter::convertBool(bDefaultSelected,
    1908           0 :             _rxAttrList->getValueByName(sDefaultSelectedAttribute));
    1909           0 :         if (bDefaultSelected)
    1910           0 :             m_xListBoxImport->implDefaultSelectCurrentItem();
    1911             : 
    1912           0 :         SvXMLImportContext::StartElement(_rxAttrList);
    1913           0 :     }
    1914             : 
    1915             :     //=====================================================================
    1916             :     //= OComboItemImport
    1917             :     //=====================================================================
    1918             :     //---------------------------------------------------------------------
    1919           0 :     OComboItemImport::OComboItemImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1920             :             const OListAndComboImportRef& _rListBox)
    1921             :         :SvXMLImportContext(_rImport, _nPrefix, _rName)
    1922           0 :         ,m_xListBoxImport(_rListBox)
    1923             :     {
    1924           0 :     }
    1925             : 
    1926             :     //---------------------------------------------------------------------
    1927           0 :     void OComboItemImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1928             :     {
    1929           0 :         const ::rtl::OUString sLabelAttributeName = GetImport().GetNamespaceMap().GetQNameByKey(
    1930           0 :             GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL)));
    1931           0 :         m_xListBoxImport->implPushBackLabel(_rxAttrList->getValueByName(sLabelAttributeName));
    1932             : 
    1933           0 :         SvXMLImportContext::StartElement(_rxAttrList);
    1934           0 :     }
    1935             : 
    1936             : 
    1937             :     //=====================================================================
    1938             :     //= OColumnWrapperImport
    1939             :     //=====================================================================
    1940             :     //---------------------------------------------------------------------
    1941           0 :     OColumnWrapperImport::OColumnWrapperImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    1942             :             const Reference< XNameContainer >& _rxParentContainer)
    1943           0 :         :SvXMLImportContext(_rImport.getGlobalContext(), _nPrefix, _rName)
    1944             :         ,m_xParentContainer(_rxParentContainer)
    1945             :         ,m_rFormImport(_rImport)
    1946           0 :         ,m_rEventManager(_rEventManager)
    1947             :     {
    1948           0 :     }
    1949             :     //---------------------------------------------------------------------
    1950           0 :     SvXMLImportContext* OColumnWrapperImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    1951             :         const Reference< XAttributeList >&)
    1952             :     {
    1953           0 :         OControlImport* pReturn = implCreateChildContext(_nPrefix, _rLocalName, OElementNameMap::getElementType(_rLocalName));
    1954           0 :         if (pReturn)
    1955             :         {
    1956             :             OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::CreateChildContext: had no form:column element!");
    1957           0 :             pReturn->addOuterAttributes(m_xOwnAttributes);
    1958             :         }
    1959           0 :         return pReturn;
    1960             :     }
    1961             :     //---------------------------------------------------------------------
    1962           0 :     void OColumnWrapperImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    1963             :     {
    1964             :         OSL_ENSURE(!m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: aready have the cloned list!");
    1965             : 
    1966             :         // clone the attributes
    1967           0 :         Reference< XCloneable > xCloneList(_rxAttrList, UNO_QUERY);
    1968             :         OSL_ENSURE(xCloneList.is(), "OColumnWrapperImport::StartElement: AttributeList not cloneable!");
    1969           0 :         if ( xCloneList.is() )
    1970           0 :             m_xOwnAttributes = Reference< XAttributeList >(xCloneList->createClone(), UNO_QUERY);
    1971           0 :         OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: no cloned list!");
    1972           0 :     }
    1973             : 
    1974             :     //---------------------------------------------------------------------
    1975           0 :     OControlImport* OColumnWrapperImport::implCreateChildContext(
    1976             :             sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    1977             :             OControlElement::ElementType _eType)
    1978             :     {
    1979             :         OSL_ENSURE( (OControlElement::TEXT == _eType)
    1980             :                 ||  (OControlElement::TEXT_AREA == _eType)
    1981             :                 ||  (OControlElement::FORMATTED_TEXT == _eType)
    1982             :                 ||  (OControlElement::CHECKBOX == _eType)
    1983             :                 ||  (OControlElement::LISTBOX == _eType)
    1984             :                 ||  (OControlElement::COMBOBOX == _eType)
    1985             :                 ||  (OControlElement::TIME == _eType)
    1986             :                 ||  (OControlElement::DATE == _eType),
    1987             :                 "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!");
    1988             : 
    1989           0 :         switch (_eType)
    1990             :         {
    1991             :             case OControlElement::COMBOBOX:
    1992             :             case OControlElement::LISTBOX:
    1993           0 :                 return new OColumnImport<OListAndComboImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType );
    1994             : 
    1995             :             case OControlElement::PASSWORD:
    1996           0 :                 return new OColumnImport<OPasswordImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType );
    1997             : 
    1998             :             case OControlElement::TEXT:
    1999             :             case OControlElement::TEXT_AREA:
    2000             :             case OControlElement::FORMATTED_TEXT:
    2001           0 :                 return new OColumnImport< OTextLikeImport >( m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType );
    2002             : 
    2003             :             default:
    2004           0 :                 return new OColumnImport<OControlImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType );
    2005             :         }
    2006             :     }
    2007             : 
    2008             :     //=====================================================================
    2009             :     //= OGridImport
    2010             :     //=====================================================================
    2011             :     //---------------------------------------------------------------------
    2012           0 :     OGridImport::OGridImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    2013             :             const Reference< XNameContainer >& _rxParentContainer,
    2014             :             OControlElement::ElementType _eType)
    2015           0 :         :OGridImport_Base(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, "column")
    2016             :     {
    2017           0 :         setElementType(_eType);
    2018           0 :     }
    2019             : 
    2020             :     //---------------------------------------------------------------------
    2021           0 :     SvXMLImportContext* OGridImport::implCreateControlWrapper(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName)
    2022             :     {
    2023           0 :         return new OColumnWrapperImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer);
    2024             :     }
    2025             : 
    2026             :     //=====================================================================
    2027             :     //= OFormImport
    2028             :     //=====================================================================
    2029             :     //---------------------------------------------------------------------
    2030           0 :     OFormImport::OFormImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
    2031             :             const Reference< XNameContainer >& _rxParentContainer)
    2032           0 :         :OFormImport_Base(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, "control")
    2033             :     {
    2034           0 :         enableTrackAttributes();
    2035           0 :     }
    2036             : 
    2037             :     //---------------------------------------------------------------------
    2038           0 :     SvXMLImportContext* OFormImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    2039             :         const Reference< XAttributeList >& _rxAttrList)
    2040             :     {
    2041           0 :         if( token::IsXMLToken(_rLocalName, token::XML_FORM) )
    2042             :             return new OFormImport( m_rFormImport, *this, _nPrefix, _rLocalName,
    2043           0 :                                     m_xMeAsContainer);
    2044           0 :         else if ( token::IsXMLToken(_rLocalName, token::XML_CONNECTION_RESOURCE) )
    2045           0 :             return new OXMLDataSourceImport(GetImport(), _nPrefix, _rLocalName, _rxAttrList,m_xElement);
    2046           0 :         else if( (token::IsXMLToken(_rLocalName, token::XML_EVENT_LISTENERS) &&
    2047             :                  (XML_NAMESPACE_OFFICE == _nPrefix)) ||
    2048           0 :                  token::IsXMLToken( _rLocalName, token::XML_PROPERTIES) )
    2049             :             return OElementImport::CreateChildContext( _nPrefix, _rLocalName,
    2050           0 :                                                        _rxAttrList );
    2051             :         else
    2052             :             return implCreateChildContext( _nPrefix, _rLocalName,
    2053           0 :                         OElementNameMap::getElementType(_rLocalName) );
    2054             :     }
    2055             : 
    2056             :     //---------------------------------------------------------------------
    2057           0 :     void OFormImport::StartElement(const Reference< XAttributeList >& _rxAttrList)
    2058             :     {
    2059           0 :         m_rFormImport.enterEventContext();
    2060           0 :         OFormImport_Base::StartElement(_rxAttrList);
    2061             : 
    2062             :         // handle the target-frame attribute
    2063           0 :         simulateDefaultedAttribute(OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank");
    2064           0 :     }
    2065             : 
    2066             :     //---------------------------------------------------------------------
    2067           0 :     void OFormImport::EndElement()
    2068             :     {
    2069           0 :         OFormImport_Base::EndElement();
    2070           0 :         m_rFormImport.leaveEventContext();
    2071           0 :     }
    2072             : 
    2073             :     //---------------------------------------------------------------------
    2074           0 :     SvXMLImportContext* OFormImport::implCreateControlWrapper(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName)
    2075             :     {
    2076             :         OSL_ENSURE( !this, "illegal call to OFormImport::implCreateControlWrapper" );
    2077           0 :         return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName );
    2078             :     }
    2079             : 
    2080             :     //---------------------------------------------------------------------
    2081           0 :     bool OFormImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
    2082             :     {
    2083             :         // handle the master/details field attributes (they're way too special to let the OPropertyImport handle them)
    2084           0 :         static const ::rtl::OUString s_sMasterFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faMasterFields));
    2085           0 :         static const ::rtl::OUString s_sDetailFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faDetailFiels));
    2086             : 
    2087           0 :         if ( s_sMasterFieldsAttributeName == _rLocalName )
    2088             :         {
    2089           0 :             implTranslateStringListProperty(PROPERTY_MASTERFIELDS, _rValue);
    2090           0 :             return true;
    2091             :         }
    2092             : 
    2093           0 :         if ( s_sDetailFieldsAttributeName == _rLocalName )
    2094             :         {
    2095           0 :             implTranslateStringListProperty(PROPERTY_DETAILFIELDS, _rValue);
    2096           0 :             return true;
    2097             :         }
    2098             : 
    2099           0 :         return OFormImport_Base::handleAttribute(_nNamespaceKey, _rLocalName, _rValue);
    2100             :     }
    2101             : 
    2102             :     //---------------------------------------------------------------------
    2103           0 :     void OFormImport::implTranslateStringListProperty(const ::rtl::OUString& _rPropertyName, const ::rtl::OUString& _rValue)
    2104             :     {
    2105           0 :         PropertyValue aProp;
    2106           0 :         aProp.Name = _rPropertyName;
    2107             : 
    2108           0 :         Sequence< ::rtl::OUString > aList;
    2109             : 
    2110             :         // split up the value string
    2111           0 :         if (!_rValue.isEmpty())
    2112             :         {
    2113             :             // For the moment, we build a vector instead of a Sequence. It's easier to handle because of it's
    2114             :             // push_back method
    2115           0 :             ::std::vector< ::rtl::OUString > aElements;
    2116             :             // estimate the number of tokens
    2117           0 :             sal_Int32 nEstimate = 0, nLength = _rValue.getLength();
    2118           0 :             const sal_Unicode* pChars = _rValue.getStr();
    2119           0 :             for (sal_Int32 i=0; i<nLength; ++i, ++pChars)
    2120           0 :                 if (*pChars == ',')
    2121           0 :                     ++nEstimate;
    2122           0 :             aElements.reserve(nEstimate + 1);
    2123             :                 // that's the worst case. If the string contains the separator character _quoted_, we reserved to much ...
    2124             : 
    2125             : 
    2126           0 :             sal_Int32 nElementStart = 0;
    2127           0 :             sal_Int32 nNextSep = 0;
    2128             :             sal_Int32 nElementLength;
    2129           0 :             ::rtl::OUString sElement;
    2130           0 :             do
    2131             :             {
    2132             :                 // extract the current element
    2133             :                 nNextSep = ::sax::Converter::indexOfComma(
    2134           0 :                     _rValue, nElementStart);
    2135           0 :                 if (-1 == nNextSep)
    2136           0 :                     nNextSep = nLength;
    2137           0 :                 sElement = _rValue.copy(nElementStart, nNextSep - nElementStart);
    2138             : 
    2139           0 :                 nElementLength = sElement.getLength();
    2140             :                 // when writing the sequence, we quoted the single elements with " characters
    2141             :                 OSL_ENSURE( (nElementLength >= 2)
    2142             :                         &&  (sElement.getStr()[0] == '"')
    2143             :                         &&  (sElement.getStr()[nElementLength - 1] == '"'),
    2144             :                         "OFormImport::implTranslateStringListProperty: invalid quoted element name.");
    2145           0 :                 sElement = sElement.copy(1, nElementLength - 2);
    2146             : 
    2147           0 :                 aElements.push_back(sElement);
    2148             : 
    2149             :                 // swith to the next element
    2150           0 :                 nElementStart = 1 + nNextSep;
    2151             :             }
    2152             :             while (nElementStart < nLength);
    2153             : 
    2154           0 :             ::rtl::OUString *pElements = aElements.empty() ? 0 : &aElements[0];
    2155           0 :             aList = Sequence< ::rtl::OUString >(pElements, aElements.size());
    2156             :         }
    2157             :         else
    2158             :         {
    2159             :             OSL_FAIL("OFormImport::implTranslateStringListProperty: invalid value (empty)!");
    2160             :         }
    2161             : 
    2162           0 :         aProp.Value <<= aList;
    2163             : 
    2164             :         // add the property to the base class' array
    2165           0 :         implPushBackPropertyValue(aProp);
    2166           0 :     }
    2167             :     //=====================================================================
    2168             :     //= OXMLDataSourceImport
    2169             :     //=====================================================================
    2170           0 :     OXMLDataSourceImport::OXMLDataSourceImport(
    2171             :                     SvXMLImport& _rImport
    2172             :                     ,sal_uInt16 nPrfx
    2173             :                     , const ::rtl::OUString& _sLocalName
    2174             :                     ,const Reference< ::com::sun::star::xml::sax::XAttributeList > & _xAttrList
    2175             :                     ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xElement) :
    2176           0 :         SvXMLImportContext( _rImport, nPrfx, _sLocalName )
    2177             :     {
    2178             :         OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
    2179           0 :         const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap();
    2180             : 
    2181           0 :         sal_Int16 nLength = (_xElement.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
    2182           0 :         for(sal_Int16 i = 0; i < nLength; ++i)
    2183             :         {
    2184           0 :             ::rtl::OUString sLocalName;
    2185           0 :             ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
    2186           0 :             sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName, &sLocalName );
    2187             : 
    2188           0 :             if  (   ( nPrefix == OAttributeMetaData::getCommonControlAttributeNamespace( CCA_TARGET_LOCATION ) )
    2189           0 :                 &&  ( sLocalName.equalsAscii( OAttributeMetaData::getCommonControlAttributeName( CCA_TARGET_LOCATION ) ) )
    2190             :                 )
    2191             :             {
    2192           0 :                 ::rtl::OUString sValue = _xAttrList->getValueByIndex( i );
    2193             : 
    2194           0 :                 INetURLObject aURL(sValue);
    2195           0 :                 if ( aURL.GetProtocol() == INET_PROT_FILE )
    2196           0 :                     _xElement->setPropertyValue(PROPERTY_DATASOURCENAME,makeAny(sValue));
    2197             :                 else
    2198           0 :                     _xElement->setPropertyValue(PROPERTY_URL,makeAny(sValue)); // the url is the "sdbc:" string
    2199           0 :                 break;
    2200             :             }
    2201           0 :         }
    2202           0 :     }
    2203             :     //---------------------------------------------------------------------
    2204           0 :     OControlImport* OFormImport::implCreateChildContext(
    2205             :             sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
    2206             :             OControlElement::ElementType _eType )
    2207             :     {
    2208           0 :         switch (_eType)
    2209             :         {
    2210             :             case OControlElement::TEXT:
    2211             :             case OControlElement::TEXT_AREA:
    2212             :             case OControlElement::FORMATTED_TEXT:
    2213           0 :                 return new OTextLikeImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2214             : 
    2215             :             case OControlElement::BUTTON:
    2216             :             case OControlElement::IMAGE:
    2217             :             case OControlElement::IMAGE_FRAME:
    2218           0 :                 return new OButtonImport( m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType );
    2219             : 
    2220             :             case OControlElement::COMBOBOX:
    2221             :             case OControlElement::LISTBOX:
    2222           0 :                 return new OListAndComboImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2223             : 
    2224             :             case OControlElement::RADIO:
    2225           0 :                 return new ORadioImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2226             : 
    2227             :             case OControlElement::CHECKBOX:
    2228           0 :                 return new OImagePositionImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2229             : 
    2230             :             case OControlElement::PASSWORD:
    2231           0 :                 return new OPasswordImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2232             : 
    2233             :             case OControlElement::FRAME:
    2234             :             case OControlElement::FIXED_TEXT:
    2235           0 :                 return new OReferredControlImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2236             : 
    2237             :             case OControlElement::GRID:
    2238           0 :                 return new OGridImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2239             : 
    2240             :             case OControlElement::VALUERANGE:
    2241           0 :                 return new OValueRangeImport( m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType );
    2242             : 
    2243             :             default:
    2244           0 :                 return new OControlImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType);
    2245             :         }
    2246             :     }
    2247             : 
    2248             : //.........................................................................
    2249          72 : }   // namespace xmloff
    2250             : //.........................................................................
    2251             : 
    2252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10