LCOV - code coverage report
Current view: top level - xmloff/source/xforms - xformsexport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 308 0.6 %
Date: 2012-08-25 Functions: 2 28 7.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 621 0.3 %

           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 "xmloff/xformsexport.hxx"
      31                 :            : 
      32                 :            : #include "XFormsModelExport.hxx"
      33                 :            : #include "xformsapi.hxx"
      34                 :            : 
      35                 :            : #include <xmloff/xmlexp.hxx>
      36                 :            : #include <xmloff/xmltoken.hxx>
      37                 :            : #include "xmloff/xmlnmspe.hxx"
      38                 :            : #include <xmloff/nmspmap.hxx>
      39                 :            : #include "DomExport.hxx"
      40                 :            : 
      41                 :            : #include <sax/tools/converter.hxx>
      42                 :            : 
      43                 :            : #include <comphelper/componentcontext.hxx>
      44                 :            : #include <comphelper/processfactory.hxx>
      45                 :            : 
      46                 :            : #include "tools/debug.hxx"
      47                 :            : #include <tools/diagnose_ex.h>
      48                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      49                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      50                 :            : #include <com/sun/star/xml/dom/XDocument.hpp>
      51                 :            : #include <com/sun/star/form/binding/XValueBinding.hpp>
      52                 :            : #include <com/sun/star/form/binding/XBindableValue.hpp>
      53                 :            : #include <com/sun/star/form/binding/XListEntrySink.hpp>
      54                 :            : #include <com/sun/star/form/binding/XListEntrySource.hpp>
      55                 :            : #include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
      56                 :            : #include <com/sun/star/xforms/XModel.hpp>
      57                 :            : #include <com/sun/star/xforms/XDataTypeRepository.hpp>
      58                 :            : #include <com/sun/star/xforms/XFormsSupplier.hpp>
      59                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      60                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      61                 :            : #include <com/sun/star/container/XEnumeration.hpp>
      62                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      63                 :            : #include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
      64                 :            : #include <com/sun/star/xsd/DataTypeClass.hpp>
      65                 :            : #include <com/sun/star/xsd/XDataType.hpp>
      66                 :            : #include <com/sun/star/util/Date.hpp>
      67                 :            : #include <com/sun/star/util/Time.hpp>
      68                 :            : #include <com/sun/star/util/DateTime.hpp>
      69                 :            : #include <com/sun/star/util/Duration.hpp>
      70                 :            : 
      71                 :            : using namespace com::sun::star;
      72                 :            : using namespace com::sun::star::uno;
      73                 :            : using namespace xmloff::token;
      74                 :            : 
      75                 :            : using rtl::OUString;
      76                 :            : using rtl::OUStringBuffer;
      77                 :            : using com::sun::star::beans::XPropertySet;
      78                 :            : using com::sun::star::beans::XPropertySetInfo;
      79                 :            : using com::sun::star::container::XIndexAccess;
      80                 :            : using com::sun::star::container::XNameAccess;
      81                 :            : using com::sun::star::container::XNameContainer;
      82                 :            : using com::sun::star::container::XEnumerationAccess;
      83                 :            : using com::sun::star::container::XEnumeration;
      84                 :            : using com::sun::star::xml::dom::XDocument;
      85                 :            : using com::sun::star::form::binding::XValueBinding;
      86                 :            : using com::sun::star::form::binding::XBindableValue;
      87                 :            : using com::sun::star::form::binding::XListEntrySink;
      88                 :            : using com::sun::star::form::submission::XSubmissionSupplier;
      89                 :            : using com::sun::star::beans::PropertyValue;
      90                 :            : using com::sun::star::xsd::XDataType;
      91                 :            : using com::sun::star::xforms::XDataTypeRepository;
      92                 :            : using com::sun::star::xforms::XFormsSupplier;
      93                 :            : using com::sun::star::util::Date;
      94                 :            : using com::sun::star::util::DateTime;
      95                 :            : using com::sun::star::util::Duration;
      96                 :            : 
      97                 :          0 : void exportXForms( SvXMLExport& rExport )
      98                 :            : {
      99         [ #  # ]:          0 :     Reference<XFormsSupplier> xSupplier( rExport.GetModel(), UNO_QUERY );
     100         [ #  # ]:          0 :     if( xSupplier.is() )
     101                 :            :     {
     102 [ #  # ][ #  # ]:          0 :         Reference<XNameContainer> xForms = xSupplier->getXForms();
     103         [ #  # ]:          0 :         if( xForms.is() )
     104                 :            :         {
     105 [ #  # ][ #  # ]:          0 :             Sequence<OUString> aNames = xForms->getElementNames();
     106                 :          0 :             const OUString* pNames = aNames.getConstArray();
     107                 :          0 :             sal_Int32 nNames = aNames.getLength();
     108                 :            : 
     109         [ #  # ]:          0 :             for( sal_Int32 n = 0; n < nNames; n++ )
     110                 :            :             {
     111         [ #  # ]:          0 :                 Reference<XPropertySet> xModel( xForms->getByName( pNames[n] ),
     112 [ #  # ][ #  # ]:          0 :                                                 UNO_QUERY );
     113         [ #  # ]:          0 :                 exportXFormsModel( rExport, xModel );
     114         [ #  # ]:          0 :             }
     115                 :          0 :         }
     116                 :          0 :     }
     117                 :          0 : }
     118                 :            : 
     119                 :            : 
     120                 :            : void exportXFormsInstance( SvXMLExport&, const Sequence<PropertyValue>& );
     121                 :            : void exportXFormsBinding( SvXMLExport&, const Reference<XPropertySet>& );
     122                 :            : void exportXFormsSubmission( SvXMLExport&, const Reference<XPropertySet>& );
     123                 :            : void exportXFormsSchemas( SvXMLExport&, const Reference<com::sun::star::xforms::XModel>& );
     124                 :            : 
     125                 :            : 
     126                 :            : typedef OUString (*convert_t)( const Any& );
     127                 :            : typedef struct
     128                 :            : {
     129                 :            :     const sal_Char* pPropertyName;
     130                 :            :     sal_uInt16 nPropertyNameLength;
     131                 :            :     sal_uInt16 nNamespace;
     132                 :            :     sal_uInt16 nToken;
     133                 :            :     convert_t aConverter;
     134                 :            : } ExportTable;
     135                 :            : void lcl_export( const Reference<XPropertySet>& rPropertySet,
     136                 :            :                  SvXMLExport& rExport,
     137                 :            :                  const ExportTable* pTable );
     138                 :            : 
     139                 :            : #define TABLE_ENTRY(NAME,NAMESPACE,TOKEN,CONVERTER) { NAME,sizeof(NAME)-1,XML_NAMESPACE_##NAMESPACE,xmloff::token::XML_##TOKEN, CONVERTER }
     140                 :            : #define TABLE_END { NULL, 0, 0, 0, NULL }
     141                 :            : 
     142                 :            : 
     143                 :            : // any conversion functions
     144                 :            : OUString lcl_string( const Any& );
     145                 :            : OUString lcl_bool( const Any& );
     146                 :            : OUString lcl_whitespace( const Any& );
     147                 :            : template<typename T, void (*FUNC)( OUStringBuffer&, T )> OUString lcl_convert( const Any& );
     148                 :            : template<typename T, void (*FUNC)( OUStringBuffer&, const T& )> OUString lcl_convertRef( const Any& );
     149                 :            : 
     150                 :            : void lcl_formatDate( OUStringBuffer& aBuffer, const Date& aDate );
     151                 :            : void lcl_formatTime( OUStringBuffer& aBuffer, const com::sun::star::util::Time& aTime );
     152                 :            : void lcl_formatDateTime( OUStringBuffer& aBuffer, const DateTime& aDateTime );
     153                 :            : 
     154                 :            : convert_t lcl_int32    = &lcl_convert<sal_Int32,&::sax::Converter::convertNumber>;
     155                 :            : convert_t lcl_double   = &lcl_convert<double,&::sax::Converter::convertDouble>;
     156                 :            : convert_t lcl_dateTime = &lcl_convertRef<DateTime,&lcl_formatDateTime>;
     157                 :            : convert_t lcl_date     = &lcl_convertRef<Date,&lcl_formatDate>;
     158                 :            : convert_t lcl_time     = &lcl_convertRef<com::sun::star::util::Time,&lcl_formatTime>;
     159                 :            : 
     160                 :            : // other functions
     161                 :            : OUString lcl_getXSDType( SvXMLExport& rExport,
     162                 :            :                          const Reference<XPropertySet>& xType );
     163                 :            : 
     164                 :            : 
     165                 :            : //
     166                 :            : // the model
     167                 :            : //
     168                 :            : 
     169                 :            : static const ExportTable aXFormsModelTable[] =
     170                 :            : {
     171                 :            :     TABLE_ENTRY( "ID", NONE, ID, lcl_string ),
     172                 :            :     TABLE_ENTRY( "SchemaRef", NONE, SCHEMA, lcl_string ),
     173                 :            :     TABLE_END
     174                 :            : };
     175                 :            : 
     176                 :          0 : void exportXFormsModel( SvXMLExport& rExport,
     177                 :            :                         const Reference<XPropertySet>& xModelPropSet )
     178                 :            : {
     179                 :            :     // no model -> don't do anything!
     180         [ #  # ]:          0 :     Reference<com::sun::star::xforms::XModel> xModel( xModelPropSet, UNO_QUERY );
     181 [ #  # ][ #  # ]:          0 :     if( ! xModel.is() || ! xModelPropSet.is() )
                 [ #  # ]
     182                 :          0 :         return;
     183                 :            : 
     184         [ #  # ]:          0 :     lcl_export( xModelPropSet, rExport, aXFormsModelTable );
     185                 :            :     SvXMLElementExport aModelElement( rExport, XML_NAMESPACE_XFORMS, XML_MODEL,
     186         [ #  # ]:          0 :                                       sal_True, sal_True );
     187                 :            : 
     188                 :            :     // instances
     189         [ #  # ]:          0 :     Reference<XIndexAccess> xInstances( xModel->getInstances(),
     190 [ #  # ][ #  # ]:          0 :                                         UNO_QUERY_THROW);
     191 [ #  # ][ #  # ]:          0 :     sal_Int32 nCount = xInstances->getCount();
     192                 :          0 :     sal_Int32 i = 0;
     193         [ #  # ]:          0 :     for( i = 0; i < nCount; i++ )
     194                 :            :     {
     195         [ #  # ]:          0 :         Sequence<PropertyValue> aInstance;
     196 [ #  # ][ #  # ]:          0 :         xInstances->getByIndex( i ) >>= aInstance;
                 [ #  # ]
     197         [ #  # ]:          0 :         exportXFormsInstance( rExport, aInstance );
     198         [ #  # ]:          0 :     }
     199                 :            : 
     200                 :            : 
     201                 :            :     // bindings
     202 [ #  # ][ #  # ]:          0 :     Reference<XIndexAccess> xBindings( xModel->getBindings(), UNO_QUERY_THROW);
                 [ #  # ]
     203 [ #  # ][ #  # ]:          0 :     nCount = xBindings->getCount();
     204         [ #  # ]:          0 :     for( i = 0; i < nCount; i++ )
     205                 :            :     {
     206         [ #  # ]:          0 :         Reference<XPropertySet> aBinding( xBindings->getByIndex( i ),
     207 [ #  # ][ #  # ]:          0 :                                           UNO_QUERY_THROW );
     208         [ #  # ]:          0 :         exportXFormsBinding( rExport, aBinding );
     209                 :          0 :     }
     210                 :            : 
     211                 :            :     // submissions
     212         [ #  # ]:          0 :     Reference<XIndexAccess> xSubmissions( xModel->getSubmissions(),
     213 [ #  # ][ #  # ]:          0 :                                           UNO_QUERY_THROW );
     214 [ #  # ][ #  # ]:          0 :     nCount = xSubmissions->getCount();
     215         [ #  # ]:          0 :     for( i = 0; i < nCount; i++ )
     216                 :            :     {
     217         [ #  # ]:          0 :         Reference<XPropertySet> xSubmission( xSubmissions->getByIndex( i ),
     218 [ #  # ][ #  # ]:          0 :                                           UNO_QUERY_THROW );
     219         [ #  # ]:          0 :         exportXFormsSubmission( rExport, xSubmission );
     220                 :          0 :     }
     221                 :            : 
     222                 :            :     // schemas
     223 [ #  # ][ #  # ]:          0 :     exportXFormsSchemas( rExport, xModel );
                 [ #  # ]
     224                 :            : }
     225                 :            : 
     226                 :            : //
     227                 :            : // the instance
     228                 :            : //
     229                 :            : 
     230                 :            : static const ExportTable aXFormsInstanceTable[] =
     231                 :            : {
     232                 :            :     TABLE_ENTRY( "InstanceURL", NONE, SRC, lcl_string ),
     233                 :            :     TABLE_END
     234                 :            : };
     235                 :            : 
     236                 :          0 : void exportXFormsInstance( SvXMLExport& rExport,
     237                 :            :                            const Sequence<PropertyValue>& xInstance )
     238                 :            : {
     239                 :          0 :     OUString sId;
     240                 :          0 :     OUString sURL;
     241                 :          0 :     Reference<XDocument> xDoc;
     242                 :            : 
     243                 :          0 :     const PropertyValue* pInstance = xInstance.getConstArray();
     244                 :          0 :     sal_Int32 nCount = xInstance.getLength();
     245         [ #  # ]:          0 :     for( sal_Int32 i = 0; i < nCount; i++ )
     246                 :            :     {
     247                 :          0 :         OUString sName = pInstance[i].Name;
     248                 :          0 :         const Any& rAny = pInstance[i].Value;
     249         [ #  # ]:          0 :         if ( sName == "ID" )
     250                 :          0 :             rAny >>= sId;
     251         [ #  # ]:          0 :         else if ( sName == "URL" )
     252                 :          0 :             rAny >>= sURL;
     253         [ #  # ]:          0 :         else if ( sName == "Instance" )
     254         [ #  # ]:          0 :             rAny >>= xDoc;
     255                 :          0 :     }
     256                 :            : 
     257         [ #  # ]:          0 :     if( !sId.isEmpty() )
     258         [ #  # ]:          0 :         rExport.AddAttribute( XML_NAMESPACE_NONE, XML_ID, sId );
     259                 :            : 
     260         [ #  # ]:          0 :     if( !sURL.isEmpty() )
     261         [ #  # ]:          0 :         rExport.AddAttribute( XML_NAMESPACE_NONE, XML_SRC, sURL );
     262                 :            : 
     263                 :            :     SvXMLElementExport aElem( rExport, XML_NAMESPACE_XFORMS, XML_INSTANCE,
     264         [ #  # ]:          0 :                               sal_True, sal_True );
     265         [ #  # ]:          0 :     rExport.IgnorableWhitespace();
     266         [ #  # ]:          0 :     if( xDoc.is() )
     267                 :            :     {
     268         [ #  # ]:          0 :         exportDom( rExport, xDoc );
     269         [ #  # ]:          0 :     }
     270                 :          0 : }
     271                 :            : 
     272                 :            : 
     273                 :            : //
     274                 :            : // the binding
     275                 :            : //
     276                 :            : 
     277                 :            : static const ExportTable aXFormsBindingTable[] =
     278                 :            : {
     279                 :            :     TABLE_ENTRY( "BindingID",            NONE, ID,         lcl_string ),
     280                 :            :     TABLE_ENTRY( "BindingExpression",    NONE, NODESET,    lcl_string ),
     281                 :            :     TABLE_ENTRY( "ReadonlyExpression",   NONE, READONLY,   lcl_string ),
     282                 :            :     TABLE_ENTRY( "RelevantExpression",   NONE, RELEVANT,   lcl_string ),
     283                 :            :     TABLE_ENTRY( "RequiredExpression",   NONE, REQUIRED,   lcl_string ),
     284                 :            :     TABLE_ENTRY( "ConstraintExpression", NONE, CONSTRAINT, lcl_string ),
     285                 :            :     TABLE_ENTRY( "CalculateExpression",  NONE, CALCULATE,  lcl_string ),
     286                 :            :     // type handled separatly, for type name <-> XSD type conversion
     287                 :            :     // TABLE_ENTRY( "Type",                 NONE, TYPE,       lcl_string ),
     288                 :            :     TABLE_END
     289                 :            : };
     290                 :            : 
     291                 :          0 : void exportXFormsBinding( SvXMLExport& rExport,
     292                 :            :                         const Reference<XPropertySet>& xBinding )
     293                 :            : {
     294                 :            :     // name check; generate binding ID if necessary
     295                 :            :     {
     296                 :          0 :         OUString sName;
     297 [ #  # ][ #  # ]:          0 :         xBinding->getPropertyValue( OUSTRING("BindingID") ) >>= sName;
                 [ #  # ]
     298         [ #  # ]:          0 :         if( sName.isEmpty() )
     299                 :            :         {
     300                 :            :             // if we don't have a name yet, generate one on the fly
     301                 :          0 :             OUStringBuffer aBuffer;
     302 [ #  # ][ #  # ]:          0 :             aBuffer.append( OUSTRING("bind_" ) );
     303         [ #  # ]:          0 :             sal_Int64 nId = reinterpret_cast<sal_uInt64>( xBinding.get() );
     304         [ #  # ]:          0 :             aBuffer.append( nId , 16 );
     305         [ #  # ]:          0 :             sName = aBuffer.makeStringAndClear();
     306 [ #  # ][ #  # ]:          0 :             xBinding->setPropertyValue( OUSTRING("BindingID"), makeAny(sName));
         [ #  # ][ #  # ]
     307                 :          0 :         }
     308                 :            :     }
     309                 :            : 
     310         [ #  # ]:          0 :     lcl_export( xBinding, rExport, aXFormsBindingTable );
     311                 :            : 
     312                 :            :     // handle type attribute
     313                 :            :     {
     314                 :          0 :         OUString sTypeName;
     315 [ #  # ][ #  # ]:          0 :         xBinding->getPropertyValue( OUSTRING("Type") ) >>= sTypeName;
                 [ #  # ]
     316                 :            : 
     317                 :            :         try
     318                 :            :         {
     319                 :            :             // now get type, and determine whether its a standard type. If
     320                 :            :             // so, export the XSD name
     321                 :            :             Reference<com::sun::star::xforms::XModel> xModel(
     322         [ #  # ]:          0 :                 xBinding->getPropertyValue( OUSTRING("Model") ),
     323 [ #  # ][ #  # ]:          0 :                 UNO_QUERY );
                 [ #  # ]
     324                 :            :             Reference<XDataTypeRepository> xRepository(
     325 [ #  # ][ #  # ]:          0 :                 xModel.is() ? xModel->getDataTypeRepository() : Reference<XDataTypeRepository>() );
                 [ #  # ]
     326         [ #  # ]:          0 :             if( xRepository.is() )
     327                 :            :             {
     328                 :            :                 Reference<XPropertySet> xDataType(
     329         [ #  # ]:          0 :                     xRepository->getDataType( sTypeName ),
     330 [ #  # ][ #  # ]:          0 :                     UNO_QUERY );
     331                 :            : 
     332                 :            :                 // if it's a basic data type, write out the XSD name
     333                 :            :                 // for the XSD type class
     334                 :          0 :                 bool bIsBasic = false;
     335 [ #  # ][ #  # ]:          0 :                 xDataType->getPropertyValue( OUSTRING("IsBasic") ) >>= bIsBasic;
                 [ #  # ]
     336         [ #  # ]:          0 :                 if( bIsBasic )
     337         [ #  # ]:          0 :                     sTypeName = lcl_getXSDType( rExport, xDataType );
     338         [ #  # ]:          0 :             }
     339                 :            :         }
     340         [ #  # ]:          0 :         catch( Exception& )
     341                 :            :         {
     342                 :            :             ; // ignore; just use typename
     343                 :            :         }
     344                 :            : 
     345                 :            :         // now that we have the proper type name, write out the attribute
     346         [ #  # ]:          0 :         if( !sTypeName.isEmpty() )
     347                 :            :         {
     348                 :            :             rExport.AddAttribute( XML_NAMESPACE_NONE, XML_TYPE,
     349         [ #  # ]:          0 :                                   sTypeName );
     350                 :          0 :         }
     351                 :            :     }
     352                 :            : 
     353                 :            :     // we need to ensure all the namespaces in the binding will work correctly.
     354                 :            :     // to do so, we will write out all missing namespace declaractions.
     355                 :          0 :     const SvXMLNamespaceMap& rMap = rExport.GetNamespaceMap();
     356                 :            :     Reference<XNameAccess> xNamespaces(
     357 [ #  # ][ #  # ]:          0 :         xBinding->getPropertyValue( OUSTRING("ModelNamespaces") ), UNO_QUERY);
         [ #  # ][ #  # ]
     358         [ #  # ]:          0 :     if( xNamespaces.is() )
     359                 :            :     {
     360                 :            :         // iterate over Prefixes for this binding
     361 [ #  # ][ #  # ]:          0 :         Sequence<OUString> aPrefixes = xNamespaces->getElementNames();
     362                 :          0 :         const OUString* pPrefixes = aPrefixes.getConstArray();
     363                 :          0 :         sal_Int32 nPrefixes = aPrefixes.getLength();
     364         [ #  # ]:          0 :         for( sal_Int32 i = 0; i < nPrefixes; i++ )
     365                 :            :         {
     366                 :          0 :             const OUString& rPrefix = pPrefixes[i];
     367                 :          0 :             OUString sURI;
     368 [ #  # ][ #  # ]:          0 :             xNamespaces->getByName( rPrefix ) >>= sURI;
     369                 :            : 
     370                 :            :             // check whether prefix/URI pair is in map; else write declaration
     371                 :            :             // (we don't need to change the map, since this element has no
     372                 :            :             // other content)
     373         [ #  # ]:          0 :             sal_uInt16 nKey = rMap.GetKeyByPrefix( rPrefix );
     374   [ #  #  #  # ]:          0 :             if( nKey == XML_NAMESPACE_UNKNOWN  ||
                 [ #  # ]
     375         [ #  # ]:          0 :                 rMap.GetNameByKey( nKey ) != sURI )
     376                 :            :             {
     377 [ #  # ][ #  # ]:          0 :                 rExport.AddAttribute( OUSTRING("xmlns:") + rPrefix, sURI );
     378                 :            :             }
     379         [ #  # ]:          0 :         }
     380                 :            :     }
     381                 :            : 
     382                 :            :     SvXMLElementExport aElement( rExport, XML_NAMESPACE_XFORMS, XML_BIND,
     383 [ #  # ][ #  # ]:          0 :                                  sal_True, sal_True );
     384                 :          0 : }
     385                 :            : 
     386                 :            : 
     387                 :            : //
     388                 :            : // the submission
     389                 :            : //
     390                 :            : 
     391                 :            : static const ExportTable aXFormsSubmissionTable[] =
     392                 :            : {
     393                 :            :     TABLE_ENTRY( "ID",         NONE, ID,        lcl_string ),
     394                 :            :     TABLE_ENTRY( "Bind",       NONE, BIND,      lcl_string ),
     395                 :            :     TABLE_ENTRY( "Ref",        NONE, REF,       lcl_string ),
     396                 :            :     TABLE_ENTRY( "Action",     NONE, ACTION,    lcl_string ),
     397                 :            :     TABLE_ENTRY( "Method",     NONE, METHOD,    lcl_string ),
     398                 :            :     TABLE_ENTRY( "Version",    NONE, VERSION,   lcl_string ),
     399                 :            :     TABLE_ENTRY( "Indent",     NONE, INDENT,    lcl_bool ),
     400                 :            :     TABLE_ENTRY( "MediaType",  NONE, MEDIATYPE, lcl_string ),
     401                 :            :     TABLE_ENTRY( "Encoding",   NONE, ENCODING, lcl_string ),
     402                 :            :     TABLE_ENTRY( "OmitXmlDeclaration",  NONE, OMIT_XML_DECLARATION, lcl_bool ),
     403                 :            :     TABLE_ENTRY( "Standalone", NONE, STANDALONE, lcl_bool ),
     404                 :            :     TABLE_ENTRY( "CDataSectionElement", NONE, CDATA_SECTION_ELEMENTS, lcl_string ),
     405                 :            :     TABLE_ENTRY( "Replace",    NONE, REPLACE, lcl_string ),
     406                 :            :     TABLE_ENTRY( "Separator",  NONE, SEPARATOR, lcl_string ),
     407                 :            :     TABLE_ENTRY( "IncludeNamespacePrefixes", NONE, INCLUDENAMESPACEPREFIXES, lcl_string ),
     408                 :            :     TABLE_END
     409                 :            : };
     410                 :            : 
     411                 :          0 : void exportXFormsSubmission( SvXMLExport& rExport,
     412                 :            :                              const Reference<XPropertySet>& xSubmission )
     413                 :            : {
     414         [ #  # ]:          0 :     lcl_export( xSubmission, rExport, aXFormsSubmissionTable );
     415                 :            :     SvXMLElementExport aElement( rExport, XML_NAMESPACE_XFORMS, XML_SUBMISSION,
     416 [ #  # ][ #  # ]:          0 :                                  sal_True, sal_True );
     417                 :          0 : }
     418                 :            : 
     419                 :            : 
     420                 :            : 
     421                 :            : //
     422                 :            : // export data types as XSD schema
     423                 :            : //
     424                 :            : 
     425                 :            : static const ExportTable aDataTypeFacetTable[] =
     426                 :            : {
     427                 :            :     TABLE_ENTRY( "Length",               XSD, LENGTH,         lcl_int32 ),
     428                 :            :     TABLE_ENTRY( "MinLength",            XSD, MINLENGTH,      lcl_int32 ),
     429                 :            :     TABLE_ENTRY( "MaxLength",            XSD, MAXLENGTH,      lcl_int32 ),
     430                 :            :     TABLE_ENTRY( "MinInclusiveInt",      XSD, MININCLUSIVE,   lcl_int32 ),
     431                 :            :     TABLE_ENTRY( "MinExclusiveInt",      XSD, MINEXCLUSIVE,   lcl_int32 ),
     432                 :            :     TABLE_ENTRY( "MaxInclusiveInt",      XSD, MAXINCLUSIVE,   lcl_int32 ),
     433                 :            :     TABLE_ENTRY( "MaxExclusiveInt",      XSD, MAXEXCLUSIVE,   lcl_int32 ),
     434                 :            :     TABLE_ENTRY( "MinInclusiveDouble",   XSD, MININCLUSIVE,   lcl_double ),
     435                 :            :     TABLE_ENTRY( "MinExclusiveDouble",   XSD, MINEXCLUSIVE,   lcl_double ),
     436                 :            :     TABLE_ENTRY( "MaxInclusiveDouble",   XSD, MAXINCLUSIVE,   lcl_double ),
     437                 :            :     TABLE_ENTRY( "MaxExclusiveDouble",   XSD, MAXEXCLUSIVE,   lcl_double ),
     438                 :            :     TABLE_ENTRY( "MinInclusiveDate",     XSD, MININCLUSIVE,   lcl_date ),
     439                 :            :     TABLE_ENTRY( "MinExclusiveDate",     XSD, MINEXCLUSIVE,   lcl_date ),
     440                 :            :     TABLE_ENTRY( "MaxInclusiveDate",     XSD, MAXINCLUSIVE,   lcl_date ),
     441                 :            :     TABLE_ENTRY( "MaxExclusiveDate",     XSD, MAXEXCLUSIVE,   lcl_date ),
     442                 :            :     TABLE_ENTRY( "MinInclusiveTime",     XSD, MININCLUSIVE,   lcl_time ),
     443                 :            :     TABLE_ENTRY( "MinExclusiveTime",     XSD, MINEXCLUSIVE,   lcl_time ),
     444                 :            :     TABLE_ENTRY( "MaxInclusiveTime",     XSD, MAXINCLUSIVE,   lcl_time ),
     445                 :            :     TABLE_ENTRY( "MaxExclusiveTime",     XSD, MAXEXCLUSIVE,   lcl_time ),
     446                 :            :     TABLE_ENTRY( "MinInclusiveDateTime", XSD, MININCLUSIVE,   lcl_dateTime ),
     447                 :            :     TABLE_ENTRY( "MinExclusiveDateTime", XSD, MINEXCLUSIVE,   lcl_dateTime ),
     448                 :            :     TABLE_ENTRY( "MaxInclusiveDateTime", XSD, MAXINCLUSIVE,   lcl_dateTime ),
     449                 :            :     TABLE_ENTRY( "MaxExclusiveDateTime", XSD, MAXEXCLUSIVE,   lcl_dateTime ),
     450                 :            :     TABLE_ENTRY( "Pattern",              XSD, PATTERN,        lcl_string ),
     451                 :            :     // ??? XML_ENUMERATION,
     452                 :            :     TABLE_ENTRY( "WhiteSpace",           XSD, WHITESPACE,     lcl_whitespace ),
     453                 :            :     TABLE_ENTRY( "TotalDigits",          XSD, TOTALDIGITS,    lcl_int32 ),
     454                 :            :     TABLE_ENTRY( "FractionDigits",       XSD, FRACTIONDIGITS, lcl_int32 ),
     455                 :            :     TABLE_END
     456                 :        163 : };
     457                 :            : 
     458                 :            : // export facets through table; use the same table as lcl_export does
     459                 :          0 : void lcl_exportDataTypeFacets( SvXMLExport& rExport,
     460                 :            :                                const Reference<XPropertySet>& rPropertySet,
     461                 :            :                                const ExportTable* pTable )
     462                 :            : {
     463 [ #  # ][ #  # ]:          0 :     Reference<XPropertySetInfo> xInfo = rPropertySet->getPropertySetInfo();
     464         [ #  # ]:          0 :     for( const ExportTable* pCurrent = pTable;
     465                 :            :          pCurrent->pPropertyName != NULL;
     466                 :            :          pCurrent++ )
     467                 :            :     {
     468                 :          0 :         OUString sName( OUString::createFromAscii( pCurrent->pPropertyName ) );
     469 [ #  # ][ #  # ]:          0 :         if( xInfo->hasPropertyByName( sName ) )
                 [ #  # ]
     470                 :            :         {
     471                 :            :             OUString sValue = (*pCurrent->aConverter)(
     472 [ #  # ][ #  # ]:          0 :                 rPropertySet->getPropertyValue( sName ) );
                 [ #  # ]
     473                 :            : 
     474         [ #  # ]:          0 :             if( !sValue.isEmpty() )
     475                 :            :             {
     476         [ #  # ]:          0 :                 rExport.AddAttribute( XML_NAMESPACE_NONE, XML_VALUE, sValue );
     477                 :            :                 SvXMLElementExport aFacet(
     478                 :            :                     rExport,
     479                 :            :                     pCurrent->nNamespace,
     480                 :            :                     static_cast<XMLTokenEnum>( pCurrent->nToken ),
     481 [ #  # ][ #  # ]:          0 :                     sal_True, sal_True );
     482                 :          0 :             }
     483                 :            :         }
     484                 :          0 :     }
     485                 :          0 : }
     486                 :            : 
     487                 :          0 : OUString lcl_getXSDType( SvXMLExport& rExport,
     488                 :            :                          const Reference<XPropertySet>& xType )
     489                 :            : {
     490                 :            :     // we use string as default...
     491                 :          0 :     XMLTokenEnum eToken = XML_STRING;
     492                 :            : 
     493                 :          0 :     sal_uInt16 nDataTypeClass = 0;
     494 [ #  # ][ #  # ]:          0 :     xType->getPropertyValue( OUSTRING("TypeClass") ) >>= nDataTypeClass;
                 [ #  # ]
     495   [ #  #  #  #  :          0 :     switch( nDataTypeClass )
          #  #  #  #  #  
             #  #  #  # ]
     496                 :            :     {
     497                 :            :     case com::sun::star::xsd::DataTypeClass::STRING:
     498                 :          0 :         eToken = XML_STRING;
     499                 :          0 :         break;
     500                 :            :     case com::sun::star::xsd::DataTypeClass::anyURI:
     501                 :          0 :         eToken = XML_ANYURI;
     502                 :          0 :         break;
     503                 :            :     case com::sun::star::xsd::DataTypeClass::DECIMAL:
     504                 :          0 :         eToken = XML_DECIMAL;
     505                 :          0 :         break;
     506                 :            :     case com::sun::star::xsd::DataTypeClass::DOUBLE:
     507                 :          0 :         eToken = XML_DOUBLE;
     508                 :          0 :         break;
     509                 :            :     case com::sun::star::xsd::DataTypeClass::FLOAT:
     510                 :          0 :         eToken = XML_FLOAT;
     511                 :          0 :         break;
     512                 :            :     case com::sun::star::xsd::DataTypeClass::BOOLEAN:
     513                 :          0 :         eToken = XML_BOOLEAN;
     514                 :          0 :         break;
     515                 :            :     case com::sun::star::xsd::DataTypeClass::DATETIME:
     516                 :          0 :         eToken = XML_DATETIME_XSD;
     517                 :          0 :         break;
     518                 :            :     case com::sun::star::xsd::DataTypeClass::TIME:
     519                 :          0 :         eToken = XML_TIME;
     520                 :          0 :         break;
     521                 :            :     case com::sun::star::xsd::DataTypeClass::DATE:
     522                 :          0 :         eToken = XML_DATE;
     523                 :          0 :         break;
     524                 :            :     case com::sun::star::xsd::DataTypeClass::gYear:
     525                 :          0 :         eToken = XML_YEAR;
     526                 :          0 :         break;
     527                 :            :     case com::sun::star::xsd::DataTypeClass::gDay:
     528                 :          0 :         eToken = XML_DAY;
     529                 :          0 :         break;
     530                 :            :     case com::sun::star::xsd::DataTypeClass::gMonth:
     531                 :          0 :         eToken = XML_MONTH;
     532                 :          0 :         break;
     533                 :            :     case com::sun::star::xsd::DataTypeClass::DURATION:
     534                 :            :     case com::sun::star::xsd::DataTypeClass::gYearMonth:
     535                 :            :     case com::sun::star::xsd::DataTypeClass::gMonthDay:
     536                 :            :     case com::sun::star::xsd::DataTypeClass::hexBinary:
     537                 :            :     case com::sun::star::xsd::DataTypeClass::base64Binary:
     538                 :            :     case com::sun::star::xsd::DataTypeClass::QName:
     539                 :            :     case com::sun::star::xsd::DataTypeClass::NOTATION:
     540                 :            :     default:
     541                 :            :         OSL_FAIL( "unknown data type" );
     542                 :            :     }
     543                 :            : 
     544                 :          0 :     return rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_XSD,
     545   [ #  #  #  # ]:          0 :                                                     GetXMLToken( eToken ) );
     546                 :            : }
     547                 :            : 
     548                 :          0 : void lcl_exportDataType( SvXMLExport& rExport,
     549                 :            :                          const Reference<XPropertySet>& xType )
     550                 :            : {
     551                 :            :     // we do not need to export basic types; exit if we have one
     552                 :          0 :     bool bIsBasic = false;
     553 [ #  # ][ #  # ]:          0 :     xType->getPropertyValue( OUSTRING("IsBasic") ) >>= bIsBasic;
                 [ #  # ]
     554         [ #  # ]:          0 :     if( bIsBasic )
     555                 :          0 :         return;
     556                 :            : 
     557                 :            :     // no basic type -> export
     558                 :            : 
     559                 :            :     // <xsd:simpleType name="...">
     560                 :          0 :     OUString sName;
     561 [ #  # ][ #  # ]:          0 :     xType->getPropertyValue( OUSTRING("Name") ) >>= sName;
                 [ #  # ]
     562         [ #  # ]:          0 :     rExport.AddAttribute( XML_NAMESPACE_NONE, XML_NAME, sName );
     563                 :            :     SvXMLElementExport aSimpleType( rExport,
     564                 :            :                                     XML_NAMESPACE_XSD, XML_SIMPLETYPE,
     565         [ #  # ]:          0 :                                     sal_True, sal_True );
     566                 :            : 
     567                 :            :     // <xsd:restriction base="xsd:...">
     568                 :            :     rExport.AddAttribute( XML_NAMESPACE_NONE, XML_BASE,
     569 [ #  # ][ #  # ]:          0 :                           lcl_getXSDType( rExport, xType ) );
     570                 :            :     SvXMLElementExport aRestriction( rExport,
     571                 :            :                                      XML_NAMESPACE_XSD,
     572                 :            :                                      XML_RESTRICTION,
     573         [ #  # ]:          0 :                                      sal_True, sal_True );
     574                 :            : 
     575                 :            :     // export facets
     576                 :            :     lcl_exportDataTypeFacets( rExport,
     577                 :            :                               Reference<XPropertySet>( xType, UNO_QUERY ),
     578 [ #  # ][ #  # ]:          0 :                               aDataTypeFacetTable );
         [ #  # ][ #  # ]
     579                 :            : }
     580                 :            : 
     581                 :          0 : void exportXFormsSchemas( SvXMLExport& rExport,
     582                 :            :                           const Reference<com::sun::star::xforms::XModel>& xModel )
     583                 :            : {
     584                 :            :     // TODO: for now, we'll fake this...
     585                 :            :     {
     586                 :            :         SvXMLElementExport aSchemaElem( rExport, XML_NAMESPACE_XSD, XML_SCHEMA,
     587         [ #  # ]:          0 :                                         sal_True, sal_True );
     588                 :            : 
     589                 :            :         // now get data type repositry, and export
     590         [ #  # ]:          0 :         Reference<XEnumerationAccess> xTypes( xModel->getDataTypeRepository(),
     591 [ #  # ][ #  # ]:          0 :                                               UNO_QUERY );
     592         [ #  # ]:          0 :         if( xTypes.is() )
     593                 :            :         {
     594 [ #  # ][ #  # ]:          0 :             Reference<XEnumeration> xEnum = xTypes->createEnumeration();
     595                 :            :             DBG_ASSERT( xEnum.is(), "no enum?" );
     596 [ #  # ][ #  # ]:          0 :             while( xEnum->hasMoreElements() )
                 [ #  # ]
     597                 :            :             {
     598 [ #  # ][ #  # ]:          0 :                 Reference<XPropertySet> xType( xEnum->nextElement(), UNO_QUERY );
                 [ #  # ]
     599         [ #  # ]:          0 :                 lcl_exportDataType( rExport, xType );
     600                 :          0 :             }
     601         [ #  # ]:          0 :         }
     602                 :            :     }
     603                 :            : 
     604                 :            :     // export other, 'foreign' schemas
     605         [ #  # ]:          0 :     Reference<XPropertySet> xPropSet( xModel, UNO_QUERY );
     606         [ #  # ]:          0 :     if( xPropSet.is() )
     607                 :            :     {
     608                 :            :         Reference<XDocument> xDocument(
     609         [ #  # ]:          0 :             xPropSet->getPropertyValue( OUSTRING("ForeignSchema") ),
     610 [ #  # ][ #  # ]:          0 :             UNO_QUERY );
                 [ #  # ]
     611                 :            : 
     612         [ #  # ]:          0 :         if( xDocument.is() )
     613         [ #  # ]:          0 :             exportDom( rExport, xDocument );
     614                 :          0 :     }
     615                 :          0 : }
     616                 :            : 
     617                 :            : 
     618                 :            : 
     619                 :            : //
     620                 :            : // helper functions
     621                 :            : //
     622                 :            : 
     623                 :          0 : void lcl_export( const Reference<XPropertySet>& rPropertySet,
     624                 :            :                  SvXMLExport& rExport,
     625                 :            :                  const ExportTable* pTable )
     626                 :            : {
     627         [ #  # ]:          0 :     for( const ExportTable* pCurrent = pTable;
     628                 :            :          pCurrent->pPropertyName != NULL;
     629                 :            :          pCurrent++ )
     630                 :            :     {
     631         [ #  # ]:          0 :         Any aAny = rPropertySet->getPropertyValue(
     632         [ #  # ]:          0 :                        OUString::createFromAscii( pCurrent->pPropertyName ) );
     633         [ #  # ]:          0 :         OUString sValue = (*pCurrent->aConverter)( aAny );
     634                 :            : 
     635         [ #  # ]:          0 :         if( !sValue.isEmpty() )
     636                 :            :             rExport.AddAttribute(
     637                 :            :                 pCurrent->nNamespace,
     638                 :            :                 static_cast<XMLTokenEnum>( pCurrent->nToken ),
     639         [ #  # ]:          0 :                 sValue );
     640                 :          0 :     }
     641                 :          0 : }
     642                 :            : 
     643                 :            : 
     644                 :            : 
     645                 :            : //
     646                 :            : // any conversion functions
     647                 :            : //
     648                 :            : 
     649                 :            : template<typename T, void (*FUNC)( OUStringBuffer&, T )>
     650                 :          0 : OUString lcl_convert( const Any& rAny )
     651                 :            : {
     652                 :          0 :     OUStringBuffer aBuffer;
     653                 :          0 :     T aData = T();
     654   [ #  #  #  # ]:          0 :     if( rAny >>= aData )
     655                 :            :     {
     656 [ #  # ][ #  # ]:          0 :         FUNC( aBuffer, aData );
     657                 :            :     }
     658 [ #  # ][ #  # ]:          0 :     return aBuffer.makeStringAndClear();
     659                 :            : }
     660                 :            : 
     661                 :            : template<typename T, void (*FUNC)( OUStringBuffer&, const T& )>
     662                 :          0 : OUString lcl_convertRef( const Any& rAny )
     663                 :            : {
     664                 :          0 :     OUStringBuffer aBuffer;
     665                 :          0 :     T aData;
     666   [ #  #  #  # ]:          0 :     if( rAny >>= aData )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     667                 :            :     {
     668 [ #  # ][ #  # ]:          0 :         FUNC( aBuffer, aData );
                 [ #  # ]
     669                 :            :     }
     670 [ #  # ][ #  # ]:          0 :     return aBuffer.makeStringAndClear();
                 [ #  # ]
     671                 :            : }
     672                 :            : 
     673                 :          0 : OUString lcl_string( const Any& rAny )
     674                 :            : {
     675                 :          0 :     OUString aResult;
     676                 :          0 :     rAny >>= aResult;
     677                 :          0 :     return aResult;
     678                 :            : }
     679                 :            : 
     680                 :          0 : OUString lcl_bool( const Any& rAny )
     681                 :            : {
     682                 :          0 :     bool bResult = bool();
     683         [ #  # ]:          0 :     if( rAny >>= bResult )
     684 [ #  # ][ #  # ]:          0 :         return GetXMLToken( bResult ? XML_TRUE : XML_FALSE );
     685                 :            :     OSL_FAIL( "expected boolean value" );
     686                 :          0 :     return OUString();
     687                 :            : }
     688                 :            : 
     689                 :          0 : void lcl_formatDate( OUStringBuffer& aBuffer, const Date& rDate )
     690                 :            : {
     691                 :          0 :     aBuffer.append( static_cast<sal_Int32>( rDate.Year ) );
     692                 :          0 :     aBuffer.append( sal_Unicode('-') );
     693                 :          0 :     aBuffer.append( static_cast<sal_Int32>( rDate.Month ) );
     694                 :          0 :     aBuffer.append( sal_Unicode('-') );
     695                 :          0 :     aBuffer.append( static_cast<sal_Int32>( rDate.Day ) );
     696                 :          0 : }
     697                 :            : 
     698                 :          0 : void lcl_formatTime( OUStringBuffer& aBuffer, const com::sun::star::util::Time& rTime )
     699                 :            : {
     700                 :          0 :     Duration aDuration;
     701                 :          0 :     aDuration.Hours = rTime.Hours;
     702                 :          0 :     aDuration.Minutes = rTime.Minutes;
     703                 :          0 :     aDuration.Seconds = rTime.Seconds;
     704                 :          0 :     aDuration.MilliSeconds = rTime.HundredthSeconds * 10;
     705         [ #  # ]:          0 :     ::sax::Converter::convertDuration( aBuffer, aDuration );
     706                 :          0 : }
     707                 :            : 
     708                 :          0 : void lcl_formatDateTime( OUStringBuffer& aBuffer, const DateTime& aDateTime )
     709                 :            : {
     710                 :          0 :     ::sax::Converter::convertDateTime( aBuffer, aDateTime );
     711                 :          0 : }
     712                 :            : 
     713                 :          0 : OUString lcl_whitespace( const Any& rAny )
     714                 :            : {
     715                 :          0 :     OUString sResult;
     716                 :          0 :     sal_uInt16 n = sal_uInt16();
     717         [ #  # ]:          0 :     if( rAny >>= n )
     718                 :            :     {
     719   [ #  #  #  # ]:          0 :         switch( n )
     720                 :            :         {
     721                 :            :         case com::sun::star::xsd::WhiteSpaceTreatment::Preserve:
     722         [ #  # ]:          0 :             sResult = GetXMLToken( XML_PRESERVE );
     723                 :          0 :             break;
     724                 :            :         case com::sun::star::xsd::WhiteSpaceTreatment::Replace:
     725         [ #  # ]:          0 :             sResult = GetXMLToken( XML_REPLACE );
     726                 :          0 :             break;
     727                 :            :         case com::sun::star::xsd::WhiteSpaceTreatment::Collapse:
     728         [ #  # ]:          0 :             sResult = GetXMLToken( XML_COLLAPSE );
     729                 :          0 :             break;
     730                 :            :         }
     731                 :            :     }
     732                 :          0 :     return sResult;
     733                 :            : }
     734                 :            : 
     735                 :            : 
     736                 :            : /// return name of Binding
     737                 :          0 : OUString lcl_getXFormsBindName( const Reference<XPropertySet>& xBinding )
     738                 :            : {
     739         [ #  # ]:          0 :     OUString sProp( OUSTRING( "BindingID" ) );
     740                 :            : 
     741                 :          0 :     OUString sReturn;
     742 [ #  # ][ #  # ]:          0 :     if( xBinding.is() &&
                 [ #  # ]
     743 [ #  # ][ #  # ]:          0 :         xBinding->getPropertySetInfo()->hasPropertyByName( sProp ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     744                 :            :     {
     745 [ #  # ][ #  # ]:          0 :         xBinding->getPropertyValue( sProp ) >>= sReturn;
     746                 :            :     }
     747                 :          0 :     return sReturn;
     748                 :            : }
     749                 :            : 
     750                 :            : // return name of binding
     751                 :          0 : OUString getXFormsBindName( const Reference<XPropertySet>& xControl )
     752                 :            : {
     753         [ #  # ]:          0 :     Reference<XBindableValue> xBindable( xControl, UNO_QUERY );
     754                 :          0 :     return xBindable.is()
     755                 :            :         ? lcl_getXFormsBindName(
     756         [ #  # ]:          0 :             Reference<XPropertySet>( xBindable->getValueBinding(), UNO_QUERY ))
     757 [ #  # ][ #  # ]:          0 :         : OUString();
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     758                 :            : }
     759                 :            : 
     760                 :            : // return name of list binding
     761                 :          0 : OUString getXFormsListBindName( const Reference<XPropertySet>& xControl )
     762                 :            : {
     763         [ #  # ]:          0 :     Reference<XListEntrySink> xListEntrySink( xControl, UNO_QUERY );
     764                 :          0 :     return xListEntrySink.is()
     765                 :            :         ? lcl_getXFormsBindName(
     766         [ #  # ]:          0 :             Reference<XPropertySet>( xListEntrySink->getListEntrySource(),
     767                 :            :                                      UNO_QUERY ) )
     768 [ #  # ][ #  # ]:          0 :         : OUString();
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     769                 :            : }
     770                 :            : 
     771                 :          0 : OUString getXFormsSubmissionName( const Reference<XPropertySet>& xBinding )
     772                 :            : {
     773                 :          0 :     OUString sReturn;
     774                 :            : 
     775         [ #  # ]:          0 :     Reference<XSubmissionSupplier> xSubmissionSupplier( xBinding, UNO_QUERY );
     776         [ #  # ]:          0 :     if( xSubmissionSupplier.is() )
     777                 :            :     {
     778                 :            :         Reference<XPropertySet> xPropertySet(
     779 [ #  # ][ #  # ]:          0 :             xSubmissionSupplier->getSubmission(), UNO_QUERY );
                 [ #  # ]
     780         [ #  # ]:          0 :         OUString sProp( OUSTRING("ID") );
     781 [ #  # ][ #  # ]:          0 :         if( xPropertySet.is() &&
                 [ #  # ]
     782 [ #  # ][ #  # ]:          0 :             xPropertySet->getPropertySetInfo()->hasPropertyByName( sProp ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     783                 :            :         {
     784 [ #  # ][ #  # ]:          0 :             xPropertySet->getPropertyValue( sProp ) >>= sReturn;
     785                 :          0 :         }
     786                 :            :     }
     787                 :            : 
     788                 :          0 :     return sReturn;
     789                 :            : }
     790                 :            : 
     791                 :          0 : void getXFormsSettings( const Reference< XNameAccess >& _rXForms, Sequence< PropertyValue >& _out_rSettings )
     792                 :            : {
     793         [ #  # ]:          0 :     _out_rSettings = Sequence< PropertyValue >();
     794                 :            : 
     795                 :            :     OSL_PRECOND( _rXForms.is(), "getXFormsSettings: invalid XForms container!" );
     796         [ #  # ]:          0 :     if ( !_rXForms.is() )
     797                 :          0 :         return;
     798                 :            : 
     799                 :            :     try
     800                 :            :     {
     801                 :            :         // we want to export some special properties of our XForms models as config-item-map-named,
     802                 :            :         // which implies we need a PropertyValue whose value is an XNameAccess, whose keys
     803                 :            :         // are the names of the XForm models, and which in turn provides named sequences of
     804                 :            :         // PropertyValues - which denote the actual property values of the given named model.
     805                 :            : 
     806 [ #  # ][ #  # ]:          0 :         Sequence< ::rtl::OUString > aModelNames( _rXForms->getElementNames() );
     807                 :            : 
     808 [ #  # ][ #  # ]:          0 :         ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
     809                 :            :         Reference< XNameContainer > xModelSettings(
     810                 :            :             aContext.createComponent( "com.sun.star.document.NamedPropertyValues" ),
     811 [ #  # ][ #  # ]:          0 :             UNO_QUERY_THROW );
     812                 :            : 
     813         [ #  # ]:          0 :         for (   const ::rtl::OUString* pModelName = aModelNames.getConstArray();
     814                 :          0 :                 pModelName != aModelNames.getConstArray() + aModelNames.getLength();
     815                 :            :                 ++pModelName
     816                 :            :             )
     817                 :            :         {
     818 [ #  # ][ #  # ]:          0 :             Reference< XPropertySet > xModelProps( _rXForms->getByName( *pModelName ), UNO_QUERY_THROW );
                 [ #  # ]
     819                 :            : 
     820         [ #  # ]:          0 :             Sequence< PropertyValue > aModelSettings( 1 );
     821 [ #  # ][ #  # ]:          0 :             aModelSettings[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) );
     822 [ #  # ][ #  # ]:          0 :             aModelSettings[0].Value = xModelProps->getPropertyValue( aModelSettings[0].Name );
         [ #  # ][ #  # ]
     823                 :            : 
     824 [ #  # ][ #  # ]:          0 :             xModelSettings->insertByName( *pModelName, makeAny( aModelSettings ) );
                 [ #  # ]
     825         [ #  # ]:          0 :         }
     826                 :            : 
     827 [ #  # ][ #  # ]:          0 :         if ( xModelSettings->hasElements() )
                 [ #  # ]
     828                 :            :         {
     829         [ #  # ]:          0 :             _out_rSettings.realloc( 1 );
     830 [ #  # ][ #  # ]:          0 :             _out_rSettings[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XFormModels" ) );
     831 [ #  # ][ #  # ]:          0 :             _out_rSettings[0].Value <<= xModelSettings;
     832 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     833                 :            :     }
     834                 :          0 :     catch( const Exception& )
     835                 :            :     {
     836                 :            :         DBG_UNHANDLED_EXCEPTION();
     837                 :            :     }
     838 [ +  - ][ +  - ]:        489 : }
     839                 :            : 
     840                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10