LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/xforms - XFormsSubmissionContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-12-27 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "XFormsSubmissionContext.hxx"
      22             : 
      23             : #include "xformsapi.hxx"
      24             : 
      25             : #include <xmloff/xmlimp.hxx>
      26             : #include "xmloff/xmlerror.hxx"
      27             : #include <xmloff/xmltoken.hxx>
      28             : #include <xmloff/xmltkmap.hxx>
      29             : #include "xmloff/xmlnmspe.hxx"
      30             : #include <xmloff/nmspmap.hxx>
      31             : 
      32             : #include <sax/tools/converter.hxx>
      33             : 
      34             : #include <com/sun/star/container/XNameContainer.hpp>
      35             : #include <com/sun/star/xforms/XModel.hpp>
      36             : 
      37             : #include <tools/debug.hxx>
      38             : 
      39             : using rtl::OUString;
      40             : using com::sun::star::beans::XPropertySet;
      41             : using com::sun::star::container::XNameContainer;
      42             : using com::sun::star::xml::sax::XAttributeList;
      43             : using com::sun::star::xforms::XModel;
      44             : 
      45             : using namespace com::sun::star::uno;
      46             : using namespace xmloff::token;
      47             : 
      48             : 
      49             : 
      50             : 
      51             : static struct SvXMLTokenMapEntry aAttributeMap[] =
      52             : {
      53             :     TOKEN_MAP_ENTRY( NONE, ID ),
      54             :     TOKEN_MAP_ENTRY( NONE, BIND ),
      55             :     TOKEN_MAP_ENTRY( NONE, REF ),
      56             :     TOKEN_MAP_ENTRY( NONE, ACTION ),
      57             :     TOKEN_MAP_ENTRY( NONE, METHOD ),
      58             :     TOKEN_MAP_ENTRY( NONE, VERSION ),
      59             :     TOKEN_MAP_ENTRY( NONE, INDENT ),
      60             :     TOKEN_MAP_ENTRY( NONE, MEDIATYPE ),
      61             :     TOKEN_MAP_ENTRY( NONE, ENCODING ),
      62             :     TOKEN_MAP_ENTRY( NONE, OMIT_XML_DECLARATION ),
      63             :     TOKEN_MAP_ENTRY( NONE, STANDALONE ),
      64             :     TOKEN_MAP_ENTRY( NONE, CDATA_SECTION_ELEMENTS ),
      65             :     TOKEN_MAP_ENTRY( NONE, REPLACE ),
      66             :     TOKEN_MAP_ENTRY( NONE, SEPARATOR ),
      67             :     TOKEN_MAP_ENTRY( NONE, INCLUDENAMESPACEPREFIXES ),
      68             :     XML_TOKEN_MAP_END
      69             : };
      70             : 
      71           0 : XFormsSubmissionContext::XFormsSubmissionContext(
      72             :     SvXMLImport& rImport,
      73             :     sal_uInt16 nPrefix,
      74             :     const OUString& rLocalName,
      75             :     const Reference<XPropertySet>& xModel ) :
      76             :         TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
      77           0 :         mxSubmission()
      78             : {
      79             :     // register submission with model
      80             :     DBG_ASSERT( xModel.is(), "need model" );
      81           0 :     Reference<XModel> xXModel( xModel, UNO_QUERY );
      82             :     DBG_ASSERT( xXModel.is(), "need XModel" );
      83           0 :     mxSubmission = xXModel->createSubmission().get();
      84             :     DBG_ASSERT( mxSubmission.is(), "can't create submission" );
      85           0 :     xXModel->getSubmissions()->insert( makeAny( mxSubmission ) );
      86           0 : }
      87             : 
      88           0 : XFormsSubmissionContext::~XFormsSubmissionContext()
      89             : {
      90           0 : }
      91             : 
      92           0 : Any toBool( const OUString& rValue )
      93             : {
      94           0 :     Any aValue;
      95           0 :     bool bValue(false);
      96           0 :     if (::sax::Converter::convertBool( bValue, rValue ))
      97             :     {
      98           0 :         aValue <<= ( bValue ? true : false );
      99             :     }
     100           0 :     return aValue;
     101             : }
     102             : 
     103           0 : void XFormsSubmissionContext::HandleAttribute( sal_uInt16 nToken,
     104             :                                                const OUString& rValue )
     105             : {
     106           0 :     switch( nToken )
     107             :     {
     108             :     case XML_ID:
     109           0 :         xforms_setValue( mxSubmission, OUSTRING("ID"), rValue );
     110           0 :         break;
     111             :     case XML_BIND:
     112           0 :         xforms_setValue( mxSubmission, OUSTRING("Bind"), rValue );
     113           0 :         break;
     114             :     case XML_REF:
     115           0 :         xforms_setValue( mxSubmission, OUSTRING("Ref"), rValue );
     116           0 :         break;
     117             :     case XML_ACTION:
     118           0 :         xforms_setValue( mxSubmission, OUSTRING("Action"), rValue );
     119           0 :         break;
     120             :     case XML_METHOD:
     121           0 :         xforms_setValue( mxSubmission, OUSTRING("Method"), rValue );
     122           0 :         break;
     123             :     case XML_VERSION:
     124           0 :         xforms_setValue( mxSubmission, OUSTRING("Version"), rValue );
     125           0 :         break;
     126             :     case XML_INDENT:
     127           0 :         xforms_setValue( mxSubmission, OUSTRING("Indent"), toBool( rValue ) );
     128           0 :         break;
     129             :     case XML_MEDIATYPE:
     130           0 :         xforms_setValue( mxSubmission, OUSTRING("MediaType"), rValue );
     131           0 :         break;
     132             :     case XML_ENCODING:
     133           0 :         xforms_setValue( mxSubmission, OUSTRING("Encoding"), rValue );
     134           0 :         break;
     135             :     case XML_OMIT_XML_DECLARATION:
     136             :         xforms_setValue( mxSubmission, OUSTRING("OmitXmlDeclaration"),
     137           0 :                       toBool( rValue ) );
     138           0 :         break;
     139             :     case XML_STANDALONE:
     140           0 :         xforms_setValue( mxSubmission, OUSTRING("Standalone"), toBool( rValue ) );
     141           0 :         break;
     142             :     case XML_CDATA_SECTION_ELEMENTS:
     143           0 :         xforms_setValue( mxSubmission, OUSTRING("CDataSectionElement"), rValue );
     144           0 :         break;
     145             :     case XML_REPLACE:
     146           0 :         xforms_setValue( mxSubmission, OUSTRING("Replace"), rValue );
     147           0 :         break;
     148             :     case XML_SEPARATOR:
     149           0 :         xforms_setValue( mxSubmission, OUSTRING("Separator"), rValue );
     150           0 :         break;
     151             :     case XML_INCLUDENAMESPACEPREFIXES:
     152           0 :         xforms_setValue( mxSubmission, OUSTRING("IncludeNamespacePrefixes"), rValue );
     153           0 :         break;
     154             :     default:
     155             :         OSL_FAIL( "unknown attribute" );
     156           0 :         break;
     157             :     }
     158           0 : }
     159             : 
     160             : /** will be called for each child element */
     161           0 : SvXMLImportContext* XFormsSubmissionContext::HandleChild(
     162             :     sal_uInt16,
     163             :     sal_uInt16,
     164             :     const OUString&,
     165             :     const Reference<XAttributeList>& )
     166             : {
     167             :     OSL_FAIL( "no children supported" );
     168           0 :     return NULL;
     169             : }
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10