LCOV - code coverage report
Current view: top level - editeng/source/misc - SvXMLAutoCorrectImport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 67 50.7 %
Date: 2015-06-13 12:38:46 Functions: 11 22 50.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             : #include <SvXMLAutoCorrectImport.hxx>
      21             : #include <SvXMLAutoCorrectTokenHandler.hxx>
      22             : 
      23             : using namespace ::css;
      24             : using namespace ::css::xml::sax;
      25             : 
      26           2 : SvXMLAutoCorrectImport::SvXMLAutoCorrectImport(
      27             :     const uno::Reference< uno::XComponentContext > xContext,
      28             :     SvxAutocorrWordList *pNewAutocorr_List,
      29             :     SvxAutoCorrect &rNewAutoCorrect,
      30             :     const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rNewStorage)
      31             : :   SvXMLImport( xContext, "" ),
      32             :     pAutocorr_List (pNewAutocorr_List),
      33             :     rAutoCorrect ( rNewAutoCorrect ),
      34           2 :     xStorage ( rNewStorage )
      35             : {
      36           2 : }
      37             : 
      38           4 : SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport() throw ()
      39             : {
      40           4 : }
      41             : 
      42           2 : SvXMLImportContext *SvXMLAutoCorrectImport::CreateFastContext( sal_Int32 Element,
      43             :         const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
      44             : {
      45           2 :     if( Element == SvXMLAutoCorrectToken::BLOCKLIST )
      46           2 :         return new SvXMLWordListContext( *this, Element, xAttrList );
      47             :     else
      48           0 :         return SvXMLImport::CreateFastContext( Element, xAttrList );
      49             : }
      50             : 
      51           2 : SvXMLWordListContext::SvXMLWordListContext(
      52             :    SvXMLAutoCorrectImport& rImport,
      53             :    sal_Int32 /*Element*/,
      54             :    const com::sun::star::uno::Reference<
      55             :    com::sun::star::xml::sax::XFastAttributeList > & /*xAttrList*/ ) :
      56             :    SvXMLImportContext ( rImport ),
      57           2 :    rLocalRef(rImport)
      58             : {
      59           2 :     rLocalRef.rAutoCorrect.refreshBlockList( rLocalRef.xStorage );
      60           2 : }
      61             : 
      62         457 : com::sun::star::uno::Reference<XFastContextHandler> SAL_CALL SvXMLWordListContext::createFastChildContext(
      63             :     sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
      64             : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception)
      65             : {
      66         457 :     if ( Element == SvXMLAutoCorrectToken::BLOCK )
      67         457 :         return new SvXMLWordContext (rLocalRef, Element, xAttrList);
      68             :     else
      69           0 :         return new SvXMLImportContext( rLocalRef );
      70             : }
      71             : 
      72           4 : SvXMLWordListContext::~SvXMLWordListContext()
      73             : {
      74           4 : }
      75             : 
      76         457 : SvXMLWordContext::SvXMLWordContext(
      77             :    SvXMLAutoCorrectImport& rImport,
      78             :    sal_Int32 /*Element*/,
      79             :    const com::sun::star::uno::Reference<
      80             :    com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) :
      81             :    SvXMLImportContext ( rImport ),
      82         457 :    rLocalRef(rImport)
      83             : {
      84         914 :     OUString sWrong, sRight;
      85         457 :     if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
      86         457 :         sWrong = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
      87             : 
      88         457 :     if ( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::NAME ) )
      89         457 :         sRight = xAttrList->getValue( SvXMLAutoCorrectToken::NAME );
      90             : 
      91         457 :    if ( sWrong.isEmpty() || sRight.isEmpty())
      92         457 :         return;
      93             : 
      94         457 :     bool bOnlyTxt = sRight != sWrong;
      95         457 :     if( !bOnlyTxt )
      96             :     {
      97           2 :         const OUString sLongSave( sRight );
      98           2 :         if( !rLocalRef.rAutoCorrect.GetLongText( sWrong, sRight ) &&
      99           0 :             !sLongSave.isEmpty() )
     100             :         {
     101           0 :             sRight = sLongSave;
     102           0 :             bOnlyTxt = true;
     103           2 :         }
     104             :     }
     105         914 :     rLocalRef.pAutocorr_List->LoadEntry( sWrong, sRight, bOnlyTxt );
     106             : }
     107             : 
     108         914 : SvXMLWordContext::~SvXMLWordContext()
     109             : {
     110         914 : }
     111             : 
     112           0 : SvXMLExceptionListImport::SvXMLExceptionListImport(
     113             :     const uno::Reference< uno::XComponentContext > xContext,
     114             :     SvStringsISortDtor & rNewList )
     115             : :   SvXMLImport( xContext, "" ),
     116           0 :     rList (rNewList)
     117             : {
     118           0 : }
     119             : 
     120           0 : SvXMLExceptionListImport::~SvXMLExceptionListImport() throw ()
     121             : {
     122           0 : }
     123             : 
     124           0 : SvXMLImportContext *SvXMLExceptionListImport::CreateFastContext(sal_Int32 Element,
     125             :     const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
     126             : {
     127           0 :     if( Element == SvXMLAutoCorrectToken::BLOCKLIST )
     128           0 :         return new SvXMLExceptionListContext( *this, Element, xAttrList );
     129             :     else
     130           0 :         return SvXMLImport::CreateFastContext( Element, xAttrList );
     131             : }
     132             : 
     133           0 : SvXMLExceptionListContext::SvXMLExceptionListContext(
     134             :    SvXMLExceptionListImport& rImport,
     135             :    sal_Int32 /*Element*/,
     136             :    const com::sun::star::uno::Reference<
     137             :    com::sun::star::xml::sax::XFastAttributeList > & /* xAttrList */ ) :
     138             :    SvXMLImportContext ( rImport ),
     139           0 :    rLocalRef(rImport)
     140             : {
     141           0 : }
     142             : 
     143           0 : com::sun::star::uno::Reference<xml::sax::XFastContextHandler> SAL_CALL SvXMLExceptionListContext::createFastChildContext(
     144             :     sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
     145             :     throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception)
     146             : {
     147           0 :     if ( Element == SvXMLAutoCorrectToken::BLOCK )
     148           0 :         return new SvXMLExceptionContext (rLocalRef, Element, xAttrList);
     149             :     else
     150           0 :         return new SvXMLImportContext( rLocalRef );
     151             : }
     152             : 
     153           0 : SvXMLExceptionListContext::~SvXMLExceptionListContext()
     154             : {
     155           0 : }
     156             : 
     157           0 : SvXMLExceptionContext::SvXMLExceptionContext(
     158             :    SvXMLExceptionListImport& rImport,
     159             :    sal_Int32 /*Element*/,
     160             :    const com::sun::star::uno::Reference<
     161             :    com::sun::star::xml::sax::XFastAttributeList > & xAttrList ) :
     162             :    SvXMLImportContext ( rImport ),
     163           0 :    rLocalRef(rImport)
     164             : {
     165           0 :     OUString sWord;
     166           0 :     if( xAttrList.is() && xAttrList->hasAttribute( SvXMLAutoCorrectToken::ABBREVIATED_NAME ) )
     167           0 :         sWord = xAttrList->getValue( SvXMLAutoCorrectToken::ABBREVIATED_NAME );
     168             : 
     169           0 :     if (sWord.isEmpty())
     170           0 :         return;
     171             : 
     172           0 :     rLocalRef.rList.insert( sWord );
     173             : }
     174             : 
     175           0 : SvXMLExceptionContext::~SvXMLExceptionContext()
     176             : {
     177           0 : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11