LCOV - code coverage report
Current view: top level - xmloff/source/xforms - XFormsModelContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 36 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 "XFormsModelContext.hxx"
      22             : 
      23             : #include "XFormsBindContext.hxx"
      24             : #include "XFormsSubmissionContext.hxx"
      25             : #include "XFormsInstanceContext.hxx"
      26             : #include "SchemaContext.hxx"
      27             : #include "xformsapi.hxx"
      28             : 
      29             : #include <xmloff/xmlimp.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/nmspmap.hxx>
      32             : #include <xmloff/xmltoken.hxx>
      33             : #include <xmloff/xmlerror.hxx>
      34             : 
      35             : #include <osl/diagnose.h>
      36             : 
      37             : #include <com/sun/star/beans/XPropertySet.hpp>
      38             : #include <com/sun/star/xml/dom/XDocument.hpp>
      39             : #include <com/sun/star/util/XUpdatable.hpp>
      40             : #include <com/sun/star/xforms/XModel2.hpp>
      41             : 
      42             : 
      43             : using com::sun::star::xml::sax::XAttributeList;
      44             : using com::sun::star::beans::XPropertySet;
      45             : using com::sun::star::util::XUpdatable;
      46             : using namespace com::sun::star::uno;
      47             : using namespace xmloff::token;
      48             : 
      49             : 
      50             : 
      51             : 
      52             : static const SvXMLTokenMapEntry aAttributes[] =
      53             : {
      54             :     TOKEN_MAP_ENTRY( NONE, ID ),
      55             :     TOKEN_MAP_ENTRY( NONE, SCHEMA ),
      56             :     XML_TOKEN_MAP_END
      57             : };
      58             : 
      59             : static const SvXMLTokenMapEntry aChildren[] =
      60             : {
      61             :     TOKEN_MAP_ENTRY( XFORMS, INSTANCE ),
      62             :     TOKEN_MAP_ENTRY( XFORMS, BIND ),
      63             :     TOKEN_MAP_ENTRY( XFORMS, SUBMISSION ),
      64             :     TOKEN_MAP_ENTRY( XSD,    SCHEMA ),
      65             :     XML_TOKEN_MAP_END
      66             : };
      67             : 
      68             : 
      69           0 : XFormsModelContext::XFormsModelContext( SvXMLImport& rImport,
      70             :                                         sal_uInt16 nPrefix,
      71             :                                         const OUString& rLocalName ) :
      72             :     TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
      73           0 :     mxModel( xforms_createXFormsModel() )
      74             : {
      75           0 : }
      76             : 
      77           0 : XFormsModelContext::~XFormsModelContext()
      78             : {
      79           0 : }
      80             : 
      81             : 
      82             : 
      83             : 
      84           0 : void XFormsModelContext::HandleAttribute(
      85             :     sal_uInt16 nToken,
      86             :     const OUString& rValue )
      87             : {
      88           0 :     switch( nToken )
      89             :     {
      90             :     case XML_ID:
      91           0 :         mxModel->setPropertyValue( "ID", makeAny( rValue ) );
      92           0 :         break;
      93             :     case XML_SCHEMA:
      94           0 :         GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
      95           0 :         break;
      96             :     default:
      97             :         OSL_FAIL( "this should not happen" );
      98           0 :         break;
      99             :     }
     100           0 : }
     101             : 
     102           0 : SvXMLImportContext* XFormsModelContext::HandleChild(
     103             :     sal_uInt16 nToken,
     104             :     sal_uInt16 nPrefix,
     105             :     const OUString& rLocalName,
     106             :     const Reference<XAttributeList>& )
     107             : {
     108           0 :     SvXMLImportContext* pContext = NULL;
     109             : 
     110           0 :     switch( nToken )
     111             :     {
     112             :     case XML_INSTANCE:
     113           0 :         pContext = new XFormsInstanceContext( GetImport(), nPrefix, rLocalName,
     114           0 :                                               mxModel );
     115           0 :         break;
     116             :     case XML_BIND:
     117           0 :         pContext = new XFormsBindContext( GetImport(), nPrefix, rLocalName,
     118           0 :                                           mxModel );
     119           0 :         break;
     120             :     case XML_SUBMISSION:
     121           0 :         pContext = new XFormsSubmissionContext( GetImport(), nPrefix,
     122           0 :                                                 rLocalName, mxModel );
     123           0 :         break;
     124             :     case XML_SCHEMA:
     125             :         pContext = new SchemaContext(
     126           0 :             GetImport(), nPrefix, rLocalName, mxModel->getDataTypeRepository() );
     127           0 :         break;
     128             :     default:
     129             :         OSL_FAIL( "Boooo!" );
     130           0 :         break;
     131             :     }
     132             : 
     133           0 :     return pContext;
     134             : }
     135             : 
     136           0 : void XFormsModelContext::EndElement()
     137             : {
     138             :     // update before putting model into document
     139           0 :     Reference<XUpdatable> xUpdate( mxModel, UNO_QUERY );
     140           0 :     if( xUpdate.is() )
     141           0 :         xUpdate->update();
     142             : 
     143           0 :     GetImport().initXForms();
     144           0 :     xforms_addXFormsModel( GetImport().GetModel(), getModel() );
     145           0 : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11