LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLChangeElementImportContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 25 92.0 %
Date: 2014-11-03 Functions: 4 9 44.4 %
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             : #include "XMLChangeElementImportContext.hxx"
      21             : #include "XMLChangedRegionImportContext.hxx"
      22             : #include "XMLChangeInfoContext.hxx"
      23             : #include <com/sun/star/uno/Reference.h>
      24             : #include <xmloff/xmlimp.hxx>
      25             : #include <xmloff/xmlnmspe.hxx>
      26             : #include <xmloff/xmltoken.hxx>
      27             : 
      28             : 
      29             : 
      30             : using ::com::sun::star::uno::Reference;
      31             : using ::com::sun::star::xml::sax::XAttributeList;
      32             : using ::xmloff::token::IsXMLToken;
      33             : using ::xmloff::token::XML_P;
      34             : using ::xmloff::token::XML_CHANGE_INFO;
      35             : 
      36           0 : TYPEINIT1( XMLChangeElementImportContext, SvXMLImportContext );
      37             : 
      38          20 : XMLChangeElementImportContext::XMLChangeElementImportContext(
      39             :     SvXMLImport& rImport,
      40             :     sal_uInt16 nPrefix,
      41             :     const OUString& rLocalName,
      42             :     bool bAccContent,
      43             :     XMLChangedRegionImportContext& rParent) :
      44             :         SvXMLImportContext(rImport, nPrefix, rLocalName),
      45             :         bAcceptContent(bAccContent),
      46          20 :         rChangedRegion(rParent)
      47             : {
      48          20 : }
      49             : 
      50          38 : SvXMLImportContext* XMLChangeElementImportContext::CreateChildContext(
      51             :     sal_uInt16 nPrefix,
      52             :     const OUString& rLocalName,
      53             :     const Reference<XAttributeList> & xAttrList)
      54             : {
      55          38 :     SvXMLImportContext* pContext = NULL;
      56             : 
      57          58 :     if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
      58          20 :          IsXMLToken( rLocalName, XML_CHANGE_INFO) )
      59             :     {
      60          20 :         pContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
      61          20 :                                             rChangedRegion, GetLocalName());
      62             :     }
      63             :     else
      64             :     {
      65             :         // import into redline -> create XText
      66          18 :         rChangedRegion.UseRedlineText();
      67             : 
      68          18 :         pContext = GetImport().GetTextImport()->CreateTextChildContext(
      69          18 :             GetImport(), nPrefix, rLocalName, xAttrList,
      70          36 :             XML_TEXT_TYPE_CHANGED_REGION);
      71             : 
      72          18 :         if (NULL == pContext)
      73             :         {
      74             :             // no text element
      75             :             // illegal element content! TODO: discard this redline!
      76             :             // for the moment -> use default
      77             :             pContext = SvXMLImportContext::CreateChildContext(
      78           0 :                 nPrefix, rLocalName, xAttrList);
      79             :         }
      80             :     }
      81             : 
      82          38 :     return pContext;
      83             : }
      84             : 
      85             : // #107848#
      86          20 : void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& )
      87             : {
      88          20 :     if(bAcceptContent)
      89             :     {
      90          12 :         GetImport().GetTextImport()->SetInsideDeleteContext(true);
      91             :     }
      92          20 : }
      93             : 
      94             : // #107848#
      95          20 : void XMLChangeElementImportContext::EndElement()
      96             : {
      97          20 :     if(bAcceptContent)
      98             :     {
      99          12 :         GetImport().GetTextImport()->SetInsideDeleteContext(false);
     100             :     }
     101          20 : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10