LCOV - code coverage report
Current view: top level - xmloff/source/xforms - XFormsSubmissionContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 49 0.0 %
Date: 2015-06-13 12:38:46 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/XModel2.hpp>
      36             : 
      37             : #include <tools/debug.hxx>
      38             : #include <osl/diagnose.h>
      39             : 
      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::XModel2;
      44             : 
      45             : using namespace com::sun::star::uno;
      46             : using namespace xmloff::token;
      47             : 
      48             : 
      49             : 
      50             : 
      51             : static const 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<XModel2>& 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 :     mxSubmission = xModel->createSubmission().get();
      82             :     DBG_ASSERT( mxSubmission.is(), "can't create submission" );
      83           0 :     xModel->getSubmissions()->insert( makeAny( mxSubmission ) );
      84           0 : }
      85             : 
      86           0 : XFormsSubmissionContext::~XFormsSubmissionContext()
      87             : {
      88           0 : }
      89             : 
      90           0 : Any toBool( const OUString& rValue )
      91             : {
      92           0 :     Any aValue;
      93           0 :     bool bValue(false);
      94           0 :     if (::sax::Converter::convertBool( bValue, rValue ))
      95             :     {
      96           0 :         aValue <<= bValue;
      97             :     }
      98           0 :     return aValue;
      99             : }
     100             : 
     101           0 : void XFormsSubmissionContext::HandleAttribute( sal_uInt16 nToken,
     102             :                                                const OUString& rValue )
     103             : {
     104           0 :     switch( nToken )
     105             :     {
     106             :     case XML_ID:
     107           0 :         xforms_setValue( mxSubmission, "ID", rValue );
     108           0 :         break;
     109             :     case XML_BIND:
     110           0 :         xforms_setValue( mxSubmission, "Bind", rValue );
     111           0 :         break;
     112             :     case XML_REF:
     113           0 :         xforms_setValue( mxSubmission, "Ref", rValue );
     114           0 :         break;
     115             :     case XML_ACTION:
     116           0 :         xforms_setValue( mxSubmission, "Action", rValue );
     117           0 :         break;
     118             :     case XML_METHOD:
     119           0 :         xforms_setValue( mxSubmission, "Method", rValue );
     120           0 :         break;
     121             :     case XML_VERSION:
     122           0 :         xforms_setValue( mxSubmission, "Version", rValue );
     123           0 :         break;
     124             :     case XML_INDENT:
     125           0 :         xforms_setValue( mxSubmission, "Indent", toBool( rValue ) );
     126           0 :         break;
     127             :     case XML_MEDIATYPE:
     128           0 :         xforms_setValue( mxSubmission, "MediaType", rValue );
     129           0 :         break;
     130             :     case XML_ENCODING:
     131           0 :         xforms_setValue( mxSubmission, "Encoding", rValue );
     132           0 :         break;
     133             :     case XML_OMIT_XML_DECLARATION:
     134             :         xforms_setValue( mxSubmission, "OmitXmlDeclaration",
     135           0 :                       toBool( rValue ) );
     136           0 :         break;
     137             :     case XML_STANDALONE:
     138           0 :         xforms_setValue( mxSubmission, "Standalone", toBool( rValue ) );
     139           0 :         break;
     140             :     case XML_CDATA_SECTION_ELEMENTS:
     141           0 :         xforms_setValue( mxSubmission, "CDataSectionElement", rValue );
     142           0 :         break;
     143             :     case XML_REPLACE:
     144           0 :         xforms_setValue( mxSubmission, "Replace", rValue );
     145           0 :         break;
     146             :     case XML_SEPARATOR:
     147           0 :         xforms_setValue( mxSubmission, "Separator", rValue );
     148           0 :         break;
     149             :     case XML_INCLUDENAMESPACEPREFIXES:
     150           0 :         xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", rValue );
     151           0 :         break;
     152             :     default:
     153             :         OSL_FAIL( "unknown attribute" );
     154           0 :         break;
     155             :     }
     156           0 : }
     157             : 
     158             : /** will be called for each child element */
     159           0 : SvXMLImportContext* XFormsSubmissionContext::HandleChild(
     160             :     sal_uInt16,
     161             :     sal_uInt16,
     162             :     const OUString&,
     163             :     const Reference<XAttributeList>& )
     164             : {
     165             :     OSL_FAIL( "no children supported" );
     166           0 :     return NULL;
     167             : }
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11