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

Generated by: LCOV version 1.10