LCOV - code coverage report
Current view: top level - xmloff/source/xforms - XFormsInstanceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 35 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 43 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "XFormsInstanceContext.hxx"
      31                 :            : 
      32                 :            : #include "DomBuilderContext.hxx"
      33                 :            : #include "xformsapi.hxx"
      34                 :            : 
      35                 :            : #include <rtl/ustring.hxx>
      36                 :            : #include <com/sun/star/uno/Reference.hxx>
      37                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      38                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      39                 :            : #include <com/sun/star/xml/dom/XDocument.hpp>
      40                 :            : #include <com/sun/star/xforms/XModel.hpp>
      41                 :            : #include <tools/debug.hxx>
      42                 :            : 
      43                 :            : #include <xmloff/xmlnmspe.hxx>
      44                 :            : #include <xmloff/xmltoken.hxx>
      45                 :            : #include <xmloff/xmlimp.hxx>
      46                 :            : #include <xmloff/xmlerror.hxx>
      47                 :            : #include <xmloff/nmspmap.hxx>
      48                 :            : 
      49                 :            : 
      50                 :            : using rtl::OUString;
      51                 :            : using com::sun::star::uno::Reference;
      52                 :            : using com::sun::star::uno::makeAny;
      53                 :            : using com::sun::star::uno::UNO_QUERY;
      54                 :            : using com::sun::star::uno::Sequence;
      55                 :            : using com::sun::star::xforms::XModel;
      56                 :            : using com::sun::star::beans::XPropertySet;
      57                 :            : using com::sun::star::beans::PropertyValue;
      58                 :            : using com::sun::star::xml::sax::XAttributeList;
      59                 :            : 
      60                 :            : using xmloff::token::IsXMLToken;
      61                 :            : using xmloff::token::XML_INSTANCE;
      62                 :            : using xmloff::token::XML_SRC;
      63                 :            : using xmloff::token::XML_ID;
      64                 :            : 
      65                 :            : static SvXMLTokenMapEntry aAttributes[] =
      66                 :            : {
      67                 :            :     TOKEN_MAP_ENTRY( NONE, SRC ),
      68                 :            :     TOKEN_MAP_ENTRY( NONE, ID ),
      69                 :            :     XML_TOKEN_MAP_END
      70                 :            : };
      71                 :            : 
      72                 :          0 : XFormsInstanceContext::XFormsInstanceContext(
      73                 :            :     SvXMLImport& rImport,
      74                 :            :     sal_uInt16 nPrefix,
      75                 :            :     const OUString& rLocalName,
      76                 :            :     Reference<XPropertySet> xModel ) :
      77                 :            :         TokenContext( rImport, nPrefix, rLocalName, aAttributes, aEmptyMap ),
      78         [ #  # ]:          0 :         mxModel( Reference<XModel>( xModel, UNO_QUERY ) )
      79                 :            : {
      80                 :            :     DBG_ASSERT( mxModel.is(), "need model" );
      81                 :          0 : }
      82                 :            : 
      83                 :          0 : XFormsInstanceContext::~XFormsInstanceContext()
      84                 :            : {
      85         [ #  # ]:          0 : }
      86                 :            : 
      87                 :          0 : SvXMLImportContext* XFormsInstanceContext::CreateChildContext(
      88                 :            :     sal_uInt16 nPrefix,
      89                 :            :     const OUString& rLocalName,
      90                 :            :     const Reference<XAttributeList>& )
      91                 :            : {
      92                 :          0 :     SvXMLImportContext* pContext = NULL;
      93                 :            : 
      94                 :            :     // only the first element child of an xforms:instance element
      95                 :            :     // is used as an instance. The other children remainder must be
      96                 :            :     // ignored.
      97         [ #  # ]:          0 :     if( mxInstance.is() )
      98                 :            :     {
      99                 :          0 :         GetImport().SetError( XMLERROR_XFORMS_ONLY_ONE_INSTANCE_ELEMENT, rLocalName );
     100         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     101                 :            :     }
     102                 :            :     else
     103                 :            :     {
     104                 :            :         // create new DomBuilderContext. Save reference to tree in Model.
     105                 :            :         DomBuilderContext* pInstance =
     106         [ #  # ]:          0 :             new DomBuilderContext( GetImport(), nPrefix, rLocalName );
     107         [ #  # ]:          0 :         mxInstance = pInstance->getTree();
     108                 :          0 :         pContext = pInstance;
     109                 :            :     }
     110                 :            : 
     111                 :            :     DBG_ASSERT( pContext != NULL, "no context!" );
     112                 :          0 :     return pContext;
     113                 :            : 
     114                 :            : }
     115                 :            : 
     116                 :          0 : void XFormsInstanceContext::EndElement()
     117                 :            : {
     118         [ #  # ]:          0 :     Sequence<PropertyValue> aSequence( 3 );
     119         [ #  # ]:          0 :     PropertyValue* pSequence = aSequence.getArray();
     120         [ #  # ]:          0 :     pSequence[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Instance") );
     121         [ #  # ]:          0 :     pSequence[0].Value <<= mxInstance;
     122         [ #  # ]:          0 :     pSequence[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ID") );
     123         [ #  # ]:          0 :     pSequence[1].Value <<= msId;
     124         [ #  # ]:          0 :     pSequence[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("URL") );
     125         [ #  # ]:          0 :     pSequence[2].Value <<= msURL;
     126                 :            : 
     127 [ #  # ][ #  # ]:          0 :     mxModel->getInstances()->insert( makeAny( aSequence ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     128                 :          0 : }
     129                 :            : 
     130                 :            : 
     131                 :          0 : void XFormsInstanceContext::HandleAttribute(
     132                 :            :     sal_uInt16 nToken,
     133                 :            :     const rtl::OUString& rValue )
     134                 :            : {
     135      [ #  #  # ]:          0 :     switch( nToken )
     136                 :            :     {
     137                 :            :     case XML_SRC:
     138                 :          0 :         msURL = rValue;
     139                 :          0 :         break;
     140                 :            :     case XML_ID:
     141                 :          0 :         msId = rValue;
     142                 :          0 :         break;
     143                 :            :     default:
     144                 :            :         OSL_FAIL( "should not happen" );
     145                 :          0 :         break;
     146                 :            :     }
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : SvXMLImportContext* XFormsInstanceContext::HandleChild(
     150                 :            :     sal_uInt16,
     151                 :            :     sal_uInt16,
     152                 :            :     const OUString&,
     153                 :            :     const Reference<XAttributeList>& )
     154                 :            : {
     155                 :            :     OSL_FAIL( "to be handled by CreateChildContext" );
     156                 :          0 :     return NULL;
     157                 :            : }
     158                 :            : 
     159                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10