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

Generated by: LCOV version 1.10