LCOV - code coverage report
Current view: top level - xmloff/source/forms - elementimport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 385 879 43.8 %
Date: 2012-08-25 Functions: 49 96 51.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 342 1367 25.0 %

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

Generated by: LCOV version 1.10