LCOV - code coverage report
Current view: top level - editeng/source/misc - SvXMLAutoCorrectImport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 104 0.0 %
Date: 2012-08-25 Functions: 0 22 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 190 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                 :            : #include <SvXMLAutoCorrectImport.hxx>
      30                 :            : #include <vcl/svapp.hxx>
      31                 :            : #include <xmloff/xmltoken.hxx>
      32                 :            : 
      33                 :            : using namespace ::com::sun::star;
      34                 :            : using namespace ::xmloff::token;
      35                 :            : using namespace ::rtl;
      36                 :            : 
      37                 :            : const char aBlockList[] =  "_block-list";
      38                 :            : 
      39                 :          0 : SvXMLAutoCorrectImport::SvXMLAutoCorrectImport(
      40                 :            :     const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
      41                 :            :     SvxAutocorrWordList *pNewAutocorr_List,
      42                 :            :     SvxAutoCorrect &rNewAutoCorrect,
      43                 :            :     const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rNewStorage)
      44                 :            : :   SvXMLImport( xServiceFactory ),
      45                 :            :     pAutocorr_List (pNewAutocorr_List),
      46                 :            :     rAutoCorrect ( rNewAutoCorrect ),
      47                 :          0 :     xStorage ( rNewStorage )
      48                 :            : {
      49                 :          0 :     GetNamespaceMap().Add(
      50                 :            :             rtl::OUString(aBlockList),
      51         [ #  # ]:          0 :             GetXMLToken ( XML_N_BLOCK_LIST),
      52         [ #  # ]:          0 :             XML_NAMESPACE_BLOCKLIST );
      53                 :          0 : }
      54                 :            : 
      55                 :          0 : SvXMLAutoCorrectImport::~SvXMLAutoCorrectImport ( void ) throw ()
      56                 :            : {
      57         [ #  # ]:          0 : }
      58                 :            : 
      59                 :          0 : SvXMLImportContext *SvXMLAutoCorrectImport::CreateContext(
      60                 :            :         sal_uInt16 nPrefix,
      61                 :            :         const OUString& rLocalName,
      62                 :            :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
      63                 :            : {
      64                 :          0 :     SvXMLImportContext *pContext = 0;
      65                 :            : 
      66   [ #  #  #  # ]:          0 :     if( XML_NAMESPACE_BLOCKLIST == nPrefix &&
                 [ #  # ]
      67                 :          0 :         IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
      68         [ #  # ]:          0 :         pContext = new SvXMLWordListContext( *this, nPrefix, rLocalName, xAttrList );
      69                 :            :     else
      70                 :          0 :         pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
      71                 :          0 :     return pContext;
      72                 :            : }
      73                 :            : 
      74                 :          0 : SvXMLWordListContext::SvXMLWordListContext(
      75                 :            :    SvXMLAutoCorrectImport& rImport,
      76                 :            :    sal_uInt16 nPrefix,
      77                 :            :    const OUString& rLocalName,
      78                 :            :    const com::sun::star::uno::Reference<
      79                 :            :    com::sun::star::xml::sax::XAttributeList > & /*xAttrList*/ ) :
      80                 :            :    SvXMLImportContext ( rImport, nPrefix, rLocalName ),
      81                 :          0 :    rLocalRef(rImport)
      82                 :            : {
      83                 :          0 : }
      84                 :            : 
      85                 :          0 : SvXMLImportContext *SvXMLWordListContext::CreateChildContext(
      86                 :            :     sal_uInt16 nPrefix,
      87                 :            :     const OUString& rLocalName,
      88                 :            :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
      89                 :            : {
      90                 :          0 :     SvXMLImportContext *pContext = 0;
      91                 :            : 
      92   [ #  #  #  # ]:          0 :     if (nPrefix == XML_NAMESPACE_BLOCKLIST &&
                 [ #  # ]
      93                 :          0 :         IsXMLToken ( rLocalName, XML_BLOCK ) )
      94         [ #  # ]:          0 :         pContext = new SvXMLWordContext (rLocalRef, nPrefix, rLocalName, xAttrList);
      95                 :            :     else
      96         [ #  # ]:          0 :         pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
      97                 :          0 :     return pContext;
      98                 :            : }
      99                 :          0 : SvXMLWordListContext::~SvXMLWordListContext ( void )
     100                 :            : {
     101         [ #  # ]:          0 : }
     102                 :            : 
     103                 :          0 : SvXMLWordContext::SvXMLWordContext(
     104                 :            :    SvXMLAutoCorrectImport& rImport,
     105                 :            :    sal_uInt16 nPrefix,
     106                 :            :    const OUString& rLocalName,
     107                 :            :    const com::sun::star::uno::Reference<
     108                 :            :    com::sun::star::xml::sax::XAttributeList > & xAttrList ) :
     109                 :            :    SvXMLImportContext ( rImport, nPrefix, rLocalName ),
     110                 :          0 :    rLocalRef(rImport)
     111                 :            : {
     112 [ #  # ][ #  # ]:          0 :     String sRight, sWrong;
     113 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ #  # ]
     114                 :            : 
     115         [ #  # ]:          0 :     for (sal_Int16 i=0; i < nAttrCount; i++)
     116                 :            :     {
     117 [ #  # ][ #  # ]:          0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
     118                 :          0 :         OUString aLocalName;
     119         [ #  # ]:          0 :         sal_uInt16 nAttrPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
     120 [ #  # ][ #  # ]:          0 :         const OUString& rAttrValue = xAttrList->getValueByIndex( i );
     121         [ #  # ]:          0 :         if (XML_NAMESPACE_BLOCKLIST == nAttrPrefix)
     122                 :            :         {
     123 [ #  # ][ #  # ]:          0 :             if ( IsXMLToken ( aLocalName, XML_ABBREVIATED_NAME ) )
     124                 :            :             {
     125         [ #  # ]:          0 :                 sWrong = rAttrValue;
     126                 :            :             }
     127 [ #  # ][ #  # ]:          0 :             else if ( IsXMLToken ( aLocalName, XML_NAME ) )
     128                 :            :             {
     129         [ #  # ]:          0 :                 sRight = rAttrValue;
     130                 :            :             }
     131                 :            :         }
     132                 :          0 :     }
     133 [ #  # ][ #  # ]:          0 :     if (!sWrong.Len() || !sRight.Len() )
                 [ #  # ]
     134                 :          0 :         return;
     135                 :            : 
     136         [ #  # ]:          0 :     sal_Bool bOnlyTxt = sRight != sWrong;
     137         [ #  # ]:          0 :     if( !bOnlyTxt )
     138                 :            :     {
     139         [ #  # ]:          0 :         String sLongSave( sRight );
     140 [ #  # ][ #  # ]:          0 :         if( !rLocalRef.rAutoCorrect.GetLongText( rLocalRef.xStorage, String(), sWrong, sRight ) &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     141                 :          0 :             sLongSave.Len() )
     142                 :            :         {
     143         [ #  # ]:          0 :             sRight = sLongSave;
     144                 :          0 :             bOnlyTxt = sal_True;
     145         [ #  # ]:          0 :         }
     146                 :            :     }
     147 [ #  # ][ #  # ]:          0 :     SvxAutocorrWord* pNew = new SvxAutocorrWord( sWrong, sRight, bOnlyTxt );
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 :     if( !rLocalRef.pAutocorr_List->insert( pNew ).second )
     150 [ #  # ][ #  # ]:          0 :         delete pNew;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     151                 :            : }
     152                 :            : 
     153                 :          0 : SvXMLWordContext::~SvXMLWordContext ( void )
     154                 :            : {
     155         [ #  # ]:          0 : }
     156                 :            : 
     157                 :          0 : SvXMLExceptionListImport::SvXMLExceptionListImport(
     158                 :            :     const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
     159                 :            :     SvStringsISortDtor & rNewList )
     160                 :            : :   SvXMLImport( xServiceFactory ),
     161                 :          0 :     rList (rNewList)
     162                 :            : {
     163                 :          0 :     GetNamespaceMap().Add(
     164                 :            :             rtl::OUString(aBlockList),
     165         [ #  # ]:          0 :             GetXMLToken ( XML_N_BLOCK_LIST),
     166         [ #  # ]:          0 :             XML_NAMESPACE_BLOCKLIST );
     167                 :          0 : }
     168                 :            : 
     169                 :          0 : SvXMLExceptionListImport::~SvXMLExceptionListImport ( void ) throw ()
     170                 :            : {
     171         [ #  # ]:          0 : }
     172                 :            : 
     173                 :          0 : SvXMLImportContext *SvXMLExceptionListImport::CreateContext(
     174                 :            :         sal_uInt16 nPrefix,
     175                 :            :         const OUString& rLocalName,
     176                 :            :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     177                 :            : {
     178                 :          0 :     SvXMLImportContext *pContext = 0;
     179                 :            : 
     180   [ #  #  #  # ]:          0 :     if( XML_NAMESPACE_BLOCKLIST==nPrefix &&
                 [ #  # ]
     181                 :          0 :         IsXMLToken ( rLocalName, XML_BLOCK_LIST ) )
     182         [ #  # ]:          0 :         pContext = new SvXMLExceptionListContext( *this, nPrefix, rLocalName, xAttrList );
     183                 :            :     else
     184                 :          0 :         pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
     185                 :          0 :     return pContext;
     186                 :            : }
     187                 :            : 
     188                 :          0 : SvXMLExceptionListContext::SvXMLExceptionListContext(
     189                 :            :    SvXMLExceptionListImport& rImport,
     190                 :            :    sal_uInt16 nPrefix,
     191                 :            :    const OUString& rLocalName,
     192                 :            :    const com::sun::star::uno::Reference<
     193                 :            :    com::sun::star::xml::sax::XAttributeList > & /* xAttrList */ ) :
     194                 :            :    SvXMLImportContext ( rImport, nPrefix, rLocalName ),
     195                 :          0 :    rLocalRef(rImport)
     196                 :            : {
     197                 :          0 : }
     198                 :            : 
     199                 :          0 : SvXMLImportContext *SvXMLExceptionListContext::CreateChildContext(
     200                 :            :     sal_uInt16 nPrefix,
     201                 :            :     const OUString& rLocalName,
     202                 :            :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     203                 :            : {
     204                 :          0 :     SvXMLImportContext *pContext = 0;
     205                 :            : 
     206   [ #  #  #  # ]:          0 :     if (nPrefix == XML_NAMESPACE_BLOCKLIST &&
                 [ #  # ]
     207                 :          0 :         IsXMLToken ( rLocalName, XML_BLOCK ) )
     208         [ #  # ]:          0 :         pContext = new SvXMLExceptionContext (rLocalRef, nPrefix, rLocalName, xAttrList);
     209                 :            :     else
     210         [ #  # ]:          0 :         pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName);
     211                 :          0 :     return pContext;
     212                 :            : }
     213                 :          0 : SvXMLExceptionListContext::~SvXMLExceptionListContext ( void )
     214                 :            : {
     215         [ #  # ]:          0 : }
     216                 :            : 
     217                 :          0 : SvXMLExceptionContext::SvXMLExceptionContext(
     218                 :            :    SvXMLExceptionListImport& rImport,
     219                 :            :    sal_uInt16 nPrefix,
     220                 :            :    const OUString& rLocalName,
     221                 :            :    const com::sun::star::uno::Reference<
     222                 :            :    com::sun::star::xml::sax::XAttributeList > & xAttrList ) :
     223                 :            :    SvXMLImportContext ( rImport, nPrefix, rLocalName ),
     224                 :          0 :    rLocalRef(rImport)
     225                 :            : {
     226         [ #  # ]:          0 :     String sWord;
     227 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ #  # ]
     228                 :            : 
     229         [ #  # ]:          0 :     for (sal_Int16 i=0; i < nAttrCount; i++)
     230                 :            :     {
     231 [ #  # ][ #  # ]:          0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
     232                 :          0 :         OUString aLocalName;
     233         [ #  # ]:          0 :         sal_uInt16 nAttrPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
     234 [ #  # ][ #  # ]:          0 :         const OUString& rAttrValue = xAttrList->getValueByIndex( i );
     235         [ #  # ]:          0 :         if (XML_NAMESPACE_BLOCKLIST == nAttrPrefix)
     236                 :            :         {
     237 [ #  # ][ #  # ]:          0 :             if ( IsXMLToken ( aLocalName, XML_ABBREVIATED_NAME ) )
     238                 :            :             {
     239         [ #  # ]:          0 :                 sWord = rAttrValue;
     240                 :            :             }
     241                 :            :         }
     242                 :          0 :     }
     243         [ #  # ]:          0 :     if (!sWord.Len() )
     244                 :          0 :         return;
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     String * pNew = new String( sWord );
     247                 :            : 
     248 [ #  # ][ #  # ]:          0 :     if( !rLocalRef.rList.insert( pNew ).second )
     249 [ #  # ][ #  # ]:          0 :         delete pNew;
         [ #  # ][ #  # ]
     250                 :            : }
     251                 :            : 
     252                 :          0 : SvXMLExceptionContext::~SvXMLExceptionContext ( void )
     253                 :            : {
     254         [ #  # ]:          0 : }
     255                 :            : 
     256                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10